From 5a3bc639d03903da0f1a6bb0988c6f2283879a1c Mon Sep 17 00:00:00 2001 From: tma Date: Fri, 28 Oct 2005 21:09:50 +0000 Subject: * Fix to https://bugzilla.icculus.org/show_bug.cgi?id=2454 git-svn-id: svn://svn.icculus.org/quake3/trunk@192 edf5b092-35ff-0310-97b2-ce42778d08ea --- code/server/server.h | 2 ++ code/server/sv_client.c | 7 +++++++ code/server/sv_init.c | 7 +++++++ code/server/sv_snapshot.c | 12 +++++++++++- 4 files changed, 27 insertions(+), 1 deletion(-) (limited to 'code/server') diff --git a/code/server/server.h b/code/server/server.h index e58bddb..51fa239 100644 --- a/code/server/server.h +++ b/code/server/server.h @@ -166,6 +166,8 @@ typedef struct client_s { // buffer them into this queue, and hand them out to netchan as needed netchan_buffer_t *netchan_start_queue; netchan_buffer_t **netchan_end_queue; + + int oldServerTime; } client_t; //============================================================================= diff --git a/code/server/sv_client.c b/code/server/sv_client.c index a69c620..01b409a 100644 --- a/code/server/sv_client.c +++ b/code/server/sv_client.c @@ -1500,6 +1500,13 @@ void SV_ExecuteClientMessage( client_t *cl, msg_t *msg ) { return; } + // this client has acknowledged the new gamestate so it's + // safe to start sending it the real time again + if( cl->oldServerTime && serverId == sv.serverId ){ + Com_DPrintf( "%s acknowledged gamestate\n", cl->name ); + cl->oldServerTime = 0; + } + // read optional clientCommand strings do { c = MSG_ReadByte( msg ); diff --git a/code/server/sv_init.c b/code/server/sv_init.c index 0fa6956..d6fd13b 100644 --- a/code/server/sv_init.c +++ b/code/server/sv_init.c @@ -396,6 +396,13 @@ void SV_SpawnServer( char *server, qboolean killBots ) { Cvar_Set( "nextmap", "map_restart 0"); // Cvar_Set( "nextmap", va("map %s", server) ); + for (i=0 ; iinteger ; i++) { + // save when the server started for each client already connected + if (svs.clients[i].state >= CS_CONNECTED) { + svs.clients[i].oldServerTime = sv.time; + } + } + // wipe the entire per-level structure SV_ClearServer(); for ( i = 0 ; i < MAX_CONFIGSTRINGS ; i++ ) { diff --git a/code/server/sv_snapshot.c b/code/server/sv_snapshot.c index 4c164da..d4ac795 100644 --- a/code/server/sv_snapshot.c +++ b/code/server/sv_snapshot.c @@ -160,7 +160,17 @@ static void SV_WriteSnapshotToClient( client_t *client, msg_t *msg ) { // send over the current server time so the client can drift // its view of time to try to match - MSG_WriteLong (msg, sv.time); + if( client->oldServerTime ) { + // The server has not yet got an acknowledgement of the + // new gamestate from this client, so continue to send it + // a time as if the server has not restarted. Note from + // the client's perspective this time is strictly speaking + // incorrect, but since it'll be busy loading a map at + // the time it doesn't really matter. + MSG_WriteLong (msg, sv.time + client->oldServerTime); + } else { + MSG_WriteLong (msg, sv.time); + } // what we are delta'ing from MSG_WriteByte (msg, lastframe); -- cgit v1.2.3