aboutsummaryrefslogtreecommitdiffstats
path: root/code
diff options
context:
space:
mode:
Diffstat (limited to 'code')
-rw-r--r--code/server/server.h2
-rw-r--r--code/server/sv_client.c7
-rw-r--r--code/server/sv_init.c7
-rw-r--r--code/server/sv_snapshot.c12
4 files changed, 27 insertions, 1 deletions
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 ; i<sv_maxclients->integer ; 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);