From: terencehill Date: Sun, 3 Apr 2022 19:51:34 +0000 (+0200) Subject: Small race_SendTime cleanup. XonStats: make sure latency stat isn't negative (can... X-Git-Tag: xonotic-v0.8.5~112 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=87341f1f306fa3e2fff6e2c4498e25c80d87564f;p=xonotic%2Fxonotic-data.pk3dir.git Small race_SendTime cleanup. XonStats: make sure latency stat isn't negative (can be slightly lower than 0 in local games due to precision errors) --- diff --git a/qcsrc/common/playerstats.qc b/qcsrc/common/playerstats.qc index 2ac431b75..6ffc50617 100644 --- a/qcsrc/common/playerstats.qc +++ b/qcsrc/common/playerstats.qc @@ -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); } diff --git a/qcsrc/server/race.qc b/qcsrc/server/race.qc index dda32ac2a..efafdf771 100644 --- a/qcsrc/server/race.qc +++ b/qcsrc/server/race.qc @@ -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)