From d12ee8c50668fb3a4373be0711901c19063fbedb Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Fri, 6 Jan 2023 16:35:20 +0100 Subject: [PATCH] [MIRROR] Refactor /ui_state/new_player_state to what it's designed for [MDB IGNORE] (#18175) Refactor /ui_state/new_player_state to what it's designed for Co-authored-by: distributivgesetz --- code/modules/interview/interview.dm | 2 ++ code/modules/mob/dead/new_player/latejoin_menu.dm | 12 +++++++++--- code/modules/tgui/states/new_player.dm | 7 ++----- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/code/modules/interview/interview.dm b/code/modules/interview/interview.dm index ebabb9d942c..d96997dc015 100644 --- a/code/modules/interview/interview.dm +++ b/code/modules/interview/interview.dm @@ -117,6 +117,8 @@ ui.open() /datum/interview/ui_state(mob/user) + if(check_rights_for(user.client, R_ADMIN)) + return GLOB.always_state return GLOB.new_player_state /datum/interview/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state) diff --git a/code/modules/mob/dead/new_player/latejoin_menu.dm b/code/modules/mob/dead/new_player/latejoin_menu.dm index 65f055d9f1c..35c9c1d0bc5 100644 --- a/code/modules/mob/dead/new_player/latejoin_menu.dm +++ b/code/modules/mob/dead/new_player/latejoin_menu.dm @@ -26,6 +26,10 @@ GLOBAL_DATUM_INIT(latejoin_menu, /datum/latejoin_menu, new) ui = SStgui.try_update_ui(user, src, ui) if(!ui) // In case they reopen the GUI +<<<<<<< HEAD +======= + // FIXME: this can cause a runtime since user can be a living mob +>>>>>>> dafef2aa4dc (Refactor /ui_state/new_player_state to what it's designed for (#71959)) if(istype(user)) user.jobs_menu_mounted = FALSE addtimer(CALLBACK(src, PROC_REF(scream_at_player), user), 5 SECONDS) @@ -113,9 +117,8 @@ GLOBAL_DATUM_INIT(latejoin_menu, /datum/latejoin_menu, new) return list("departments_static" = departments) -// we can't use GLOB.new_player_state here since it also allows any admin to see the ui, which will cause runtimes -/datum/latejoin_menu/ui_status(mob/user) - return isnewplayer(user) ? UI_INTERACTIVE : UI_CLOSE +/datum/latejoin_menu/ui_state(mob/user) + return GLOB.new_player_state /datum/latejoin_menu/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state) . = ..() @@ -166,8 +169,11 @@ GLOBAL_DATUM_INIT(latejoin_menu, /datum/latejoin_menu, new) // SAFETY: AttemptLateSpawn has it's own sanity checks. This is perfectly safe. owner.AttemptLateSpawn(params["job"]) +<<<<<<< HEAD return TRUE +======= +>>>>>>> dafef2aa4dc (Refactor /ui_state/new_player_state to what it's designed for (#71959)) if("viewpoll") var/datum/poll_question/poll = locate(params["viewpoll"]) in GLOB.polls if(!poll) diff --git a/code/modules/tgui/states/new_player.dm b/code/modules/tgui/states/new_player.dm index cf6f83ed3a1..cd33bcfcfae 100644 --- a/code/modules/tgui/states/new_player.dm +++ b/code/modules/tgui/states/new_player.dm @@ -1,13 +1,10 @@ /** * tgui state: new_player_state * - * Checks that the user is a new_player, or if user is an admin + * Checks that the user is a /mob/dead/new_player */ GLOBAL_DATUM_INIT(new_player_state, /datum/ui_state/new_player_state, new) /datum/ui_state/new_player_state/can_use_topic(src_object, mob/user) - if(isnewplayer(user) || check_rights_for(user.client, R_ADMIN)) - return UI_INTERACTIVE - return UI_CLOSE - + return isnewplayer(user) ? UI_INTERACTIVE : UI_CLOSE