diff --git a/code/__DEFINES/mode.dm b/code/__DEFINES/mode.dm index 0f04006859e9..2b018c0a2810 100644 --- a/code/__DEFINES/mode.dm +++ b/code/__DEFINES/mode.dm @@ -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) @@ -170,15 +171,20 @@ 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) @@ -186,7 +192,29 @@ GLOBAL_LIST_INIT(whitelist_hierarchy, list(WHITELIST_NORMAL, WHITELIST_COUNCIL, #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, +)) //================================================= diff --git a/code/datums/emergency_calls/clf.dm b/code/datums/emergency_calls/clf.dm index 837ecb340dda..88c95ef31bc4 100644 --- a/code/datums/emergency_calls/clf.dm +++ b/code/datums/emergency_calls/clf.dm @@ -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) diff --git a/code/datums/emergency_calls/cmb.dm b/code/datums/emergency_calls/cmb.dm index 5dba3ee8fc7d..56b8b169b313 100644 --- a/code/datums/emergency_calls/cmb.dm +++ b/code/datums/emergency_calls/cmb.dm @@ -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) diff --git a/code/datums/emergency_calls/contractor.dm b/code/datums/emergency_calls/contractor.dm index 0e0c975f0d13..05d6ab7b4671 100644 --- a/code/datums/emergency_calls/contractor.dm +++ b/code/datums/emergency_calls/contractor.dm @@ -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) @@ -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) diff --git a/code/datums/emergency_calls/inspection.dm b/code/datums/emergency_calls/inspection.dm index 2cd121093ea4..f0400528ac31 100644 --- a/code/datums/emergency_calls/inspection.dm +++ b/code/datums/emergency_calls/inspection.dm @@ -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) diff --git a/code/datums/emergency_calls/pmc.dm b/code/datums/emergency_calls/pmc.dm index 2d21dc768f4a..2f43e94828d6 100644 --- a/code/datums/emergency_calls/pmc.dm +++ b/code/datums/emergency_calls/pmc.dm @@ -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) diff --git a/code/datums/emergency_calls/upp.dm b/code/datums/emergency_calls/upp.dm index 80ef111be3e4..c075c4be25db 100644 --- a/code/datums/emergency_calls/upp.dm +++ b/code/datums/emergency_calls/upp.dm @@ -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) diff --git a/code/datums/emergency_calls/xeno_cultists.dm b/code/datums/emergency_calls/xeno_cultists.dm index 5da5c9c17e59..f112511b5e22 100644 --- a/code/datums/emergency_calls/xeno_cultists.dm +++ b/code/datums/emergency_calls/xeno_cultists.dm @@ -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) diff --git a/code/datums/entities/player.dm b/code/datums/entities/player.dm index e5fa811002a2..2973a174858f 100644 --- a/code/datums/entities/player.dm +++ b/code/datums/entities/player.dm @@ -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 @@ -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, @@ -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() @@ -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 @@ -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 @@ -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 @@ -702,4 +715,5 @@ BSQL_PROTECT_DATUM(/datum/entity/player) "last_known_ip", "last_known_cid", "discord_link_id", + "whitelist_status" ) diff --git a/code/game/gamemodes/cm_initialize.dm b/code/game/gamemodes/cm_initialize.dm index c017733de7fd..af66052ddf05 100644 --- a/code/game/gamemodes/cm_initialize.dm +++ b/code/game/gamemodes/cm_initialize.dm @@ -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. @@ -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 @@ -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.")) @@ -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 @@ -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) diff --git a/code/game/gamemodes/extended/infection.dm b/code/game/gamemodes/extended/infection.dm index 1e0032a8e6fa..58d92355269d 100644 --- a/code/game/gamemodes/extended/infection.dm +++ b/code/game/gamemodes/extended/infection.dm @@ -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 diff --git a/code/game/jobs/job/antag/other/pred.dm b/code/game/jobs/job/antag/other/pred.dm index 77439276d04a..3808c5637da9 100644 --- a/code/game/jobs/job/antag/other/pred.dm +++ b/code/game/jobs/job/antag/other/pred.dm @@ -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 @@ -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 diff --git a/code/game/jobs/job/civilians/support/synthetic.dm b/code/game/jobs/job/civilians/support/synthetic.dm index 70060fb36a15..12e50ef6c809 100644 --- a/code/game/jobs/job/civilians/support/synthetic.dm +++ b/code/game/jobs/job/civilians/support/synthetic.dm @@ -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) diff --git a/code/game/jobs/job/civilians/support/working_joe.dm b/code/game/jobs/job/civilians/support/working_joe.dm index bc8f8c439900..d890b3684084 100644 --- a/code/game/jobs/job/civilians/support/working_joe.dm +++ b/code/game/jobs/job/civilians/support/working_joe.dm @@ -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 diff --git a/code/game/jobs/job/command/cic/captain.dm b/code/game/jobs/job/command/cic/captain.dm index 72f861351912..30fa455beeee 100644 --- a/code/game/jobs/job/command/cic/captain.dm +++ b/code/game/jobs/job/command/cic/captain.dm @@ -19,16 +19,16 @@ entry_message_body = "You are the Commanding Officer of the [MAIN_SHIP_NAME] as well as the operation. 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 Commanding Officer Code of Conduct. 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) diff --git a/code/game/jobs/job/job.dm b/code/game/jobs/job/job.dm index 094b899c1691..1a04c3cafeb5 100644 --- a/code/game/jobs/job/job.dm +++ b/code/game/jobs/job/job.dm @@ -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 @@ -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]" @@ -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 diff --git a/code/game/jobs/role_authority.dm b/code/game/jobs/role_authority.dm index be2b75e0e7f6..58c9ad5b5092 100644 --- a/code/game/jobs/role_authority.dm +++ b/code/game/jobs/role_authority.dm @@ -36,7 +36,6 @@ GLOBAL_VAR_INIT(players_preassigned, 0) var/list/roles_by_path //Master list generated when role aithority is created, listing every role by path, including variable roles. Great for manually equipping with. var/list/roles_by_name //Master list generated when role authority is created, listing every default role by name, including those that may not be regularly selected. var/list/roles_for_mode //Derived list of roles only for the game mode, generated when the round starts. - var/list/roles_whitelist //Associated list of lists, by ckey. Checks to see if a person is whitelisted for a specific role. var/list/castes_by_path //Master list generated when role aithority is created, listing every caste by path. var/list/castes_by_name //Master list generated when role authority is created, listing every default caste by name. @@ -116,57 +115,6 @@ GLOBAL_VAR_INIT(players_preassigned, 0) squads += S squads_by_type[S.type] = S - load_whitelist() - - -/datum/authority/branch/role/proc/load_whitelist(filename = "config/role_whitelist.txt") - var/L[] = file2list(filename) - var/P[] - var/W[] = new //We want a temporary whitelist list, in case we need to reload. - - var/i - var/r - var/ckey - var/role - roles_whitelist = list() - for(i in L) - if(!i) continue - i = trim(i) - if(!length(i)) continue - else if (copytext(i, 1, 2) == "#") continue - - P = splittext(i, "+") - if(!P.len) continue - ckey = ckey(P[1]) //Converting their key to canonical form. ckey() does this by stripping all spaces, underscores and converting to lower case. - - role = NO_FLAGS - r = 1 - while(++r <= P.len) - switch(ckey(P[r])) - if("yautja") role |= WHITELIST_YAUTJA - if("yautjalegacy") role |= WHITELIST_YAUTJA_LEGACY - if("yautjacouncil") role |= WHITELIST_YAUTJA_COUNCIL - if("yautjacouncillegacy") role |= WHITELIST_YAUTJA_COUNCIL_LEGACY - if("yautjaleader") role |= WHITELIST_YAUTJA_LEADER - if("commander") role |= WHITELIST_COMMANDER - if("commandercouncil") role |= WHITELIST_COMMANDER_COUNCIL - if("commandercouncillegacy") role |= WHITELIST_COMMANDER_COUNCIL_LEGACY - if("commanderleader") role |= WHITELIST_COMMANDER_LEADER - if("workingjoe") role |= WHITELIST_JOE - if("synthetic") role |= (WHITELIST_SYNTHETIC|WHITELIST_JOE) - if("syntheticcouncil") role |= WHITELIST_SYNTHETIC_COUNCIL - if("syntheticcouncillegacy") role |= WHITELIST_SYNTHETIC_COUNCIL_LEGACY - if("syntheticleader") role |= WHITELIST_SYNTHETIC_LEADER - if("advisor") role |= WHITELIST_MENTOR - if("allgeneral") role |= WHITELISTS_GENERAL - if("allcouncil") role |= (WHITELISTS_COUNCIL|WHITELISTS_GENERAL) - if("alllegacycouncil") role |= (WHITELISTS_LEGACY_COUNCIL|WHITELISTS_GENERAL) - if("everything", "allleader") role |= WHITELIST_EVERYTHING - - W[ckey] = role - - roles_whitelist = W - //#undef FACTION_TO_JOIN /* @@ -415,7 +363,7 @@ I hope it's easier to tell what the heck this proc is even doing, unlike previou return FALSE if(!J.can_play_role(M.client)) return FALSE - if(J.flags_startup_parameters & ROLE_WHITELISTED && !(roles_whitelist[M.ckey] & J.flags_whitelist)) + if(!J.check_whitelist_status(M)) return FALSE if(J.total_positions != -1 && J.get_total_positions(latejoin) <= J.current_positions) return FALSE @@ -518,7 +466,7 @@ I hope it's easier to tell what the heck this proc is even doing, unlike previou new_job.handle_job_options(new_human.client.prefs.pref_special_job_options[new_job.title]) var/job_whitelist = new_job.title - var/whitelist_status = new_job.get_whitelist_status(roles_whitelist, new_human.client) + var/whitelist_status = new_job.get_whitelist_status(new_human.client) if(whitelist_status) job_whitelist = "[new_job.title][whitelist_status]" diff --git a/code/game/jobs/whitelist.dm b/code/game/jobs/whitelist.dm index 3a4b94145ca1..09db84fec2c2 100644 --- a/code/game/jobs/whitelist.dm +++ b/code/game/jobs/whitelist.dm @@ -1,12 +1,3 @@ -#define WHITELISTFILE "data/whitelist.txt" - -GLOBAL_LIST_FILE_LOAD(whitelist, WHITELISTFILE) - -/proc/check_whitelist(mob/M /*, rank*/) - if(!CONFIG_GET(flag/usewhitelist) || !GLOB.whitelist) - return 0 - return ("[M.ckey]" in GLOB.whitelist) - /proc/can_play_special_job(client/client, job) if(client.admin_holder && (client.admin_holder.rights & R_ADMIN)) return TRUE @@ -18,35 +9,208 @@ GLOBAL_LIST_FILE_LOAD(whitelist, WHITELISTFILE) return J.can_play_role(client) return TRUE -GLOBAL_LIST_FILE_LOAD(alien_whitelist, "config/alienwhitelist.txt") - -//todo: admin aliens -/proc/is_alien_whitelisted(mob/M, species) - if(!CONFIG_GET(flag/usealienwhitelist)) //If there's not config to use the whitelist. - return 1 - if(species == "human" || species == "Human") - return 1 -// if(check_rights(R_ADMIN, 0)) //Admins are not automatically considered to be whitelisted anymore. ~N -// return 1 //This actually screwed up a bunch of procs, but I only noticed it with the wrong spawn point. - if(!CONFIG_GET(flag/usealienwhitelist) || !GLOB.alien_whitelist) - return 0 - if(M && species) - for (var/s in GLOB.alien_whitelist) - if(findtext(lowertext(s),"[lowertext(M.key)] - [species]")) - return 1 - //if(findtext(lowertext(s),"[lowertext(M.key)] - [species] Elder")) //Unnecessary. - // return 1 - if(findtext(lowertext(s),"[lowertext(M.key)] - All")) - return 1 - return 0 - /// returns a list of strings containing the whitelists held by a specific ckey /proc/get_whitelisted_roles(ckey) - if(GLOB.RoleAuthority.roles_whitelist[ckey] & WHITELIST_PREDATOR) + var/datum/entity/player/player = get_player_from_key(ckey) + if(player.check_whitelist_status(WHITELIST_YAUTJA)) LAZYADD(., "predator") - if(GLOB.RoleAuthority.roles_whitelist[ckey] & WHITELIST_COMMANDER) + if(player.check_whitelist_status(WHITELIST_COMMANDER)) LAZYADD(., "commander") - if(GLOB.RoleAuthority.roles_whitelist[ckey] & WHITELIST_SYNTHETIC) + if(player.check_whitelist_status(WHITELIST_SYNTHETIC)) LAZYADD(., "synthetic") -#undef WHITELISTFILE +/client/load_player_data_info(datum/entity/player/player) + . = ..() + + if(isSenator(src)) + add_verb(src, /client/proc/whitelist_panel) + +/client + var/datum/whitelist_panel/wl_panel + +/client/proc/whitelist_panel() + set name = "Whitelist Panel" + set category = "Admin.Panels" + + if(wl_panel) + qdel(wl_panel) + wl_panel = new + wl_panel.tgui_interact(mob) + +#define WL_PANEL_RIGHT_CO (1<<0) +#define WL_PANEL_RIGHT_SYNTH (1<<1) +#define WL_PANEL_RIGHT_YAUTJA (1<<2) +#define WL_PANEL_RIGHT_MENTOR (1<<3) +#define WL_PANEL_RIGHT_OVERSEER (1<<4) +#define WL_PANEL_ALL_COUNCILS (WL_PANEL_RIGHT_CO|WL_PANEL_RIGHT_SYNTH|WL_PANEL_RIGHT_YAUTJA) +#define WL_PANEL_ALL_RIGHTS (WL_PANEL_RIGHT_CO|WL_PANEL_RIGHT_SYNTH|WL_PANEL_RIGHT_YAUTJA|WL_PANEL_RIGHT_MENTOR|WL_PANEL_RIGHT_OVERSEER) + +/datum/whitelist_panel + var/viewed_player = list() + var/current_menu = "Panel" + var/user_rights = 0 + var/target_rights = 0 + var/new_rights = 0 + +/datum/whitelist_panel/proc/get_user_rights(mob/user) + if(!user.client) + return + var/client/person = user.client + if(CLIENT_HAS_RIGHTS(person, R_PERMISSIONS)) + return WL_PANEL_ALL_RIGHTS + var/rights + if(person.check_whitelist_status(WHITELIST_COMMANDER_LEADER)) + rights |= WL_PANEL_RIGHT_CO + if(person.check_whitelist_status(WHITELIST_SYNTHETIC_LEADER)) + rights |= WL_PANEL_RIGHT_SYNTH + if(person.check_whitelist_status(WHITELIST_YAUTJA_LEADER)) + rights |= WL_PANEL_RIGHT_YAUTJA + if(rights == WL_PANEL_ALL_COUNCILS) + return WL_PANEL_ALL_RIGHTS + return rights + +/datum/whitelist_panel/tgui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) + if(!ui) + ui = new(user, src, "WhitelistPanel", "Whitelist Panel") + ui.open() + +/datum/whitelist_panel/ui_state(mob/user) + return GLOB.always_state + +/datum/whitelist_panel/ui_close(mob/user) + . = ..() + if(user?.client.wl_panel) + qdel(user.client.wl_panel) + +/datum/whitelist_panel/vv_edit_var(var_name, var_value) + return FALSE + +/datum/whitelist_panel/ui_data(mob/user) + var/list/data = list() + + data["current_menu"] = current_menu + data["user_rights"] = user_rights + data["viewed_player"] = viewed_player + data["target_rights"] = target_rights + data["new_rights"] = new_rights + + return data + +GLOBAL_LIST_INIT(co_flags, list( + list(name = "Commander", bitflag = WHITELIST_COMMANDER, permission = WL_PANEL_RIGHT_CO), + list(name = "Council", bitflag = WHITELIST_COMMANDER_COUNCIL, permission = WL_PANEL_RIGHT_CO), + list(name = "Legacy Council", bitflag = WHITELIST_COMMANDER_COUNCIL_LEGACY, permission = WL_PANEL_RIGHT_CO), + list(name = "Senator", bitflag = WHITELIST_COMMANDER_LEADER, permission = WL_PANEL_RIGHT_OVERSEER), + list(name = "Colonel", bitflag = WHITELIST_COMMANDER_COLONEL, permission = WL_PANEL_RIGHT_OVERSEER) +)) +GLOBAL_LIST_INIT(syn_flags, list( + list(name = "Synthetic", bitflag = WHITELIST_SYNTHETIC, permission = WL_PANEL_RIGHT_SYNTH), + list(name = "Council", bitflag = WHITELIST_SYNTHETIC_COUNCIL, permission = WL_PANEL_RIGHT_SYNTH), + list(name = "Legacy Council", bitflag = WHITELIST_SYNTHETIC_COUNCIL_LEGACY, permission = WL_PANEL_RIGHT_SYNTH), + list(name = "Senator", bitflag = WHITELIST_SYNTHETIC_LEADER, permission = WL_PANEL_RIGHT_OVERSEER) +)) +GLOBAL_LIST_INIT(yaut_flags, list( + list(name = "Yautja", bitflag = WHITELIST_YAUTJA, permission = WL_PANEL_RIGHT_YAUTJA), + list(name = "Legacy Holder", bitflag = WHITELIST_YAUTJA_LEGACY, permission = WL_PANEL_RIGHT_OVERSEER), + list(name = "Council", bitflag = WHITELIST_YAUTJA_COUNCIL, permission = WL_PANEL_RIGHT_YAUTJA), + list(name = "Legacy Council", bitflag = WHITELIST_YAUTJA_COUNCIL_LEGACY, permission = WL_PANEL_RIGHT_YAUTJA), + list(name = "Senator", bitflag = WHITELIST_YAUTJA_LEADER, permission = WL_PANEL_RIGHT_OVERSEER) +)) +GLOBAL_LIST_INIT(misc_flags, list( + list(name = "Senior Enlisted Advisor", bitflag = WHITELIST_MENTOR, permission = WL_PANEL_RIGHT_MENTOR), + list(name = "Working Joe", bitflag = WHITELIST_JOE, permission = WL_PANEL_RIGHT_SYNTH), +)) + +/datum/whitelist_panel/ui_static_data(mob/user) + . = list() + .["co_flags"] = GLOB.co_flags + .["syn_flags"] = GLOB.syn_flags + .["yaut_flags"] = GLOB.yaut_flags + .["misc_flags"] = GLOB.misc_flags + + var/list/datum/view_record/players/players_view = DB_VIEW(/datum/view_record/players, DB_COMP("whitelist_status", DB_NOTEQUAL, "")) + + var/list/whitelisted_players = list() + for(var/datum/view_record/players/whitelistee in players_view) + var/list/current_player = list() + current_player["ckey"] = whitelistee.ckey + var/list/unreadable_list = splittext(whitelistee.whitelist_status, "|") + var/readable_list = unreadable_list.Join(" | ") + current_player["status"] = readable_list + whitelisted_players += list(current_player) + .["whitelisted_players"] = whitelisted_players + +/datum/whitelist_panel/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state) + . = ..() + if(.) + return + var/mob/user = ui.user + switch(action) + if("go_back") + go_back() + if("select_player") + select_player(user, params["player"]) + return + if("add_player") + select_player(user, TRUE) + return + if("update_number") + new_rights = text2num(params["wl_flag"]) + return + if("update_perms") + var/player_key = params["player"] + var/reason = tgui_input_text(user, "What is the reason for this change?", "Update Reason") + if(!reason) + return + var/datum/entity/player/player = get_player_from_key(player_key) + player.set_whitelist_status(new_rights) + to_chat(user, SPAN_HELPFUL("Whitelists for [player_key] updated.")) + message_admins("Whitelists for [player_key] updated by [key_name(user)]. Reason: '[reason]'.") + log_admin("WHITELISTS: Flags for [player_key] changed from [target_rights] to [new_rights]. Reason: '[reason]'.") + go_back() + update_static_data(user, ui) + return + if("refresh_data") + update_static_data(user, ui) + to_chat(user, SPAN_NOTICE("Whitelist data refreshed.")) + +/datum/whitelist_panel/proc/select_player(mob/user, player_key) + var/target_key = player_key + if(IsAdminAdvancedProcCall()) + return PROC_BLOCKED + if(!target_key) + return FALSE + + if(target_key == TRUE) + var/new_player = tgui_input_text(user, "Enter the new ckey you wish to add. Do not include spaces or special characters.", "New Whitelistee") + if(!new_player) + return FALSE + target_key = new_player + + var/datum/entity/player/player = get_player_from_key(target_key) + var/list/current_player = list() + current_player["ckey"] = target_key + current_player["status"] = player.whitelist_status + + target_rights = player.whitelist_flags + new_rights = player.whitelist_flags + viewed_player = current_player + current_menu = "Update" + user_rights = get_user_rights(user) + return + +/datum/whitelist_panel/proc/go_back() + viewed_player = list() + user_rights = 0 + current_menu = "Panel" + target_rights = 0 + new_rights = 0 + + +#undef WL_PANEL_RIGHT_CO +#undef WL_PANEL_RIGHT_SYNTH +#undef WL_PANEL_RIGHT_YAUTJA +#undef WL_PANEL_RIGHT_MENTOR +#undef WL_PANEL_RIGHT_OVERSEER +#undef WL_PANEL_ALL_RIGHTS diff --git a/code/game/verbs/records.dm b/code/game/verbs/records.dm index 6b80d19bbabf..743a09d0ab6e 100644 --- a/code/game/verbs/records.dm +++ b/code/game/verbs/records.dm @@ -97,13 +97,13 @@ return target = ckey(target) - if(GLOB.RoleAuthority.roles_whitelist[src.ckey] & WHITELIST_COMMANDER_COUNCIL) + if(check_whitelist_status(WHITELIST_COMMANDER_COUNCIL)) options |= "Commanding Officer" edit_C = TRUE - if(GLOB.RoleAuthority.roles_whitelist[src.ckey] & WHITELIST_SYNTHETIC_COUNCIL) + if(check_whitelist_status(WHITELIST_SYNTHETIC_COUNCIL)) options |= "Synthetic" edit_S = TRUE - if(GLOB.RoleAuthority.roles_whitelist[src.ckey] & WHITELIST_YAUTJA_COUNCIL) + if(check_whitelist_status(WHITELIST_YAUTJA_COUNCIL)) options |= "Yautja" edit_Y = TRUE @@ -116,17 +116,17 @@ if("Merit") show_other_record(NOTE_MERIT, choice, target, TRUE) if("Commanding Officer") - if(MA || (GLOB.RoleAuthority.roles_whitelist[src.ckey] & WHITELIST_COMMANDER_LEADER)) + if(MA || check_whitelist_status(WHITELIST_COMMANDER_LEADER)) show_other_record(NOTE_COMMANDER, choice, target, TRUE, TRUE) else show_other_record(NOTE_COMMANDER, choice, target, edit_C) if("Synthetic") - if(MA || (GLOB.RoleAuthority.roles_whitelist[src.ckey] & WHITELIST_SYNTHETIC_LEADER)) + if(MA || check_whitelist_status(WHITELIST_SYNTHETIC_LEADER)) show_other_record(NOTE_SYNTHETIC, choice, target, TRUE, TRUE) else show_other_record(NOTE_SYNTHETIC, choice, target, edit_S) if("Yautja") - if(MA || (GLOB.RoleAuthority.roles_whitelist[src.ckey] & WHITELIST_YAUTJA_LEADER)) + if(MA || check_whitelist_status(WHITELIST_YAUTJA_LEADER)) show_other_record(NOTE_YAUTJA, choice, target, TRUE, TRUE) else show_other_record(NOTE_YAUTJA, choice, target, edit_Y) diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 4623df8a5dc5..56002d139599 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -190,7 +190,6 @@ GLOBAL_LIST_INIT(admin_verbs_debug, list( /client/proc/cmd_admin_delete, /client/proc/cmd_debug_del_all, /client/proc/reload_admins, - /client/proc/reload_whitelist, /client/proc/restart_controller, /client/proc/debug_controller, /client/proc/cmd_debug_toggle_should_check_for_win, @@ -243,7 +242,8 @@ GLOBAL_LIST_INIT(admin_verbs_possess, list( )) GLOBAL_LIST_INIT(admin_verbs_permissions, list( - /client/proc/ToRban + /client/proc/ToRban, + /client/proc/whitelist_panel, )) GLOBAL_LIST_INIT(admin_verbs_color, list( @@ -347,15 +347,9 @@ GLOBAL_LIST_INIT(roundstart_mod_verbs, list( add_verb(src, GLOB.admin_verbs_spawn) if(CLIENT_HAS_RIGHTS(src, R_STEALTH)) add_verb(src, GLOB.admin_verbs_stealth) - if(GLOB.RoleAuthority && (GLOB.RoleAuthority.roles_whitelist[ckey] & WHITELIST_YAUTJA_LEADER)) + if(check_whitelist_status(WHITELIST_YAUTJA_LEADER)) add_verb(src, GLOB.clan_verbs) -/client/proc/add_admin_whitelists() - if(CLIENT_IS_MENTOR(src)) - GLOB.RoleAuthority.roles_whitelist[ckey] |= WHITELIST_MENTOR - if(CLIENT_IS_STAFF(src)) - GLOB.RoleAuthority.roles_whitelist[ckey] |= WHITELIST_JOE - /client/proc/remove_admin_verbs() remove_verb(src, list( GLOB.admin_verbs_default, diff --git a/code/modules/admin/banjob.dm b/code/modules/admin/banjob.dm index 13c3b4664a15..dd6516b2ede3 100644 --- a/code/modules/admin/banjob.dm +++ b/code/modules/admin/banjob.dm @@ -42,8 +42,6 @@ GLOBAL_LIST_EMPTY(jobban_keylist) if(guest_jobbans(rank)) if(CONFIG_GET(flag/guest_jobban) && IsGuestKey(M.key)) return "Guest Job-ban" - if(CONFIG_GET(flag/usewhitelist) && !check_whitelist(M)) - return "Whitelisted Job" var/datum/entity/player_job_ban/PJB = M.client.player_data.job_bans[rank] return PJB ? PJB.text : null diff --git a/code/modules/admin/holder2.dm b/code/modules/admin/holder2.dm index e31d372743c5..82f25a6ebe3e 100644 --- a/code/modules/admin/holder2.dm +++ b/code/modules/admin/holder2.dm @@ -47,7 +47,6 @@ GLOBAL_PROTECT(href_token) owner = C owner.admin_holder = src owner.add_admin_verbs() - owner.add_admin_whitelists() owner.tgui_say.load() owner.update_special_keybinds() GLOB.admins |= C diff --git a/code/modules/admin/tabs/debug_tab.dm b/code/modules/admin/tabs/debug_tab.dm index df11917f087a..03068c577045 100644 --- a/code/modules/admin/tabs/debug_tab.dm +++ b/code/modules/admin/tabs/debug_tab.dm @@ -161,15 +161,6 @@ message_admins("[usr.ckey] manually reloaded admins.") load_admins() -/client/proc/reload_whitelist() - set name = "Reload Whitelist" - set category = "Debug" - if(alert("Are you sure you want to do this?",, "Yes", "No") != "Yes") return - if(!check_rights(R_SERVER) || !GLOB.RoleAuthority) return - - message_admins("[usr.ckey] manually reloaded the role whitelist.") - GLOB.RoleAuthority.load_whitelist() - /client/proc/bulk_fetcher() set name = "Bulk Fetch Items" set category = "Debug" diff --git a/code/modules/admin/topic/topic.dm b/code/modules/admin/topic/topic.dm index 886ba888ff0a..b1cab3603af8 100644 --- a/code/modules/admin/topic/topic.dm +++ b/code/modules/admin/topic/topic.dm @@ -894,12 +894,7 @@ qdel(M.skills) M.skills = null //no skill restriction - if(is_alien_whitelisted(M,"Yautja Elder")) - M.change_real_name(M, "Elder [y_name]") - H.equip_to_slot_or_del(new /obj/item/clothing/suit/armor/yautja/hunter/full(H), WEAR_JACKET) - H.equip_to_slot_or_del(new /obj/item/weapon/twohanded/yautja/glaive(H), WEAR_L_HAND) - else - M.change_real_name(M, y_name) + M.change_real_name(M, y_name) M.name = "Unknown" // Yautja names are not visible for oomans if(H) diff --git a/code/modules/clans/client.dm b/code/modules/clans/client.dm index c46adf89711a..c4948b2a6923 100644 --- a/code/modules/clans/client.dm +++ b/code/modules/clans/client.dm @@ -5,11 +5,11 @@ set waitfor = FALSE . = ..() - if(GLOB.RoleAuthority && (GLOB.RoleAuthority.roles_whitelist[ckey] & WHITELIST_PREDATOR)) + if(GLOB.RoleAuthority && check_whitelist_status(WHITELIST_PREDATOR)) clan_info = GET_CLAN_PLAYER(player.id) clan_info.sync() - if(GLOB.RoleAuthority.roles_whitelist[ckey] & WHITELIST_YAUTJA_LEADER) + if(check_whitelist_status(WHITELIST_YAUTJA_LEADER)) clan_info.clan_rank = GLOB.clan_ranks_ordered[CLAN_RANK_ADMIN] clan_info.permissions |= CLAN_PERMISSION_ALL else diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index 3dfe2d38d81f..44820444a955 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -319,12 +319,9 @@ GLOBAL_LIST_INIT(whitelisted_client_procs, list( player_entity = setup_player_entity(ckey) - if(!CONFIG_GET(flag/no_localhost_rank)) - var/static/list/localhost_addresses = list("127.0.0.1", "::1") - if(isnull(address) || (address in localhost_addresses)) - var/datum/admins/admin = new("!localhost!", RL_HOST, ckey) - admin.associate(src) - GLOB.RoleAuthority.roles_whitelist[ckey] = WHITELIST_EVERYTHING + if(check_localhost_status()) + var/datum/admins/admin = new("!localhost!", RL_HOST, ckey) + admin.associate(src) //Admin Authorisation admin_holder = GLOB.admin_datums[ckey] @@ -878,3 +875,41 @@ GLOBAL_LIST_INIT(whitelisted_client_procs, list( if(!selected_action.player_hidden && selected_action.hidden) //Inform the player that even if they are unhiding it, itll still not be visible to_chat(user, SPAN_NOTICE("[selected_action] is forcefully hidden, bypassing player unhiding.")) + + +/client/proc/check_whitelist_status(flag_to_check) + if(check_localhost_status()) + return TRUE + + if((flag_to_check & WHITELIST_MENTOR) && CLIENT_IS_MENTOR(src)) + return TRUE + + if((flag_to_check & WHITELIST_JOE) && CLIENT_IS_STAFF(src)) + return TRUE + + if(!player_data) + load_player_data() + if(!player_data) + return FALSE + + return player_data.check_whitelist_status(flag_to_check) + +/client/proc/check_whitelist_status_list(flags_to_check) /// Logical OR list, not match all. + var/success = FALSE + if(!player_data) + load_player_data() + for(var/bitfield in flags_to_check) + success = player_data.check_whitelist_status(bitfield) + if(success) + break + return success + +/client/proc/check_localhost_status() + if(CONFIG_GET(flag/no_localhost_rank)) + return FALSE + + var/static/list/localhost_addresses = list("127.0.0.1", "::1") + if(isnull(address) || (address in localhost_addresses)) + return TRUE + + return FALSE diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 29676ddb4ac8..221736b5c84f 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -308,13 +308,13 @@ GLOBAL_LIST_INIT(bgstate_options, list( dat += "
" dat += "Human - " dat += "Xenomorph - " - if(GLOB.RoleAuthority.roles_whitelist[user.ckey] & WHITELIST_COMMANDER) + if(owner.check_whitelist_status(WHITELIST_COMMANDER)) dat += "Commanding Officer - " - if(GLOB.RoleAuthority.roles_whitelist[user.ckey] & WHITELIST_SYNTHETIC) + if(owner.check_whitelist_status(WHITELIST_SYNTHETIC)) dat += "Synthetic - " - if(GLOB.RoleAuthority.roles_whitelist[user.ckey] & WHITELIST_PREDATOR) + if(owner.check_whitelist_status(WHITELIST_PREDATOR)) dat += "Yautja - " - if(GLOB.RoleAuthority.roles_whitelist[user.ckey] & WHITELIST_MENTOR) + if(owner.check_whitelist_status(WHITELIST_MENTOR)) dat += "Mentor - " dat += "Settings - " dat += "Special Roles" @@ -484,7 +484,7 @@ GLOBAL_LIST_INIT(bgstate_options, list( n++ if(MENU_CO) - if(GLOB.RoleAuthority.roles_whitelist[user.ckey] & WHITELIST_COMMANDER) + if(owner.check_whitelist_status(WHITELIST_COMMANDER)) dat += "
" dat += "

Commander Settings:

" dat += "Commander Whitelist Status: [commander_status]
" @@ -494,7 +494,7 @@ GLOBAL_LIST_INIT(bgstate_options, list( else dat += "You do not have the whitelist for this role." if(MENU_SYNTHETIC) - if(GLOB.RoleAuthority.roles_whitelist[user.ckey] & WHITELIST_SYNTHETIC) + if(owner.check_whitelist_status(WHITELIST_SYNTHETIC)) dat += "
" dat += "

Synthetic Settings:

" dat += "Synthetic Name: [synthetic_name]
" @@ -504,7 +504,7 @@ GLOBAL_LIST_INIT(bgstate_options, list( else dat += "You do not have the whitelist for this role." if(MENU_YAUTJA) - if(GLOB.RoleAuthority.roles_whitelist[user.ckey] & WHITELIST_PREDATOR) + if(owner.check_whitelist_status(WHITELIST_PREDATOR)) dat += "
" dat += "

Yautja Information:

" dat += "Yautja Name: [predator_name]
" @@ -518,7 +518,7 @@ GLOBAL_LIST_INIT(bgstate_options, list( dat += "
" dat += "

Equipment Setup:

" - if(GLOB.RoleAuthority.roles_whitelist[user.ckey] & WHITELIST_YAUTJA_LEGACY) + if(owner.check_whitelist_status(WHITELIST_YAUTJA_LEGACY)) dat += "Legacy Gear: [predator_use_legacy]
" dat += "Translator Type: [predator_translator_type]
" dat += "Mask Style: ([predator_mask_type])
" @@ -542,7 +542,7 @@ GLOBAL_LIST_INIT(bgstate_options, list( else dat += "You do not have the whitelist for this role." if(MENU_MENTOR) - if(GLOB.RoleAuthority.roles_whitelist[user.ckey] & WHITELIST_MENTOR) + if(owner.check_whitelist_status(WHITELIST_MENTOR)) dat += "Nothing here. For now." else dat += "You do not have the whitelist for this role." @@ -636,7 +636,7 @@ GLOBAL_LIST_INIT(bgstate_options, list( dat += "Spawn as Engineer: [toggles_ert & PLAY_ENGINEER ? "Yes" : "No"]
" dat += "Spawn as Specialist: [toggles_ert & PLAY_HEAVY ? "Yes" : "No"]
" dat += "Spawn as Smartgunner: [toggles_ert & PLAY_SMARTGUNNER ? "Yes" : "No"]
" - if(GLOB.RoleAuthority.roles_whitelist[user.ckey] & WHITELIST_SYNTHETIC) + if(owner.check_whitelist_status(WHITELIST_SYNTHETIC)) dat += "Spawn as Synth: [toggles_ert & PLAY_SYNTH ? "Yes" : "No"]
" dat += "Spawn as Miscellaneous: [toggles_ert & PLAY_MISC ? "Yes" : "No"]
" dat += "
" @@ -684,7 +684,7 @@ GLOBAL_LIST_INIT(bgstate_options, list( if(jobban_isbanned(user, job.title)) HTML += "[job.disp_title]BANNED" continue - else if(job.flags_startup_parameters & ROLE_WHITELISTED && !(GLOB.RoleAuthority.roles_whitelist[user.ckey] & job.flags_whitelist)) + else if(!job.check_whitelist_status(user)) HTML += "[job.disp_title]WHITELISTED" continue else if(!job.can_play_role(user.client)) @@ -796,7 +796,7 @@ GLOBAL_LIST_INIT(bgstate_options, list( if(jobban_isbanned(user, job.title)) HTML += "[job.disp_title]BANNED" continue - else if(job.flags_startup_parameters & ROLE_WHITELISTED && !(GLOB.RoleAuthority.roles_whitelist[user.ckey] & job.flags_whitelist)) + else if(!job.check_whitelist_status(user)) HTML += "[job.disp_title]WHITELISTED" continue else if(!job.can_play_role(user.client)) @@ -962,7 +962,7 @@ GLOBAL_LIST_INIT(bgstate_options, list( pref_job_slots[J.title] = JOB_SLOT_CURRENT_SLOT /datum/preferences/proc/process_link(mob/user, list/href_list) - var/whitelist_flags = GLOB.RoleAuthority.roles_whitelist[user.ckey] + switch(href_list["preference"]) if("job") @@ -1198,6 +1198,9 @@ GLOBAL_LIST_INIT(bgstate_options, list( if ("all") randomize_appearance() if("input") + var/datum/entity/player/player = get_player_from_key(user.ckey) + var/whitelist_flags = player.whitelist_flags + switch(href_list["preference"]) if("name") if(human_name_ban) @@ -1286,7 +1289,7 @@ GLOBAL_LIST_INIT(bgstate_options, list( predator_caster_material = new_pred_caster_mat if("pred_cape_type") var/datum/job/J = GLOB.RoleAuthority.roles_by_name[JOB_PREDATOR] - var/whitelist_status = GLOB.clan_ranks_ordered[J.get_whitelist_status(GLOB.RoleAuthority.roles_whitelist, owner)] + var/whitelist_status = GLOB.clan_ranks_ordered[J.get_whitelist_status(owner)] var/list/options = list("None" = "None") for(var/cape_name in GLOB.all_yautja_capes) @@ -1325,7 +1328,7 @@ GLOBAL_LIST_INIT(bgstate_options, list( if(whitelist_flags & (WHITELIST_COMMANDER_COUNCIL|WHITELIST_COMMANDER_COUNCIL_LEGACY)) options += list("Council" = WHITELIST_COUNCIL) - if(whitelist_flags & WHITELIST_COMMANDER_LEADER) + if(whitelist_flags & (WHITELIST_COMMANDER_LEADER|WHITELIST_COMMANDER_COLONEL)) options += list("Leader" = WHITELIST_LEADER) var/new_commander_status = tgui_input_list(user, "Choose your new Commander Whitelist Status.", "Commander Status", options) diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm index 22bd9aa0cf61..a55080dc837d 100644 --- a/code/modules/mob/dead/observer/observer.dm +++ b/code/modules/mob/dead/observer/observer.dm @@ -137,8 +137,6 @@ var/datum/action/observer_action/new_action = new path() new_action.give_to(src) - RegisterSignal(SSdcs, COMSIG_GLOB_PREDATOR_ROUND_TOGGLED, PROC_REF(toggle_predator_action)) - if(SSticker.mode && SSticker.mode.flags_round_type & MODE_PREDATOR) addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(to_chat), src, "This is a PREDATOR ROUND! If you are whitelisted, you may Join the Hunt!"), 2 SECONDS) @@ -319,7 +317,9 @@ /mob/dead/observer/Login() ..() - toggle_predator_action() + if(client.check_whitelist_status(WHITELIST_PREDATOR)) + RegisterSignal(SSdcs, COMSIG_GLOB_PREDATOR_ROUND_TOGGLED, PROC_REF(toggle_predator_action)) + toggle_predator_action() client.move_delay = MINIMAL_MOVEMENT_INTERVAL @@ -1284,9 +1284,6 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp if(!key_to_use) return - if(!(GLOB.RoleAuthority.roles_whitelist[key_to_use] & WHITELIST_PREDATOR)) - return - if(!SSticker.mode) SSticker.OnRoundstart(CALLBACK(src, PROC_REF(toggle_predator_action))) return diff --git a/code/modules/mob/new_player/new_player.dm b/code/modules/mob/new_player/new_player.dm index ccf649fb0509..810eb4006634 100644 --- a/code/modules/mob/new_player/new_player.dm +++ b/code/modules/mob/new_player/new_player.dm @@ -168,16 +168,6 @@ tutorial_menu() return - if(client.prefs.species != "Human") - if(!is_alien_whitelisted(src, client.prefs.species) && CONFIG_GET(flag/usealienwhitelist)) - to_chat(src, "You are currently not whitelisted to play [client.prefs.species].") - return - - var/datum/species/S = GLOB.all_species[client.prefs.species] - if(!(S.flags & IS_WHITELISTED)) - to_chat(src, alert("Your current species,[client.prefs.species], is not available for play on the station.")) - return - LateChoices() if("late_join_xeno") @@ -217,16 +207,6 @@ to_chat(usr, SPAN_WARNING("There is an administrative lock on entering the game! (The dropship likely crashed into the Almayer. This should take at most 20 minutes.)")) return - if(client.prefs.species != "Human") - if(!is_alien_whitelisted(src, client.prefs.species) && CONFIG_GET(flag/usealienwhitelist)) - to_chat(src, alert("You are currently not whitelisted to play [client.prefs.species].")) - return 0 - - var/datum/species/S = GLOB.all_species[client.prefs.species] - if(!(S.flags & IS_WHITELISTED)) - to_chat(src, alert("Your current species,[client.prefs.species], is not available for play on the station.")) - return 0 - AttemptLateSpawn(href_list["job_selected"]) return @@ -382,14 +362,6 @@ var/mob/living/carbon/human/new_character - var/datum/species/chosen_species - if(client.prefs.species) - chosen_species = GLOB.all_species[client.prefs.species] - if(chosen_species) - // Have to recheck admin due to no usr at roundstart. Latejoins are fine though. - if(is_species_whitelisted(chosen_species) || has_admin_rights()) - new_character = new(loc, client.prefs.species) - if(!new_character) new_character = new(loc) @@ -456,26 +428,6 @@ ui.close() continue -/mob/new_player/proc/has_admin_rights() - return client.admin_holder.rights & R_ADMIN - -/mob/new_player/proc/is_species_whitelisted(datum/species/S) - if(!S) return 1 - return is_alien_whitelisted(src, S.name) || !CONFIG_GET(flag/usealienwhitelist) || !(S.flags & IS_WHITELISTED) - -/mob/new_player/get_species() - var/datum/species/chosen_species - if(client.prefs.species) - chosen_species = GLOB.all_species[client.prefs.species] - - if(!chosen_species) - return "Human" - - if(is_species_whitelisted(chosen_species) || has_admin_rights()) - return chosen_species.name - - return "Human" - /mob/new_player/get_gender() if(!client || !client.prefs) ..() return client.prefs.gender diff --git a/code/modules/mob/new_player/preferences_setup.dm b/code/modules/mob/new_player/preferences_setup.dm index a4525e16a6c6..7e8439cee244 100644 --- a/code/modules/mob/new_player/preferences_setup.dm +++ b/code/modules/mob/new_player/preferences_setup.dm @@ -247,10 +247,8 @@ if(JOB_SQUAD_TEAM_LEADER) return /datum/equipment_preset/uscm/tl_equipped if(JOB_CO) - if(length(GLOB.RoleAuthority.roles_whitelist)) - var/datum/job/J = GLOB.RoleAuthority.roles_by_name[JOB_CO] - return J.gear_preset_whitelist["[JOB_CO][J.get_whitelist_status(GLOB.RoleAuthority.roles_whitelist, owner)]"] - return /datum/equipment_preset/uscm_ship/commander + var/datum/job/J = GLOB.RoleAuthority.roles_by_name[JOB_CO] + return J.gear_preset_whitelist["[JOB_CO][J.get_whitelist_status(owner)]"] if(JOB_SO) return /datum/equipment_preset/uscm_ship/so if(JOB_XO) @@ -268,10 +266,8 @@ if(JOB_COMBAT_REPORTER) return /datum/equipment_preset/uscm_ship/reporter if(JOB_SYNTH) - if(length(GLOB.RoleAuthority.roles_whitelist)) - var/datum/job/J = GLOB.RoleAuthority.roles_by_name[JOB_SYNTH] - return J.gear_preset_whitelist["[JOB_SYNTH][J.get_whitelist_status(GLOB.RoleAuthority.roles_whitelist, owner)]"] - return /datum/equipment_preset/synth/uscm + var/datum/job/J = GLOB.RoleAuthority.roles_by_name[JOB_SYNTH] + return J.gear_preset_whitelist["[JOB_SYNTH][J.get_whitelist_status(owner)]"] if(JOB_WORKING_JOE) return /datum/equipment_preset/synth/working_joe if(JOB_POLICE) @@ -317,10 +313,8 @@ return pick(SSmapping.configs[GROUND_MAP].CO_survivor_types) return /datum/equipment_preset/uscm_ship/commander if(JOB_PREDATOR) - if(length(GLOB.RoleAuthority.roles_whitelist)) - var/datum/job/J = GLOB.RoleAuthority.roles_by_name[JOB_PREDATOR] - return J.gear_preset_whitelist["[JOB_PREDATOR][J.get_whitelist_status(GLOB.RoleAuthority.roles_whitelist, owner)]"] - return /datum/equipment_preset/yautja/blooded + var/datum/job/J = GLOB.RoleAuthority.roles_by_name[JOB_PREDATOR] + return J.gear_preset_whitelist["[JOB_PREDATOR][J.get_whitelist_status(owner)]"] return /datum/equipment_preset/uscm/private_equipped diff --git a/tgui/packages/tgui/interfaces/WhitelistPanel.jsx b/tgui/packages/tgui/interfaces/WhitelistPanel.jsx new file mode 100644 index 000000000000..128045bf2694 --- /dev/null +++ b/tgui/packages/tgui/interfaces/WhitelistPanel.jsx @@ -0,0 +1,288 @@ +import { useBackend } from '../backend'; +import { Button, Stack, Section, Flex } from '../components'; +import { Window } from '../layouts'; + +const PAGES = { + 'Panel': () => PlayerList, + 'Update': () => StatusUpdate, +}; + +export const WhitelistPanel = (props, context) => { + const { data } = useBackend(context); + const { current_menu } = data; + const PageComponent = PAGES[current_menu](); + + return ( + + + + + + ); +}; + +const PlayerList = (props, context) => { + const { data, act } = useBackend(context); + const { whitelisted_players } = data; + + return ( +
+ + +
+ ); +}; + +const StatusUpdate = (props, context) => { + const { act, data } = useBackend(context); + const { + co_flags, + syn_flags, + yaut_flags, + misc_flags, + viewed_player, + user_rights, + target_rights, + new_rights, + } = data; + return ( +
+ +
+
+ + {syn_flags.map((bit, i) => { + const isWhitelisted = target_rights && target_rights & bit.bitflag; + return ( +
+
+ + {yaut_flags.map((bit, i) => { + const isWhitelisted = target_rights && target_rights & bit.bitflag; + return ( +
+
+ + {misc_flags.map((bit, i) => { + const isWhitelisted = target_rights && target_rights & bit.bitflag; + return ( +
+ +