From f3c456d06aa8339262846aa4dbe8eae4b80853ab Mon Sep 17 00:00:00 2001 From: Fluffy <65877598+FluffyGhoster@users.noreply.github.com> Date: Thu, 28 Mar 2024 02:11:08 +0100 Subject: [PATCH] Mob atom movable destroy cleanup (#18769) * Atomization * sdaf --------- Co-authored-by: FluffyGhost --- code/game/atoms_movable.dm | 23 +++++++++-- code/modules/client/preferences.dm | 11 ++--- .../modules/ghostroles/spawner/human/human.dm | 1 - code/modules/mob/living/carbon/human/human.dm | 18 +++++--- code/modules/mob/living/living.dm | 2 - code/modules/mob/living/silicon/silicon.dm | 3 ++ code/modules/mob/mob.dm | 15 +++++-- code/modules/orbit/orbit.dm | 2 +- code/modules/shareddream/dream_entry.dm | 1 - ...Ghost-mob_atom_movable_destroy_cleanup.yml | 41 +++++++++++++++++++ 10 files changed, 95 insertions(+), 22 deletions(-) create mode 100644 html/changelogs/FluffyGhost-mob_atom_movable_destroy_cleanup.yml diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index 388006419d8..ab60ec6a844 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -57,7 +57,11 @@ /atom/movable/Destroy() GLOB.moved_event.unregister_all_movement(loc, src) - . = ..() + //Recalculate opacity + var/turf/T = loc + if(opacity && istype(T)) + T.recalc_atom_opacity() + T.reconsider_lights() if(move_packet) if(!QDELETED(move_packet)) @@ -67,11 +71,13 @@ if(spatial_grid_key) SSspatial_grid.force_remove_from_grid(src) + QDEL_LAZYLIST(contained_mobs) + + . = ..() + for(var/movable_content in contents) qdel(movable_content) - QDEL_LAZYLIST(contained_mobs) - //Pretend this is moveToNullspace() moveToNullspace() loc = null @@ -81,6 +87,13 @@ //If we clear this before the nullspace move, a ref to this object will be hung in any of its movable containers LAZYNULL(important_recursive_contents) + + vis_locs = null //clears this atom out of all viscontents + + // Checking length(vis_contents) before cutting has significant speed benefits + if (length(vis_contents)) + vis_contents.Cut() + screen_loc = null if(ismob(pulledby)) var/mob/M = pulledby @@ -281,6 +294,10 @@ verbs.Cut() ..() +/atom/movable/overlay/Destroy(force) + master = null + . = ..() + /atom/movable/overlay/attackby(a, b) if (src.master) return src.master.attackby(a, b) diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 5745321878c..c82a2250156 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -321,6 +321,7 @@ var/list/preferences_datums = list() var/obj/screen/S = char_render_holders[index] client?.screen -= S qdel(S) + QDEL_LIST_ASSOC_VAL(char_render_holders) char_render_holders = null /datum/preferences/proc/process_link(mob/user, list/href_list) @@ -336,10 +337,6 @@ var/list/preferences_datums = list() else to_chat(user, "The forum URL is not set in the server configuration.") return - else if(href_list["close"]) - // User closed preferences window, cleanup anything we need to. - clear_character_previews() - return 1 return 1 /datum/preferences/Topic(href, list/href_list) @@ -375,8 +372,12 @@ var/list/preferences_datums = list() if (alert(usr, "You will be unable to re-create a character with the same name! Are you sure you want to permanently [real_name]? The slot can not be restored.", "Permanently Delete Character", "No", "Yes") == "Yes") if(alert(usr, "Are you sure you want to PERMANENTLY delete your character?","Confirm Permanent Deletion","Yes","No") == "Yes") delete_character_sql(usr.client) + else if(href_list["close"]) + // User closed preferences window, cleanup anything we need to. + clear_character_previews() + return 1 else - return 0 + return ShowChoices(usr) return 1 diff --git a/code/modules/ghostroles/spawner/human/human.dm b/code/modules/ghostroles/spawner/human/human.dm index aa5b9e9fe8a..654c1c6f3c4 100644 --- a/code/modules/ghostroles/spawner/human/human.dm +++ b/code/modules/ghostroles/spawner/human/human.dm @@ -185,4 +185,3 @@ /mob/living/carbon/human/Destroy() ghost_spawner = null . = ..() - GC_TEMPORARY_HARDDEL diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 6bcc9d460e5..fbacd35cd9f 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -127,11 +127,20 @@ QDEL_NULL(l_store) QDEL_NULL(s_store) QDEL_NULL(wear_suit) + QDEL_NULL(wear_mask) // Do this last so the mob's stuff doesn't drop on del. QDEL_NULL(w_uniform) + //Yes this is shit, but since someone had the brillant mind to use images for this, we must suffer + if(length(hud_list)) + for(var/image/hud_overlay/an_hud_overlay in hud_list) + if(an_hud_overlay.owner) + an_hud_overlay.owner.client?.images -= an_hud_overlay + an_hud_overlay.owner = null + qdel(an_hud_overlay) + hud_list = null + . = ..() - GC_TEMPORARY_HARDDEL /mob/living/carbon/human/can_devour(atom/movable/victim, var/silent = FALSE) if(!should_have_organ(BP_STOMACH)) @@ -1464,10 +1473,9 @@ maxHealth = species.total_health health = maxHealth - spawn(0) - regenerate_icons() - if (vessel) - restore_blood() + regenerate_icons() + if (vessel) + restore_blood() // Rebuild the HUD. If they aren't logged in then login() should reinstantiate it for them. if(client && client.screen) diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 82c30fbb154..6fc8d60b4fa 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -926,8 +926,6 @@ default behaviour is: for(var/a in auras) remove_aura(a) - QDEL_NULL(ability_master) - return ..() /mob/living/proc/nervous_system_failure() diff --git a/code/modules/mob/living/silicon/silicon.dm b/code/modules/mob/living/silicon/silicon.dm index 0c978dd061b..920b6bc884b 100644 --- a/code/modules/mob/living/silicon/silicon.dm +++ b/code/modules/mob/living/silicon/silicon.dm @@ -77,6 +77,9 @@ QDEL_NULL(common_radio) for(var/datum/alarm_handler/AH in SSalarm.all_handlers) AH.unregister_alarm(src) + + QDEL_LIST_ASSOC_VAL(hud_list) + return ..() /mob/living/silicon/proc/init_id() diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 254660f4192..f2490b26a52 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -3,25 +3,32 @@ #define FULLY_BUCKLED 2 /mob/Destroy()//This makes sure that mobs with clients/keys are not just deleted from the game. + MOB_STOP_THINKING(src) + GLOB.mob_list -= src GLOB.dead_mob_list -= src GLOB.living_mob_list -= src unset_machine() QDEL_NULL(hud_used) lose_hearing_sensitivity() + + QDEL_LIST(spell_masters) + remove_screen_obj_references() + if(client) - for(var/obj/screen/movable/spell_master/spell_master in spell_masters) - qdel(spell_master) - remove_screen_obj_references() for(var/atom/movable/AM in client.screen) qdel(AM) client.screen = list() + if (mind) mind.handle_mob_deletion(src) + for(var/infection in viruses) qdel(infection) + for(var/cc in client_colors) qdel(cc) + client_colors = null viruses.Cut() item_verbs = null @@ -41,7 +48,7 @@ var/atom/movable/AM = src.loc LAZYREMOVE(AM.contained_mobs, src) - MOB_STOP_THINKING(src) + QDEL_NULL(ability_master) return ..() diff --git a/code/modules/orbit/orbit.dm b/code/modules/orbit/orbit.dm index ffdec2f7e14..531135af5b8 100644 --- a/code/modules/orbit/orbit.dm +++ b/code/modules/orbit/orbit.dm @@ -92,7 +92,7 @@ /atom/movable/proc/stop_orbit() SpinAnimation(0,0) - qdel(orbiting) + QDEL_NULL(orbiting) /atom/movable/Destroy(force = FALSE) . = ..() diff --git a/code/modules/shareddream/dream_entry.dm b/code/modules/shareddream/dream_entry.dm index 9d05bbefde8..39f0e5d32bc 100644 --- a/code/modules/shareddream/dream_entry.dm +++ b/code/modules/shareddream/dream_entry.dm @@ -12,7 +12,6 @@ var/list/dream_entries = list() srom_pulling = null bg = null //Just to be sure. . = ..() - GC_TEMPORARY_HARDDEL /mob/living/carbon/human/proc/handle_shared_dreaming(var/force_wakeup = FALSE) // If they're an Unconsious person with the abillity to do Skrellepathy. diff --git a/html/changelogs/FluffyGhost-mob_atom_movable_destroy_cleanup.yml b/html/changelogs/FluffyGhost-mob_atom_movable_destroy_cleanup.yml new file mode 100644 index 00000000000..f22b00b00be --- /dev/null +++ b/html/changelogs/FluffyGhost-mob_atom_movable_destroy_cleanup.yml @@ -0,0 +1,41 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# wip (For works in progress) +# tweak +# soundadd +# sounddel +# rscadd (general adding of nice things) +# rscdel (general deleting of nice things) +# imageadd +# imagedel +# maptweak +# spellcheck (typo fixes) +# experiment +# balance +# admin +# backend +# security +# refactor +################################# + +# Your name. +author: FluffyGhost + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. +# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. +changes: + - bugfix: "Fixed some mobs and mannequins harddels."