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/organs/organ.dm b/code/modules/organs/organ.dm index 7e7e2e8178..933c1de708 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.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 ..() 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 b2e584c136..095c172aac 100644 --- a/code/modules/power/smes_construction.dm +++ b/code/modules/power/smes_construction.dm @@ -75,6 +75,13 @@ charge = 0 should_be_mapped = 1 +/obj/machinery/power/smes/buildable/Destroy() + ..() + qdel(wires) + for(var/obj/nano_module/rcon/R in world) + R.FindDevices() + + // Proc: process() // Parameters: None // Description: Uses parent process, but if grounding wire is cut causes sparks to fly around. @@ -345,6 +352,7 @@ if(I.reliability != 100 && crit_fail) I.crit_fail = 1 I.loc = src.loc + component_parts -= I qdel(src) return