fixes a big harddel source (#83987)

## About The Pull Request
this hard delete would happen everytime a player joins/observers the
round. upon using the ref tracker i discovered this problem was caused
by movable/screens not cleaning up after their owning huds if it gets
deleted. i didnt weakref it was cause it meant id have to resolve it in
so many places, but if weakrefing is preferable i will do it

![image](https://github.com/tgstation/tgstation/assets/138636438/d4b5465e-85b6-4e79-80a7-551684bdd831)


## Why It's Good For The Game
fixes a hard delete
This commit is contained in:
Ben10Omintrix
2024-07-16 07:05:21 +02:00
committed by GitHub
parent 7d19c04a8e
commit a61e8eaef5
3 changed files with 20 additions and 5 deletions
+1 -2
View File
@@ -63,8 +63,7 @@
///Set the HUD in New, as lobby screens are made before Atoms are Initialized.
/atom/movable/screen/lobby/New(loc, datum/hud/our_hud, ...)
if(our_hud)
hud = our_hud
set_new_hud(our_hud)
return ..()
///Run sleeping actions after initialize
+1 -1
View File
@@ -275,7 +275,7 @@ INITIALIZE_IMMEDIATE(/atom/movable/screen/parallax_layer)
. = ..()
// Parallax layers are independant of hud, they care about client
// Not doing this will just create a bunch of hard deletes
hud = null
set_new_hud(hud_owner = null)
if(template)
return
+18 -2
View File
@@ -45,8 +45,9 @@
/atom/movable/screen/Initialize(mapload, datum/hud/hud_owner)
. = ..()
if(hud_owner && istype(hud_owner))
hud = hud_owner
if(isnull(hud_owner)) //some screens set their hud owners on /new, this prevents overriding them with null post atoms init
return
set_new_hud(hud_owner)
/atom/movable/screen/Destroy()
master_ref = null
@@ -72,10 +73,25 @@
/atom/movable/screen/proc/component_click(atom/movable/screen/component_button/component, params)
return
///setter used to set our new hud
/atom/movable/screen/proc/set_new_hud(datum/hud/hud_owner)
if(hud)
UnregisterSignal(hud, COMSIG_QDELETING)
if(isnull(hud_owner))
hud = null
return
hud = hud_owner
RegisterSignal(hud, COMSIG_QDELETING, PROC_REF(on_hud_delete))
/// Returns the mob this is being displayed to, if any
/atom/movable/screen/proc/get_mob()
return hud?.mymob
/atom/movable/screen/proc/on_hud_delete(datum/source)
SIGNAL_HANDLER
set_new_hud(hud_owner = null)
/atom/movable/screen/text
icon = null
icon_state = null