From ea41b22c7e1a89d4aea5ec73566ac96ceb6e7077 Mon Sep 17 00:00:00 2001 From: quotefox Date: Thu, 22 Jul 2021 14:41:29 +0100 Subject: [PATCH] Whitelisting on jobs framework. --- code/__DEFINES/jobs.dm | 1 + code/modules/admin/admin.dm | 7 ++- code/modules/admin/topic.dm | 63 ++++++++++++++++++- code/modules/client/preferences.dm | 6 +- code/modules/client/preferences_savefile.dm | 9 +++ code/modules/jobs/job_types/civilian.dm | 3 + code/modules/jobs/job_types/job.dm | 3 + code/modules/jobs/jobs.dm | 1 - .../modules/mob/dead/new_player/new_player.dm | 9 +++ .../code/modules/jobs/job_types/roleplay.dm | 13 ++++ tgstation.dme | 1 + 11 files changed, 111 insertions(+), 5 deletions(-) create mode 100644 hyperstation/code/modules/jobs/job_types/roleplay.dm diff --git a/code/__DEFINES/jobs.dm b/code/__DEFINES/jobs.dm index 3a64637a..86dd868a 100644 --- a/code/__DEFINES/jobs.dm +++ b/code/__DEFINES/jobs.dm @@ -53,3 +53,4 @@ #define JOB_UNAVAILABLE_PLAYTIME 3 #define JOB_UNAVAILABLE_ACCOUNTAGE 4 #define JOB_UNAVAILABLE_SLOTFULL 5 +#define JOB_UNAVAILABLE_WHITELIST 6 \ No newline at end of file diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index 7121aaac..acdfc605 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -199,8 +199,11 @@ body += "Thunderdome Admin | " body += "Thunderdome Observer | " body += "Make mentor | " - body += "Remove mentor" - body += "Allow reentering round" + body += "Remove mentor |" + body += "Allow reentering round |" + body += "Toggle Silly Roles |" + body += "Toggle Roleplay Roles |" + body += "Toggle Important Roles |" body += "
" body += "" diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index c781cf31..3e1d04b0 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -22,6 +22,16 @@ if(!CheckAdminHref(href, href_list)) return + + if(href_list["sillyroles"]) //toggle, clown and mime. + togglesilly(href_list["sillyroles"]) + + if(href_list["roleplayroles"]) //toggle, roleplay jobs + toggleroleplay(href_list["roleplayroles"]) + + if(href_list["importantroles"]) //toggle, roleplay jobs + toggleimportant(href_list["importantroles"]) + if(href_list["makementor"]) makeMentor(href_list["makementor"]) else if(href_list["removementor"]) @@ -1359,7 +1369,7 @@ else if(href_list["f_secret"]) return HandleFSecret() - + //Dynamic mode else if(href_list["f_dynamic_roundstart"]) if(!check_rights(R_ADMIN)) @@ -2991,3 +3001,54 @@ to_chat(usr, "Failed to establish database connection. The changes will last only for the current round.") to_chat(usr, "Mentor removed.") +/datum/admins/proc/togglesilly(ckey) + if(!usr.client) + return + if (!check_rights(0)) + return + if(!ckey) + return + var/client/C = GLOB.directory[ckey] + if(!C) + return + C.prefs.sillyroles = !C.prefs.sillyroles + if(C.prefs.sillyroles) + to_chat(usr, "Silly roles have been allowed.") + else + to_chat(usr, "Silly roles have been disabled.") + C.prefs.save_preferences() + + +/datum/admins/proc/toggleroleplay(ckey) + if(!usr.client) + return + if (!check_rights(0)) + return + if(!ckey) + return + var/client/C = GLOB.directory[ckey] + if(!C) + return + C.prefs.roleplayroles = !C.prefs.roleplayroles + if(C.prefs.roleplayroles) + to_chat(usr, "Roleplay roles have been allowed.") + else + to_chat(usr, "Roleplay roles have been disabled.") + C.prefs.save_preferences() + +/datum/admins/proc/toggleimportant(ckey) + if(!usr.client) + return + if (!check_rights(0)) + return + if(!ckey) + return + var/client/C = GLOB.directory[ckey] + if(!C) + return + C.prefs.importantroles = !C.prefs.importantroles + if(C.prefs.importantroles) + to_chat(usr, "Important roles have been allowed.") + else + to_chat(usr, "Important roles have been disabled.") + C.prefs.save_preferences() \ No newline at end of file diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 42ae307a..b1c2229c 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -96,10 +96,14 @@ GLOBAL_LIST_EMPTY(preferences_datums) var/eye_color = "000" //Eye color var/wing_color = "fff" //Wing color - //H13 + //HS13 var/body_size = 100 //Body Size in percent var/can_get_preg = 0 //if they can get preggers + //HS13 jobs + var/sillyroles = FALSE //for clown and mime + var/roleplayroles = FALSE //for the roleplay roles + var/importantroles = FALSE //for things that define as important. var/datum/species/pref_species = new /datum/species/human() //Mutant race var/list/features = list("mcolor" = "FFF", diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index 71379b48..f4c91da8 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -141,6 +141,9 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car //Hyper code S["noncon"] >> noncon + S["sillyroles"] >> sillyroles + S["roleplayroles"] >> roleplayroles + S["importantroles"] >> importantroles //try to fix any outdated data if necessfary if(needs_update >= 0) @@ -152,6 +155,9 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car UI_style = sanitize_inlist(UI_style, GLOB.available_ui_styles, GLOB.available_ui_styles[1]) hotkeys = sanitize_integer(hotkeys, 0, 1, initial(hotkeys)) autocorrect = sanitize_integer(autocorrect, 0, 1, initial(autocorrect)) + sillyroles = sanitize_integer(sillyroles, 0, 1, initial(sillyroles)) + roleplayroles = sanitize_integer(roleplayroles, 0, 1, initial(roleplayroles)) + importantroles = sanitize_integer(importantroles, 0, 1, initial(importantroles)) chat_on_map = sanitize_integer(chat_on_map, 0, 1, initial(chat_on_map)) radiosounds = sanitize_integer(radiosounds, 0, 1, initial(radiosounds)) max_chat_length = sanitize_integer(max_chat_length, 1, CHAT_MESSAGE_MAX_LENGTH, initial(max_chat_length)) @@ -212,6 +218,9 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car WRITE_FILE(S["hotkeys"], hotkeys) WRITE_FILE(S["chat_on_map"], chat_on_map) WRITE_FILE(S["autocorrect"], autocorrect) + WRITE_FILE(S["sillyroles"], sillyroles) + WRITE_FILE(S["roleplayroles"], roleplayroles) + WRITE_FILE(S["importantroles"], importantroles) WRITE_FILE(S["radiosounds"], radiosounds) WRITE_FILE(S["max_chat_length"], max_chat_length) WRITE_FILE(S["see_chat_non_mob"], see_chat_non_mob) diff --git a/code/modules/jobs/job_types/civilian.dm b/code/modules/jobs/job_types/civilian.dm index 7d97858f..bceea381 100644 --- a/code/modules/jobs/job_types/civilian.dm +++ b/code/modules/jobs/job_types/civilian.dm @@ -17,6 +17,8 @@ Clown access = list(ACCESS_THEATRE) minimal_access = list(ACCESS_THEATRE) + whitelist_type = "silly" + /datum/job/clown/after_spawn(mob/living/carbon/human/H, mob/M) ..() H.apply_pref_name("clown", M.client) @@ -81,6 +83,7 @@ Mime access = list(ACCESS_THEATRE) minimal_access = list(ACCESS_THEATRE) + whitelist_type = "silly" /datum/job/mime/after_spawn(mob/living/carbon/human/H, mob/M) ..() diff --git a/code/modules/jobs/job_types/job.dm b/code/modules/jobs/job_types/job.dm index 7b4ed75c..79711fd1 100644 --- a/code/modules/jobs/job_types/job.dm +++ b/code/modules/jobs/job_types/job.dm @@ -63,6 +63,9 @@ var/override_roundstart_spawn = null //Where the player spawns at roundstart if defined + //whitelisting + var/whitelist_type = "" + //Only override this proc //H is usually a human unless an /equip override transformed it /datum/job/proc/after_spawn(mob/living/H, mob/M, latejoin = FALSE) diff --git a/code/modules/jobs/jobs.dm b/code/modules/jobs/jobs.dm index df3f48aa..08616e28 100644 --- a/code/modules/jobs/jobs.dm +++ b/code/modules/jobs/jobs.dm @@ -55,7 +55,6 @@ GLOBAL_LIST_INIT(security_positions, list( "Security Officer", "Rookie")) - GLOBAL_LIST_INIT(nonhuman_positions, list( "AI", "Cyborg", diff --git a/code/modules/mob/dead/new_player/new_player.dm b/code/modules/mob/dead/new_player/new_player.dm index 7382647a..c4ec1cf4 100644 --- a/code/modules/mob/dead/new_player/new_player.dm +++ b/code/modules/mob/dead/new_player/new_player.dm @@ -318,6 +318,8 @@ return "[jobtitle] is unavailable." if(JOB_UNAVAILABLE_BANNED) return "You are currently banned from [jobtitle]." + if(JOB_UNAVAILABLE_WHITELIST) + return "You are not whitelisted for [jobtitle]." if(JOB_UNAVAILABLE_PLAYTIME) return "You do not have enough relevant playtime for [jobtitle]." if(JOB_UNAVAILABLE_ACCOUNTAGE) @@ -341,6 +343,13 @@ return JOB_UNAVAILABLE_SLOTFULL if(jobban_isbanned(src,rank)) return JOB_UNAVAILABLE_BANNED + if(job.whitelist_type) //whitelisting + if(job.whitelist_type == "roleplay" && !client.prefs.roleplayroles) + return JOB_UNAVAILABLE_WHITELIST + if(job.whitelist_type == "important" && !client.prefs.importantroles) + return JOB_UNAVAILABLE_WHITELIST + if(job.whitelist_type == "silly" && !client.prefs.sillyroles) + return JOB_UNAVAILABLE_WHITELIST if(QDELETED(src)) return JOB_UNAVAILABLE_GENERIC if(!job.player_old_enough(client)) diff --git a/hyperstation/code/modules/jobs/job_types/roleplay.dm b/hyperstation/code/modules/jobs/job_types/roleplay.dm new file mode 100644 index 00000000..9becaf9b --- /dev/null +++ b/hyperstation/code/modules/jobs/job_types/roleplay.dm @@ -0,0 +1,13 @@ +/* +Roleplay Jobs, Currently borked. + +/datum/job/rpcentral + title = "Central Command Inspector" + faction = "Station" + total_positions = 1 + spawn_positions = 1 + minimal_player_age = 1 + supervisors = "central command" + selection_color = "#ffeef0" + custom_spawn_text = "You are from central command doing a routine inspection of the station, please fill out the provided information and submit it to central command by the end of the shift." +*/ \ No newline at end of file diff --git a/tgstation.dme b/tgstation.dme index 35c9308a..9ae84b47 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -3126,6 +3126,7 @@ #include "hyperstation\code\modules\economy\account.dm" #include "hyperstation\code\modules\events\crystalline_reentry.dm" #include "hyperstation\code\modules\integrated_electronics\input.dm" +#include "hyperstation\code\modules\jobs\job_types\roleplay.dm" #include "hyperstation\code\modules\mining\shelters.dm" #include "hyperstation\code\modules\mining\equipment\survival_pod.dm" #include "hyperstation\code\modules\mob\mob_helpers.dm"