From e016ea8a026ce20cb0435e9bc0320e701d26cd87 Mon Sep 17 00:00:00 2001 From: zxaber <37497534+zxaber@users.noreply.github.com> Date: Thu, 7 Jan 2021 04:36:57 -0800 Subject: [PATCH] Fixes AI laws being eaten by the garbage collector in certain conditions (#55984) Extra AIs created by players will no longer lose their laws shortly after they are created. --- code/game/objects/structures/ai_core.dm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/game/objects/structures/ai_core.dm b/code/game/objects/structures/ai_core.dm index 3fa9c292fc5..eda4d23e946 100644 --- a/code/game/objects/structures/ai_core.dm +++ b/code/game/objects/structures/ai_core.dm @@ -237,8 +237,10 @@ if (brain.overrides_aicore_laws) A = new /mob/living/silicon/ai(loc, brain.laws, B) + brain.laws = null //Brain's law datum is being donated, so we need the brain to let it go or the GC will eat it else A = new /mob/living/silicon/ai(loc, laws, B) + laws = null //we're giving the new AI this datum, so let's not delete it when we qdel(src) 5 lines from now if(brain.force_replace_ai_name) A.fully_replace_character_name(A.name, brain.replacement_ai_name())