Skip to content

Commit

Permalink
server: don't delta from pre-map restart messages
Browse files Browse the repository at this point in the history
During map restart, client->deltaActive is set to false for active clients via SV_ClientEnterWorld. This typically causes one non-delta snapshot to be sent, but as client moves come in, client->deltaActive is set back to true, and subsequent snapshots have delta enabled even though the source frame may be prior to the map restart.

This restores the behavior prior to 250179b where snapshots are non-delta until a post-restart frame is available, regardless of client commands. I don't expect this makes much difference in practice, but it is more consistent and perhaps a bit safer to stick to the original behavior in case of theoretical snapshot overflow issues.
  • Loading branch information
Chomenor committed Jan 26, 2025
1 parent 8aa6fa1 commit 46b908d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions code/server/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ typedef struct client_s {
int downloadSendTime; // time we last got an ack from the client

qboolean deltaActive; // delta snapshots enabled
int deltaStart; // don't delta from messages earlier than this
int deltaMessage; // message to create delta snapshot from
int lastPacketTime; // svs.time when packet was last received
int lastConnectTime; // svs.time when connection started
Expand Down
3 changes: 3 additions & 0 deletions code/server/sv_ccmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ static void SV_MapRestart_f( void ) {
for ( i = 0; i < sv.maxclients; i++ ) {
client = &svs.clients[i];

// don't delta from pre-restart messages
client->deltaStart = client->netchan.outgoingSequence;

// send the new gamestate to all connected clients
if ( client->state < CS_CONNECTED ) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion code/server/sv_snapshot.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static void SV_WriteSnapshotToClient( const client_t *client, msg_t *msg ) {
frame = &client->frames[ client->netchan.outgoingSequence & PACKET_MASK ];

// try to use a previous frame as the source for delta compressing the snapshot
if ( !client->deltaActive || client->state != CS_ACTIVE ) {
if ( !client->deltaActive || client->deltaMessage < client->deltaStart || client->state != CS_ACTIVE ) {
oldframe = NULL;
lastframe = 0;
} else if ( client->netchan.outgoingSequence - client->deltaMessage >= (PACKET_BACKUP - 3) ) {
Expand Down

0 comments on commit 46b908d

Please sign in to comment.