]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/playerstats.qc
Revert "Make sure endless function call loop actually works"
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / playerstats.qc
index 3e1444a35f9f28fcc98a16ed8553e042a1777d82..e83305886cee1522ddbb5b8db4c11388ee59e0e7 100644 (file)
@@ -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));
@@ -366,6 +372,7 @@ void PlayerStats_GameReport_Handler(entity fh, entity pass, float status)
                 * i: player index
                 * n: nickname of the player (optional)
                 * t: team ID
+                * r: player ranking enabled / disabled
                 * e: followed by an event name, a space, and the event count/score
                 *  event names can be:
                 *   alivetime: total playing time of the player