# HG changeset patch # User Adam Kaminski # Date 1643413409 18000 # Fri Jan 28 18:43:29 2022 -0500 # Node ID af58e1908f5823a0b528baa07f719ce5215e954e # 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 af58e1908f58 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] Weapon select commands with the same client gametic but different network + // indices 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] If this is a weapon select command, save the network index of the weapon that was sent. + if ( bIsMoveCMD == false ) + g_aClients[g_lCurrentClient].usLastWeaponNetworkIndex = cmd->getWeaponNetworkIndex( ); + if ( sv_useticbuffer ) { if ( ulClientTic != 0 ) diff -r 9b4137e5ae05 -r af58e1908f58 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; } + + unsigned short getWeaponNetworkIndex ( ) const + { + return 0; + } }; //***************************************************************************** @@ -311,6 +316,11 @@ { moveCmd.ulGametic = ulTic; } + + unsigned short getWeaponNetworkIndex ( ) const + { + return moveCmd.usWeaponNetworkIndex; + } }; //***************************************************************************** @@ -321,6 +331,11 @@ ClientWeaponSelectCommand ( BYTESTREAM_s *pByteStream ); bool process ( const ULONG ulClient ) const; + + 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;