Whitelisting on jobs framework.

This commit is contained in:
quotefox
2021-07-22 14:41:29 +01:00
parent d63137a189
commit ea41b22c7e
11 changed files with 111 additions and 5 deletions
+5 -2
View File
@@ -199,8 +199,11 @@
body += "<A href='?_src_=holder;[HrefToken()];tdomeadmin=[REF(M)]'>Thunderdome Admin</A> | "
body += "<A href='?_src_=holder;[HrefToken()];tdomeobserve=[REF(M)]'>Thunderdome Observer</A> | "
body += "<A href='?_src_=holder;[HrefToken()];makementor=[M.ckey]'>Make mentor</A> | "
body += "<A href='?_src_=holder;[HrefToken()];removementor=[M.ckey]'>Remove mentor</A>"
body += "<A href='?_src_=holder;[HrefToken()];makeeligible=[REF(M)]'>Allow reentering round</A>"
body += "<A href='?_src_=holder;[HrefToken()];removementor=[M.ckey]'>Remove mentor</A> |"
body += "<A href='?_src_=holder;[HrefToken()];makeeligible=[REF(M)]'>Allow reentering round</A> |"
body += "<A href='?_src_=holder;[HrefToken()];sillyroles=[M.ckey]'>Toggle Silly Roles</A> |"
body += "<A href='?_src_=holder;[HrefToken()];roleplayroles=[M.ckey]'>Toggle Roleplay Roles</A> |"
body += "<A href='?_src_=holder;[HrefToken()];importantroles=[M.ckey]'>Toggle Important Roles</A> |"
body += "<br>"
body += "</body></html>"
+62 -1
View File
@@ -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, "<span class='danger'>Failed to establish database connection. The changes will last only for the current round.</span>")
to_chat(usr, "<span class='adminnotice'>Mentor removed.</span>")
/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, "<span class='adminnotice'>Silly roles have been allowed.</span>")
else
to_chat(usr, "<span class='adminnotice'>Silly roles have been disabled.</span>")
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, "<span class='adminnotice'>Roleplay roles have been allowed.</span>")
else
to_chat(usr, "<span class='adminnotice'>Roleplay roles have been disabled.</span>")
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, "<span class='adminnotice'>Important roles have been allowed.</span>")
else
to_chat(usr, "<span class='adminnotice'>Important roles have been disabled.</span>")
C.prefs.save_preferences()
+5 -1
View File
@@ -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",
@@ -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)
+3
View File
@@ -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)
..()
+3
View File
@@ -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)
-1
View File
@@ -55,7 +55,6 @@ GLOBAL_LIST_INIT(security_positions, list(
"Security Officer",
"Rookie"))
GLOBAL_LIST_INIT(nonhuman_positions, list(
"AI",
"Cyborg",
@@ -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))