Skip to content

Commit

Permalink
cmod: Server-side fix for 'Delta parseEntitiesNum' errors on old clients
Browse files Browse the repository at this point in the history
This allows higher sv_fps values (40+) to be used with less chance of causing issues for 1.20 clients with high pings.
  • Loading branch information
Chomenor committed Feb 14, 2024
1 parent 9b94af8 commit daaae7d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
4 changes: 4 additions & 0 deletions code/eliteforce/stef_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@
// being added in SV_AddServerCommand which can accumulate without being sent properly.
#define STEF_DOWNLOAD_CONNECTION_STATE_FIX

// [BUGFIX] Fix for "Delta parseEntitiesNum too old" errors in certain cases.
// (40+ sv_fps value + 1.20 client + high ping/bad connection)
#define STEF_SNAPSHOT_DELTA_BUFFER_FIX

// [BUGFIX] Use alternative to changing serverid during map restarts.
// This avoids the need for a systeminfo update during map restarts and potentially fixes
// some intermittent buggy behavior seen in the EF 1.20 client.
Expand Down
35 changes: 35 additions & 0 deletions code/server/sv_snapshot.c
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,41 @@ void SV_SendClientMessages( void )
continue;
}

#ifdef STEF_SNAPSHOT_DELTA_BUFFER_FIX
if ( c->compat ) {
int bufferUsage = 0;

if ( c->state == CS_ACTIVE && c->netchan.outgoingSequence - c->deltaMessage < ( PACKET_BACKUP - 3 ) ) {
const clientSnapshot_t *deltaFrame = &c->frames[c->deltaMessage & PACKET_MASK];
if ( deltaFrame->frameNum - svs.lastValidFrame >= 0 ) {
// Got valid delta frame according to SV_WriteSnapshotToClient conditions
// Now tally entity usage from delta frame up to current frame
int j;
for ( j = 0; j < PACKET_BACKUP; ++j ) {
int messageNum = c->deltaMessage + j;
const clientSnapshot_t *frame = &c->frames[messageNum & PACKET_MASK];
if ( messageNum >= c->netchan.outgoingSequence ) {
break;
}
if ( frame->frameNum >= deltaFrame->frameNum ) {
bufferUsage += frame->num_entities;
}
}
}
}

// Old clients (prior to ioq3 update in 2013) use MAX_PARSE_ENTITIES value of 2048 with
// CL_ParseSnapshot failing if the buffer usage ahead of the new snapshot is greater than
// MAX_PARSE_ENTITIES-128. I reduced the limit here to MAX_PARSE_ENTITIES-256 to be extra
// safe against theoretically possible (but probably unlikely) entity corruption.
if ( bufferUsage >= 2048 - 256 ) {
Logging_Printf( LP_INFO, "SV_DELTABUFFER", "Forcing non-delta snapshot %i for client "
"%i due to entity buffer usage %i", c->netchan.outgoingSequence, i, bufferUsage );
c->deltaMessage = c->netchan.outgoingSequence - ( PACKET_BACKUP + 1 );
}
}
#endif

// generate and send a new message
SV_SendClientSnapshot( c );
c->lastSnapshotTime = svs.time;
Expand Down

0 comments on commit daaae7d

Please sign in to comment.