From de0e3cba34667c6c488ddd087c2dd8e3a010f83c Mon Sep 17 00:00:00 2001 From: Thilo Schulz Date: Thu, 27 Jan 2011 16:40:15 +0000 Subject: [PATCH] Fix hanging client when map_restart executed on the server while client is still loading the map --- code/server/sv_ccmds.c | 12 +++++++++--- code/server/sv_client.c | 6 +++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/code/server/sv_ccmds.c b/code/server/sv_ccmds.c index 2b425c88..ba2d3b31 100644 --- a/code/server/sv_ccmds.c +++ b/code/server/sv_ccmds.c @@ -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 diff --git a/code/server/sv_client.c b/code/server/sv_client.c index d6c355ad..1db1a3bb 100644 --- a/code/server/sv_client.c +++ b/code/server/sv_client.c @@ -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 );