[READY TO MERGE] Port's RS's anti job camping to Anomoly (#8618)

This commit is contained in:
tacoguy7765093
2024-07-18 01:52:45 -04:00
committed by GitHub
parent 6423d0ff47
commit c3b129f1a3
8 changed files with 83 additions and 14 deletions

View File

@@ -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")

View File

@@ -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

View File

@@ -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