Skip to content

Commit

Permalink
server: delta snapshot developer print fix
Browse files Browse the repository at this point in the history
Set client->deltaMessage to -1 when disabling delta snapshots, allowing developer prints to correctly distinguish between delta being disabled intentionally versus by PACKET_BACKUP limit. Reverts part of 3f92ee4.
  • Loading branch information
Chomenor committed Jan 17, 2025
1 parent 4b6c96e commit ca6e680
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion code/server/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ typedef struct client_s {
qboolean downloadEOF; // We have sent the EOF block
int downloadSendTime; // time we last got an ack from the client

int deltaMessage; // frame last client usercmd message
int deltaMessage; // message to create delta snapshot from (-1 for no delta)
int lastPacketTime; // svs.time when packet was last received
int lastConnectTime; // svs.time when connection started
int lastDisconnectTime;
Expand Down
6 changes: 3 additions & 3 deletions code/server/sv_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ void SV_ClientEnterWorld( client_t *client ) {
ent->s.number = clientNum;
client->gentity = ent;

client->deltaMessage = client->netchan.outgoingSequence - (PACKET_BACKUP + 1); // force delta reset
client->deltaMessage = -1;
client->lastSnapshotTime = svs.time - 9999; // generate a snapshot immediately

// call the game begin function
Expand Down Expand Up @@ -2138,7 +2138,7 @@ static void SV_UserMove( client_t *cl, msg_t *msg, qboolean delta ) {
if ( delta ) {
cl->deltaMessage = cl->messageAcknowledge;
} else {
cl->deltaMessage = cl->netchan.outgoingSequence - ( PACKET_BACKUP + 1 ); // force delta reset
cl->deltaMessage = -1;
}

cmdCount = MSG_ReadByte( msg );
Expand Down Expand Up @@ -2194,7 +2194,7 @@ static void SV_UserMove( client_t *cl, msg_t *msg, qboolean delta ) {
}

if ( cl->state != CS_ACTIVE ) {
cl->deltaMessage = cl->netchan.outgoingSequence - ( PACKET_BACKUP + 1 ); // force delta reset
cl->deltaMessage = -1;
return;
}

Expand Down
9 changes: 2 additions & 7 deletions code/server/sv_snapshot.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,12 @@ 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->deltaMessage <= 0 || */ client->state != CS_ACTIVE ) {
// client is asking for a retransmit
if ( client->deltaMessage <= 0 || client->state != CS_ACTIVE ) {
oldframe = NULL;
lastframe = 0;
} else if ( client->netchan.outgoingSequence - client->deltaMessage >= (PACKET_BACKUP - 3) ) {
// client hasn't gotten a good message through in a long time
if ( com_developer->integer ) {
if ( client->deltaMessage != client->netchan.outgoingSequence - ( PACKET_BACKUP + 1 ) ) {
Com_Printf( "%s: Delta request from out of date packet.\n", client->name );
}
}
Com_DPrintf( "%s: Delta request from out of date packet.\n", client->name );
oldframe = NULL;
lastframe = 0;
} else {
Expand Down

0 comments on commit ca6e680

Please sign in to comment.