]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Small race_SendTime cleanup. XonStats: make sure latency stat isn't negative (can...
authorterencehill <piuntn@gmail.com>
Sun, 3 Apr 2022 19:51:34 +0000 (21:51 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 3 Apr 2022 19:51:34 +0000 (21:51 +0200)
qcsrc/common/playerstats.qc
qcsrc/server/race.qc

index 2ac431b75ae4610599a7181880aeb1431789f040..6ffc506170a077d91b309fe7dd86a3afb1d7ba09 100644 (file)
@@ -203,7 +203,7 @@ void PlayerStats_GameReport_FinalizePlayer(entity p)
        {
                if(CS(p).latency_cnt)
                {
-                       float latency = (CS(p).latency_sum / CS(p).latency_cnt);
+                       float latency = max(0, CS(p).latency_sum / CS(p).latency_cnt);
                        if(latency)
                                PlayerStats_GameReport_Event_Player(p, PLAYERSTATS_AVGLATENCY, latency);
                }
index dda32ac2a419c92135177b28820a8a14ae47ed58..efafdf7717d7235067c28666ea1c8eb81a17c36a 100644 (file)
@@ -475,8 +475,6 @@ void race_deleteTime(string map, float pos)
 
 void race_SendTime(entity e, float cp, float t, float tvalid)
 {
-       float snew, l;
-
        if(g_race_qualifying)
                t += e.race_penalty_accumulator;
 
@@ -486,23 +484,15 @@ void race_SendTime(entity e, float cp, float t, float tvalid)
        if(cp == race_timed_checkpoint) // finish line
        if (!CS(e).race_completed)
        {
-               float s;
-               if(g_race_qualifying)
-               {
-                       s = GameRules_scoring_add(e, RACE_FASTEST, 0);
-                       if(!s || t < s)
-                               GameRules_scoring_add(e, RACE_FASTEST, t - s);
-               }
-               else
+               int s = GameRules_scoring_add(e, RACE_FASTEST, 0);
+               if(!s || t < s)
+                       GameRules_scoring_add(e, RACE_FASTEST, t - s);
+               if(!g_race_qualifying)
                {
-                       s = GameRules_scoring_add(e, RACE_FASTEST, 0);
-                       if(!s || t < s)
-                               GameRules_scoring_add(e, RACE_FASTEST, t - s);
-
                        s = GameRules_scoring_add(e, RACE_TIME, 0);
-                       snew = TIME_ENCODE(time - game_starttime);
+                       int snew = TIME_ENCODE(time - game_starttime);
                        GameRules_scoring_add(e, RACE_TIME, snew - s);
-                       l = GameRules_scoring_add_team(e, RACE_LAPS, 1);
+                       int l = GameRules_scoring_add_team(e, RACE_LAPS, 1);
 
                        if(autocvar_fraglimit)
                                if(l >= autocvar_fraglimit)