From: Mario Date: Mon, 17 Jul 2017 21:24:08 +0000 (+1000) Subject: Port latency_sum, latency_cnt and latency_time to ClientState X-Git-Tag: xonotic-v0.8.5~2577 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=4f599756edd8fcfd61061daafb470a3fe18ef1f9;p=xonotic%2Fxonotic-data.pk3dir.git Port latency_sum, latency_cnt and latency_time to ClientState --- 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