#include "racetimer.qh"
+#include "physics.qh"
#include <client/draw.qh>
#include <common/ent_cs.qh>
s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, ((race_mypreviousbesttime) ? TIME_DECODE(race_time) - TIME_DECODE(race_mypreviousbesttime) : 0), 0, race_previousbestname);
else
s = MakeRaceString(race_checkpoint, 0, -1, 0, 0, race_previousbestname);
+
+ if(autocvar_cl_race_cptimes_showspeed)
+ {
+ float speed_conversion_factor = GetSpeedUnitFactor(autocvar_hud_speed_unit);
+ float speed = race_timespeed;
+ float speed_diff = rint(speed - race_checkpoint_splits_speed[race_checkpoint]);
+ string units_text = autocvar_cl_race_cptimes_showspeed_unit ? GetSpeedUnit(autocvar_hud_speed_unit) : "";
+
+ // figure out color
+ string speed_color = rgb_to_hexcolor(autocvar_hud_progressbar_acceleration_neg_color);
+ if(speed_diff > 0) speed_color = rgb_to_hexcolor(autocvar_hud_progressbar_acceleration_color);
+ else if (speed_diff == 0) speed_color = "^3";
+
+ if(race_time && race_previousbesttime && race_checkpoint_splits_speed[race_checkpoint])
+ s = sprintf("%s ^7%d%s %s(%+d%s)", s, speed * speed_conversion_factor, units_text, speed_color, speed_diff * speed_conversion_factor, units_text);
+ else
+ s = sprintf("%s ^7%d%s", s, speed * speed_conversion_factor, units_text);
+
+ // if fastest cp time, store speed for later comparison
+ if((TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime)) < 0 || !race_checkpoint_splits_speed[race_checkpoint])
+ {
+ race_checkpoint_splits_speed[race_checkpoint] = speed;
+ }
+
+ }
if(race_time)
forcetime = TIME_ENCODED_TOSTRING(race_time, false);
// this can't be done now as players would lack these from their configs then
bool autocvar_cl_race_checkpoint_splits_console;
bool autocvar_cl_race_checkpoint_splits_hud;
+bool autocvar_cl_race_cptimes_showspeed = false;
+bool autocvar_cl_race_cptimes_showspeed_unit = true;
#else
AUTOCVAR_SAVE(cl_race_checkpoint_splits_console, bool, 1, "Print checkpoint splits to console");
AUTOCVAR_SAVE(cl_race_checkpoint_splits_hud, bool, 1, "Show race checkpoint splits on HUD in infomessages");
+AUTOCVAR_SAVE(cl_race_cptimes_showspeed, bool, 0, "Show race checkpoint speed (NOTE: ignores vertical speed)");
+AUTOCVAR_SAVE(cl_race_cptimes_showspeed_unit, bool, 1, "Show race checkpoint speed units");
#endif
bool autocvar_cl_race_cptimes_onlyself; // TODO: move to race gamemode
bool autocvar_cl_race_cptimes_showself = false;
seta cl_race_cptimes_showself 1 "Always show your own times as well as the current best on checkpoints in Race/CTS"
seta cl_race_cptimes_onlyself 0 "Only show your own times on checkpoints in Race/CTS. Can be forced on by the server via g_race_cptimes_onlyself"
+seta cl_race_cptimes_showspeed 0 "Show race checkpoint speed (NOTE: ignores vertical speed)"
+seta cl_race_cptimes_showspeed_unit 1 "Show race checkpoint speed units"
seta cl_race_checkpoint_splits_console 1 "Print checkpoint splits to console"
seta cl_race_checkpoint_splits_hud 1 "Show race checkpoint splits on HUD in infomessages"