diff --git a/src/d_net.cpp b/src/d_net.cpp index 7de859269..6e2877495 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -110,7 +110,7 @@ unsigned int lastrecvtime[MAXPLAYERS]; // [RH] Used for pings unsigned int currrecvtime[MAXPLAYERS]; unsigned int lastglobalrecvtime; // Identify the last time a packet was recieved. bool hadlate; -int netdelay[MAXNETNODES]; // Used for storing network delay times. +int netdelay[MAXNETNODES][BACKUPTICS]; // Used for storing network delay times. int nodeforplayer[MAXPLAYERS]; int playerfornode[MAXNETNODES]; @@ -803,7 +803,7 @@ void GetPackets (void) } // Pull current network delay from node - netdelay[netnode] = netbuffer[k++]; + netdelay[netnode][(nettics[netnode]+1) % BACKUPTICS] = netbuffer[k++]; playerbytes[0] = netconsole; if (netbuffer[0] & NCMD_MULTI) @@ -1340,7 +1340,15 @@ void NetUpdate (void) // [ED850] It seems that there is a bias based on network adaption (which the arbitrator doesn't do), // so I have set this up to assume one less tic, which appears to balance it out. if (net_ticbalance) - average = ((netdelay[0] + ARBITRATOR_DELAY) / 2) - 1; + { + for (i = 0; i < BACKUPTICS; i++) + { + average += netdelay[nodeforplayer[Net_Arbitrator]][i]; + } + average /= BACKUPTICS; + average = ((netdelay[0][nettics[0] % BACKUPTICS] + average) / 2) - 1; + } + mastertics = nettics[nodeforplayer[Net_Arbitrator]] + average; } if (nettics[0] <= mastertics) @@ -2750,7 +2758,6 @@ void Net_SkipCommand (int type, BYTE **stream) CCMD (pings) { int i; - Printf("%d (%d ms) arbitrator buffer time\n", ARBITRATOR_DELAY * ticdup, (ARBITRATOR_DELAY * ticdup) * (1000 / TICRATE)); for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i]) Printf ("% 4d %s\n", currrecvtime[i] - lastrecvtime[i], diff --git a/src/d_net.h b/src/d_net.h index 64c4e0f43..07921a301 100644 --- a/src/d_net.h +++ b/src/d_net.h @@ -142,9 +142,8 @@ extern struct ticcmd_t localcmds[LOCALCMDTICS]; extern int maketic; extern int nettics[MAXNETNODES]; -extern int netdelay[MAXNETNODES]; +extern int netdelay[MAXNETNODES][BACKUPTICS]; extern int nodeforplayer[MAXPLAYERS]; -#define ARBITRATOR_DELAY netdelay[nodeforplayer[Net_Arbitrator]] extern ticcmd_t netcmds[MAXPLAYERS][BACKUPTICS]; extern int ticdup; diff --git a/src/g_shared/shared_hud.cpp b/src/g_shared/shared_hud.cpp index e83e2e988..110675791 100644 --- a/src/g_shared/shared_hud.cpp +++ b/src/g_shared/shared_hud.cpp @@ -934,9 +934,11 @@ static void DrawLatency() { return; } - - int localdelay = (netdelay[0] * ticdup) * (1000 / TICRATE); - int arbitratordelay = (ARBITRATOR_DELAY * ticdup) * (1000 / TICRATE); + int i, localdelay = 0, arbitratordelay = 0; + for (i = 0; i < BACKUPTICS; i++) localdelay += netdelay[0][i]; + for (i = 0; i < BACKUPTICS; i++) arbitratordelay += netdelay[nodeforplayer[Net_Arbitrator]][i]; + localdelay = ((localdelay / BACKUPTICS) * ticdup) * (1000 / TICRATE); + arbitratordelay = ((arbitratordelay / BACKUPTICS) * ticdup) * (1000 / TICRATE); int color = CR_GREEN; if (MAX(localdelay, arbitratordelay) > 200) { diff --git a/src/hu_scores.cpp b/src/hu_scores.cpp index 7d6c5fb1e..8b9a7d0ad 100644 --- a/src/hu_scores.cpp +++ b/src/hu_scores.cpp @@ -419,7 +419,14 @@ static void HU_DrawPlayer (player_t *player, bool highlight, int col1, int col2, screen->DrawText (SmallFont, color, col4, y + ypadding, player->userinfo.GetName(), DTA_CleanNoMove, true, TAG_DONE); - mysnprintf(str, countof(str), "%d", (netdelay[nodeforplayer[(int)(player - players)]] * ticdup) * (1000 / TICRATE)); + int avgdelay = 0; + for (int i = 0; i < BACKUPTICS; i++) + { + avgdelay += netdelay[nodeforplayer[(int)(player - players)]][i]; + } + avgdelay /= BACKUPTICS; + + mysnprintf(str, countof(str), "%d", (avgdelay * ticdup) * (1000 / TICRATE)); screen->DrawText(SmallFont, color, col5, y + ypadding, str, DTA_CleanNoMove, true, TAG_DONE);