if(mytime >= theirtime)
timestr = strcat("+", ftos_decimals(mytime - theirtime, TIME_DECIMALS));
else
- timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(theirtime));
+ timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(theirtime), false);
col = "^3";
if(mytime >= othertime)
othertimestr = strcat("+", ftos_decimals(mytime - othertime, TIME_DECIMALS));
else
- othertimestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(othertime));
+ othertimestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(othertime), false);
othercol = "^7";
}
else
s = MakeRaceString(race_checkpoint, 0, -1, 0, 0, race_previousbestname);
if(race_time)
- forcetime = TIME_ENCODED_TOSTRING(race_time);
+ forcetime = TIME_ENCODED_TOSTRING(race_time, false);
}
}
else
if(race_laptime && race_checkpoint != 255)
{
- s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
+ s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime), false);
str_pos = pos + eX * 0.5 * (mySize.x - stringwidth(s, false, '0.6 0.6 0' * mySize.y));
drawstring(str_pos, s, '0.6 0.6 0' * mySize.y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
}
pl = NULL;
score = me.(scores(ps_primary));
- timer = TIME_ENCODED_TOSTRING(score);
+ timer = TIME_ENCODED_TOSTRING(score, false);
draw_beginBoldFont();
if (pl && ((!(scores_flags(ps_primary) & SFL_ZERO_IS_WORST)) || score)) {
str = count_ordinal(i+1);
drawstring(pos + text_ofs, str, hud_fontsize, '1 1 1', sbt_fg_alpha, DRAWFLAG_NORMAL);
- drawstring(pos + text_ofs + eX * ranksize, TIME_ENCODED_TOSTRING(t), hud_fontsize, '1 1 1', sbt_fg_alpha, DRAWFLAG_NORMAL);
+ drawstring(pos + text_ofs + eX * ranksize, TIME_ENCODED_TOSTRING(t, true), hud_fontsize, '1 1 1', sbt_fg_alpha, DRAWFLAG_NORMAL);
str = ColorTranslateRGB(grecordholder[i]);
if(cut)
str = textShortenToWidth(str, namesize, hud_fontsize, stringwidth_colors);
continue;
string h = race_readName(MapInfo_Map_bspname, 1);
- ret_string = strcat(ret_string, strpad(32, MapInfo_Map_bspname), " ", strpad(-8, TIME_ENCODED_TOSTRING(r)), " ", h, "\n");
+ ret_string = strcat(ret_string, strpad(32, MapInfo_Map_bspname), " ", strpad(-8, TIME_ENCODED_TOSTRING(r, false)), " ", h, "\n");
}
}
void race_showTime(string text, vector pos, vector timeText_ofs, float theTime, vector textSize, float f)
{
drawstring_aspect(pos, text, textSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
- drawstring_aspect(pos + timeText_ofs, TIME_ENCODED_TOSTRING(theTime), textSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+ drawstring_aspect(pos + timeText_ofs, TIME_ENCODED_TOSTRING(theTime, false), textSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
if (f < 1) {
drawstring_aspect_expanding(pos, text, textSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
- drawstring_aspect_expanding(pos + timeText_ofs, TIME_ENCODED_TOSTRING(theTime), textSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
+ drawstring_aspect_expanding(pos + timeText_ofs, TIME_ENCODED_TOSTRING(theTime, false), textSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
}
}
continue;
string h = race_readName(MapInfo_Map_bspname, 1);
- ret_string = strcat(ret_string, strpad(32, MapInfo_Map_bspname), " ", strpad(-8, TIME_ENCODED_TOSTRING(r)), " ", h, "\n");
+ ret_string = strcat(ret_string, strpad(32, MapInfo_Map_bspname), " ", strpad(-8, TIME_ENCODED_TOSTRING(r, false)), " ", h, "\n");
}
}
f1points: point or points depending on f1
f1ord: count_ordinal of f1
f1time: process_time of f1
- f1race_time: mmssth of f1
- f2race_time: mmssth of f2
+ f1race_time: TIME_ENCODED_TOSTRING of f1
+ f2race_time: TIME_ENCODED_TOSTRING of f2
race_col: color of race time/position (i.e. good or bad)
race_diff: show time difference between f2 and f3
missing_teams: show which teams still need players
ARG_CASE(ARG_CS, "f1points", (f1 == 1 ? _("point") : _("points"))) \
ARG_CASE(ARG_CS_SV, "f1ord", count_ordinal(f1)) \
ARG_CASE(ARG_CS_SV, "f1time", process_time(2, f1)) \
- ARG_CASE(ARG_CS_SV_HA, "f1race_time", mmssth(f1)) \
- ARG_CASE(ARG_CS_SV_HA, "f2race_time", mmssth(f2)) \
- ARG_CASE(ARG_CS_SV_HA, "f3race_time", mmssth(f3)) \
+ ARG_CASE(ARG_CS_SV_HA, "f1race_time", TIME_ENCODED_TOSTRING(f1, true)) \
+ ARG_CASE(ARG_CS_SV_HA, "f2race_time", TIME_ENCODED_TOSTRING(f2, true)) \
+ ARG_CASE(ARG_CS_SV_HA, "f3race_time", TIME_ENCODED_TOSTRING(f3, true)) \
ARG_CASE(ARG_CS_SV, "race_col", CCR(((f1 == 1) ? "^F1" : "^F2"))) \
- ARG_CASE(ARG_CS_SV, "race_diff", ((f2 > f3) ? sprintf(CCR("^1[+%s]"), mmssth(f2 - f3)) : sprintf(CCR("^2[-%s]"), mmssth(f3 - f2)))) \
+ ARG_CASE(ARG_CS_SV, "race_diff", ((f2 > f3) ? sprintf(CCR("^1[+%s]"), TIME_ENCODED_TOSTRING(f2 - f3, true)) : sprintf(CCR("^2[-%s]"), TIME_ENCODED_TOSTRING(f3 - f2, true)))) \
ARG_CASE(ARG_CS, "missing_teams", notif_arg_missing_teams(f1)) \
ARG_CASE(ARG_CS, "pass_key", getcommandkey(_("drop flag"), "+use")) \
ARG_CASE(ARG_CS, "nade_key", getcommandkey(_("throw nade"), "dropweapon")) \
else if(pFlags & SFL_RANK)
valstr = (pValue < 256 ? count_ordinal(pValue) : _("N/A"));
else if(pFlags & SFL_TIME)
- valstr = TIME_ENCODED_TOSTRING(pValue);
+ valstr = TIME_ENCODED_TOSTRING(pValue, true);
else
valstr = ftos(pValue);
const int TIME_DECIMALS = 2;
const float TIME_FACTOR = 100;
-#define TIME_ENCODED_TOSTRING(n) mmssth(n)
+#define TIME_ENCODED_TOSTRING(n, compact) mmssth(n, compact)
#define RACE_RECORD "/race100record/"
#define CTS_RECORD "/cts100record/"
#define CTF_RECORD "/ctf100record/"
/// \param[in] tm integer clocked time in tenths or hundredths, CANNOT be negative
/// \param[in] hundredths if true append hundredths too, otherwise only tenths
+/// \param[in] compact if true leading 0s are omitted (except the seconds unit digit)
/// \return clocked time as "m:ss.t" or "m:ss.th" string (rounded)
ERASEABLE
-string clockedtime_tostring(int tm, bool hundredths)
+string clockedtime_tostring(int tm, bool hundredths, bool compact)
{
if (tm < 0)
- return strcat("0:00:0", hundredths ? "0" : "");
+ {
+ if (compact)
+ return strcat("0.0", hundredths ? "0" : "");
+ else
+ return strcat("0:00.0", hundredths ? "0" : "");
+ }
int acc = hundredths ? 6000 : 600;
tm = floor(tm + 0.5);
int minutes = floor(tm / acc);
int tm_without_minutes = tm - minutes * acc;
// NOTE: the start digit of s is a placeholder and won't be displayed
string s = ftos(acc * 10 + tm_without_minutes);
- return strcat(ftos(minutes), ":", substring(s, 1, 2), ".", substring(s, 3, hundredths ? 2 : 1));
+ if (!compact || minutes > 0)
+ return strcat(ftos(minutes), ":", substring(s, 1, 2), ".", substring(s, 3, hundredths ? 2 : 1));
+
+ int ofs = 2, digits = 1;
+ if (tm_without_minutes >= 10 * (hundredths ? 100 : 10))
+ {
+ ofs = 1;
+ digits = 2;
+ }
+ return strcat(substring(s, ofs, digits), ".", substring(s, 3, hundredths ? 2 : 1));
+
}
-#define mmsst(tm) clockedtime_tostring(tm, false)
-#define mmssth(tm) clockedtime_tostring(tm, true)
+#define mmsst(tm, compact) clockedtime_tostring(tm, false, compact)
+#define mmssth(tm, compact) clockedtime_tostring(tm, true, compact)
ERASEABLE
string format_time(float seconds)
n = race_readName(map, i);
p = count_ordinal(i);
- s = strcat(s, strpad(8, p), " ", strpad(-8, TIME_ENCODED_TOSTRING(t)), " ", n, "\n");
+ s = strcat(s, strpad(8, p), " ", strpad(-8, TIME_ENCODED_TOSTRING(t, false)), " ", n, "\n");
}
MapInfo_ClearTemps();
// also write a marker into demo files for demotc-race-record-extractor to find
stuffcmd(pl,
strcat(
- strcat("//", strconv(2, 0, 0, GetGametype()), " RECORD SET ", TIME_ENCODED_TOSTRING(TIME_ENCODE(dt))),
+ strcat("//", strconv(2, 0, 0, GetGametype()), " RECORD SET ", TIME_ENCODED_TOSTRING(TIME_ENCODE(dt), false)),
" ", ftos(tstart), " ", ftos(dt), "\n"));
}