Skip to content

Allow mentors/admins/donators to bypass the popcap #5168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Feb 13, 2025
5 changes: 4 additions & 1 deletion code/_onclick/hud/new_player.dm
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@

var/mob/dead/new_player/new_player = hud.mymob

if(SSticker.queued_players.len || (relevant_cap && living_player_count() >= relevant_cap && !(ckey(new_player.key) in GLOB.admin_datums)))
//Allow admins and Patreon supporters to bypass the cap/queue
if ((relevant_cap && living_player_count() >= relevant_cap) && (new_player.client.player_details.patreon.is_donator() || is_admin(new_player.client) || new_player.client?.is_mentor()))
to_chat(new_player, span_notice("The server is currently overcap, but you are a(n) patreon/mentor/admin!"))
else if (SSticker.queued_players.len || (relevant_cap && living_player_count() >= relevant_cap))
to_chat(new_player, span_danger("[CONFIG_GET(string/hard_popcap_message)]"))

var/queue_position = SSticker.queued_players.Find(new_player)
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/subsystem/job.dm
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ SUBSYSTEM_DEF(job)

// Loop through all unassigned players
for(var/mob/dead/new_player/player in unassigned)
if(PopcapReached())
if(!(player.client.player_details.patreon.is_donator() || is_admin(player.client) || player.client.is_mentor()) && PopcapReached())
RejectPlayer(player)

// Loop through all jobs
Expand Down
26 changes: 20 additions & 6 deletions code/modules/admin/IsBanned.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
return ..() //shunt world topic banchecks to purely to byond's internal ban system

var/admin = FALSE
var/mentor = FALSE
var/supporter = FALSE
var/ckey = ckey(key)

var/client/C = GLOB.directory[ckey]
Expand All @@ -29,9 +31,15 @@
//magic voodo to check for a key in a list while also adding that key to the list without having to do two associated lookups
var/message = !checkedckeys[ckey]++

if(GLOB.admin_datums[ckey] || GLOB.deadmins[ckey])
if (GLOB.admin_datums[ckey] || GLOB.deadmins[ckey] || (ckey in GLOB.protected_admins))
admin = TRUE

if (raw_is_mentor(ckey))
mentor = TRUE

if (raw_get_patreon_rank(ckey) > 0)
supporter = TRUE

if(!real_bans_only && !admin && CONFIG_GET(flag/panic_bunker) && !CONFIG_GET(flag/panic_bunker_interview))
var/datum/db_query/query_client_in_db = SSdbcore.NewQuery(
"SELECT 1 FROM [format_table_name("player")] WHERE ckey = :ckey",
Expand All @@ -55,10 +63,10 @@
//Whitelist
if(!real_bans_only && !C && CONFIG_GET(flag/usewhitelist))
if(!check_whitelist(ckey))
if (admin)
log_admin("The admin [ckey] has been allowed to bypass the whitelist")
if (admin || mentor)
log_admin("The admin/mentor [ckey] has been allowed to bypass the whitelist")
if (message)
message_admins(span_adminnotice("The admin [ckey] has been allowed to bypass the whitelist"))
message_admins(span_adminnotice("The admin/mentor [ckey] has been allowed to bypass the whitelist"))
addclientmessage(ckey,span_adminnotice("You have been allowed to bypass the whitelist"))
else
log_access("Failed Login: [ckey] - Not on whitelist")
Expand All @@ -75,11 +83,17 @@

//Population Cap Checking
var/extreme_popcap = CONFIG_GET(number/extreme_popcap)
if(!real_bans_only && !C && extreme_popcap && !admin)
if(!real_bans_only && !C && extreme_popcap)
var/popcap_value = GLOB.clients.len
if(popcap_value >= extreme_popcap && !GLOB.joined_player_list.Find(ckey))
if (admin || mentor || supporter)
var/msg = "Popcap Login: [ckey] - Is a(n) [admin ? "admin" : mentor ? "mentor" : supporter ? "patreon supporter" : "???"], therefore allowed passed the popcap of [extreme_popcap] - [popcap_value] clients connected"
log_access(msg)
message_admins(msg)
if(!CONFIG_GET(flag/byond_member_bypass_popcap) || !world.IsSubscribed(ckey, "BYOND"))
log_access("Failed Login: [ckey] - Population cap reached")
var/msg = "Failed Login: [ckey] - Population cap reached"
log_access(msg)
message_admins(msg)
return list("reason"="popcap", "desc"= "\nReason: [CONFIG_GET(string/extreme_popcap_message)]")

if(CONFIG_GET(flag/sql_enabled))
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/dead/new_player/latejoin_menu.dm
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ GLOBAL_DATUM_INIT(latejoin_menu, /datum/latejoin_menu, new)
else
relevant_cap = max(hard_popcap, extreme_popcap)

if(SSticker.queued_players.len && !(ckey(owner.key) in GLOB.admin_datums))
if(SSticker.queued_players.len && !(owner.client.player_details.patreon.access_rank > 0 || is_admin(owner.client) || owner.client?.is_mentor()))
if((living_player_count() >= relevant_cap) || (owner != SSticker.queued_players[1]))
tgui_alert(owner, "The server is full!", "Oh No!")
return TRUE
Expand Down
6 changes: 6 additions & 0 deletions monkestation/code/datums/patreon_data.dm
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,9 @@

/datum/patreon_data/proc/is_donator()
return owned_rank && owned_rank != NO_RANK && owned_rank != UNSUBBED

/proc/raw_get_patreon_rank(ckey)
var/datum/player_details/playerdetails = new(ckey)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just query the DB please...

var/datum/patreon_data/patreonthing = new(playerdetails)

return patreonthing.access_rank
11 changes: 10 additions & 1 deletion monkestation/code/modules/mentor/client.dm
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,13 @@
if(owner.is_mentor())
owner.mentor_datum.not_active = FALSE


/proc/raw_is_mentor(ckey)
. = FALSE
var/list/mentors = world.file2list("[global.config.directory]/mentors.txt")
for(var/mentor in mentors)
if(!length(mentor))
continue
if(findtextEx(mentor, "#", 1, 2))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(findtextEx(mentor, "#", 1, 2))
if(mentor[1] == "#")

continue
if (ckey == ckey(mentor))
return TRUE
Loading