no longer feeding cs commands that came from a previous gamestate to cgame

This commit is contained in:
myT 2018-12-08 00:03:26 +01:00
parent 8ecb5683d1
commit 4a848e7b6a
4 changed files with 26 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;