Fix hanging client when map_restart executed on the server while client is still loading the map

This commit is contained in:
Thilo Schulz 2011-01-27 16:40:15 +00:00
parent d1c0401c73
commit de0e3cba34
2 changed files with 14 additions and 4 deletions

View File

@ -338,9 +338,15 @@ static void SV_MapRestart_f( void ) {
continue;
}
client->state = CS_ACTIVE;
SV_ClientEnterWorld( client, &client->lastUsercmd );
if(client->state == CS_ACTIVE)
SV_ClientEnterWorld(client, &client->lastUsercmd);
else
{
// If we don't reset client->lastUsercmd and are restarting during map load,
// the client will hang because we'll use the last Usercmd from the previous map,
// which is wrong obviously.
SV_ClientEnterWorld(client, NULL);
}
}
// run another frame to allow things to look at all the players

View File

@ -715,7 +715,11 @@ void SV_ClientEnterWorld( client_t *client, usercmd_t *cmd ) {
client->deltaMessage = -1;
client->nextSnapshotTime = svs.time; // generate a snapshot immediately
client->lastUsercmd = *cmd;
if(cmd)
memcpy(&client->lastUsercmd, cmd, sizeof(client->lastUsercmd));
else
memset(&client->lastUsercmd, '\0', sizeof(client->lastUsercmd));
// call the game begin function
VM_Call( gvm, GAME_CLIENT_BEGIN, client - svs.clients );