]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
allow maxplayers to be changed in game (it'll then be latched and the change will...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 7 Mar 2009 13:41:21 +0000 (13:41 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 7 Mar 2009 13:41:21 +0000 (13:41 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8778 d7cf8633-e32d-0410-b094-e92efae38249

host.c
host_cmd.c
server.h

diff --git a/host.c b/host.c
index dbad918f04bd65a6e7dc45bf07853f3c55cd13a9..b8209a6718a0f934a0a20dab43bac05806efc574 100644 (file)
--- a/host.c
+++ b/host.c
@@ -188,7 +188,7 @@ void Host_ServerOptions (void)
                }
        }
 
-       svs.maxclients = bound(1, svs.maxclients, MAX_SCOREBOARD);
+       svs.maxclients = svs.maxclients_next = bound(1, svs.maxclients, MAX_SCOREBOARD);
 
        svs.clients = (client_t *)Mem_Alloc(sv_mempool, sizeof(client_t) * svs.maxclients);
 
index 0437bbde0815721b1056f4513481a77b6c23ab8a..b5a9c45205ef7f3ac659391335536f4daf026fa4 100644 (file)
@@ -363,6 +363,14 @@ void Host_Map_f (void)
        CL_Disconnect ();
        Host_ShutdownServer();
 
+       if(svs.maxclients != svs.maxclients_next)
+       {
+               svs.maxclients = svs.maxclients_next;
+               if (svs.clients)
+                       Mem_Free(svs.clients);
+               svs.clients = (client_t *)Mem_Alloc(sv_mempool, sizeof(client_t) * svs.maxclients);
+       }
+
        // remove menu
        key_dest = key_game;
 
@@ -2308,17 +2316,14 @@ static void MaxPlayers_f(void)
        if (sv.active)
        {
                Con_Print("maxplayers can not be changed while a server is running.\n");
-               return;
+               Con_Print("It will be changed on next server startup (\"map\" command).\n");
        }
 
        n = atoi(Cmd_Argv(1));
        n = bound(1, n, MAX_SCOREBOARD);
        Con_Printf("\"maxplayers\" set to \"%u\"\n", n);
 
-       if (svs.clients)
-               Mem_Free(svs.clients);
-       svs.maxclients = n;
-       svs.clients = (client_t *)Mem_Alloc(sv_mempool, sizeof(client_t) * svs.maxclients);
+       svs.maxclients_next = n;
        if (n == 1)
                Cvar_Set ("deathmatch", "0");
        else
index 99c5296d263be02a4519cf44a195623191f8cc3a..0d7b239f10e176536ec8aee8d9ec90ce89b84b07 100644 (file)
--- a/server.h
+++ b/server.h
@@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 typedef struct server_static_s
 {
        // number of svs.clients slots (updated by maxplayers command)
-       int maxclients;
+       int maxclients, maxclients_next;
        // client slots
        struct client_s *clients;
        // episode completion information