リビジョン | 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.
@@ -1988,6 +1988,7 @@ | ||
1988 | 1988 | g_aClients[lClient].IgnoredAddresses.clear(); |
1989 | 1989 | g_aClients[lClient].ScreenWidth = 0; |
1990 | 1990 | g_aClients[lClient].ScreenHeight = 0; |
1991 | + g_aClients[lClient].ulExtraDelay = 0; | |
1991 | 1992 | // [CK] Since the client is not up to date at all, the farthest the client |
1992 | 1993 | // should be able to go back is the gametic they connected with. |
1993 | 1994 | g_aClients[lClient].lLastServerGametic = gametic; |
@@ -6040,12 +6041,27 @@ | ||
6040 | 6041 | } |
6041 | 6042 | else |
6042 | 6043 | { |
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 ); | |
6046 | 6049 | // [BB] The most recent ping measurement should always have a noticeable influence on the average ping. |
6047 | 6050 | if ( p->ulPingAverages < 20 ) |
6048 | 6051 | 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 | + } | |
6049 | 6065 | } |
6050 | 6066 | |
6051 | 6067 | return ( false ); |
@@ -466,6 +466,10 @@ | ||
466 | 466 | // means we're expecting them to also send us backups of older commands. |
467 | 467 | ULONG ulNumExpectedCMDs; |
468 | 468 | |
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 | + | |
469 | 473 | // [BB] Variables for the account system |
470 | 474 | FString username; |
471 | 475 | unsigned int clientSessionID; |