From 27c1e6f700a9201ab010b0340b232db6601398ea Mon Sep 17 00:00:00 2001 From: Des Date: Wed, 4 Sep 2024 10:45:40 -0300 Subject: [PATCH] Add speed comparison with speed in previous best cp time. --- qcsrc/client/hud/panel/racetimer.qc | 16 +++++++++++++--- qcsrc/client/hud/panel/racetimer.qh | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/qcsrc/client/hud/panel/racetimer.qc b/qcsrc/client/hud/panel/racetimer.qc index b79b76cb6..04544683a 100644 --- a/qcsrc/client/hud/panel/racetimer.qc +++ b/qcsrc/client/hud/panel/racetimer.qc @@ -2,6 +2,7 @@ #include #include +#include // used for caching the string after passing through a checkpoint float racetimer_lastcheckpoint; @@ -217,12 +218,21 @@ void HUD_RaceTimer () } else { - float speed_conversion_factor; string speed_text = string_null; if(autocvar_cl_race_cptimes_showspeed) { - speed_conversion_factor = GetSpeedUnitFactor(autocvar_hud_speed_unit); - speed_text = sprintf(" @%d%s",vlen(vec2(csqcplayer.velocity)) * speed_conversion_factor, autocvar_cl_race_cptimes_showspeed_unit ? GetSpeedUnit(autocvar_hud_speed_unit) : ""); + string speed_color = "^xf73"; + float speed_conversion_factor = GetSpeedUnitFactor(autocvar_hud_speed_unit);; + float speed = vlen(vec2(csqcplayer.velocity)); + float speed_diff = speed - race_checkpoint_splits_speed[race_checkpoint] ; + string units_text = autocvar_cl_race_cptimes_showspeed_unit ? GetSpeedUnit(autocvar_hud_speed_unit) : ""; + if(speed_diff > 0) speed_color = "^x66f"; + else if (speed_diff == 0) speed_color = "^3"; + if((TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime)) < 0 || !race_checkpoint_splits_speed[race_checkpoint]) + { + race_checkpoint_splits_speed[race_checkpoint] = speed; + } + speed_text = sprintf(" ^7%d%s %s(%+d%s)", speed * speed_conversion_factor, units_text, speed_color, speed_diff, units_text); } // build checkpoint split strings if(race_time && race_previousbesttime) diff --git a/qcsrc/client/hud/panel/racetimer.qh b/qcsrc/client/hud/panel/racetimer.qh index d213584df..934e42f33 100644 --- a/qcsrc/client/hud/panel/racetimer.qh +++ b/qcsrc/client/hud/panel/racetimer.qh @@ -10,6 +10,7 @@ float race_time; float race_laptime; float race_checkpointtime; string race_checkpoint_splits[256]; +float race_checkpoint_splits_speed[256]; float race_previousbesttime; float race_mypreviousbesttime; string race_previousbestname; -- 2.39.2