コミットメタ情報

リビジョン22b486393cf76e9058d32f7dba1cf4d68920e1e4 (tree)
日時2021-10-20 23:22:12
作者Adam Kaminski <kaminskiadam9@gmai...>
コミッターAdam Kaminski

ログメッセージ

Increase the client's ping proportionally to the number of expected backup commands.

変更サマリ

差分

diff -r eff6a90ae21b -r 22b486393cf7 src/sv_main.cpp
--- a/src/sv_main.cpp Sun Oct 24 02:01:10 2021 +0100
+++ b/src/sv_main.cpp Wed Oct 20 10:22:12 2021 -0400
@@ -1988,6 +1988,7 @@
19881988 g_aClients[lClient].IgnoredAddresses.clear();
19891989 g_aClients[lClient].ScreenWidth = 0;
19901990 g_aClients[lClient].ScreenHeight = 0;
1991+ g_aClients[lClient].ulExtraDelay = 0;
19911992 // [CK] Since the client is not up to date at all, the farthest the client
19921993 // should be able to go back is the gametic they connected with.
19931994 g_aClients[lClient].lLastServerGametic = gametic;
@@ -6040,12 +6041,27 @@
60406041 }
60416042 else
60426043 {
6043- ULONG oldPing = p->ulPing;
6044- ULONG ulPingAverages = p->ulPingAverages;
6045- p->ulPing = ( p->ulPingAverages * p->ulPing + currentPing ) / ( 1 + p->ulPingAverages );
6044+ // [AK] Adjust the client's old ping based on the extra delay there is due to them sending us backup
6045+ // commands. We must do this so that the ping calculation below produces a consistent result.
6046+ ULONG oldPing = p->ulPing - g_aClients[g_lCurrentClient].ulExtraDelay;
6047+
6048+ p->ulPing = ( p->ulPingAverages * oldPing + currentPing ) / ( 1 + p->ulPingAverages );
60466049 // [BB] The most recent ping measurement should always have a noticeable influence on the average ping.
60476050 if ( p->ulPingAverages < 20 )
60486051 p->ulPingAverages++;
6052+
6053+ // [AK] If the client is sending us backup commands, we always have to delay their input enough so that
6054+ // we get all the commands at the right time. Therefore, we also increase the client's ping proportionally
6055+ // to the number of expected backup commands to indicate this delay to everyone.
6056+ if (( p->bSpectating == false ) && ( g_aClients[g_lCurrentClient].ulNumExpectedCMDs > 1 ))
6057+ {
6058+ g_aClients[g_lCurrentClient].ulExtraDelay = ( g_aClients[g_lCurrentClient].ulNumExpectedCMDs - 1 ) * ticLength;
6059+ p->ulPing += g_aClients[g_lCurrentClient].ulExtraDelay;
6060+ }
6061+ else
6062+ {
6063+ g_aClients[g_lCurrentClient].ulExtraDelay = 0;
6064+ }
60496065 }
60506066
60516067 return ( false );
diff -r eff6a90ae21b -r 22b486393cf7 src/sv_main.h
--- a/src/sv_main.h Sun Oct 24 02:01:10 2021 +0100
+++ b/src/sv_main.h Wed Oct 20 10:22:12 2021 -0400
@@ -466,6 +466,10 @@
466466 // means we're expecting them to also send us backups of older commands.
467467 ULONG ulNumExpectedCMDs;
468468
469+ // [AK] How much artificial delay there is in the client's inputs due to them sending us backup commands.
470+ // Each backup command received per tic delays the client's ping by ~29 ms.
471+ ULONG ulExtraDelay;
472+
469473 // [BB] Variables for the account system
470474 FString username;
471475 unsigned int clientSessionID;
旧リポジトリブラウザで表示