# HG changeset patch # User Adam Kaminski # Date 1643413409 18000 # Fri Jan 28 18:43:29 2022 -0500 # Node ID e60f5c40d535687cb758114d4cab1ed22cbfdb79 # Parent 9b4137e5ae0526ab3ebf260995b5e9d5abe53ee2 Fixed: the server rejected backup weapon select commands that used different weapon network indices but had the same client gametic. diff -r 9b4137e5ae05 -r e60f5c40d535 src/sv_main.cpp --- a/src/sv_main.cpp Wed Jan 26 22:53:56 2022 -0500 +++ b/src/sv_main.cpp Fri Jan 28 18:43:29 2022 -0500 @@ -2029,6 +2029,7 @@ g_aClients[lClient].lLastPacketLossTick = 0; g_aClients[lClient].lLastMoveTick = 0; g_aClients[lClient].lLastMoveTickProcess = 0; + g_aClients[lClient].usLastWeaponNetworkIndex = 0; g_aClients[lClient].lOverMovementLevel = 0; g_aClients[lClient].bRunEnterScripts = false; g_aClients[lClient].bSuspicious = false; @@ -5222,8 +5223,13 @@ { if ( recentCMDs->getOldestEntry( i ) == ulClientTic ) { - delete cmd; - return false; + // [AK] Non-move (i.e. weapon select) commands with the same client gametic but + // different weapon net ids are not duplicates, so don't delete them. + if (( bIsMoveCMD ) || ( cmd->getWeaponNetworkIndex( ) == g_aClients[g_lCurrentClient].usLastWeaponNetworkIndex )) + { + delete cmd; + return false; + } } } @@ -5231,6 +5237,10 @@ recentCMDs->put( ulClientTic ); } + // [AK] Save the net id of the weapon sent last if this is a non-move (i.e. weapon select) command. + if ( bIsMoveCMD == false ) + g_aClients[g_lCurrentClient].usLastWeaponNetworkIndex = cmd->getWeaponNetworkIndex( ); + if ( sv_useticbuffer ) { if ( ulClientTic != 0 ) diff -r 9b4137e5ae05 -r e60f5c40d535 src/sv_main.h --- a/src/sv_main.h Wed Jan 26 22:53:56 2022 -0500 +++ b/src/sv_main.h Fri Jan 28 18:43:29 2022 -0500 @@ -285,6 +285,11 @@ { return 0; } + + virtual unsigned short getWeaponNetworkIndex ( ) const + { + return 0; + } }; //***************************************************************************** @@ -307,6 +312,11 @@ return moveCmd.ulGametic; } + virtual unsigned short getWeaponNetworkIndex ( ) const + { + return moveCmd.usWeaponNetworkIndex; + } + void setClientTic( ULONG ulTic ) { moveCmd.ulGametic = ulTic; @@ -321,6 +331,11 @@ ClientWeaponSelectCommand ( BYTESTREAM_s *pByteStream ); bool process ( const ULONG ulClient ) const; + + virtual unsigned short getWeaponNetworkIndex ( ) const + { + return usActorNetworkIndex; + } }; //***************************************************************************** @@ -431,6 +446,9 @@ // [AK] The last movement command we received from this client. ClientMoveCommand *LastMoveCMD; + // [AK] The network index the client sent with their last weapon select command. + USHORT usLastWeaponNetworkIndex; + // We keep track of how many extra movement commands we get from the client. If it // exceeds a certain level over time, we kick him. LONG lOverMovementLevel;