diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index d7a9b4c3afb..f5c9a6b0391 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -1449,3 +1449,9 @@ var/list/WALLITEMS = list( chance = max(chance - (initial_chance / steps), 0) steps-- +/proc/living_player_count() + var/living_player_count = 0 + for(var/mob in player_list) + if(mob in living_mob_list) + living_player_count += 1 + return living_player_count \ No newline at end of file diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index ad92db7f1b6..22705c54267 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -67,6 +67,14 @@ var/use_age_restriction_for_jobs = 0 //Do jobs use account age restrictions? --requires database var/see_own_notes = 0 //Can players see their own admin notes (read-only)? Config option in config.txt + //Population cap vars + var/soft_popcap = 0 + var/hard_popcap = 0 + var/extreme_popcap = 0 + var/soft_popcap_message = "Be warned that the server is currently serving a high number of users, consider using alternative game servers." + var/hard_popcap_message = "The server is currently serving a high number of users, You cannot currently join. You may wait for the number of living crew to decline, observe, or find alternative servers." + var/extreme_popcap_message = "The server is currently serving a high number of users, find alternative servers." + //game_options.txt configs var/force_random_names = 0 var/list/mode_names = list() @@ -292,6 +300,18 @@ global.comms_allowed = 1 if("see_own_notes") config.see_own_notes = 1 + if("soft_popcap") + config.soft_popcap = text2num(value) + if("hard_popcap") + config.hard_popcap = text2num(value) + if("extreme_popcap") + config.extreme_popcap = text2num(value) + if("soft_popcap_message") + config.soft_popcap_message = value + if("hard_popcap_message") + config.hard_popcap_message = value + if("extreme_popcap_message") + config.extreme_popcap_message = value else diary << "Unknown setting in configuration: '[name]'" diff --git a/code/controllers/subsystem/jobs.dm b/code/controllers/subsystem/jobs.dm index 178d194afd5..ef35a1923ee 100644 --- a/code/controllers/subsystem/jobs.dm +++ b/code/controllers/subsystem/jobs.dm @@ -4,9 +4,10 @@ var/datum/subsystem/job/SSjob name = "Jobs" priority = 5 - var/list/occupations = list() //List of all jobs - var/list/unassigned = list() //Players who need jobs - var/list/job_debug = list() //Debug info + var/list/occupations = list() //List of all jobs + var/list/unassigned = list() //Players who need jobs + var/list/job_debug = list() //Debug info + var/initial_players_to_assign = 0 //used for checking against population caps /datum/subsystem/job/New() NEW_SS_GLOBAL(SSjob) @@ -205,6 +206,8 @@ var/datum/subsystem/job/SSjob if(player.ready && player.mind && !player.mind.assigned_role) unassigned += player + initial_players_to_assign = unassigned.len + Debug("DO, Len: [unassigned.len]") if(unassigned.len == 0) return 0 @@ -260,6 +263,8 @@ var/datum/subsystem/job/SSjob // Loop through all unassigned players for(var/mob/new_player/player in unassigned) + if(PopcapReached()) + RejectPlayer(player) // Loop through all jobs for(var/datum/job/job in shuffledoccupations) // SHUFFLE ME BABY @@ -292,11 +297,15 @@ var/datum/subsystem/job/SSjob // Hand out random jobs to the people who didn't get any in the last check // Also makes sure that they got their preference correct for(var/mob/new_player/player in unassigned) - if(jobban_isbanned(player, "Assistant")) + if(PopcapReached()) + RejectPlayer(player) + else if(jobban_isbanned(player, "Assistant")) GiveRandomJob(player) //you get to roll for random before everyone else just to be sure you don't get assistant. you're so speshul for(var/mob/new_player/player in unassigned) - if(player.client.prefs.userandomjob) + if(PopcapReached()) + RejectPlayer(player) + else if(player.client.prefs.userandomjob) GiveRandomJob(player) Debug("DO, Standard Check end") @@ -305,6 +314,8 @@ var/datum/subsystem/job/SSjob // For those who wanted to be assistant if their preferences were filled, here you go. for(var/mob/new_player/player in unassigned) + if(PopcapReached()) + RejectPlayer(player) Debug("AC2 Assistant located, Player: [player]") AssignRole(player, "Assistant") return 1 @@ -431,3 +442,16 @@ var/datum/subsystem/job/SSjob tmp_str += "HIGH=[level1]|MEDIUM=[level2]|LOW=[level3]|NEVER=[level4]|BANNED=[level5]|YOUNG=[level6]|-" feedback_add_details("job_preferences",tmp_str) + +/datum/subsystem/job/proc/PopcapReached() + if(config.hard_popcap || config.extreme_popcap) + var/relevent_cap = max(config.hard_popcap, config.extreme_popcap) + if((initial_players_to_assign - unassigned.len) >= relevent_cap) + return 1 + return 0 + +/datum/subsystem/job/proc/RejectPlayer(var/mob/new_player/player) + Debug("Popcap overflow Check observer located, Player: [player]") + player << "You have failed to qualify for any job you desired." + unassigned -= player + player.ready = 0 \ No newline at end of file diff --git a/code/modules/admin/IsBanned.dm b/code/modules/admin/IsBanned.dm index 404d7c07a06..4a6433fe273 100644 --- a/code/modules/admin/IsBanned.dm +++ b/code/modules/admin/IsBanned.dm @@ -47,6 +47,11 @@ world/IsBanned(key,address,computer_id) message_admins("Failed Login: [key] - Guests not allowed") return list("reason"="guest", "desc"="\nReason: Guests not allowed. Please sign in with a byond account.") + //Population Cap Checking + if(config.extreme_popcap && living_player_count() >= config.extreme_popcap && !(ckey(key) in admin_datums)) + log_access("Failed Login: [key] - Population cap reached") + return list("reason"="popcap", "desc"= "\nReason: [config.extreme_popcap_message]") + if(config.ban_legacy_system) //Ban Checking diff --git a/code/modules/mob/new_player/login.dm b/code/modules/mob/new_player/login.dm index 280e4e70347..979e77b2855 100644 --- a/code/modules/mob/new_player/login.dm +++ b/code/modules/mob/new_player/login.dm @@ -6,6 +6,9 @@ if(admin_notice) src << "Admin Notice:\n \t [admin_notice]" + if(config.soft_popcap && living_player_count() >= config.soft_popcap) + src << "Server Notice:\n \t [config.soft_popcap_message]" + if(!mind) mind = new /datum/mind(key) mind.active = 1 diff --git a/code/modules/mob/new_player/new_player.dm b/code/modules/mob/new_player/new_player.dm index 6af82653cfc..d5582392910 100644 --- a/code/modules/mob/new_player/new_player.dm +++ b/code/modules/mob/new_player/new_player.dm @@ -126,6 +126,10 @@ if(!ticker || ticker.current_state != GAME_STATE_PLAYING) usr << "The round is either not ready, or has already finished..." return + var/relevent_cap = max(config.hard_popcap, config.extreme_popcap) + if(relevent_cap && living_player_count() >= relevent_cap && !(ckey(key) in admin_datums)) + usr << "[config.hard_popcap_message]" + return LateChoices() if(href_list["manifest"]) diff --git a/config/config.txt b/config/config.txt index 0d112194334..412245906b1 100644 --- a/config/config.txt +++ b/config/config.txt @@ -156,3 +156,23 @@ TICKCOMP 0 ## Uncomment this to let players see their own notes (they can still be set by admins only) #SEE_OWN_NOTES + +##Note: all population caps can be used with each other if desired. + +## Uncomment for 'soft' population caps, players will be warned while joining if the living crew exceeds the listed number. +#SOFT_POPCAP 100 + +## Message for soft cap +SOFT_MESSAGE Be warned that the server is currently serving a high number of users, consider using alternative game servers. + +## Uncomment for 'hard' population caps, players will not be allowed to spawn if the living crew exceeds the listed number, though they may still observe or wait for the living crew to decrease in size. +#HARD_POPCAP 150 + +## Message for hard cap +HARD_MESSAGE The server is currently serving a high number of users, You cannot currently join. You may wait for the number of living crew to decline, observe, or find alternative servers. + +## Uncomment for 'extreme' population caps, players will not be allowed to join the server if living crew exceeds the listed number. +#EXTREME_POPCAP 200 + +## Message for extreme cap +EXTREME_MESSAGE The server is currently serving a high number of users, find alternative servers. \ No newline at end of file