Skip to content

Commit

Permalink
Databasing whitelists (#5402)
Browse files Browse the repository at this point in the history
# About the pull request
In theory, this should now make whitelists entirely controllable by
their senators/the overseer(s) without direct management input.
Major thanks to HarryOB for the major base of this code, all I did is
make the UI and some code.
<!-- Remove this text and explain what the purpose of your PR is.

Mention if you have tested your changes. If you changed a map, make sure
you used the mapmerge tool.
If this is an Issue Correction, you can type "Fixes Issue #169420" to
link the PR to the corresponding Issue number #169420.

Remember: something that is self-evident to you might not be to others.
Explain your rationale fully, even if you feel it goes without saying.
-->

# Explain why it's good for the game
# Testing Photographs and Procedure
<details>
<summary>Screenshots & Videos</summary>

Put screenshots and videos here with an empty line between the
screenshots and the `<details>` tags.

</details>


# Changelog
:cl:
add: Added Whitelist Panel for whitelist senators to manage their own
whitelists.
refactor: Whitelist.txt is no longer functional, owing to the new
system.
del: Removed "Alien Whitelist" checks regarding base SS13 races.
/:cl:

---------

Co-authored-by: harryob <[email protected]>
Co-authored-by: harryob <[email protected]>
  • Loading branch information
3 people committed Jan 22, 2024
1 parent b8a2117 commit 6a24a44
Show file tree
Hide file tree
Showing 31 changed files with 672 additions and 269 deletions.
42 changes: 35 additions & 7 deletions code/__DEFINES/mode.dm
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ GLOBAL_LIST_INIT(ROLES_UNASSIGNED, list(JOB_SQUAD_MARINE))
GLOBAL_LIST_INIT(whitelist_hierarchy, list(WHITELIST_NORMAL, WHITELIST_COUNCIL, WHITELIST_LEADER))

//=================================================

#define WHITELIST_YAUTJA (1<<0)
///Old holders of YAUTJA_ELDER
#define WHITELIST_YAUTJA_LEGACY (1<<1)
Expand All @@ -170,23 +171,50 @@ GLOBAL_LIST_INIT(whitelist_hierarchy, list(WHITELIST_NORMAL, WHITELIST_COUNCIL,
///Old holders of COMMANDER_COUNCIL for 3 months
#define WHITELIST_COMMANDER_COUNCIL_LEGACY (1<<7)
#define WHITELIST_COMMANDER_LEADER (1<<8)
///Former CO senator/whitelist overseer award
#define WHITELIST_COMMANDER_COLONEL (1<<9)

#define WHITELIST_JOE (1<<9)
#define WHITELIST_SYNTHETIC (1<<10)
#define WHITELIST_SYNTHETIC_COUNCIL (1<<11)
#define WHITELIST_JOE (1<<10)
#define WHITELIST_SYNTHETIC (1<<11)
#define WHITELIST_SYNTHETIC_COUNCIL (1<<12)
///Old holders of SYNTHETIC_COUNCIL for 3 months
#define WHITELIST_SYNTHETIC_COUNCIL_LEGACY (1<<12)
#define WHITELIST_SYNTHETIC_LEADER (1<<13)
#define WHITELIST_SYNTHETIC_COUNCIL_LEGACY (1<<13)
#define WHITELIST_SYNTHETIC_LEADER (1<<14)

///Senior Enlisted Advisor, auto granted by R_MENTOR
#define WHITELIST_MENTOR (1<<15)


#define WHITELIST_MENTOR (1<<14)
#define WHITELISTS_GENERAL (WHITELIST_YAUTJA|WHITELIST_COMMANDER|WHITELIST_SYNTHETIC|WHITELIST_MENTOR|WHITELIST_JOE)
#define WHITELISTS_COUNCIL (WHITELIST_YAUTJA_COUNCIL|WHITELIST_COMMANDER_COUNCIL|WHITELIST_SYNTHETIC_COUNCIL)
#define WHITELISTS_LEGACY_COUNCIL (WHITELIST_YAUTJA_COUNCIL_LEGACY|WHITELIST_COMMANDER_COUNCIL_LEGACY|WHITELIST_SYNTHETIC_COUNCIL_LEGACY)
#define WHITELISTS_LEADER (WHITELIST_YAUTJA_LEADER|WHITELIST_COMMANDER_LEADER|WHITELIST_SYNTHETIC_LEADER)

#define WHITELIST_EVERYTHING (WHITELISTS_GENERAL|WHITELISTS_COUNCIL|WHITELISTS_LEADER)

#define isCouncil(A) (GLOB.RoleAuthority.roles_whitelist[A.ckey] & WHITELIST_YAUTJA_COUNCIL) || (GLOB.RoleAuthority.roles_whitelist[A.ckey] & WHITELIST_SYNTHETIC_COUNCIL) || (GLOB.RoleAuthority.roles_whitelist[A.ckey] & WHITELIST_COMMANDER_COUNCIL)
#define COUNCIL_LIST list(WHITELIST_COMMANDER_COUNCIL, WHITELIST_SYNTHETIC_COUNCIL, WHITELIST_YAUTJA_COUNCIL)
#define SENATOR_LIST list(WHITELIST_COMMANDER_LEADER, WHITELIST_SYNTHETIC_LEADER, WHITELIST_YAUTJA_LEADER)
#define isCouncil(A) (A.check_whitelist_status_list(COUNCIL_LIST))
#define isSenator(A) (A.check_whitelist_status_list(SENATOR_LIST))

DEFINE_BITFIELD(whitelist_status, list(
"WHITELIST_YAUTJA" = WHITELIST_YAUTJA,
"WHITELIST_YAUTJA_LEGACY" = WHITELIST_YAUTJA_LEGACY,
"WHITELIST_YAUTJA_COUNCIL" = WHITELIST_YAUTJA_COUNCIL,
"WHITELIST_YAUTJA_COUNCIL_LEGACY" = WHITELIST_YAUTJA_COUNCIL_LEGACY,
"WHITELIST_YAUTJA_LEADER" = WHITELIST_YAUTJA_LEADER,
"WHITELIST_COMMANDER" = WHITELIST_COMMANDER,
"WHITELIST_COMMANDER_COUNCIL" = WHITELIST_COMMANDER_COUNCIL,
"WHITELIST_COMMANDER_COUNCIL_LEGACY" = WHITELIST_COMMANDER_COUNCIL_LEGACY,
"WHITELIST_COMMANDER_COLONEL" = WHITELIST_COMMANDER_COLONEL,
"WHITELIST_COMMANDER_LEADER" = WHITELIST_COMMANDER_LEADER,
"WHITELIST_JOE" = WHITELIST_JOE,
"WHITELIST_SYNTHETIC" = WHITELIST_SYNTHETIC,
"WHITELIST_SYNTHETIC_COUNCIL" = WHITELIST_SYNTHETIC_COUNCIL,
"WHITELIST_SYNTHETIC_COUNCIL_LEGACY" = WHITELIST_SYNTHETIC_COUNCIL_LEGACY,
"WHITELIST_SYNTHETIC_LEADER" = WHITELIST_SYNTHETIC_LEADER,
"WHITELIST_MENTOR" = WHITELIST_MENTOR,
))

//=================================================

Expand Down
2 changes: 1 addition & 1 deletion code/datums/emergency_calls/clf.dm
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
leader = H
to_chat(H, SPAN_ROLE_HEADER("You are a Cell Leader of the local resistance group, the Colonial Liberation Front!"))
arm_equipment(H, /datum/equipment_preset/clf/leader, TRUE, TRUE)
else if(synths < max_synths && HAS_FLAG(H.client.prefs.toggles_ert, PLAY_SYNTH) && GLOB.RoleAuthority.roles_whitelist[H.ckey] & WHITELIST_SYNTHETIC)
else if(synths < max_synths && HAS_FLAG(H.client.prefs.toggles_ert, PLAY_SYNTH) && H.client.check_whitelist_status(WHITELIST_SYNTHETIC))
synths++
to_chat(H, SPAN_ROLE_HEADER("You are a Multi-Purpose Synthetic for the local resistance group, the Colonial Liberation Front!"))
arm_equipment(H, /datum/equipment_preset/clf/synth, TRUE, TRUE)
Expand Down
2 changes: 1 addition & 1 deletion code/datums/emergency_calls/cmb.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
leader = mob
to_chat(mob, SPAN_ROLE_HEADER("You are the Colonial Marshal!"))
arm_equipment(mob, /datum/equipment_preset/cmb/leader, TRUE, TRUE)
else if(synths < max_synths && HAS_FLAG(mob?.client.prefs.toggles_ert, PLAY_SYNTH) && GLOB.RoleAuthority.roles_whitelist[mob.ckey] & WHITELIST_SYNTHETIC)
else if(synths < max_synths && HAS_FLAG(mob?.client.prefs.toggles_ert, PLAY_SYNTH) && mob.client.check_whitelist_status(WHITELIST_SYNTHETIC))
synths++
to_chat(mob, SPAN_ROLE_HEADER("You are a CMB Investigative Synthetic!"))
arm_equipment(mob, /datum/equipment_preset/cmb/synth, TRUE, TRUE)
Expand Down
4 changes: 2 additions & 2 deletions code/datums/emergency_calls/contractor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
leader = mob
to_chat(mob, SPAN_ROLE_HEADER("You are a Contractor Team Leader of Vanguard's Arrow Incorporated!"))
arm_equipment(mob, /datum/equipment_preset/contractor/duty/leader, TRUE, TRUE)
else if(synths < max_synths && HAS_FLAG(mob.client.prefs.toggles_ert, PLAY_SYNTH) && GLOB.RoleAuthority.roles_whitelist[mob.ckey] & WHITELIST_SYNTHETIC)
else if(synths < max_synths && HAS_FLAG(mob.client.prefs.toggles_ert, PLAY_SYNTH) && mob.client.check_whitelist_status(WHITELIST_SYNTHETIC))
synths++
to_chat(mob, SPAN_ROLE_HEADER("You are a Contractor Support Synthetic of Vanguard's Arrow Incorporated!"))
arm_equipment(mob, /datum/equipment_preset/contractor/duty/synth, TRUE, TRUE)
Expand Down Expand Up @@ -123,7 +123,7 @@
leader = H
to_chat(H, SPAN_ROLE_HEADER("You are a Covert Contractor Team Leader of Vanguard's Arrow Incorporated!"))
arm_equipment(H, /datum/equipment_preset/contractor/covert/leader, TRUE, TRUE)
else if(synths < max_synths && HAS_FLAG(H.client.prefs.toggles_ert, PLAY_SYNTH) && GLOB.RoleAuthority.roles_whitelist[H.ckey] & WHITELIST_SYNTHETIC)
else if(synths < max_synths && HAS_FLAG(H.client.prefs.toggles_ert, PLAY_SYNTH) && H.client.check_whitelist_status(WHITELIST_SYNTHETIC))
synths++
to_chat(H, SPAN_ROLE_HEADER("You are a Contractor Support Synthetic of Vanguard's Arrow Incorporated!"))
arm_equipment(H, /datum/equipment_preset/contractor/covert/synth, TRUE, TRUE)
Expand Down
2 changes: 1 addition & 1 deletion code/datums/emergency_calls/inspection.dm
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
leader = mob
to_chat(mob, SPAN_ROLE_HEADER("You are the Colonial Marshal!"))
arm_equipment(mob, /datum/equipment_preset/cmb/leader, TRUE, TRUE)
else if(synths < max_synths && HAS_FLAG(mob?.client.prefs.toggles_ert, PLAY_SYNTH) && GLOB.RoleAuthority.roles_whitelist[mob.ckey] & WHITELIST_SYNTHETIC)
else if(synths < max_synths && HAS_FLAG(mob?.client.prefs.toggles_ert, PLAY_SYNTH) && mob.client.check_whitelist_status(WHITELIST_SYNTHETIC))
synths++
to_chat(mob, SPAN_ROLE_HEADER("You are a CMB Investigative Synthetic!"))
arm_equipment(mob, /datum/equipment_preset/cmb/synth, TRUE, TRUE)
Expand Down
2 changes: 1 addition & 1 deletion code/datums/emergency_calls/pmc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
leader = mob
to_chat(mob, SPAN_ROLE_HEADER("You are a Weyland-Yutani PMC Squad Leader!"))
arm_equipment(mob, /datum/equipment_preset/pmc/pmc_leader, TRUE, TRUE)
else if(synths < max_synths && HAS_FLAG(mob.client.prefs.toggles_ert, PLAY_SYNTH) && GLOB.RoleAuthority.roles_whitelist[mob.ckey] & WHITELIST_SYNTHETIC)
else if(synths < max_synths && HAS_FLAG(mob.client.prefs.toggles_ert, PLAY_SYNTH) && mob.client.check_whitelist_status(WHITELIST_SYNTHETIC))
synths++
to_chat(mob, SPAN_ROLE_HEADER("You are a Weyland-Yutani PMC Support Synthetic!"))
arm_equipment(mob, /datum/equipment_preset/pmc/synth, TRUE, TRUE)
Expand Down
2 changes: 1 addition & 1 deletion code/datums/emergency_calls/upp.dm
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
leader = H
arm_equipment(H, /datum/equipment_preset/upp/leader, TRUE, TRUE)
to_chat(H, SPAN_ROLE_HEADER("You are an Officer of the Union of Progressive People, a powerful socialist state that rivals the United Americas!"))
else if(synths < max_synths && HAS_FLAG(H.client.prefs.toggles_ert, PLAY_SYNTH) && GLOB.RoleAuthority.roles_whitelist[H.ckey] & WHITELIST_SYNTHETIC)
else if(synths < max_synths && HAS_FLAG(H.client.prefs.toggles_ert, PLAY_SYNTH) && H.client.check_whitelist_status(WHITELIST_SYNTHETIC))
synths++
to_chat(H, SPAN_ROLE_HEADER("You are a Combat Synthetic of the Union of Progressive People, a powerful socialist state that rivals the United Americas!"))
arm_equipment(H, /datum/equipment_preset/upp/synth, TRUE, TRUE)
Expand Down
2 changes: 1 addition & 1 deletion code/datums/emergency_calls/xeno_cultists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
leader = H
to_chat(H, SPAN_ROLE_HEADER("You are the leader of this xeno cult! Bring glory to Queen Mother!"))
arm_equipment(H, /datum/equipment_preset/other/xeno_cultist/leader, TRUE, TRUE)
else if(synths < max_synths && HAS_FLAG(H.client.prefs.toggles_ert, PLAY_SYNTH) && GLOB.RoleAuthority.roles_whitelist[H.ckey] & WHITELIST_SYNTHETIC)
else if(synths < max_synths && HAS_FLAG(H.client.prefs.toggles_ert, PLAY_SYNTH) && H.client.check_whitelist_status(WHITELIST_SYNTHETIC))
synths++
to_chat(H, SPAN_ROLE_HEADER("You are the xeno cult's synthetic! Tend to the Hive and the captured hosts, make sure the Hive grows!"))
arm_equipment(H, /datum/equipment_preset/synth/survivor/cultist_synth, TRUE, TRUE)
Expand Down
42 changes: 28 additions & 14 deletions code/datums/entities/player.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
var/last_known_ip
var/last_known_cid

var/whitelist_status
var/whitelist_flags

var/discord_link_id

var/last_login
Expand Down Expand Up @@ -63,6 +66,7 @@ BSQL_PROTECT_DATUM(/datum/entity/player)
"is_permabanned" = DB_FIELDTYPE_INT,
"permaban_reason" = DB_FIELDTYPE_STRING_MAX,
"permaban_date" = DB_FIELDTYPE_STRING_LARGE,
"whitelist_status" = DB_FIELDTYPE_STRING_MAX,
"discord_link_id" = DB_FIELDTYPE_BIGINT,
"permaban_admin_id" = DB_FIELDTYPE_BIGINT,
"is_time_banned" = DB_FIELDTYPE_INT,
Expand Down Expand Up @@ -321,20 +325,6 @@ BSQL_PROTECT_DATUM(/datum/entity/player)
value.delete()
job_bans -= value

/datum/entity/player/proc/load_refs()
if(refs_loaded)
return
while(!notes_loaded || !jobbans_loaded)
stoplag()
for(var/key in job_bans)
var/datum/entity/player_job_ban/value = job_bans[key]
if(istype(value))
value.load_refs()
for(var/datum/entity/player_note/note in notes)
if(istype(note))
note.load_refs()
refs_loaded = TRUE

/datum/entity_meta/player/on_read(datum/entity/player/player)
player.job_bans = list()
player.notes = list()
Expand Down Expand Up @@ -391,7 +381,12 @@ BSQL_PROTECT_DATUM(/datum/entity/player)
if(discord_link_id)
discord_link = DB_ENTITY(/datum/entity/discord_link, discord_link_id)

if(whitelist_status)
var/list/whitelists = splittext(whitelist_status, "|")

for(var/whitelist in whitelists)
if(whitelist in GLOB.bitfields["whitelist_status"])
whitelist_flags |= GLOB.bitfields["whitelist_status"]["[whitelist]"]

/datum/entity/player/proc/on_read_notes(list/datum/entity/player_note/_notes)
notes_loaded = TRUE
Expand Down Expand Up @@ -657,6 +652,23 @@ BSQL_PROTECT_DATUM(/datum/entity/player)
stat.stat_number += num
stat.save()

/datum/entity/player/proc/check_whitelist_status(flag_to_check)
if(whitelist_flags & flag_to_check)
return TRUE

return FALSE

/datum/entity/player/proc/set_whitelist_status(field_to_set)
whitelist_flags = field_to_set

var/list/output = list()
for(var/bitfield in GLOB.bitfields["whitelist_status"])
if(field_to_set & GLOB.bitfields["whitelist_status"]["[bitfield]"])
output += bitfield
whitelist_status = output.Join("|")

save()

/datum/entity_link/player_to_banning_admin
parent_entity = /datum/entity/player
child_entity = /datum/entity/player
Expand Down Expand Up @@ -685,6 +697,7 @@ BSQL_PROTECT_DATUM(/datum/entity/player)
var/last_known_cid
var/last_known_ip
var/discord_link_id
var/whitelist_status

/datum/entity_view_meta/players
root_record_type = /datum/entity/player
Expand All @@ -702,4 +715,5 @@ BSQL_PROTECT_DATUM(/datum/entity/player)
"last_known_ip",
"last_known_cid",
"discord_link_id",
"whitelist_status"
)
12 changes: 6 additions & 6 deletions code/game/gamemodes/cm_initialize.dm
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ Additional game mode variables.
else
if(!istype(player,/mob/dead)) continue //Otherwise we just want to grab the ghosts.

if(GLOB.RoleAuthority.roles_whitelist[player.ckey] & WHITELIST_PREDATOR) //Are they whitelisted?
if(player?.client.check_whitelist_status(WHITELIST_PREDATOR)) //Are they whitelisted?
if(!player.client.prefs)
player.client.prefs = new /datum/preferences(player.client) //Somehow they don't have one.

Expand Down Expand Up @@ -188,7 +188,7 @@ Additional game mode variables.
if(show_warning) to_chat(pred_candidate, SPAN_WARNING("Something went wrong!"))
return

if(!(GLOB.RoleAuthority.roles_whitelist[pred_candidate.ckey] & WHITELIST_PREDATOR))
if(!(pred_candidate?.client.check_whitelist_status(WHITELIST_PREDATOR)))
if(show_warning) to_chat(pred_candidate, SPAN_WARNING("You are not whitelisted! You may apply on the forums to be whitelisted as a predator."))
return

Expand All @@ -201,9 +201,9 @@ Additional game mode variables.
to_chat(pred_candidate, SPAN_WARNING("You already were a Yautja! Give someone else a chance."))
return

if(show_warning && tgui_alert(pred_candidate, "Confirm joining the hunt. You will join as \a [lowertext(J.get_whitelist_status(GLOB.RoleAuthority.roles_whitelist, pred_candidate.client))] predator", "Confirmation", list("Yes", "No"), 10 SECONDS) != "Yes")
if(show_warning && tgui_alert(pred_candidate, "Confirm joining the hunt. You will join as \a [lowertext(J.get_whitelist_status(pred_candidate.client))] predator", "Confirmation", list("Yes", "No"), 10 SECONDS) != "Yes")
return
if(J.get_whitelist_status(GLOB.RoleAuthority.roles_whitelist, pred_candidate.client) == WHITELIST_NORMAL)
if(J.get_whitelist_status(pred_candidate.client) == WHITELIST_NORMAL)
var/pred_max = calculate_pred_max
if(pred_current_num >= pred_max)
if(show_warning) to_chat(pred_candidate, SPAN_WARNING("Only [pred_max] predators may spawn this round, but Councillors and Ancients do not count."))
Expand Down Expand Up @@ -1001,7 +1001,7 @@ Additional game mode variables.
to_chat(joe_candidate, SPAN_WARNING("Something went wrong!"))
return

if(!(GLOB.RoleAuthority.roles_whitelist[joe_candidate.ckey] & WHITELIST_JOE))
if(!joe_job.check_whitelist_status(joe_candidate))
if(show_warning)
to_chat(joe_candidate, SPAN_WARNING("You are not whitelisted! You may apply on the forums to be whitelisted as a synth."))
return
Expand All @@ -1012,7 +1012,7 @@ Additional game mode variables.
return

// council doesn't count towards this conditional.
if(joe_job.get_whitelist_status(GLOB.RoleAuthority.roles_whitelist, joe_candidate.client) == WHITELIST_NORMAL)
if(joe_job.get_whitelist_status(joe_candidate.client) == WHITELIST_NORMAL)
var/joe_max = joe_job.total_positions
if((joe_job.current_positions >= joe_max) && !MODE_HAS_TOGGLEABLE_FLAG(MODE_BYPASS_JOE))
if(show_warning)
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/extended/infection.dm
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
possible_synth_survivors -= A
continue

if(GLOB.RoleAuthority.roles_whitelist[ckey(A.key)] & WHITELIST_SYNTHETIC)
if(A.current.client?.check_whitelist_status(WHITELIST_SYNTHETIC))
if(A in possible_survivors)
continue //they are already applying to be a survivor
else
Expand Down
11 changes: 2 additions & 9 deletions code/game/jobs/job/antag/other/pred.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@

SSticker.mode.attempt_to_join_as_predator(player)

/datum/job/antag/predator/get_whitelist_status(list/roles_whitelist, client/player) // Might be a problem waiting here, but we've got no choice
. = ..()
if(!.)
return

/datum/job/antag/predator/get_whitelist_status(client/player) // Might be a problem waiting here, but we've got no choice
if(!player.clan_info)
return CLAN_RANK_BLOODED

Expand All @@ -49,10 +45,7 @@
if(!("[JOB_PREDATOR][rank]" in gear_preset_whitelist))
return CLAN_RANK_BLOODED

if(\
(roles_whitelist[player.ckey] & (WHITELIST_YAUTJA_LEADER|WHITELIST_YAUTJA_COUNCIL|WHITELIST_YAUTJA_COUNCIL_LEGACY)) &&\
get_desired_status(player.prefs.yautja_status, WHITELIST_COUNCIL) == WHITELIST_NORMAL\
)
if(player.check_whitelist_status(WHITELIST_YAUTJA_LEADER|WHITELIST_YAUTJA_COUNCIL|WHITELIST_YAUTJA_COUNCIL_LEGACY) && get_desired_status(player.prefs.yautja_status, WHITELIST_COUNCIL) == WHITELIST_NORMAL)
return CLAN_RANK_BLOODED

return rank
Expand Down
8 changes: 4 additions & 4 deletions code/game/jobs/job/civilians/support/synthetic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
"[JOB_SYNTH][WHITELIST_LEADER]" = /datum/equipment_preset/synth/uscm/councillor
)

/datum/job/civilian/synthetic/get_whitelist_status(list/roles_whitelist, client/player)
/datum/job/civilian/synthetic/get_whitelist_status(client/player)
. = ..()
if(!.)
return

if(roles_whitelist[player.ckey] & WHITELIST_SYNTHETIC_LEADER)
if(player.check_whitelist_status(WHITELIST_SYNTHETIC_LEADER))
return get_desired_status(player.prefs.synth_status, WHITELIST_LEADER)
else if(roles_whitelist[player.ckey] & (WHITELIST_SYNTHETIC_COUNCIL|WHITELIST_SYNTHETIC_COUNCIL_LEGACY))
if(player.check_whitelist_status(WHITELIST_SYNTHETIC_COUNCIL|WHITELIST_SYNTHETIC_COUNCIL_LEGACY))
return get_desired_status(player.prefs.synth_status, WHITELIST_COUNCIL)
else if(roles_whitelist[player.ckey] & WHITELIST_SYNTHETIC)
if(player.check_whitelist_status(WHITELIST_SYNTHETIC))
return get_desired_status(player.prefs.synth_status, WHITELIST_NORMAL)

/datum/job/civilian/synthetic/set_spawn_positions(count)
Expand Down
6 changes: 6 additions & 0 deletions code/game/jobs/job/civilians/support/working_joe.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
job_options = list(STANDARD_VARIANT = "JOE", HAZMAT_VARIANT = "HAZ")
var/standard = TRUE

/datum/job/civilian/working_joe/check_whitelist_status(mob/user)
if(user.client.check_whitelist_status(WHITELIST_SYNTHETIC))
return TRUE

return ..()

/datum/job/civilian/working_joe/handle_job_options(option)
if(option != HAZMAT_VARIANT)
standard = TRUE
Expand Down
8 changes: 4 additions & 4 deletions code/game/jobs/job/command/cic/captain.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
entry_message_body = "<a href='[generate_wiki_link()]'>You are the Commanding Officer of the [MAIN_SHIP_NAME] as well as the operation.</a> Your goal is to lead the Marines on their mission as well as protect and command the ship and her crew. Your job involves heavy roleplay and requires you to behave like a high-ranking officer and to stay in character at all times. As the Commanding Officer your only superior is High Command itself. You must abide by the <a href='[CONFIG_GET(string/wikiarticleurl)]/[URL_WIKI_CO_RULES]'>Commanding Officer Code of Conduct</a>. Failure to do so may result in punitive action against you. Godspeed."
return ..()

/datum/job/command/commander/get_whitelist_status(list/roles_whitelist, client/player)
/datum/job/command/commander/get_whitelist_status(client/player)
. = ..()
if(!.)
return

if(roles_whitelist[player.ckey] & WHITELIST_COMMANDER_LEADER)
if(player.check_whitelist_status(WHITELIST_COMMANDER_LEADER|WHITELIST_COMMANDER_COLONEL))
return get_desired_status(player.prefs.commander_status, WHITELIST_LEADER)
else if(roles_whitelist[player.ckey] & (WHITELIST_COMMANDER_COUNCIL|WHITELIST_COMMANDER_COUNCIL_LEGACY))
if(player.check_whitelist_status(WHITELIST_COMMANDER_COUNCIL|WHITELIST_COMMANDER_COUNCIL_LEGACY))
return get_desired_status(player.prefs.commander_status, WHITELIST_COUNCIL)
else if(roles_whitelist[player.ckey] & WHITELIST_COMMANDER)
if(player.check_whitelist_status(WHITELIST_COMMANDER))
return get_desired_status(player.prefs.commander_status, WHITELIST_NORMAL)

/datum/job/command/commander/announce_entry_message(mob/living/carbon/human/H)
Expand Down
14 changes: 9 additions & 5 deletions code/game/jobs/job/job.dm
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@
return ""
return "[CONFIG_GET(string/wikiarticleurl)]/[replacetext(title, " ", "_")]"

/datum/job/proc/get_whitelist_status(list/roles_whitelist, client/player)
if(!roles_whitelist)
return FALSE

/datum/job/proc/get_whitelist_status(client/player)
return WHITELIST_NORMAL

/datum/timelock
Expand Down Expand Up @@ -252,7 +249,7 @@
var/mob/living/carbon/human/human = M

var/job_whitelist = title
var/whitelist_status = get_whitelist_status(GLOB.RoleAuthority.roles_whitelist, human.client)
var/whitelist_status = get_whitelist_status(human.client)

if(whitelist_status)
job_whitelist = "[title][whitelist_status]"
Expand Down Expand Up @@ -314,3 +311,10 @@
/// Intended to be overwritten to handle any requirements for specific job variations that can be selected
/datum/job/proc/filter_job_option(mob/job_applicant)
return job_options

/datum/job/proc/check_whitelist_status(mob/user)
if(!(flags_startup_parameters & ROLE_WHITELISTED))
return TRUE

if(user.client.check_whitelist_status(flags_whitelist))
return TRUE
Loading

0 comments on commit 6a24a44

Please sign in to comment.