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 dbad918..b8209a6 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 0437bbd..b5a9c45 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 99c5296..0d7b239 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