]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
properly report 0 free slots to server browser on restricted servers
authorRudolf Polzer <divverent@xonotic.org>
Sun, 19 Feb 2012 18:11:44 +0000 (19:11 +0100)
committerRudolf Polzer <divverent@xonotic.org>
Sun, 19 Feb 2012 18:11:44 +0000 (19:11 +0100)
qcsrc/server/cl_client.qc
qcsrc/server/command/cmd.qc
qcsrc/server/defs.qh
qcsrc/server/scores.qc

index ba4249744eb90862ab299b96b151ebdad0cd41da..6f7cda2b8c9ad328b9bde1d92666b2ff02f47d63 100644 (file)
@@ -2314,7 +2314,7 @@ void ShowRespawnCountdown()
 .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";
 
@@ -2364,26 +2364,36 @@ void LeaveSpectatorMode()
  * 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;
 }
index b901aca6bc01947c0d6279ab20db5473ecf1cdee..8a086fcd5aaa43c9e82c8de7d7b562b85fb40f07 100644 (file)
@@ -152,7 +152,7 @@ void ClientCommand_join(float request)
                        {
                                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; }
@@ -732,4 +732,4 @@ void SV_ParseClientCommand(string command)
        }
        else
                clientcommand(self, command);
-}
\ No newline at end of file
+}
index 61e3215e124bf867dfe044d33e7296b33cb6002d..e2d4c7ad8c7db8672b6963952d025fc15fbe81b3 100644 (file)
@@ -280,7 +280,7 @@ void checkSpectatorBlock();
 .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;
index 3a9a7ada36963cc6551ab92cdcc5d72c32f49ca6..a7d325f22163674203ec389991bc0a02766a936b 100644 (file)
@@ -385,7 +385,7 @@ void WinningConditionHelper()
        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>