From 4f599756edd8fcfd61061daafb470a3fe18ef1f9 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 18 Jul 2017 07:24:08 +1000 Subject: [PATCH] Port latency_sum, latency_cnt and latency_time to ClientState --- qcsrc/common/playerstats.qc | 4 ++-- qcsrc/server/client.qh | 3 +++ qcsrc/server/g_world.qc | 10 +++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/qcsrc/common/playerstats.qc b/qcsrc/common/playerstats.qc index 2342af6d9..913e46362 100644 --- a/qcsrc/common/playerstats.qc +++ b/qcsrc/common/playerstats.qc @@ -146,9 +146,9 @@ void PlayerStats_GameReport_FinalizePlayer(entity p) if(IS_REAL_CLIENT(p)) { - if(p.latency_cnt) + if(CS(p).latency_cnt) { - float latency = (p.latency_sum / p.latency_cnt); + float latency = (CS(p).latency_sum / CS(p).latency_cnt); if(latency) { PS_GR_P_ADDVAL(p, PLAYERSTATS_AVGLATENCY, latency); } } } diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index 431ea8a01..d5552dacd 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -96,6 +96,9 @@ CLASS(Client, Object) ATTRIB(Client, just_joined, bool, this.just_joined); ATTRIB(Client, race_completed, bool, this.race_completed); ATTRIBARRAY(Client, msg_choice_choices, int, 50); // TODO: actually NOTIF_CHOICE_MAX + ATTRIB(Client, latency_sum, float, this.latency_sum); + ATTRIB(Client, latency_cnt, int, this.latency_cnt); + ATTRIB(Client, latency_time, float, this.latency_time); METHOD(Client, m_unwind, bool(Client this)); diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index e2532a9d5..73a5b8a88 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -62,12 +62,12 @@ void PingPLReport_Think(entity this) WriteByte(MSG_BROADCAST, min(ceil(CS(e).ping_movementloss * 255), 255)); // record latency times for clients throughout the match so we can report it to playerstats - if(time > (e.latency_time + LATENCY_THINKRATE)) + if(time > (CS(e).latency_time + LATENCY_THINKRATE)) { - e.latency_sum += CS(e).ping; - e.latency_cnt += 1; - e.latency_time = time; - //print("sum: ", ftos(e.latency_sum), ", cnt: ", ftos(e.latency_cnt), ", avg: ", ftos(e.latency_sum / e.latency_cnt), ".\n"); + CS(e).latency_sum += CS(e).ping; + CS(e).latency_cnt += 1; + CS(e).latency_time = time; + //print("sum: ", ftos(CS(e).latency_sum), ", cnt: ", ftos(CS(e).latency_cnt), ", avg: ", ftos(CS(e).latency_sum / CS(e).latency_cnt), ".\n"); } } else -- 2.39.2