Skip to content

Fix entity baseline overflow #1427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions src/engine/client/cl_parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,13 @@ void CL_ParseGamestate( msg_t *msg )

clc.connectPacketCount = 0;

// wipe local client state
CL_ClearState();
if ( !cl.reading ) {
// wipe local client state
CL_ClearState();

// a gamestate always marks a server command sequence
clc.serverCommandSequence = MSG_ReadLong( msg );
// a gamestate always marks a server command sequence
clc.serverCommandSequence = MSG_ReadLong( msg );
}

// parse all the configstrings and baselines
while (true)
Expand Down Expand Up @@ -443,21 +445,30 @@ void CL_ParseGamestate( msg_t *msg )
entityState_t nullstate{};
es = &cl.entityBaselines[ newnum ];
MSG_ReadDeltaEntity( msg, &nullstate, es, newnum );

cl.reading = false;
}
else if ( cmd == svc_gamestatePartial )
{
cl.reading = true;
break;
}
else
{
Sys::Drop( "CL_ParseGamestate: bad command byte" );
}
}

clc.clientNum = MSG_ReadLong( msg );
if ( !cl.reading ) {
clc.clientNum = MSG_ReadLong( msg );

// parse serverId and other cvars
CL_SystemInfoChanged();
// parse serverId and other cvars
CL_SystemInfoChanged();

// This used to call CL_StartHunkUsers, but now we enter the download state before loading the
// cgame
CL_InitDownloads();
// This used to call CL_StartHunkUsers, but now we enter the download state before loading the
// cgame
CL_InitDownloads();
}
}

//=====================================================================
Expand Down
2 changes: 2 additions & 0 deletions src/engine/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ struct clientActive_t
clSnapshot_t snapshots[ PACKET_BACKUP ];

entityState_t entityBaselines[ MAX_GENTITIES ]; // for delta compression when not in previous frame

bool reading; // For gamestate that is split between different msg_t
};

extern clientActive_t cl;
Expand Down
3 changes: 2 additions & 1 deletion src/engine/qcommon/qcommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,13 @@ enum svc_ops_e
svc_bad,
svc_nop,
svc_gamestate,
svc_gamestatePartial,
svc_configstring, // [short] [string] only in gamestate messages
svc_baseline, // only in gamestate messages
svc_serverCommand, // [string] to be executed by client game module
svc_download, // [short] size [size bytes]
svc_snapshot,
svc_EOF,
svc_EOF
};

//
Expand Down
10 changes: 10 additions & 0 deletions src/engine/server/sv_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,16 @@ void SV_SendClientGameState( client_t *client )

MSG_WriteByte( &msg, svc_baseline );
MSG_WriteDeltaEntity( &msg, &nullstate, base, true );

if ( MAX_MSGLEN - msg.cursize < 128 ) {
// We have too many entities to put them all into one msg_t, so split it here
MSG_WriteByte( &msg, svc_gamestatePartial );
SV_SendMessageToClient( &msg, client );

MSG_Init( &msg, msgBuffer, sizeof( msgBuffer ) );
MSG_WriteLong( &msg, client->lastClientCommand );
MSG_WriteByte( &msg, svc_gamestate );
}
}

MSG_WriteByte( &msg, svc_EOF );
Expand Down
Loading