Fix loading Coop savegames without starting server first

This commit is contained in:
Daniel Gibson 2019-02-03 19:35:38 +01:00
parent b44fd32572
commit 04a33c9837

View file

@ -645,7 +645,16 @@ SV_FinalMessage(char *message, qboolean reconnect)
}
/* stagger the packets to crutch operating system limited buffers */
for (i = 0, cl = svs.clients; i < maxclients->value; i++, cl++)
/* DG: we can't just use the maxclients cvar here for the number of clients,
* because this is called by SV_Shutdown() and the shut down server might have
* a different number of clients (e.g. 1 if it's single player), when maxclients
* has already been set to a higher value for multiplayer (e.g. 4 for coop)
* Luckily, svs.num_client_entities = maxclients->value * UPDATE_BACKUP * 64;
* with the maxclients value from when the current server was started (see SV_InitGame())
* so we can just calculate the right number of clients from that
*/
int numClients = svs.num_client_entities / ( UPDATE_BACKUP * 64 );
for (i = 0, cl = svs.clients; i < numClients; i++, cl++)
{
if (cl->state >= cs_connected)
{
@ -654,7 +663,7 @@ SV_FinalMessage(char *message, qboolean reconnect)
}
}
for (i = 0, cl = svs.clients; i < maxclients->value; i++, cl++)
for (i = 0, cl = svs.clients; i < numClients; i++, cl++)
{
if (cl->state >= cs_connected)
{