From: Dr. Jaska Date: Thu, 30 May 2024 20:46:47 +0000 (+0000) Subject: Show racetimer's Race/CTS checkpoint splits in console X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=3cf5cc3161d5bf8a369e401f0628bc7a51e60367;p=xonotic%2Fxonotic-data.pk3dir.git Show racetimer's Race/CTS checkpoint splits in console --- diff --git a/qcsrc/client/hud/panel/racetimer.qc b/qcsrc/client/hud/panel/racetimer.qc index 9b812b81a..072e6a0d1 100644 --- a/qcsrc/client/hud/panel/racetimer.qc +++ b/qcsrc/client/hud/panel/racetimer.qc @@ -1,6 +1,7 @@ #include "racetimer.qh" #include +#include // Race timer (#8) @@ -173,6 +174,25 @@ void HUD_RaceTimer () s = MakeRaceString(race_checkpoint, 0, -1, 0, 0, race_previousbestname); if(race_time) forcetime = TIME_ENCODED_TOSTRING(race_time, false); + + // store checkpoint splits string for later printing + // check if we advanced to next cp + if (!entcs_IsSpectating(player_localnum) && race_checkpoint_splits_previous != race_checkpoint) + { + // are we somehow overwriting something? how? + if (race_checkpoint_splits[race_checkpoint_splits_previous+1]) + { + LOG_WARNF("race_checkpoint_splits: overwriting #%f %s\n", + race_checkpoint_splits_previous+1, + race_checkpoint_splits[race_checkpoint_splits_previous+1]); + strfree(race_checkpoint_splits[race_checkpoint_splits_previous+1]); + } + + strcpy(race_checkpoint_splits[race_checkpoint_splits_previous+1], sprintf("%s %s", forcetime, s)); + + // don't use ++ in case that checkpoints have jumps like 10th to 20th + race_checkpoint_splits_previous = race_checkpoint; + } } } else diff --git a/qcsrc/client/hud/panel/racetimer.qh b/qcsrc/client/hud/panel/racetimer.qh index a12e69f79..2efcd0815 100644 --- a/qcsrc/client/hud/panel/racetimer.qh +++ b/qcsrc/client/hud/panel/racetimer.qh @@ -9,6 +9,8 @@ float race_checkpoint; float race_time; float race_laptime; float race_checkpointtime; +string race_checkpoint_splits[255]; +int race_checkpoint_splits_previous = 0; float race_previousbesttime; float race_mypreviousbesttime; string race_previousbestname; diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 650f80c01..8116b1d34 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -1195,6 +1195,29 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew) race_penaltyaccumulator = 0; race_laptime = time; // valid } + + // show checkpoint splits after a run + // specs can switch players for confusing splits, deny service + // if hit 255 finish line or if finish line is 0 or if restarted + if (!entcs_IsSpectating(player_localnum) + && (race_checkpoint == 255 + || race_checkpoint < race_checkpoint_splits_previous)) + { + LOG_HELP("Checkpoint Splits:\n"); + for (int i = 0; i < 255; ++i) + { + // does this index have a split? + if (race_checkpoint_splits[i]) + { + // print it and free it + LOG_HELP(race_checkpoint_splits[i]); + strfree(race_checkpoint_splits[i]); + } + } + + // allow registering 0th cp in case we start at 254 start line + race_checkpoint_splits_previous = 0; + } break; case RACE_NET_CHECKPOINT_CLEAR: