From 69e0ebf71e39e5f86d472bbf4508b38d46a122e1 Mon Sep 17 00:00:00 2001 From: Atlantis Date: Sat, 6 Jun 2015 07:21:34 +0200 Subject: [PATCH 1/4] Implements Destroy() for organs - This fixes annoying roundstart GC errors, and should fix other limb/organ related GC errors as well. --- code/modules/organs/organ.dm | 21 +++++++++++++++++++++ code/modules/organs/organ_external.dm | 14 ++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/code/modules/organs/organ.dm b/code/modules/organs/organ.dm index 7e7e2e8178..86620ba50e 100644 --- a/code/modules/organs/organ.dm +++ b/code/modules/organs/organ.dm @@ -24,6 +24,27 @@ var/list/organ_cache = list() // links chemical IDs to number of ticks for which they'll stay in the blood germ_level = 0 +/obj/item/organ/Destroy() + if(!owner) + return ..() + + if((owner.internal_organs) && (src in owner.internal_organs)) + owner.internal_organs -= src + + if((owner.internal_organs_by_name) && (src in owner.internal_organs_by_name)) + owner.internal_organs_by_name -= src + + if((owner.organs) && (src in owner.organs)) + owner.internal_organs -= src + + if((owner.organs_by_name) && (src in owner.organs_by_name)) + owner.organs_by_name -= src + + if(src in owner.contents) + owner.contents -= src + + return ..() + /obj/item/organ/proc/update_health() return diff --git a/code/modules/organs/organ_external.dm b/code/modules/organs/organ_external.dm index a92219c733..5434e98acc 100644 --- a/code/modules/organs/organ_external.dm +++ b/code/modules/organs/organ_external.dm @@ -48,6 +48,20 @@ var/can_grasp var/can_stand +/obj/item/organ/external/Destroy() + if(parent && parent.children) + parent.children -= src + + if(children) + for(var/obj/item/organ/external/C in children) + qdel(C) + + if(internal_organs) + for(var/obj/item/organ/O in internal_organs) + qdel(O) + + return ..() + /obj/item/organ/external/attack_self(var/mob/user) if(!contents.len) return ..() From b16bf61d03930e8841a9db5eda9d0e04036668c6 Mon Sep 17 00:00:00 2001 From: Atlantis Date: Sat, 6 Jun 2015 09:43:39 +0200 Subject: [PATCH 2/4] Implements Destroy() for buildable SMES units. - This also means GC errors for SMES coils and probably cable coils are fixed. Both of these things are in used in SMESs' construction components. --- code/modules/power/smes_construction.dm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/code/modules/power/smes_construction.dm b/code/modules/power/smes_construction.dm index b2e584c136..0160868a14 100644 --- a/code/modules/power/smes_construction.dm +++ b/code/modules/power/smes_construction.dm @@ -75,6 +75,15 @@ charge = 0 should_be_mapped = 1 +/obj/machinery/power/smes/buildable/Destroy() + qdel(wires) + if(component_parts) + for(var/atom/A in component_parts) + qdel(A) + + return ..() + + // Proc: process() // Parameters: None // Description: Uses parent process, but if grounding wire is cut causes sparks to fly around. From 8a5a969002aede928a7b8a6bfcc2e6f938d1b7c5 Mon Sep 17 00:00:00 2001 From: Atlantis Date: Sat, 6 Jun 2015 11:04:41 +0200 Subject: [PATCH 3/4] More Destroy()s, better implementation - Re-implements Destroy() for SMES units. This time moves relevant (de)construction code all the way up to obj/machinery/. This should fix any potential GC issues with deconstruction of component-based machines. - Implements Destroy() for breaker boxes. - Fixes SMES units lacking disconnect_terminal(), causing GC errors. --- code/game/machinery/machinery.dm | 9 +++++++++ code/modules/power/breaker_box.dm | 5 +++++ code/modules/power/power.dm | 2 ++ code/modules/power/smes.dm | 8 +++++--- code/modules/power/smes_construction.dm | 9 ++++----- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/code/game/machinery/machinery.dm b/code/game/machinery/machinery.dm index d9b579ab03..313efe3bb2 100644 --- a/code/game/machinery/machinery.dm +++ b/code/game/machinery/machinery.dm @@ -123,6 +123,15 @@ Class Procs: /obj/machinery/Destroy() machines -= src + if(component_parts) + for(var/atom/A in component_parts) + if(A.loc == src) // If the components are inside the machine, delete them. + qdel(A) + else // Otherwise we assume they were dropped to the ground during deconstruction, and were not removed from the component_parts list by deconstruction code. + component_parts -= A + if(contents) // The same for contents. + for(var/atom/A in contents) + qdel(A) ..() /obj/machinery/process()//If you dont use process or power why are you here diff --git a/code/modules/power/breaker_box.dm b/code/modules/power/breaker_box.dm index 2faa50a4e6..5930dd53e7 100644 --- a/code/modules/power/breaker_box.dm +++ b/code/modules/power/breaker_box.dm @@ -19,6 +19,11 @@ var/RCon_tag = "NO_TAG" var/update_locked = 0 +/obj/machinery/power/breakerbox/Destroy() + ..() + for(var/obj/nano_module/rcon/R in world) + R.FindDevices() + /obj/machinery/power/breakerbox/activated icon_state = "bbox_on" diff --git a/code/modules/power/power.dm b/code/modules/power/power.dm index 3b9d094bda..7d51af8e35 100644 --- a/code/modules/power/power.dm +++ b/code/modules/power/power.dm @@ -17,6 +17,8 @@ /obj/machinery/power/Destroy() disconnect_from_network() + disconnect_terminal() + ..() /////////////////////////////// diff --git a/code/modules/power/smes.dm b/code/modules/power/smes.dm index e42c5289b7..5fcffca120 100644 --- a/code/modules/power/smes.dm +++ b/code/modules/power/smes.dm @@ -84,10 +84,12 @@ return -/obj/machinery/power/smes/Destroy() +/obj/machinery/power/smes/disconnect_terminal() if(terminal) - disconnect_terminal() - ..() + terminal.master = null + terminal = null + return 1 + return 0 /obj/machinery/power/smes/update_icon() overlays.Cut() diff --git a/code/modules/power/smes_construction.dm b/code/modules/power/smes_construction.dm index 0160868a14..095c172aac 100644 --- a/code/modules/power/smes_construction.dm +++ b/code/modules/power/smes_construction.dm @@ -76,12 +76,10 @@ should_be_mapped = 1 /obj/machinery/power/smes/buildable/Destroy() + ..() qdel(wires) - if(component_parts) - for(var/atom/A in component_parts) - qdel(A) - - return ..() + for(var/obj/nano_module/rcon/R in world) + R.FindDevices() // Proc: process() @@ -354,6 +352,7 @@ if(I.reliability != 100 && crit_fail) I.crit_fail = 1 I.loc = src.loc + component_parts -= I qdel(src) return From bb33905803b2ab179b8ea9b66fc70249a476ea0c Mon Sep 17 00:00:00 2001 From: Atlantis Date: Sun, 7 Jun 2015 05:29:43 +0200 Subject: [PATCH 4/4] Fixes minor typo in organ Destroy() --- code/modules/organs/organ.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/organs/organ.dm b/code/modules/organs/organ.dm index 86620ba50e..933c1de708 100644 --- a/code/modules/organs/organ.dm +++ b/code/modules/organs/organ.dm @@ -35,7 +35,7 @@ var/list/organ_cache = list() owner.internal_organs_by_name -= src if((owner.organs) && (src in owner.organs)) - owner.internal_organs -= src + owner.organs -= src if((owner.organs_by_name) && (src in owner.organs_by_name)) owner.organs_by_name -= src