diff --git a/code/_onclick/hud/new_player.dm b/code/_onclick/hud/new_player.dm index 5fa44b7f054..371341aec0b 100644 --- a/code/_onclick/hud/new_player.dm +++ b/code/_onclick/hud/new_player.dm @@ -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 diff --git a/code/_onclick/hud/parallax/parallax.dm b/code/_onclick/hud/parallax/parallax.dm index bcdcd0e74fe..0a3732e134f 100644 --- a/code/_onclick/hud/parallax/parallax.dm +++ b/code/_onclick/hud/parallax/parallax.dm @@ -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 diff --git a/code/_onclick/hud/screen_objects.dm b/code/_onclick/hud/screen_objects.dm index 8cc29740870..315efe48778 100644 --- a/code/_onclick/hud/screen_objects.dm +++ b/code/_onclick/hud/screen_objects.dm @@ -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