Adds optional population caps for those that want them. These be dark measures, so tread carefully ye who dare enter this place.

There are three "levels" of popcaps, and you can use them in any assortment you like:

The "soft" cap produces a message on join, and takes no action.

The "hard" cap disallows joining whilst too many other people are alive and playing in game, but allows observing.

The "extreme" cap prevents people from joining the server at all while the cap is exceeded. It won't kick out people who failed to qualify during roundstart, but if they leave they won't be able to get back in.

In each case a customizable message config option has been given. Admins are also immune to most population caps (they still are hit by the ones in job shuffling, but can late join as normal afterwards)
This commit is contained in:
Incoming
2015-02-04 01:58:02 -05:00
parent 7dd1d73975
commit 7903aba6d3
7 changed files with 87 additions and 5 deletions
+29 -5
View File
@@ -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 << "<b>You have failed to qualify for any job you desired.</b>"
unassigned -= player
player.ready = 0