]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Port latency_sum, latency_cnt and latency_time to ClientState
authorMario <mario@smbclan.net>
Mon, 17 Jul 2017 21:24:08 +0000 (07:24 +1000)
committerMario <mario@smbclan.net>
Mon, 17 Jul 2017 21:24:08 +0000 (07:24 +1000)
qcsrc/common/playerstats.qc
qcsrc/server/client.qh
qcsrc/server/g_world.qc

index 2342af6d978abb79c1d29e2d648e0c192ee294d0..913e46362352c19ec5d1e05d9012944ae23e1cef 100644 (file)
@@ -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); }
                }
        }
index 431ea8a01ec80246411fc59c94387debb5dbc21d..d5552dacd9bd7814d8a106cdfe5b56743095b881 100644 (file)
@@ -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));
 
index e2532a9d5b62e536368711fac015ac7f50589f95..73a5b8a88b983359954eb7e032c6cf206dcb97d5 100644 (file)
@@ -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