From 409c253e220226b9822de54316326f0e96a315e9 Mon Sep 17 00:00:00 2001 From: slipher Date: Wed, 8 Apr 2026 19:13:25 -0300 Subject: [PATCH] Discard old server commands upon new gamestate Fixes https://github.com/Unvanquished/Unvanquished/issues/1102. This fixes a bug where the configstring state could be wrong due to `cs` server commands being executed out of order with respect to game state processing. Server commands are only processed when the cgame requests a snapshot, so commands received before the client loads the current map which were sent before the gamestate could be processed after the gamestate. Of course there are other commands besides setting configstrings. In general, processing a command from a previous game seems very likely to be a bad idea and unlikely to be good. --- src/engine/client/cl_parse.cpp | 3 +++ src/engine/server/sv_client.cpp | 1 + 2 files changed, 4 insertions(+) diff --git a/src/engine/client/cl_parse.cpp b/src/engine/client/cl_parse.cpp index cf91714f19..2169c114fd 100644 --- a/src/engine/client/cl_parse.cpp +++ b/src/engine/client/cl_parse.cpp @@ -409,6 +409,9 @@ void CL_ParseGamestate( msg_t *msg ) // a gamestate always marks a server command sequence clc.serverCommandSequence = MSG_ReadLong( msg ); + + // trash any commands from previous game + clc.lastExecutedServerCommand = clc.serverCommandSequence; } // parse all the configstrings and baselines diff --git a/src/engine/server/sv_client.cpp b/src/engine/server/sv_client.cpp index 3b6f336754..469c99f96a 100644 --- a/src/engine/server/sv_client.cpp +++ b/src/engine/server/sv_client.cpp @@ -354,6 +354,7 @@ void SV_SendClientGameState( client_t *client ) // we have to do this cause we send the client->reliableSequence // with a gamestate and it sets the clc.serverCommandSequence at // the client side + // TODO(0.57): remove. The client will just throw away old commands on getting a gamestate SV_UpdateServerCommandsToClient( client, &msg ); // send the gamestate