From a8223c2ba33c5f925fcb3d6348a5d69ab4be73ec Mon Sep 17 00:00:00 2001 From: Fox McCloud Date: Thu, 17 Oct 2019 22:01:48 -0400 Subject: [PATCH] Better Slime and Xenobiology Equipment Garbage Collection (#46961) --- .../kitchen_machinery/monkeyrecycler.dm | 7 +++-- .../mob/living/simple_animal/slime/slime.dm | 4 +++ .../research/xenobiology/xenobio_camera.dm | 28 ++++++++++--------- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/code/modules/food_and_drinks/kitchen_machinery/monkeyrecycler.dm b/code/modules/food_and_drinks/kitchen_machinery/monkeyrecycler.dm index 54ed2794206..7edba9e0f12 100644 --- a/code/modules/food_and_drinks/kitchen_machinery/monkeyrecycler.dm +++ b/code/modules/food_and_drinks/kitchen_machinery/monkeyrecycler.dm @@ -21,10 +21,11 @@ GLOBAL_LIST_EMPTY(monkey_recyclers) GLOB.monkey_recyclers += src /obj/machinery/monkey_recycler/Destroy() - if(src in GLOB.monkey_recyclers) - GLOB.monkey_recyclers -= src - for(var/obj/machinery/computer/camera_advanced/xenobio/console in connected) + GLOB.monkey_recyclers -= src + for(var/thing in connected) + var/obj/machinery/computer/camera_advanced/xenobio/console = thing console.connected_recycler = null + connected.Cut() return ..() /obj/machinery/monkey_recycler/RefreshParts() //Ranges from 0.2 to 0.8 per monkey recycled diff --git a/code/modules/mob/living/simple_animal/slime/slime.dm b/code/modules/mob/living/simple_animal/slime/slime.dm index d3f9696f504..f34194de8cd 100644 --- a/code/modules/mob/living/simple_animal/slime/slime.dm +++ b/code/modules/mob/living/simple_animal/slime/slime.dm @@ -108,6 +108,10 @@ for (var/A in actions) var/datum/action/AC = A AC.Remove(src) + Target = null + Leader = null + Friends.Cut() + speech_buffer.Cut() return ..() /mob/living/simple_animal/slime/proc/set_colour(new_colour) diff --git a/code/modules/research/xenobiology/xenobio_camera.dm b/code/modules/research/xenobiology/xenobio_camera.dm index 06d806a6157..e3c78ace832 100644 --- a/code/modules/research/xenobiology/xenobio_camera.dm +++ b/code/modules/research/xenobiology/xenobio_camera.dm @@ -41,7 +41,7 @@ light_color = LIGHT_COLOR_PINK -/obj/machinery/computer/camera_advanced/xenobio/Initialize() +/obj/machinery/computer/camera_advanced/xenobio/Initialize(mapload) . = ..() slime_place_action = new slime_up_action = new @@ -51,19 +51,27 @@ potion_action = new hotkey_help = new stored_slimes = list() - RegisterSignal(src, COMSIG_ATOM_CONTENTS_DEL, .proc/on_contents_del) for(var/obj/machinery/monkey_recycler/recycler in GLOB.monkey_recyclers) if(get_area(recycler.loc) == get_area(loc)) connected_recycler = recycler connected_recycler.connected += src /obj/machinery/computer/camera_advanced/xenobio/Destroy() - stored_slimes = null QDEL_NULL(current_potion) - for(var/i in contents) - var/mob/living/simple_animal/slime/S = i - if(istype(S)) - S.forceMove(drop_location()) + for(var/thing in stored_slimes) + var/mob/living/simple_animal/slime/S = thing + S.forceMove(drop_location()) + stored_slimes.Cut() + if(connected_recycler) + connected_recycler.connected -= src + connected_recycler = null + return ..() + +/obj/machinery/computer/camera_advanced/xenobio/handle_atom_del(atom/A) + if(A == current_potion) + current_potion = null + if(A in stored_slimes) + stored_slimes -= A return ..() /obj/machinery/computer/camera_advanced/xenobio/CreateEye() @@ -134,12 +142,6 @@ UnregisterSignal(user, COMSIG_XENO_MONKEY_CLICK_CTRL) ..() -/obj/machinery/computer/camera_advanced/xenobio/proc/on_contents_del(datum/source, atom/deleted) - if(current_potion == deleted) - current_potion = null - if(deleted in stored_slimes) - stored_slimes -= deleted - /obj/machinery/computer/camera_advanced/xenobio/attackby(obj/item/O, mob/user, params) if(istype(O, /obj/item/reagent_containers/food/snacks/monkeycube)) monkeys++