From 206bb29d521725de66d36431283c269ee07eb049 Mon Sep 17 00:00:00 2001 From: VMSolidus Date: Fri, 19 Jun 2026 10:18:33 -0400 Subject: [PATCH] Final Mob Destroy Audit (#22728) I've audited the entire destroy path between datum and human, this time paying attention to byond's built-in vars to make sure that the built-in refs are correctly being cleared. I've also gone and corrected some null-access mistakes, which are most prominently caused by as anything casts not being null checked, since as anything allows null entries in a list to be read. By far the worst offender I've found was the lack of clearing of the atom.underlays var, which contains a list of refs. And when searching for uses of this var across the repo, I've discovered it's associated with an overwhelming majority of the remaining objects still in the hard del trackers. --- code/datums/components/_component.dm | 2 +- code/datums/datum.dm | 4 +++- code/datums/langchat/langchat.dm | 8 ++++++-- code/game/atom/_atom.dm | 3 +++ code/game/atoms_movable.dm | 7 ++++--- code/modules/mob/living/carbon/diona_base.dm | 3 ++- code/modules/mob/living/carbon/human/human.dm | 1 - html/changelogs/hellfirejag-final-atoms-audit.yml | 4 ++++ 8 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 html/changelogs/hellfirejag-final-atoms-audit.yml diff --git a/code/datums/components/_component.dm b/code/datums/components/_component.dm index de0ae7226ea..9000cf3a982 100644 --- a/code/datums/components/_component.dm +++ b/code/datums/components/_component.dm @@ -99,7 +99,7 @@ for(var/J in 1 to components_of_type.len) var/datum/component/C = components_of_type[J] if(C.type != our_type) //but not over other exact matches - components_of_type.Insert(J, I) + components_of_type.Insert(J, src) inserted = TRUE break if(!inserted) diff --git a/code/datums/datum.dm b/code/datums/datum.dm index d6916cc9d5b..b1fea17c964 100644 --- a/code/datums/datum.dm +++ b/code/datums/datum.dm @@ -106,7 +106,7 @@ var/list/timers = _active_timers _active_timers = null for(var/datum/timedevent/timer as anything in timers) - if (timer.spent && !(timer.flags & TIMER_DELETE_ME)) + if (!timer || (timer.spent && !(timer.flags & TIMER_DELETE_ME))) continue qdel(timer) @@ -126,6 +126,8 @@ var/component_or_list = dc[component_key] if(islist(component_or_list)) for(var/datum/component/component as anything in component_or_list) + if (!component) + continue qdel(component, FALSE) else var/datum/component/C = component_or_list diff --git a/code/datums/langchat/langchat.dm b/code/datums/langchat/langchat.dm index 45ddd09b561..5f7d91ff629 100644 --- a/code/datums/langchat/langchat.dm +++ b/code/datums/langchat/langchat.dm @@ -46,9 +46,13 @@ /// Drops all active bubbles for this atom. /atom/proc/langchat_drop_images() for(var/datum/langchat_bubble/entry as anything in langchat_images) + if (!entry || !entry.bubble) + continue + for(var/mob/listener as anything in entry.listeners) - if(listener.client) - listener.client.images -= entry.bubble + if (!listener || !listener.client) + continue + listener.client.images -= entry.bubble langchat_images = null /atom/proc/get_maptext_x_offset(image/maptext_image) diff --git a/code/game/atom/_atom.dm b/code/game/atom/_atom.dm index 2ac365e804d..77c21d85c0b 100644 --- a/code/game/atom/_atom.dm +++ b/code/game/atom/_atom.dm @@ -155,6 +155,9 @@ if(length(overlays)) overlays.Cut() + if (length(underlays)) + underlays.Cut() + QDEL_NULL(light) QDEL_NULL(static_light) diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index 61a0c5975b7..6ac8ac31238 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -124,10 +124,9 @@ AddComponent(/datum/component/overlay_lighting, is_directional = TRUE) /atom/movable/Destroy(force) - if(orbiting) - orbiting.end_orbit(src) - + orbiting?.end_orbit(src) QDEL_NULL(emissive_overlay) + particles = null if(move_packet) if(!QDELETED(move_packet)) @@ -687,6 +686,8 @@ SSspatial_grid.remove_grid_membership(src, our_turf, SPATIAL_GRID_CONTENTS_TYPE_HEARING) for(var/atom/movable/location as anything in get_nested_locs(src) + src) + if (!location) + continue var/list/recursive_contents = location.important_recursive_contents // blue hedgehog velocity recursive_contents[RECURSIVE_CONTENTS_HEARING_SENSITIVE] -= src if(!length(recursive_contents[RECURSIVE_CONTENTS_HEARING_SENSITIVE])) diff --git a/code/modules/mob/living/carbon/diona_base.dm b/code/modules/mob/living/carbon/diona_base.dm index 4e28ee2c62c..3a5dd9014da 100644 --- a/code/modules/mob/living/carbon/diona_base.dm +++ b/code/modules/mob/living/carbon/diona_base.dm @@ -636,7 +636,8 @@ Most of these values are calculated from information configured at authortime in last_location = null regen_limb = null regen_extra = null - . = ..() + nym = null + return ..() /datum/dionastats/proc/do_blood_suck(var/mob/living/carbon/user, var/mob/living/carbon/human/H) user.visible_message(SPAN_DANGER("[user] is trying to bite [H.name]."), SPAN_DANGER("You start biting \the [H], you both must stay still!")) diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 363485acba8..79eff55dfbe 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -101,7 +101,6 @@ //Srom (Shared Dreaming) srom_pulled_by = null srom_pulling = null - bg = null //Just to be sure. GLOB.human_mob_list -= src GLOB.intent_listener -= src diff --git a/html/changelogs/hellfirejag-final-atoms-audit.yml b/html/changelogs/hellfirejag-final-atoms-audit.yml new file mode 100644 index 00000000000..e630ef3430b --- /dev/null +++ b/html/changelogs/hellfirejag-final-atoms-audit.yml @@ -0,0 +1,4 @@ +author: Hellfirejag +delete-after: True +changes: + - bugfix: "Fixed numerous hard dels related to byond built-in refs not being cleared."