Skip to content

Commit

Permalink
Mob atom movable destroy cleanup (Aurorastation#18769)
Browse files Browse the repository at this point in the history
* Atomization

* sdaf

---------

Co-authored-by: FluffyGhost <FluffyGhost>
  • Loading branch information
FluffyGhoster authored Mar 28, 2024
1 parent 613967e commit f3c456d
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 22 deletions.
23 changes: 20 additions & 3 deletions code/game/atoms_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 6 additions & 5 deletions code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -336,10 +337,6 @@ var/list/preferences_datums = list()
else
to_chat(user, "<span class='danger'>The forum URL is not set in the server configuration.</span>")
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)
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion code/modules/ghostroles/spawner/human/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,3 @@
/mob/living/carbon/human/Destroy()
ghost_spawner = null
. = ..()
GC_TEMPORARY_HARDDEL
18 changes: 13 additions & 5 deletions code/modules/mob/living/carbon/human/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions code/modules/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions code/modules/mob/living/silicon/silicon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
15 changes: 11 additions & 4 deletions code/modules/mob/mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -41,7 +48,7 @@
var/atom/movable/AM = src.loc
LAZYREMOVE(AM.contained_mobs, src)

MOB_STOP_THINKING(src)
QDEL_NULL(ability_master)

return ..()

Expand Down
2 changes: 1 addition & 1 deletion code/modules/orbit/orbit.dm
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@

/atom/movable/proc/stop_orbit()
SpinAnimation(0,0)
qdel(orbiting)
QDEL_NULL(orbiting)

/atom/movable/Destroy(force = FALSE)
. = ..()
Expand Down
1 change: 0 additions & 1 deletion code/modules/shareddream/dream_entry.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
41 changes: 41 additions & 0 deletions html/changelogs/FluffyGhost-mob_atom_movable_destroy_cleanup.yml
Original file line number Diff line number Diff line change
@@ -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."

0 comments on commit f3c456d

Please sign in to comment.