From: terencehill Date: Wed, 18 May 2022 00:42:24 +0000 (+0200) Subject: Playerstats: fix higher average ping for players who disconnect and reconnect X-Git-Tag: xonotic-v0.8.5~32 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8d03c0628d5f679248e46de22adc17cb27c4cf3c;p=xonotic%2Fxonotic-data.pk3dir.git Playerstats: fix higher average ping for players who disconnect and reconnect --- diff --git a/qcsrc/common/playerstats.qc b/qcsrc/common/playerstats.qc index f8aa2b514..e83305886 100644 --- a/qcsrc/common/playerstats.qc +++ b/qcsrc/common/playerstats.qc @@ -207,7 +207,13 @@ void PlayerStats_GameReport_FinalizePlayer(entity p) { float latency = max(0, CS(p).latency_sum / CS(p).latency_cnt); if(latency) - PlayerStats_GameReport_Event_Player(p, PLAYERSTATS_AVGLATENCY, latency); + { + // if previous average latency exists (player disconnected and reconnected) + // make the average of previous and current average latency + float prev_latency = PlayerStats_GameReport_Event_Player(p, PLAYERSTATS_AVGLATENCY, 0); + float new_latency = !prev_latency ? latency : (prev_latency + latency) / 2; + PlayerStats_GameReport_Event_Player(p, PLAYERSTATS_AVGLATENCY, -prev_latency + new_latency); + } } db_put(PS_GR_OUT_DB, sprintf("%s:_ranked", p.playerstats_id), ftos(CS_CVAR(p).cvar_cl_allow_uidranking));