.float prevent_join_msgtime;
void LeaveSpectatorMode()
{
- if(nJoinAllowed(1)) {
+ if(nJoinAllowed(self)) {
if(!teamplay || autocvar_g_campaign || autocvar_g_balance_teams || (self.wasplayer && autocvar_g_changeteam_banned) || self.team_forced > 0) {
self.classname = "player";
* it checks whether the number of currently playing players exceeds g_maxplayers.
* @return int number of free slots for players, 0 if none
*/
-float nJoinAllowed(float includeMe) {
+float nJoinAllowed(entity ignore) {
+ if(!ignore)
+ // this is called that way when checking if anyone may be able to join (to build qcstatus)
+ // so report 0 free slots if restricted
+ {
+ if(autocvar_g_forced_team_otherwise == "spectate")
+ return 0;
+ if(autocvar_g_forced_team_otherwise == "spectator")
+ return 0;
+ }
+
if(self.team_forced < 0)
- return FALSE; // forced spectators can never join
+ return 0; // forced spectators can never join
// TODO simplify this
entity e;
-
float totalClients;
FOR_EACH_CLIENT(e)
- totalClients += 1;
+ if(e != ignore)
+ totalClients += 1;
if (!autocvar_g_maxplayers)
- return maxclients - totalClients + includeMe;
+ return maxclients - totalClients;
float currentlyPlaying;
FOR_EACH_REALPLAYER(e)
currentlyPlaying += 1;
if(currentlyPlaying < autocvar_g_maxplayers)
- return min(maxclients - totalClients + includeMe, autocvar_g_maxplayers - currentlyPlaying);
+ return min(maxclients - totalClients, autocvar_g_maxplayers - currentlyPlaying);
return 0;
}
{
if(self.classname != "player" && !lockteams && !g_arena)
{
- if(nJoinAllowed(1))
+ if(nJoinAllowed(self))
{
if(g_ca) { self.caplayer = 1; }
if(autocvar_g_campaign) { campaign_bots_may_start = 1; }
}
else
clientcommand(self, command);
-}
\ No newline at end of file
+}
.float jointime; // time of joining
.float alivetime; // time of being alive
-float nJoinAllowed(float includeMe);
+float nJoinAllowed(entity ignore);
#define PREVENT_JOIN_TEXT "^1You may not join the game at this time.\n\nThe player limit reached maximum capacity."
.float spawnshieldtime;
s = GetGametype();
s = strcat(s, ":", autocvar_g_xonoticversion);
s = strcat(s, ":P", ftos(cvar_purechanges_count));
- s = strcat(s, ":S", ftos(nJoinAllowed(0)));
+ s = strcat(s, ":S", ftos(nJoinAllowed(world)));
s = strcat(s, ":F", ftos(serverflags));
s = strcat(s, ":M", modname);
s = strcat(s, "::", GetPlayerScoreString(world, 1)); // make this 1 once we can, note: this doesn't contain any :<letter>