Fixes storage UI breaking upon an observer detaching while having your storage UI open under odd circumstances (#86842)

## About The Pull Request
This is one of the stupidest issues I had the displeasure of working
with and I still do not know concrete details behind the issue because
some of the code introduced in this (supposed-to-be) debug PR
accidentally fixed said issue. Essentially, under odd circumstances of
the user either being SSD or having their storage focus stolen by
something else, an observer who had their storage UI open via
autoobserve could break their UI by moving away because that improperly
removed the user from some lists. This is the primary theory judging
from what fixed the issue, but sadly there is no concrete info behind it
as all attempts to reproduce the bug, both locally and on live, have
failed.

Closes #85259

## Changelog
🆑
fix: Storage UI should no longer (not so much) randomly disappear,
hooray!
/🆑
This commit is contained in:
SmArtKar
2024-09-24 21:30:07 +02:00
committed by GitHub
parent c1ca5c5989
commit 057135702d
+7 -6
View File
@@ -974,7 +974,7 @@ GLOBAL_LIST_EMPTY(cached_storage_typecaches)
if(user.active_storage == src && user.client)
seeing += user
else
is_using -= user
hide_contents(user)
return seeing
/**
@@ -1032,8 +1032,6 @@ GLOBAL_LIST_EMPTY(cached_storage_typecaches)
* * mob/to_hide - the mob to hide the storage from
*/
/datum/storage/proc/hide_contents(mob/to_hide)
if(!to_hide.client)
return TRUE
if(to_hide.active_storage == src)
to_hide.active_storage = null
@@ -1046,8 +1044,9 @@ GLOBAL_LIST_EMPTY(cached_storage_typecaches)
is_using -= to_hide
to_hide.client.screen -= storage_interfaces[to_hide].list_ui_elements()
to_hide.client.screen -= real_location.contents
if(to_hide.client)
to_hide.client.screen -= storage_interfaces[to_hide].list_ui_elements()
to_hide.client.screen -= real_location.contents
QDEL_NULL(storage_interfaces[to_hide])
storage_interfaces -= to_hide
@@ -1078,7 +1077,9 @@ GLOBAL_LIST_EMPTY(cached_storage_typecaches)
var/columns = clamp(max_slots, 1, screen_max_columns)
var/rows = clamp(CEILING(adjusted_contents / columns, 1) + additional_row, 1, screen_max_rows)
for (var/ui_user in storage_interfaces)
for (var/mob/ui_user as anything in storage_interfaces)
if (isnull(storage_interfaces[ui_user]))
continue
storage_interfaces[ui_user].update_position(screen_start_x, screen_pixel_x, screen_start_y, screen_pixel_y, columns, rows)
var/current_x = screen_start_x