Fixes GC for observers and new players, and tons of loose references to stuff that shouldnt be (#55563)

I've done this on a signal because atom_hud is applied very loosely in some contexes, and the objects themselves dont have an easy way to track back into what huds they're affected by, so this seemed the best. Properly cleans up next_time_allowed, which was missing.

Update: I discovered this is also an issue for a lot of simple mobs, such as slimes and bots and such. So fixing this is huge
This commit is contained in:
Azarak
2020-12-17 10:42:49 +01:00
committed by GitHub
parent 2782356a85
commit 0a3edac8fb
2 changed files with 13 additions and 2 deletions
+10 -2
View File
@@ -51,11 +51,14 @@ GLOBAL_LIST_INIT(huds, list(
GLOB.all_huds -= src
return ..()
/datum/atom_hud/proc/remove_hud_from(mob/M)
/datum/atom_hud/proc/remove_hud_from(mob/M, absolute = FALSE)
if(!M || !hudusers[M])
return
if (!--hudusers[M])
if (absolute || !--hudusers[M])
UnregisterSignal(M, COMSIG_PARENT_QDELETING)
hudusers -= M
if(next_time_allowed[M])
next_time_allowed -= M
if(queued_to_see[M])
queued_to_see -= M
else
@@ -81,6 +84,7 @@ GLOBAL_LIST_INIT(huds, list(
return
if(!hudusers[M])
hudusers[M] = 1
RegisterSignal(M, COMSIG_PARENT_QDELETING, .proc/unregister_mob)
if(next_time_allowed[M] > world.time)
if(!queued_to_see[M])
addtimer(CALLBACK(src, .proc/show_hud_images_after_cooldown, M), next_time_allowed[M] - world.time)
@@ -92,6 +96,10 @@ GLOBAL_LIST_INIT(huds, list(
else
hudusers[M]++
/datum/atom_hud/proc/unregister_mob(datum/source, force)
SIGNAL_HANDLER
remove_hud_from(source, TRUE)
/datum/atom_hud/proc/hide_single_atomhud_from(hud_user,hidden_atom)
if(hudusers[hud_user])
remove_from_single_hud(hud_user,hidden_atom)
@@ -160,6 +160,9 @@ GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER)
addtimer(CALLBACK(src, /atom/proc/update_atom_colour), 10)
/mob/dead/observer/Destroy()
if(data_huds_on)
remove_data_huds()
// Update our old body's medhud since we're abandoning it
if(mind?.current)
mind.current.med_hud_set_status()