diff --git a/src/d_clisrv.c b/src/d_clisrv.c index e20c6d442..a864c8b7d 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -116,6 +116,9 @@ UINT16 pingmeasurecount = 1; UINT32 realpingtable[MAXPLAYERS]; //the base table of ping where an average will be sent to everyone. 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; boolean server_lagless; static CV_PossibleValue_t mindelay_cons_t[] = {{0, "MIN"}, {30, "MAX"}, {0, NULL}}; @@ -5974,6 +5977,30 @@ static void CL_SendClientCmd(void) { // Gentlemens' ping. 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! lagDelay *= 2; // Simulate the HELLFUCK NIGHTMARE of a complete round trip. }