mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 04:21:47 +00:00
Smooth out gentleman delay
This commit is contained in:
parent
8240dbe4e6
commit
dd5332df83
1 changed files with 27 additions and 0 deletions
|
|
@ -116,6 +116,9 @@ UINT16 pingmeasurecount = 1;
|
||||||
UINT32 realpingtable[MAXPLAYERS]; //the base table of ping where an average will be sent to everyone.
|
UINT32 realpingtable[MAXPLAYERS]; //the base table of ping where an average will be sent to everyone.
|
||||||
UINT32 playerpingtable[MAXPLAYERS]; //table of player latency values.
|
UINT32 playerpingtable[MAXPLAYERS]; //table of player latency values.
|
||||||
|
|
||||||
|
#define GENTLEMANSMOOTHING (TICRATE)
|
||||||
|
static tic_t reference_lag;
|
||||||
|
static UINT8 spike_time;
|
||||||
static tic_t lowest_lag;
|
static tic_t lowest_lag;
|
||||||
boolean server_lagless;
|
boolean server_lagless;
|
||||||
static CV_PossibleValue_t mindelay_cons_t[] = {{0, "MIN"}, {30, "MAX"}, {0, NULL}};
|
static CV_PossibleValue_t mindelay_cons_t[] = {{0, "MIN"}, {30, "MAX"}, {0, NULL}};
|
||||||
|
|
@ -5974,6 +5977,30 @@ static void CL_SendClientCmd(void)
|
||||||
{
|
{
|
||||||
// Gentlemens' ping.
|
// Gentlemens' ping.
|
||||||
lagDelay = min(lowest_lag, MAXGENTLEMENDELAY);
|
lagDelay = min(lowest_lag, MAXGENTLEMENDELAY);
|
||||||
|
|
||||||
|
// Is our connection worse than our current gentleman point?
|
||||||
|
// Make sure it stays that way for a bit before increasing delay levels.
|
||||||
|
if (lagDelay > reference_lag)
|
||||||
|
{
|
||||||
|
spike_time++;
|
||||||
|
if (spike_time >= GENTLEMANSMOOTHING)
|
||||||
|
{
|
||||||
|
// Okay, this is genuinely the new baseline delay.
|
||||||
|
reference_lag = lagDelay;
|
||||||
|
spike_time = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Just a temporary fluctuation, ignore it.
|
||||||
|
lagDelay = reference_lag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reference_lag = lagDelay; // Adjust quickly if the connection improves.
|
||||||
|
spike_time = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (server) // Clients have to wait for the gamestate to make it back. Servers don't!
|
if (server) // Clients have to wait for the gamestate to make it back. Servers don't!
|
||||||
lagDelay *= 2; // Simulate the HELLFUCK NIGHTMARE of a complete round trip.
|
lagDelay *= 2; // Simulate the HELLFUCK NIGHTMARE of a complete round trip.
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue