• R/O
  • SSH

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得cocoawindowspythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdombtronvb.netdirectxarduinopreviewerゲームエンジン

This is a fork of Zandronum for Mac Os (M1 and Intel)


Commit MetaInfo

Revisionbbe5606eb974b7fb154117d1cf950d3b6785abab (tree)
Time2021-12-01 13:46:46
AuthorAdam Kaminski <kaminskiadam9@gmai...>
CommiterAdam Kaminski

Log Message

The server no longer ignores commands that arrived too late anymore, but rather only ignores duplicates of commands it already received from a player.

Change Summary

Incremental Difference

diff -r fad199a4c89b -r bbe5606eb974 src/sv_main.cpp
--- a/src/sv_main.cpp Tue Nov 30 22:54:42 2021 -0500
+++ b/src/sv_main.cpp Tue Nov 30 23:46:46 2021 -0500
@@ -2038,6 +2038,10 @@
20382038 // should be able to go back is the gametic they connected with.
20392039 g_aClients[lClient].lLastServerGametic = gametic;
20402040
2041+ // [AK] Clear any recent command gametics from the client.
2042+ g_aClients[lClient].recentMoveCMDs.clear();
2043+ g_aClients[lClient].recentSelectCMDs.clear();
2044+
20412045 // [AK] Reset the client's tic buffer.
20422046 SERVER_ResetClientTicBuffer( lClient );
20432047
@@ -5200,13 +5204,27 @@
52005204 const ULONG ulClientTic = cmd->getClientTic( );
52015205 const bool bIsMoveCMD = cmd->isMoveCmd( );
52025206
5203- // [AK] Ignore commands that arrived too late or are duplicates of commands we already processed,
5204- // neither of which we can account for anymore. This way, we aren't processing the same commands
5205- // again, or that happened too far into the past.
5206- if (( ulClientTic != 0 ) && ( ulClientTic <= g_aClients[g_lCurrentClient].ulClientGameTic ))
5207- {
5208- delete cmd;
5209- return false;
5207+ // [AK] Ignore commands that are duplicates of commands we already received and/or processed.
5208+ // This way, we won't process the exact same commands multiple times.
5209+ if ( ulClientTic != 0 )
5210+ {
5211+ RingBuffer<ULONG, MAX_RECENT_COMMANDS> *recentCMDs;
5212+
5213+ // [AK] Move commands and weapon select commands each have their own ring buffers, since
5214+ // a movement and weapon select commands with the same gametic can co-exist.
5215+ recentCMDs = bIsMoveCMD ? &g_aClients[g_lCurrentClient].recentMoveCMDs : &g_aClients[g_lCurrentClient].recentSelectCMDs;
5216+
5217+ for ( unsigned int i = 0; i < MAX_RECENT_COMMANDS; i++ )
5218+ {
5219+ if ( recentCMDs->getOldestEntry( i ) == ulClientTic )
5220+ {
5221+ delete cmd;
5222+ return false;
5223+ }
5224+ }
5225+
5226+ // [AK] Save this gametic into the ring buffer for later use.
5227+ recentCMDs->put( ulClientTic );
52105228 }
52115229
52125230 if ( sv_useticbuffer )
@@ -5236,25 +5254,11 @@
52365254 {
52375255 ULONG ulBufferClientTic = (*buffer)[i]->getClientTic( );
52385256
5239- if ( ulBufferClientTic != 0 )
5257+ // [AK] Reorganize the commands in case they arrived in the wrong order.
5258+ if (( ulBufferClientTic != 0 ) && ( ulClientTic < ulBufferClientTic ))
52405259 {
5241- // [AK] Double-check to make sure we don't already have this command stored anywhere in the buffer.
5242- // If it's not a late command, we also need to make sure there aren't any newer move commands already
5243- // in the tic buffer. If any of these conditions fail, we have to ignore this command.
5244- // Movement and weapon select commands with the same gametic can co-exist in the tic buffer, as
5245- // they're not the same command, but two movement or weapon select commands cannot.
5246- if (( ulBufferClientTic == ulClientTic ) && ( bIsMoveCMD == (*buffer)[i]->isMoveCmd( )))
5247- {
5248- delete cmd;
5249- return false;
5250- }
5251-
5252- // [AK] Reorganize the commands in case they arrived in the wrong order.
5253- if ( ulClientTic < ulBufferClientTic )
5254- {
5255- buffer->Insert( i, cmd );
5256- return false;
5257- }
5260+ buffer->Insert( i, cmd );
5261+ return false;
52585262 }
52595263 }
52605264 }
@@ -5463,14 +5467,7 @@
54635467
54645468 // [AK] Clear all stored commands in the tic buffer.
54655469 for ( unsigned int i = 0; i < g_aClients[ulClient].MoveCMDs.Size( ); i++ )
5466- {
5467- // [AK] Set the client's gametic to the last command in their tic buffer that has a non-zero
5468- // gametic. This way, any old and therefore invalid backup commands will be rejected.
5469- if ( g_aClients[ulClient].MoveCMDs[i]->getClientTic( ) != 0 )
5470- g_aClients[ulClient].ulClientGameTic = g_aClients[ulClient].MoveCMDs[i]->getClientTic( );
5471-
54725470 delete g_aClients[ulClient].MoveCMDs[i];
5473- }
54745471
54755472 g_aClients[ulClient].MoveCMDs.Clear( );
54765473
@@ -5500,12 +5497,9 @@
55005497 // to the last late command we received from them and update their gametic.
55015498 if ( bUpdatedLastMoveCMD == false )
55025499 {
5503- ULONG ulNewClientGametic = g_aClients[ulClient].LastMoveCMD->getClientTic( ) + g_aClients[ulClient].ulExtrapolatedTics;
5504-
55055500 delete g_aClients[ulClient].LastMoveCMD;
55065501 g_aClients[ulClient].LastMoveCMD = static_cast<ClientMoveCommand *>( g_aClients[ulClient].LateMoveCMDs[i] );
55075502
5508- g_aClients[ulClient].LastMoveCMD->setClientTic( ulNewClientGametic );
55095503 bUpdatedLastMoveCMD = true;
55105504 continue;
55115505 }
diff -r fad199a4c89b -r bbe5606eb974 src/sv_main.h
--- a/src/sv_main.h Tue Nov 30 22:54:42 2021 -0500
+++ b/src/sv_main.h Tue Nov 30 23:46:46 2021 -0500
@@ -82,6 +82,9 @@
8282 // Amount of time the client has to report his checksum of the level.
8383 #define CLIENT_CHECKSUM_WAITTIME ( 15 * TICRATE )
8484
85+// [AK] Maximum amount of gametics of recent commands from a client that we can store.
86+#define MAX_RECENT_COMMANDS 15
87+
8588 // This is for the server console, but since we normally can't include that (win32 stuff),
8689 // we can just put it here.
8790 #define UDF_NAME 0x00000001
@@ -392,6 +395,12 @@
392395 // [BB] A record of the gametics the client called protected minor commands, e.g. toggleconsole.
393396 RingBuffer<LONG, 100> minorCommandInstances;
394397
398+ // [AK] A list of gametics of the last few movement commands the client sent us.
399+ RingBuffer<ULONG, MAX_RECENT_COMMANDS> recentMoveCMDs;
400+
401+ // [AK] A list of (non-zero) gametics of the last few weapon select commands the client sent us.
402+ RingBuffer<ULONG, MAX_RECENT_COMMANDS> recentSelectCMDs;
403+
395404 // A record of the gametic the client spoke at. We store the last MAX_CHATINSTANCE_STORAGE
396405 // times the client chatted. This is used to chat spam protection.
397406 LONG lChatInstances[MAX_CHATINSTANCE_STORAGE];