string s;
if(!autocvar__hud_configure)
{
- if(spectatee_status)
- {
- // RaceSplit(_("Splits not supported while spectating"));
+ int mlines[HUD_RACESPLITS_MAX_NRLINES];
+ int ln = nrlines -1;
+ // show up to race_nextcheckpoint (not including) or everything
+ // if you are before start (0 or 254)
+ // (except race_laptime != 0 for race, means next is
+ // start+finish so don't show previous lap finish)
+ int i;
+ if (race_checkpoint != 0 && race_checkpoint != 254)
+ { // middle of run/race
+ i = race_checkpoint;
}
-
- if(!spectatee_status)
+ else if (ISGAMETYPE(RACE) && race_nextcheckpoint == 0)
+ { // before start, but on race, so don't keep old finish visible
+ i = 253;
+ }
+ else
+ { // before start, not on race (cts), keep old run cps visible
+ i = 255;
+ }
+ for (; ln >= 0 && i >= 0; --i)
{
- int mlines[HUD_RACESPLITS_MAX_NRLINES];
- int ln = nrlines -1;
- // show up to race_nextcheckpoint (not including) or everything
- // if you are before start (0 or 254)
- // (except race_laptime != 0 for race, means next is
- // start+finish so don't show previous lap finish)
- int i;
- if (race_checkpoint != 0 && race_checkpoint != 254)
- { // middle of run/race
- i = race_checkpoint;
- }
- else if (ISGAMETYPE(RACE) && race_nextcheckpoint == 0)
- { // before start, but on race, so don't keep old finish visible
- i = 253;
- }
- else
- { // before start, not on race (cts), keep old run cps visible
- i = 255;
- }
- for (; ln >= 0 && i >= 0; --i)
+ if (race_checkpoint_splits[i])
{
- if (race_checkpoint_splits[i])
- {
- mlines[ln] = i;
- --ln;
- }
+ mlines[ln] = i;
+ --ln;
}
- for (int j = 0; j < nrlines; ++j)
- RaceSplit(race_checkpoint_splits[mlines[j]]);
}
+ for (int j = 0; j < nrlines; ++j)
+ RaceSplit(race_checkpoint_splits[mlines[j]]);
}
else
{
string racetimer_checkpoint_comparison;
string racetimer_checkpoint_time;
bool racetimer_have_stored_splits;
+float racetimer_have_stored_splits_player;
// Race timer (#8)
return strcat(col, sprintf("%s (%s %s)", cpname, timestr, strcat(ColorTranslateRGB(theirname), col, lapstr)));
}
-void ClearRaceSplits() {
+void ClearRaceSplits(bool quiet) {
bool once = true;
racetimer_lastcheckpoint = 0;
for (int i = 0; i <= 255; ++i)
{
if(race_checkpoint_splits[i]
- && autocvar_cl_race_checkpoint_splits_console)
+ && autocvar_cl_race_checkpoint_splits_console
+ && !quiet)
{
if(once)
{
void StoreRaceSplits(float race_checkpoint, string forcetime, string s) {
// store checkpoint splits string for later printing
- if (!entcs_IsSpectating(player_localnum))
+ if (spectatee_status
+ && racetimer_have_stored_splits
+ && racetimer_have_stored_splits_player != spectatorlist[0]) // we changed spectated player
{
- // 0 or 255 go to 255 as finish, strcpy does the free if needed
- strcpy(race_checkpoint_splits[race_checkpoint ? race_checkpoint : 255], (forcetime != "") ? sprintf("%s %s", forcetime, s) : s);
+ ClearRaceSplits(true);
}
+ // 0 or 255 go to 255 as finish, strcpy does the free if needed
+ strcpy(race_checkpoint_splits[race_checkpoint ? race_checkpoint : 255], (forcetime != "") ? sprintf("%s %s", forcetime, s) : s);
// cache
racetimer_lastcheckpoint = race_checkpoint;
strcpy(racetimer_checkpoint_comparison, s);
strcpy(racetimer_checkpoint_time, forcetime);
racetimer_have_stored_splits = true;
+ racetimer_have_stored_splits_player = ((spectatee_status) ? spectatorlist[0] : player_localnum);
}
void HUD_RaceTimer ()
{
if(race_checkpoint != 254 && race_time != 0)
{
- if (race_checkpoint == racetimer_lastcheckpoint)
+ if (race_checkpoint == racetimer_lastcheckpoint // same cp *and* player
+ && racetimer_have_stored_splits_player == (spectatee_status ? spectatorlist[0] : player_localnum))
{
// use cached strings
s = racetimer_checkpoint_comparison;
{
// clean cp splits on start
if(racetimer_have_stored_splits && race_time == 0)
- ClearRaceSplits();
+ ClearRaceSplits(false);
}
}
else
else
{
if(racetimer_have_stored_splits && (race_time == 0 || time < STAT(GAMESTARTTIME)))
- ClearRaceSplits();
+ ClearRaceSplits(false);
if(race_mycheckpointtime)
{