mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
Made delay updates less erratic
This commit is contained in:
parent
6cd4fd8151
commit
4db8b3e421
4 changed files with 25 additions and 10 deletions
|
@ -110,7 +110,7 @@ unsigned int lastrecvtime[MAXPLAYERS]; // [RH] Used for pings
|
||||||
unsigned int currrecvtime[MAXPLAYERS];
|
unsigned int currrecvtime[MAXPLAYERS];
|
||||||
unsigned int lastglobalrecvtime; // Identify the last time a packet was recieved.
|
unsigned int lastglobalrecvtime; // Identify the last time a packet was recieved.
|
||||||
bool hadlate;
|
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 nodeforplayer[MAXPLAYERS];
|
||||||
int playerfornode[MAXNETNODES];
|
int playerfornode[MAXNETNODES];
|
||||||
|
@ -803,7 +803,7 @@ void GetPackets (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pull current network delay from node
|
// Pull current network delay from node
|
||||||
netdelay[netnode] = netbuffer[k++];
|
netdelay[netnode][(nettics[netnode]+1) % BACKUPTICS] = netbuffer[k++];
|
||||||
|
|
||||||
playerbytes[0] = netconsole;
|
playerbytes[0] = netconsole;
|
||||||
if (netbuffer[0] & NCMD_MULTI)
|
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),
|
// [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.
|
// so I have set this up to assume one less tic, which appears to balance it out.
|
||||||
if (net_ticbalance)
|
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;
|
mastertics = nettics[nodeforplayer[Net_Arbitrator]] + average;
|
||||||
}
|
}
|
||||||
if (nettics[0] <= mastertics)
|
if (nettics[0] <= mastertics)
|
||||||
|
@ -2750,7 +2758,6 @@ void Net_SkipCommand (int type, BYTE **stream)
|
||||||
CCMD (pings)
|
CCMD (pings)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
Printf("%d (%d ms) arbitrator buffer time\n", ARBITRATOR_DELAY * ticdup, (ARBITRATOR_DELAY * ticdup) * (1000 / TICRATE));
|
|
||||||
for (i = 0; i < MAXPLAYERS; i++)
|
for (i = 0; i < MAXPLAYERS; i++)
|
||||||
if (playeringame[i])
|
if (playeringame[i])
|
||||||
Printf ("% 4d %s\n", currrecvtime[i] - lastrecvtime[i],
|
Printf ("% 4d %s\n", currrecvtime[i] - lastrecvtime[i],
|
||||||
|
|
|
@ -142,9 +142,8 @@ extern struct ticcmd_t localcmds[LOCALCMDTICS];
|
||||||
|
|
||||||
extern int maketic;
|
extern int maketic;
|
||||||
extern int nettics[MAXNETNODES];
|
extern int nettics[MAXNETNODES];
|
||||||
extern int netdelay[MAXNETNODES];
|
extern int netdelay[MAXNETNODES][BACKUPTICS];
|
||||||
extern int nodeforplayer[MAXPLAYERS];
|
extern int nodeforplayer[MAXPLAYERS];
|
||||||
#define ARBITRATOR_DELAY netdelay[nodeforplayer[Net_Arbitrator]]
|
|
||||||
|
|
||||||
extern ticcmd_t netcmds[MAXPLAYERS][BACKUPTICS];
|
extern ticcmd_t netcmds[MAXPLAYERS][BACKUPTICS];
|
||||||
extern int ticdup;
|
extern int ticdup;
|
||||||
|
|
|
@ -934,9 +934,11 @@ static void DrawLatency()
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
int i, localdelay = 0, arbitratordelay = 0;
|
||||||
int localdelay = (netdelay[0] * ticdup) * (1000 / TICRATE);
|
for (i = 0; i < BACKUPTICS; i++) localdelay += netdelay[0][i];
|
||||||
int arbitratordelay = (ARBITRATOR_DELAY * ticdup) * (1000 / TICRATE);
|
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;
|
int color = CR_GREEN;
|
||||||
if (MAX(localdelay, arbitratordelay) > 200)
|
if (MAX(localdelay, arbitratordelay) > 200)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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(),
|
screen->DrawText (SmallFont, color, col4, y + ypadding, player->userinfo.GetName(),
|
||||||
DTA_CleanNoMove, true, TAG_DONE);
|
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,
|
screen->DrawText(SmallFont, color, col5, y + ypadding, str,
|
||||||
DTA_CleanNoMove, true, TAG_DONE);
|
DTA_CleanNoMove, true, TAG_DONE);
|
||||||
|
|
Loading…
Reference in a new issue