]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fixed a bug in multiplayer savegame loading that caused all players
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 18 Oct 2007 07:09:15 +0000 (07:09 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 18 Oct 2007 07:09:15 +0000 (07:09 +0000)
after the first one to respawn immediately after loading
(sv.loadgame and sv.paused were being cleared by the first player)

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7646 d7cf8633-e32d-0410-b094-e92efae38249

host.c
host_cmd.c

diff --git a/host.c b/host.c
index 7888bffd8d57babefadea2d6cf56d3baf6bdbd7e..e0536ff6505e49ed76052b5595b7da0a056d3b35 100644 (file)
--- a/host.c
+++ b/host.c
@@ -462,6 +462,18 @@ void SV_DropClient(qboolean crash)
        // update server listing on the master because player count changed
        // (which the master uses for filtering empty/full servers)
        NetConn_Heartbeat(1);
+
+       if (sv.loadgame)
+       {
+               for (i = 0;i < svs.maxclients;i++)
+                       if (svs.clients[i].active && !svs.clients[i].spawned)
+                               break;
+               if (i == svs.maxclients)
+               {
+                       Con_Printf("Loaded game, everyone rejoined - unpausing\n");
+                       sv.paused = sv.loadgame = false; // we're basically done with loading now
+               }
+       }
 }
 
 /*
@@ -527,7 +539,7 @@ void Host_GetConsoleCommands (void)
 ==================
 Host_TimeReport
 
-Returns a time report string, for example for 
+Returns a time report string, for example for
 ==================
 */
 const char *Host_TimingReport()
index 21c8690ab492e94af922be38f158dbb85dd6dd04..8bb5e69a71379ccfe559275e4bfe5ad78ce496df 100644 (file)
@@ -1405,9 +1405,6 @@ void Host_Spawn_f (void)
        if (sv.loadgame)
        {
                // loaded games are fully initialized already
-               // if this is the last client to be connected, unpause
-               sv.paused = false;
-
                if (prog->funcoffsets.RestoreGame)
                {
                        Con_DPrint("Calling RestoreGame\n");
@@ -1430,8 +1427,8 @@ void Host_Spawn_f (void)
                prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
                PRVM_ExecuteProgram (prog->globals.server->ClientConnect, "QC function ClientConnect is missing");
 
-               if (svs.maxclients > 1 || cls.state == ca_dedicated)
-                       Con_Printf("%s entered the game\n", host_client->name);
+               if (cls.state == ca_dedicated)
+                       Con_Printf("%s connected\n", host_client->name);
 
                PRVM_ExecuteProgram (prog->globals.server->PutClientInServer, "QC function PutClientInServer is missing");
        }
@@ -1498,7 +1495,6 @@ void Host_Spawn_f (void)
                MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->v_angle[0], sv.protocol);
                MSG_WriteAngle (&host_client->netconnection->message, host_client->edict->fields.server->v_angle[1], sv.protocol);
                MSG_WriteAngle (&host_client->netconnection->message, 0, sv.protocol);
-               sv.loadgame = false; // we're basically done with loading now
        }
        else
        {
@@ -1522,6 +1518,20 @@ Host_Begin_f
 void Host_Begin_f (void)
 {
        host_client->spawned = true;
+
+       // LordHavoc: note: this code also exists in SV_DropClient
+       if (sv.loadgame)
+       {
+               int i;
+               for (i = 0;i < svs.maxclients;i++)
+                       if (svs.clients[i].active && !svs.clients[i].spawned)
+                               break;
+               if (i == svs.maxclients)
+               {
+                       Con_Printf("Loaded game, everyone rejoined - unpausing\n");
+                       sv.paused = sv.loadgame = false; // we're basically done with loading now
+               }
+       }
 }
 
 //===========================================================================