From f4c2fd65c4585d8b67acaddd53e16e1fd3fc41ed Mon Sep 17 00:00:00 2001 From: Lucy Date: Wed, 4 Dec 2024 02:39:45 -0500 Subject: [PATCH] [s] interview code tweaks --- code/__DEFINES/~monkestation/admin.dm | 2 ++ .../~monkestation-helpers/clients.dm | 26 +++++++++++++++++++ code/_onclick/hud/new_player.dm | 1 + code/controllers/subsystem/ticker.dm | 4 +++ .../mob/dead/new_player/latejoin_menu.dm | 2 +- .../modules/mob/dead/new_player/new_player.dm | 8 ++++++ code/modules/mob/dead/observer/login.dm | 3 +++ code/modules/mob/living/login.dm | 4 +++ 8 files changed, 49 insertions(+), 1 deletion(-) diff --git a/code/__DEFINES/~monkestation/admin.dm b/code/__DEFINES/~monkestation/admin.dm index 9edb809cbaba..64ddc4de5ccd 100644 --- a/code/__DEFINES/~monkestation/admin.dm +++ b/code/__DEFINES/~monkestation/admin.dm @@ -16,3 +16,5 @@ #define AHELP_CLOSEREASON_NONE 0 #define AHELP_CLOSEREASON_IC 1 #define AHELP_CLOSEREASON_MENTOR 2 + +#define ADMIN_SUSINFO(user) "[ADMIN_LOOKUP(user)] [ADMIN_PP(user)] [ADMIN_INDIVIDUALLOG(user)] [ADMIN_SMITE(user)]" diff --git a/code/__HELPERS/~monkestation-helpers/clients.dm b/code/__HELPERS/~monkestation-helpers/clients.dm index 6f824905e3da..3ee482320d98 100644 --- a/code/__HELPERS/~monkestation-helpers/clients.dm +++ b/code/__HELPERS/~monkestation-helpers/clients.dm @@ -20,3 +20,29 @@ RETURN_TYPE(/datum/admins) var/client/client = CLIENT_FROM_VAR(doohickey) return client?.holder + +/proc/should_be_interviewing(mob/target) + . = FALSE + if(QDELETED(target)) + return + . = target.client?.interviewee + var/ckey = target.ckey + if(ckey) + if(ckey in GLOB.interviews.approved_ckeys) + return FALSE + var/datum/interview/interview = GLOB.interviews.open_interviews[ckey] + if(interview && interview.status != INTERVIEW_APPROVED) + return TRUE + if(ckey in GLOB.interviews.cooldown_ckeys) + return TRUE + +/proc/interview_safety(mob/target, context) + . = should_be_interviewing(target) + if(.) + message_admins(span_danger("WARNING: [ADMIN_SUSINFO(target)] has seemingly bypassed an interview! (context: [context]) note: this detection is still wip, tell absolucy if it's causing false positives")) + log_admin_private("[key_name(target)] has seemingly bypassed an interview! (context: [context])") + if(isnewplayer(target)) + var/mob/dead/new_player/dingbat = target + if(dingbat.ready == PLAYER_READY_TO_PLAY) + dingbat.ready = PLAYER_NOT_READY + qdel(dingbat.client) diff --git a/code/_onclick/hud/new_player.dm b/code/_onclick/hud/new_player.dm index ecf8ab55a5a8..7e26afc06091 100644 --- a/code/_onclick/hud/new_player.dm +++ b/code/_onclick/hud/new_player.dm @@ -169,6 +169,7 @@ if(!new_client.readied_store) new_client.readied_store = new(new_player) new_client.readied_store.ui_interact(new_player) + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(interview_safety), new_player, "readied up"), 1 SECONDS, TIMER_UNIQUE) else new_player.ready = PLAYER_NOT_READY base_icon_state = "not_ready" diff --git a/code/controllers/subsystem/ticker.dm b/code/controllers/subsystem/ticker.dm index c2db691f6e98..8d46ec714c30 100755 --- a/code/controllers/subsystem/ticker.dm +++ b/code/controllers/subsystem/ticker.dm @@ -399,6 +399,10 @@ SUBSYSTEM_DEF(ticker) for(var/i in GLOB.new_player_list) var/mob/dead/new_player/player = i if(player.ready == PLAYER_READY_TO_PLAY && player.mind) + if(interview_safety(player, "readied up")) + player.ready = PLAYER_NOT_READY + QDEL_IN(player.client, 0) + continue GLOB.joined_player_list += player.ckey var/chosen_title = player.client?.prefs.alt_job_titles[player.mind.assigned_role.title] || player.mind.assigned_role.title var/atom/destination = player.mind.assigned_role.get_roundstart_spawn_point(chosen_title) diff --git a/code/modules/mob/dead/new_player/latejoin_menu.dm b/code/modules/mob/dead/new_player/latejoin_menu.dm index c6831a2fa638..fe7081d07548 100644 --- a/code/modules/mob/dead/new_player/latejoin_menu.dm +++ b/code/modules/mob/dead/new_player/latejoin_menu.dm @@ -117,7 +117,7 @@ GLOBAL_DATUM_INIT(latejoin_menu, /datum/latejoin_menu, new) /datum/latejoin_menu/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state) . = ..() - if(!ui.user.client || ui.user.client.interviewee || !isnewplayer(ui.user)) + if(!ui.user.client || should_be_interviewing(ui.user) || !isnewplayer(ui.user)) return TRUE var/mob/dead/new_player/owner = ui.user diff --git a/code/modules/mob/dead/new_player/new_player.dm b/code/modules/mob/dead/new_player/new_player.dm index 6286383fa318..5f0a7ecda1cc 100644 --- a/code/modules/mob/dead/new_player/new_player.dm +++ b/code/modules/mob/dead/new_player/new_player.dm @@ -67,6 +67,10 @@ ready = PLAYER_NOT_READY return FALSE + if(interview_safety(src, "attempting to observe")) + qdel(client) + return FALSE + var/less_input_message if(SSlag_switch.measures[DISABLE_DEAD_KEYLOOP]) less_input_message = " - Notice: Observer freelook is currently disabled." @@ -143,6 +147,10 @@ return JOB_AVAILABLE /mob/dead/new_player/proc/AttemptLateSpawn(rank) + if(interview_safety(src, "attempting to latejoin")) + qdel(client) + return FALSE + var/error = IsJobUnavailable(rank) if(error != JOB_AVAILABLE) tgui_alert(usr, get_job_unavailable_error_message(error, rank)) diff --git a/code/modules/mob/dead/observer/login.dm b/code/modules/mob/dead/observer/login.dm index d5f2ab6b5db0..606f2187094f 100644 --- a/code/modules/mob/dead/observer/login.dm +++ b/code/modules/mob/dead/observer/login.dm @@ -1,4 +1,7 @@ /mob/dead/observer/Login() + if(interview_safety(src, "observing")) + qdel(client) + return FALSE . = ..() if(!. || !client) return FALSE diff --git a/code/modules/mob/living/login.dm b/code/modules/mob/living/login.dm index c6d6b6a5e9d7..fc64fee3ef00 100644 --- a/code/modules/mob/living/login.dm +++ b/code/modules/mob/living/login.dm @@ -3,6 +3,10 @@ if(!. || !client) return FALSE + if(interview_safety(src, "client in living mob")) + qdel(client) + return FALSE + //Mind updates sync_mind()