diff --git a/code/datums/ai_laws/ai_laws.dm b/code/datums/ai_laws/ai_laws.dm index 9b9f9c62841..971dc118f3a 100644 --- a/code/datums/ai_laws/ai_laws.dm +++ b/code/datums/ai_laws/ai_laws.dm @@ -139,7 +139,7 @@ GLOBAL_VAR(round_default_lawset) /// These laws will go away when an AI is reset var/list/hacked = list() -/datum/ai_laws/Destroy(force = FALSE, ...) +/datum/ai_laws/Destroy(force = FALSE) if(!QDELETED(owner)) //Stopgap to help with laws randomly being lost. This stack_trace will hopefully help find the real issues. if(force) //Unless we're forced... stack_trace("AI law datum for [owner] has been forcefully destroyed incorrectly; the owner variable should be cleared first!") @@ -149,6 +149,18 @@ GLOBAL_VAR(round_default_lawset) owner = null return ..() +/// Makes a copy of the lawset and returns a new law datum. +/datum/ai_laws/proc/copy_lawset() + var/datum/ai_laws/new_lawset = new type() + new_lawset.protected_zeroth = protected_zeroth + new_lawset.zeroth = zeroth + new_lawset.zeroth_borg = zeroth_borg + new_lawset.inherent = inherent.Copy() + new_lawset.supplied = supplied.Copy() + new_lawset.ion = ion.Copy() + new_lawset.hacked = hacked.Copy() + return new_lawset + /datum/ai_laws/pai name = "pAI Directives" zeroth = ("Serve your master.") @@ -429,8 +441,10 @@ GLOBAL_VAR(round_default_lawset) to_chat(to_who, examine_block(jointext(printable_laws, "\n"))) /datum/ai_laws/proc/associate(mob/living/silicon/M) - if(!owner) - owner = M + if(owner) + CRASH("AI law datum linked to [owner] attempted to associate with another mob [M]") + + owner = M /** * Generates a list of all laws on this datum, including rendered HTML tags if required diff --git a/code/modules/power/apc/apc_malf.dm b/code/modules/power/apc/apc_malf.dm index 3b070368804..62134de146e 100644 --- a/code/modules/power/apc/apc_malf.dm +++ b/code/modules/power/apc/apc_malf.dm @@ -37,7 +37,7 @@ if(!is_station_level(z)) return malf.ShutOffDoomsdayDevice() - occupier = new /mob/living/silicon/ai(src, malf.laws, malf) //DEAR GOD WHY? //IKR???? + occupier = new /mob/living/silicon/ai(src, malf.laws.copy_lawset(), malf) //DEAR GOD WHY? //IKR???? occupier.adjustOxyLoss(malf.getOxyLoss()) if(!findtext(occupier.name, "APC Copy")) occupier.name = "[malf.name] APC Copy"