diff --git a/code/datums/orbit.dm b/code/datums/orbit.dm
index 745d16053e..a892f88c3d 100644
--- a/code/datums/orbit.dm
+++ b/code/datums/orbit.dm
@@ -113,6 +113,7 @@
for(var/datum/orbit/O as anything in orbiters)
if (O.orbiter)
O.orbiter.stop_orbit()
+ orbiters = null
/atom/movable/Destroy(force = FALSE)
. = ..()
diff --git a/code/game/atom/_atom.dm b/code/game/atom/_atom.dm
index 53590180a9..86d04711c0 100644
--- a/code/game/atom/_atom.dm
+++ b/code/game/atom/_atom.dm
@@ -67,6 +67,17 @@
QDEL_NULL(light)
if(forensic_data)
QDEL_NULL(forensic_data)
+ // Checking length(overlays) before cutting has significant speed benefits
+ if (length(overlays))
+ overlays.Cut()
+ if (length(our_overlays))
+ our_overlays.Cut()
+ if (length(priority_overlays))
+ priority_overlays.Cut()
+ if (length(managed_vis_overlays))
+ managed_vis_overlays.Cut()
+ if (length(original_atom))
+ original_atom.Cut()
return ..()
/atom/proc/reveal_blood()
diff --git a/code/game/objects/items/stacks/stack.dm b/code/game/objects/items/stacks/stack.dm
index c072792351..b9c47b4cfd 100644
--- a/code/game/objects/items/stacks/stack.dm
+++ b/code/game/objects/items/stacks/stack.dm
@@ -48,8 +48,6 @@
AddElement(/datum/element/sellable/material_stack)
/obj/item/stack/Destroy()
- if(uses_charge)
- return 1
if (src && usr && usr.machine == src)
usr << browse(null, "window=stack")
if(islist(synths))
diff --git a/code/game/objects/items/weapons/RMS.dm b/code/game/objects/items/weapons/RMS.dm
index 1e6521c448..0edefe20fd 100644
--- a/code/game/objects/items/weapons/RMS.dm
+++ b/code/game/objects/items/weapons/RMS.dm
@@ -69,7 +69,7 @@ var/list/RMS_random_malfunction = list(/obj/item/fbp_backup_cell,
spark_system.attach(src)
add_overlay("rms_charge[charge_stage]")
-/obj/item/pipe_dispenser/Destroy()
+/obj/item/rms/Destroy()
QDEL_NULL(spark_system)
return ..()
diff --git a/code/modules/food/food/drinks/bottle.dm b/code/modules/food/food/drinks/bottle.dm
index f353a25139..6e11b2fdc3 100644
--- a/code/modules/food/food/drinks/bottle.dm
+++ b/code/modules/food/food/drinks/bottle.dm
@@ -25,8 +25,12 @@
/obj/item/reagent_containers/food/drinks/bottle/Destroy()
if(rag)
- rag.forceMove(src.loc)
- rag = null
+ var/turf/possible_loc = get_turf(src)
+ if(possible_loc)
+ rag.forceMove(possible_loc)
+ else
+ qdel(rag)
+ rag = null
return ..()
//when thrown on impact, bottles smash and spill their contents
diff --git a/code/modules/materials/sheets/_sheets.dm b/code/modules/materials/sheets/_sheets.dm
index 53b7cd74d9..1ba2b0f989 100644
--- a/code/modules/materials/sheets/_sheets.dm
+++ b/code/modules/materials/sheets/_sheets.dm
@@ -48,6 +48,10 @@
matter = material.get_matter()
update_strings()
+/obj/item/stack/material/Destroy()
+ material = null
+ . = ..()
+
/obj/item/stack/material/get_material()
return material
diff --git a/code/modules/mob/living/carbon/brain/MMI.dm b/code/modules/mob/living/carbon/brain/MMI.dm
index 945a3ed373..23f463b4bc 100644
--- a/code/modules/mob/living/carbon/brain/MMI.dm
+++ b/code/modules/mob/living/carbon/brain/MMI.dm
@@ -155,6 +155,8 @@
borg.mmi = null
QDEL_NULL(radio)
QDEL_NULL(brainmob)
+ if(brainobj)
+ QDEL_NULL(brainobj)
return ..()
/obj/item/mmi/radio_enabled
diff --git a/code/modules/mob/living/silicon/ai/ai.dm b/code/modules/mob/living/silicon/ai/ai.dm
index fce7b1a8f6..882bdea048 100644
--- a/code/modules/mob/living/silicon/ai/ai.dm
+++ b/code/modules/mob/living/silicon/ai/ai.dm
@@ -240,7 +240,6 @@ var/list/ai_verbs_default = list(
QDEL_NULL(aiCommunicator)
QDEL_NULL(aiMulti)
QDEL_NULL(aiRadio)
- QDEL_NULL(aiCamera)
hack = null
destroy_eyeobj()
diff --git a/code/modules/mob/living/silicon/robot/component.dm b/code/modules/mob/living/silicon/robot/component.dm
index 7584985777..6bf785ff7a 100644
--- a/code/modules/mob/living/silicon/robot/component.dm
+++ b/code/modules/mob/living/silicon/robot/component.dm
@@ -36,6 +36,11 @@
idle_usage = initial(idle_usage)
active_usage = initial(active_usage)
+/datum/robot_component/Destroy(force)
+ if(wrapped)
+ QDEL_NULL(wrapped)
+ . = ..()
+
/datum/robot_component/proc/destroy()
var/brokenstate = "broken" // Generic icon
if (istype(wrapped, /obj/item/robot_parts/robot_component))
diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm
index 1e25c41680..c6140e7416 100644
--- a/code/modules/mob/living/silicon/robot/robot.dm
+++ b/code/modules/mob/living/silicon/robot/robot.dm
@@ -96,7 +96,7 @@
var/lower_mod = 0
var/jetpack = 0
var/datum/effect/effect/system/ion_trail_follow/ion_trail = null
- var/datum/effect/effect/system/spark_spread/spark_system//So they can initialize sparks whenever/N
+ var/datum/effect/effect/system/spark_spread/spark_system //So they can initialize sparks whenever/N
var/jeton = 0
var/killswitch = 0
var/killswitch_time = 60
@@ -111,6 +111,7 @@
var/braintype = JOB_CYBORG
var/obj/item/implant/restrainingbolt/bolt // The restraining bolt installed into the cyborg.
+ var/datum/tgui_module/robot_ui/robotact
var/list/robot_verbs_default = list(
/mob/living/silicon/robot/proc/sensor_mode,
@@ -306,31 +307,66 @@
//If there's an MMI in the robot, have it ejected when the mob goes away. --NEO
//Improved /N
/mob/living/silicon/robot/Destroy()
- if(mmi && mind)//Safety for when a cyborg gets dust()ed. Or there is no MMI inside.
- var/turf/T = get_turf(loc)//To hopefully prevent run time errors.
- if(T) mmi.loc = T
- if(mmi.brainmob)
- var/obj/item/robot_module/M = locate() in contents
- if(M)
- mmi.brainmob.languages = M.original_languages
- else
- mmi.brainmob.languages = languages
- mmi.brainmob.remove_language(LANGUAGE_ROBOT_TALK)
- mind.transfer_to(mmi.brainmob)
- else if(!shell) // Shells don't have brainmbos in their MMIs.
- to_chat(src, span_danger("Oops! Something went very wrong, your MMI was unable to receive your mind. You have been ghosted. Please make a bug report so we can fix this bug."))
- ghostize()
- //ERROR("A borg has been destroyed, but its MMI lacked a brainmob, so the mind could not be transferred. Player: [ckey].")
- mmi = null
- if(connected_ai)
- connected_ai.connected_robots -= src
+ if(mmi)//Safety for when a cyborg gets dust()ed. Or there is no MMI inside.
+ if(mind)
+ var/turf/T = get_turf(loc)//To hopefully prevent run time errors.
+ if(T)
+ mmi.forceMove(T)
+ if(mmi.brainmob)
+ var/obj/item/robot_module/M = locate() in contents
+ if(M)
+ mmi.brainmob.languages = M.original_languages
+ else
+ mmi.brainmob.languages = languages
+ mmi.brainmob.remove_language(LANGUAGE_ROBOT_TALK)
+ mind.transfer_to(mmi.brainmob)
+ else if(!shell) // Shells don't have brainmbos in their MMIs.
+ to_chat(src, span_danger("Oops! Something went very wrong, your MMI was unable to receive your mind. You have been ghosted. Please make a bug report so we can fix this bug."))
+ ghostize()
+ //ERROR("A borg has been destroyed, but its MMI lacked a brainmob, so the mind could not be transferred. Player: [ckey].")
+ mmi = null
+ else
+ QDEL_NULL(mmi)
+ disconnect_from_ai(TRUE)
if(shell)
if(deployed)
undeploy()
revert_shell() // To get it out of the GLOB list.
- qdel(wires)
- wires = null
+ QDEL_NULL(wires)
+ sprite_datum = null
QDEL_NULL(robotact)
+ QDEL_LIST_ASSOC_VAL(components)
+ if(bolt)
+ QDEL_NULL(bolt)
+ if(module)
+ QDEL_NULL(module)
+ if(radio)
+ QDEL_NULL(radio)
+ if(communicator)
+ QDEL_NULL(communicator)
+ if(cell)
+ QDEL_NULL(cell)
+ if(camera)
+ QDEL_NULL(camera)
+ if(rbPDA)
+ QDEL_NULL(rbPDA)
+ if(inv1)
+ QDEL_NULL(inv1)
+ if(inv2)
+ QDEL_NULL(inv2)
+ if(inv3)
+ QDEL_NULL(inv3)
+ if(robot_modules_background)
+ QDEL_NULL(robot_modules_background)
+ if(ion_trail)
+ QDEL_NULL(ion_trail)
+ if(spark_system)
+ QDEL_NULL(spark_system)
+ module_active = null
+ module_state_1 = null
+ module_state_2 = null
+ module_state_3 = null
+
return ..()
// CONTINUE CODING HERE
@@ -862,9 +898,8 @@
if(notify)
notify_ai(ROBOT_NOTIFICATION_MODULE_RESET, module.name)
module.Reset(src)
- qdel(module)
+ QDEL_NULL(module)
icon_selected = FALSE
- module = null
updatename("Default")
has_recoloured = FALSE
robotact?.update_static_data_for_all_viewers()
@@ -1252,9 +1287,10 @@
if(ROBOT_NOTIFICATION_AI_SHELL) //New Shell
to_chat(connected_ai, span_filter_notice("
" + span_notice("NOTICE - New AI shell detected: [name]") + "
"))
-/mob/living/silicon/robot/proc/disconnect_from_ai()
+/mob/living/silicon/robot/proc/disconnect_from_ai(silent)
if(connected_ai)
- sync() // One last sync attempt
+ if(!silent)
+ sync() // One last sync attempt
connected_ai.connected_robots -= src
connected_ai = null
diff --git a/code/modules/mob/living/silicon/robot/robot_modules/station.dm b/code/modules/mob/living/silicon/robot/robot_modules/station.dm
index a93e6fa0b6..6d3a0f19d9 100644
--- a/code/modules/mob/living/silicon/robot/robot_modules/station.dm
+++ b/code/modules/mob/living/silicon/robot/robot_modules/station.dm
@@ -83,15 +83,9 @@
R.scrubbing = FALSE
/obj/item/robot_module/Destroy()
- for(var/module in modules)
- qdel(module)
- for(var/emg in emag)
- qdel(emg)
- for(var/synth in synths)
- qdel(synth)
- modules.Cut()
- synths.Cut()
- emag.Cut()
+ QDEL_LIST(modules)
+ QDEL_LIST(emag)
+ QDEL_LIST(synths)
return ..()
/obj/item/robot_module/emp_act(severity)
diff --git a/code/modules/mob/living/silicon/robot/robot_simple_items.dm b/code/modules/mob/living/silicon/robot/robot_simple_items.dm
index 142e6c17be..113f3aad9c 100644
--- a/code/modules/mob/living/silicon/robot/robot_simple_items.dm
+++ b/code/modules/mob/living/silicon/robot/robot_simple_items.dm
@@ -490,6 +490,10 @@
. = ..()
+/obj/item/robotic_multibelt/materials/Destroy()
+ QDEL_LIST(cyborg_integrated_tools)
+ . = ..()
+
///Allows the material fabricator to pick up materials if they hit an appropriate stack.
/obj/item/robotic_multibelt/materials/afterattack(atom/target, mob/user, proximity_flag, click_parameters)
if(istype(target, /obj/item/stack)) //We are targeting a stack.
diff --git a/code/modules/mob/living/silicon/robot/robot_ui.dm b/code/modules/mob/living/silicon/robot/robot_ui.dm
index 8cec2aa542..aa673cd700 100644
--- a/code/modules/mob/living/silicon/robot/robot_ui.dm
+++ b/code/modules/mob/living/silicon/robot/robot_ui.dm
@@ -1,6 +1,3 @@
-/mob/living/silicon/robot
- var/datum/tgui_module/robot_ui/robotact
-
// Major Control UI for all things robots can do.
/datum/tgui_module/robot_ui
name = "Robotact"
diff --git a/code/modules/mob/living/silicon/silicon.dm b/code/modules/mob/living/silicon/silicon.dm
index d1343f0d57..79b407da4f 100644
--- a/code/modules/mob/living/silicon/silicon.dm
+++ b/code/modules/mob/living/silicon/silicon.dm
@@ -41,9 +41,16 @@
AddElement(/datum/element/footstep, FOOTSTEP_MOB_SHOE, 1, -6)
/mob/living/silicon/Destroy()
+ common_radio = null // same ref as radio, deleted by child
GLOB.silicon_mob_list -= src
for(var/datum/alarm_handler/AH in SSalarm.all_handlers)
AH.unregister_alarm(src)
+ if(aiCamera)
+ QDEL_NULL(aiCamera)
+ if(idcard)
+ QDEL_NULL(idcard)
+ if(laws)
+ QDEL_NULL(laws)
return ..()
/mob/living/silicon/proc/init_id()
diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm
index 445a572e12..bd736224e6 100644
--- a/code/modules/mob/mob.dm
+++ b/code/modules/mob/mob.dm
@@ -27,7 +27,7 @@
if(ability_master)
QDEL_NULL(ability_master)
- if(vore_organs)
+ if(LAZYLEN(vore_organs))
QDEL_NULL_LIST(vore_organs)
if(vorePanel)
QDEL_NULL(vorePanel)
diff --git a/code/modules/paperwork/silicon_photography.dm b/code/modules/paperwork/silicon_photography.dm
index 26ea8bbf4f..ac43bbde06 100644
--- a/code/modules/paperwork/silicon_photography.dm
+++ b/code/modules/paperwork/silicon_photography.dm
@@ -15,6 +15,10 @@
/obj/item/camera/siliconcam/drone_camera //currently doesn't offer the verbs, thus cannot be used
name = "Drone photo camera"
+/obj/item/camera/siliconcam/Destroy()
+ QDEL_LIST(aipictures)
+ . = ..()
+
/obj/item/camera/siliconcam/proc/injectaialbum(obj/item/photo/p, var/sufix = "") //stores image information to a list similar to that of the datacore
p.loc = src
photos_taken++
@@ -69,6 +73,7 @@
return
aipictures -= selection
+ qdel(selection)
to_chat(user, span_unconscious("Local image deleted"))
/obj/item/camera/siliconcam/ai_camera/can_capture_turf(turf/T, mob/user)
diff --git a/code/modules/tgui/modules/_base.dm b/code/modules/tgui/modules/_base.dm
index d5e754412d..8fe164699c 100644
--- a/code/modules/tgui/modules/_base.dm
+++ b/code/modules/tgui/modules/_base.dm
@@ -19,6 +19,10 @@ Code is pretty much ripped verbatim from nano modules, but with un-needed stuff
if(ntos)
tgui_id = "Ntos" + tgui_id
+/datum/tgui_module/Destroy(force)
+ host = null
+ . = ..()
+
/datum/tgui_module/tgui_host()
return host ? host.tgui_host() : src
diff --git a/code/modules/tickets/tickets_player_ui.dm b/code/modules/tickets/tickets_player_ui.dm
index 31e3ed6f07..84d2b5147e 100644
--- a/code/modules/tickets/tickets_player_ui.dm
+++ b/code/modules/tickets/tickets_player_ui.dm
@@ -14,7 +14,7 @@
/datum/ticket_chat/tgui_close(mob/user)
. = ..()
- if(user.client.current_ticket)
+ if(user.client?.current_ticket)
user.throw_alert("open ticket", /obj/screen/alert/open_ticket)
/datum/ticket_chat/tgui_state(mob/user)
diff --git a/code/modules/vore/eating/belly_obj_vr.dm b/code/modules/vore/eating/belly_obj_vr.dm
index 698cecfa10..bd4dc8dc79 100644
--- a/code/modules/vore/eating/belly_obj_vr.dm
+++ b/code/modules/vore/eating/belly_obj_vr.dm
@@ -267,6 +267,7 @@
var/list/belly_surrounding = list() // A list of living mobs surrounded by this belly, including inside containers, food, on mobs, etc. Exclusing inside other bellies.
var/bellytemperature = T20C // Temperature applied to humans in the belly.
var/temperature_damage = FALSE // Does temperature damage prey?
+ flags = NOREACT // We dont want bellies to start bubling nonstop due to people mixing when transfering and making different reagents
//For serialization, keep this updated, required for bellies to save correctly.
/obj/belly/vars_to_save()
@@ -487,7 +488,7 @@
//If not, we're probably just in a prefs list or something.
if(ismob(loc))
owner = loc
- owner.vore_organs |= src
+ owner.vore_organs += src
if(isliving(loc))
if(mode_flags & DM_FLAG_TURBOMODE)
START_PROCESSING(SSobj, src)
@@ -495,7 +496,6 @@
START_PROCESSING(SSbellies, src)
create_reagents(300) // So we can have some liquids in bellies
- flags |= NOREACT // We dont want bellies to start bubling nonstop due to people mixing when transfering and making different reagents
/obj/belly/Destroy()
if(mode_flags & DM_FLAG_TURBOMODE)