From c3b129f1a3cca6094a3bdc05bc401293674e0d16 Mon Sep 17 00:00:00 2001 From: tacoguy7765093 Date: Thu, 18 Jul 2024 01:52:45 -0400 Subject: [PATCH] [READY TO MERGE] Port's RS's anti job camping to Anomoly (#8618) --- code/controllers/configuration_ch.dm | 3 ++ .../configuration_ch/entries/chompstation.dm | 3 ++ code/controllers/subsystems/job.dm | 29 +++++++++++++++++++ code/game/jobs/job/job.dm | 11 +++++++ code/game/jobs/job_controller.dm | 4 +++ code/game/machinery/computer/timeclock_vr.dm | 10 +++++++ code/modules/mob/new_player/new_player_vr.dm | 8 +++++ modular_chomp/code/game/jobs/job/noncrew.dm | 29 ++++++++++--------- 8 files changed, 83 insertions(+), 14 deletions(-) diff --git a/code/controllers/configuration_ch.dm b/code/controllers/configuration_ch.dm index f7f09f5f3c..2dcb5657db 100644 --- a/code/controllers/configuration_ch.dm +++ b/code/controllers/configuration_ch.dm @@ -33,6 +33,7 @@ var/discord_ahelps_disabled = 0 //Turn this off if you don't want the TGS bot sending you messages whenever an ahelp ticket is created. var/discord_ahelps_all = 0 //Turn this on if you want all admin-PMs to go to be sent to discord, and not only the first message of a ticket. + var/list/ip_whitelist = list() /hook/startup/proc/read_ch_config() @@ -102,6 +103,8 @@ config.role_request_id_expedition = value if ("role_request_id_silicon") config.role_request_id_silicon = value + if("job_camp_time_limit") + config.job_camp_time_limit = value MINUTES var/list/ip_whitelist_lines = file2list("config/ip_whitelist.txt") diff --git a/code/controllers/configuration_ch/entries/chompstation.dm b/code/controllers/configuration_ch/entries/chompstation.dm index e2b7d71d09..6721c9a13b 100644 --- a/code/controllers/configuration_ch/entries/chompstation.dm +++ b/code/controllers/configuration_ch/entries/chompstation.dm @@ -65,3 +65,6 @@ /datum/config_entry/str_list/ip_whitelist protection = CONFIG_ENTRY_LOCKED | CONFIG_ENTRY_HIDDEN + +/datum/config_entry/number/job_camp_time_limit + default = 10 MINUTES diff --git a/code/controllers/subsystems/job.dm b/code/controllers/subsystems/job.dm index 42956bee8f..1c4ca61292 100644 --- a/code/controllers/subsystems/job.dm +++ b/code/controllers/subsystems/job.dm @@ -10,12 +10,20 @@ SUBSYSTEM_DEF(job) var/list/department_datums = list() var/debug_messages = FALSE + var/savepath = "data/job_camp_list.json" // CHOMPadd + var/list/shift_keys = list() // CHOMPadd + var/list/restricted_keys = list() // CHOMPadd + /datum/controller/subsystem/job/Initialize() // CHOMPEdit if(!department_datums.len) setup_departments() if(!occupations.len) setup_occupations() + //CHOMPadd begin + if(CONFIG_GET(number/job_camp_time_limit)) + load_camp_lists() + //CHOMPadd end return SS_INIT_SUCCESS // CHOMPEdit /datum/controller/subsystem/job/proc/setup_occupations(faction = "Station") @@ -141,3 +149,24 @@ SUBSYSTEM_DEF(job) /datum/controller/subsystem/job/proc/job_debug_message(message) if(debug_messages) log_debug("JOB DEBUG: [message]") + +//CHOMPadd start +/datum/controller/subsystem/job/proc/load_camp_lists() + if(fexists(savepath)) + restricted_keys = json_decode(file2text(savepath)) + fdel(savepath) + +/datum/controller/subsystem/job/Shutdown(Addr, Natural) + . = ..() + if(fexists(savepath)) + fdel(savepath) + var/json_to_file = json_encode(shift_keys) + if(!json_to_file) + log_debug("Saving: [savepath] failed jsonencode") + return + + //Write it out + rustg_file_write(json_to_file, savepath) + if(!fexists(savepath)) + log_debug("Saving: failed to save [savepath]") +//CHOMPadd end diff --git a/code/game/jobs/job/job.dm b/code/game/jobs/job/job.dm index da5b5055ec..348585b089 100644 --- a/code/game/jobs/job/job.dm +++ b/code/game/jobs/job/job.dm @@ -39,6 +39,10 @@ // Description of the job's role and minimum responsibilities. var/job_description = "This Job doesn't have a description! Please report it!" + var/camp_protection = FALSE //CHOMPadd + var/list/restricted_keys = list() //CHOMPadd + var/list/shift_keys = list() //CHOMPadd + /datum/job/New() . = ..() department_accounts = department_accounts || departments_managed @@ -189,6 +193,13 @@ return TRUE */ +//CHOMPadd start +/datum/job/proc/register_shift_key(key) + if(key) + var/list/keylist = list(key) + SSjob.shift_keys[title] += keylist +//CHOMPadd end + //CHOMPAdd Start /datum/job/proc/update_limit(var/comperator) return diff --git a/code/game/jobs/job_controller.dm b/code/game/jobs/job_controller.dm index f6674d508d..70fe124fff 100644 --- a/code/game/jobs/job_controller.dm +++ b/code/game/jobs/job_controller.dm @@ -72,6 +72,10 @@ var/global/datum/controller/occupations/job_master player.mind.role_alt_title = GetPlayerAltTitle(player, rank) unassigned -= player job.current_positions++ + //CHOMPadd START + if(job.camp_protection && round_duration_in_ds < transfer_controller.shift_hard_end - 30 MINUTES) + job.register_shift_key(player.client.ckey) + //CHOMPadd END return 1 Debug("AR has failed, Player: [player], Rank: [rank]") return 0 diff --git a/code/game/machinery/computer/timeclock_vr.dm b/code/game/machinery/computer/timeclock_vr.dm index 86612d7615..1426531d29 100644 --- a/code/game/machinery/computer/timeclock_vr.dm +++ b/code/game/machinery/computer/timeclock_vr.dm @@ -177,7 +177,17 @@ return if(newassignment != newjob.title && !(newassignment in newjob.alt_titles)) return + //CHOMPadd START + if(newjob.camp_protection && round_duration_in_ds < CONFIG_GET(number/job_camp_time_limit)) + if(SSjob.restricted_keys.len) + var/list/check = SSjob.restricted_keys[newjob.title] + if(usr.client.ckey in check) + to_chat(usr,span_danger("[newjob.title] is not presently selectable because you played as it last round. It will become available to you in [round((CONFIG_GET(number/job_camp_time_limit) - round_duration_in_ds) / 600)] minutes, if slots remain open.")) + return + //CHOMPadd END + if(newjob) + newjob.register_shift_key(usr.client.ckey)//CHOMPadd card.access = newjob.get_access() card.rank = newjob.title card.assignment = newassignment diff --git a/code/modules/mob/new_player/new_player_vr.dm b/code/modules/mob/new_player/new_player_vr.dm index e985512847..afb7ada28c 100644 --- a/code/modules/mob/new_player/new_player_vr.dm +++ b/code/modules/mob/new_player/new_player_vr.dm @@ -74,6 +74,14 @@ if(points_left < 0 || traits_left < 0) pass = FALSE to_chat(src,"Your custom species is not playable. Reconfigure your traits on the VORE tab.") +//CHOMPadd start + if(J.camp_protection && round_duration_in_ds < CONFIG_GET(number/job_camp_time_limit)) + if(SSjob.restricted_keys.len) + var/list/check = SSjob.restricted_keys[J.title] + if(client.ckey in check) + to_chat(client,span_danger("[J.title] is not presently selectable because you played as it last round. It will become available to you in [round(CONFIG_GET(number/job_camp_time_limit - round_duration_in_ds) / 600)] minutes, if slots remain open.")) + pass = FALSE + //CHOMPadd end //CHOMP Addition Begin if(client?.prefs?.neu_traits) diff --git a/modular_chomp/code/game/jobs/job/noncrew.dm b/modular_chomp/code/game/jobs/job/noncrew.dm index d5a46e9920..058af7e4f4 100644 --- a/modular_chomp/code/game/jobs/job/noncrew.dm +++ b/modular_chomp/code/game/jobs/job/noncrew.dm @@ -32,22 +32,23 @@ */ /datum/job/shadekin - title = JOB_ANOMALY - disallow_jobhop = TRUE - total_positions = 5 - spawn_positions = 5 - supervisors = "nobody, but you fall under NanoTrasen's Unauthorized Personnel SOP while on NT property. Please read the Shadekin Guidelines clearly before playing" + title = JOB_ANOMALY + disallow_jobhop = TRUE + total_positions = 5 + spawn_positions = 5 + supervisors = "nobody, but you fall under NanoTrasen's Unauthorized Personnel SOP while on NT property. Please read the Shadekin Guidelines clearly before playing" - flag = NONCREW - departments = list(DEPARTMENT_NONCREW) - department_flag = OTHER - faction = "Station" - assignable = FALSE - account_allowed = 0 - offmap_spawn = TRUE + flag = NONCREW + departments = list(DEPARTMENT_NONCREW) + department_flag = OTHER + faction = "Station" + assignable = FALSE + account_allowed = 0 + offmap_spawn = TRUE + camp_protection = TRUE //So far leave this for shadekin - outfit_type = /decl/hierarchy/outfit/noncrew - job_description = {"Players taking a role of an outsider not employed by NT with no special mechanics. One superpose pod is provided. + outfit_type = /decl/hierarchy/outfit/noncrew + job_description = {"Players taking a role of an outsider not employed by NT with no special mechanics. One superpose pod is provided. -----Server rules still apply to the fullest -----Outsiders are considered unauthorized personnel on Southern Cross. -----Outsiders are not allowed to take part in events and mini-event areas unless the EM says otherwise.