Skip to content

Commit

Permalink
[MIRROR] Fixes an odd bug with record consoles (#1550) (#2495)
Browse files Browse the repository at this point in the history
* Fixes an odd bug with record consoles (#82103)

## About The Pull Request

1. Record computers never had ``character_preview_view`` set because it
was never returned, and it was additionally never deleted. This caused
an odd bug that, if you joined a round, ghosted, sent yourself back to
lobby, then rejoined, record consoles would no longer have a character
preview view. This fixes that, and also adds a define because I didn't
like the copypasta it had going on.

Security records currently have a big difference from the previous
version in that every person on the UI sees their own thing (it's local
instead of shared), which is a bigger problem that affects the whole
computer and really should be addressed.

This PR compliments tgstation/tgstation#82105 -
This was a bug I found while working on that.

## Why It's Good For The Game

Fixes an odd bug with security records that I've been trying to find out
the cause to for a while.

## Changelog

:cl:
fix: Clients joining a round twice as a crewmember (via admins or
otherwise) no longer break security/medical record consoles permanently.
/:cl:

* Fixes an odd bug with record consoles

---------

Co-authored-by: NovaBot <[email protected]>
Co-authored-by: John Willard <[email protected]>
  • Loading branch information
3 people authored Mar 22, 2024
1 parent 356fba4 commit e24c76c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions code/__DEFINES/computers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@
#define CATEGORY_BEPIS "Bepis Tech"
#define CATEGORY_BITRUNNING_FLAIR "Misc"
#define CATEGORY_BITRUNNING_TECH "Tech"

///Helper macro for record computers' preview views, used to ensure consistency in all use cases.
#define USER_PREVIEW_ASSIGNED_VIEW(user_ckey) "preview_[user_ckey]_[REF(src)]_records"
2 changes: 1 addition & 1 deletion code/game/machinery/computer/records/medical.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
return
ui = SStgui.try_update_ui(user, src, ui)
if (!ui)
create_character_preview_view(user)
character_preview_view = create_character_preview_view(user)
ui = new(user, src, "MedicalRecords")
ui.set_autoupdate(FALSE)
ui.open()
Expand Down
11 changes: 9 additions & 2 deletions code/game/machinery/computer/records/records.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@
if(!has_access)
return data

data["assigned_view"] = "preview_[user.ckey]_[REF(src)]_records"
data["assigned_view"] = USER_PREVIEW_ASSIGNED_VIEW(user.ckey)
data["station_z"] = !!(z && is_station_level(z))

return data

/obj/machinery/computer/records/ui_close(mob/user)
. = ..()
user.client?.screen_maps -= USER_PREVIEW_ASSIGNED_VIEW(user.ckey)
if((LAZYLEN(open_uis) <= 1) && character_preview_view) //only delete the preview if we're the last one to close the console.
QDEL_NULL(character_preview_view)

/obj/machinery/computer/records/ui_act(action, list/params, datum/tgui/ui)
. = ..()
if(.)
Expand Down Expand Up @@ -107,13 +113,14 @@

/// Creates a character preview view for the UI.
/obj/machinery/computer/records/proc/create_character_preview_view(mob/user)
var/assigned_view = "preview_[user.ckey]_[REF(src)]_records"
var/assigned_view = USER_PREVIEW_ASSIGNED_VIEW(user.ckey)
if(user.client?.screen_maps[assigned_view])
return

var/atom/movable/screen/map_view/char_preview/new_view = new(null, src)
new_view.generate_view(assigned_view)
new_view.display_to(user)
return new_view

/// Takes a record and updates the character preview view to match it.
/obj/machinery/computer/records/proc/update_preview(mob/user, assigned_view, datum/record/crew/target)
Expand Down

0 comments on commit e24c76c

Please sign in to comment.