From 4a848e7b6af632f3928c6dd2f79cdc27cea37a0c Mon Sep 17 00:00:00 2001 From: myT Date: Sat, 8 Dec 2018 00:03:26 +0100 Subject: [PATCH] no longer feeding cs commands that came from a previous gamestate to cgame --- changelog.txt | 3 +++ code/client/cl_cgame.cpp | 10 +++++++--- code/client/cl_parse.cpp | 18 +++++++++++++++--- code/client/client.h | 1 + 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/changelog.txt b/changelog.txt index 9b394c9..7bae606 100644 --- a/changelog.txt +++ b/changelog.txt @@ -16,6 +16,9 @@ add: /toggle can now accept a value sequence (2 or more entries) to loop through chg: on Windows, the upper limit of open stdio file handles was raised from 512 to 2048 +fix: no longer feeding cs commands that came from a previous gamestate to cgame + example: "/map cpm22" -> "/cv map cpm25" -> elevator sound was broken + fix: on Windows, could sometimes click outside the engine's window in raw mouse input mode fix: when r_msaa was in the range [2, 16], the requested sample count was always 4 diff --git a/code/client/cl_cgame.cpp b/code/client/cl_cgame.cpp index be88f42..918c0fc 100644 --- a/code/client/cl_cgame.cpp +++ b/code/client/cl_cgame.cpp @@ -226,14 +226,18 @@ static qbool CL_GetServerCommand( int serverCommandNumber ) return qfalse; } - const char* s = clc.serverCommands[ serverCommandNumber & ( MAX_RELIABLE_COMMANDS - 1 ) ]; + const int index = serverCommandNumber & (MAX_RELIABLE_COMMANDS - 1); + if ( clc.serverCommandsBad[ index ] ) + return qfalse; + + const char* s = clc.serverCommands[ index ]; clc.lastExecutedServerCommand = serverCommandNumber; Com_DPrintf( "serverCommand: %i : %s\n", serverCommandNumber, s ); rescan: Cmd_TokenizeString( s ); - int argc = Cmd_Argc(); - const char* cmd = Cmd_Argv(0); + const int argc = Cmd_Argc(); + const char* const cmd = Cmd_Argv(0); if ( !strcmp( cmd, "disconnect" ) ) { // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=552 diff --git a/code/client/cl_parse.cpp b/code/client/cl_parse.cpp index b9fd97c..653e7fb 100644 --- a/code/client/cl_parse.cpp +++ b/code/client/cl_parse.cpp @@ -429,6 +429,17 @@ static void CL_ParseGamestate( msg_t *msg ) // wipe local client state CL_ClearState(); + // all previous config string commands need to be marked as invalid + for ( i = 0; i < MAX_RELIABLE_COMMANDS; ++i ) { + const char* const cmd = clc.serverCommands[i]; + + if ( !strncmp(cmd, "cs " , 3) || + !strncmp(cmd, "bcs0 ", 5) || + !strncmp(cmd, "bcs1 ", 5) || + !strncmp(cmd, "bcs2 ", 5) ) + clc.serverCommandsBad[i] = qtrue; + } + // a gamestate always marks a server command sequence clc.serverCommandSequence = MSG_ReadLong( msg ); @@ -588,8 +599,8 @@ when it transitions a snapshot */ static void CL_ParseCommandString( msg_t* msg ) { - int seq = MSG_ReadLong( msg ); - const char* s = MSG_ReadString( msg ); + const int seq = MSG_ReadLong( msg ); + const char* const s = MSG_ReadString( msg ); // see if we have already stored it off if ( clc.serverCommandSequence >= seq ) { @@ -597,8 +608,9 @@ static void CL_ParseCommandString( msg_t* msg ) } clc.serverCommandSequence = seq; - int index = seq & (MAX_RELIABLE_COMMANDS-1); + const int index = seq & (MAX_RELIABLE_COMMANDS - 1); Q_strncpyz( clc.serverCommands[ index ], s, sizeof( clc.serverCommands[ index ] ) ); + clc.serverCommandsBad[ index ] = qfalse; // We normally don't process commands before being CA_ACTIVE, // but it's possible we receive a "disconnect" command while diff --git a/code/client/client.h b/code/client/client.h index 035d22a..2def6dc 100644 --- a/code/client/client.h +++ b/code/client/client.h @@ -176,6 +176,7 @@ typedef struct { int serverCommandSequence; int lastExecutedServerCommand; // last server command grabbed or executed with CL_GetServerCommand char serverCommands[MAX_RELIABLE_COMMANDS][MAX_STRING_CHARS]; + qbool serverCommandsBad[MAX_RELIABLE_COMMANDS]; // non-zero means the command shouldn't be fed to cgame // file transfer from server fileHandle_t download;