Skip to content

Commit

Permalink
Makes map view hiding a bit more robust against unusual circumstances (
Browse files Browse the repository at this point in the history
…tgstation#85900)

While in the middle of a destroy chain the mob can no longer be
associated with the client you need to clear huds from. This allows you
to just pass a client into a different proc and has some more error
checking to hopefully avoid visible issues for players if something goes
wrong.

This fixes a runtime I cam across while working on something else.
  • Loading branch information
ninjanomnom authored Aug 18, 2024
1 parent db4cf65 commit 8b0cd15
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions code/_onclick/hud/map_view.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ INITIALIZE_IMMEDIATE(/atom/movable/screen/map_view)

/atom/movable/screen/map_view/Destroy()
for(var/datum/weakref/client_ref in viewers_to_huds)
var/client/our_client = client_ref.resolve()
if(!our_client)
continue
hide_from(our_client.mob)
hide_from_client(client_ref.resolve())

return ..()

Expand Down Expand Up @@ -55,12 +52,18 @@ INITIALIZE_IMMEDIATE(/atom/movable/screen/map_view)
return pop_planes

/atom/movable/screen/map_view/proc/hide_from(mob/hide_from)
hide_from?.canon_client.clear_map(assigned_map)
var/client_ref = WEAKREF(hide_from?.canon_client)
hide_from_client(hide_from?.canon_client)

/atom/movable/screen/map_view/proc/hide_from_client(client/hide_from)
if(!hide_from)
return
hide_from.clear_map(assigned_map)

var/datum/weakref/client_ref = WEAKREF(hide_from)
// Make sure we clear the *right* hud
var/datum/weakref/hud_ref = viewers_to_huds[client_ref]
viewers_to_huds -= client_ref

var/datum/hud/clear_from = hud_ref?.resolve()
if(!clear_from)
return
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/devices/spyglasses.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

/obj/item/clothing/glasses/sunglasses/spy/proc/on_screen_clear(client/source, window)
SIGNAL_HANDLER
linked_bug.cam_screen.hide_from(source.mob)
linked_bug.cam_screen.hide_from_client(source)

/obj/item/clothing/glasses/sunglasses/spy/equipped(mob/user, slot)
. = ..()
Expand Down

0 comments on commit 8b0cd15

Please sign in to comment.