- scriptified and cleaned up the AltHUD's DrawCoordinates, DrawTime and DrawLatency functions.

Some backing functionality was moved elsewhere because scripting should not have access to low level system information.
This commit is contained in:
Christoph Oelckers 2018-12-02 12:24:51 +01:00
commit ddaab4d2ab
7 changed files with 258 additions and 170 deletions

View file

@ -2851,6 +2851,34 @@ void Net_SkipCommand (int type, uint8_t **stream)
*stream += skip;
}
// This was taken out of shared_hud, because UI code shouldn't do low level calculations that may change if the backing implementation changes.
int Net_GetLatency(int *ld, int *ad)
{
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];
arbitratordelay = ((arbitratordelay / BACKUPTICS) * ticdup) * (1000 / TICRATE);
localdelay = ((localdelay / BACKUPTICS) * ticdup) * (1000 / TICRATE);
int severity = 0;
if (MAX(localdelay, arbitratordelay) > 200)
{
severity = 1;
}
if (MAX(localdelay, arbitratordelay) > 400)
{
severity = 2;
}
if (MAX(localdelay, arbitratordelay) >= ((BACKUPTICS / 2 - 1) * ticdup) * (1000 / TICRATE))
{
severity = 3;
}
*ld = localdelay;
*ad = arbitratordelay;
return severity;
}
// [RH] List "ping" times
CCMD (pings)
{