27 float stringwidth_colors(
string s,
vector theSize)
29 return stringwidth_builtin(s,
true, theSize);
32 float stringwidth_nocolors(
string s,
vector theSize)
34 return stringwidth_builtin(s,
false, theSize);
38 float stringwidth_colors(
string s,
vector theSize)
43 float stringwidth_nocolors(
string s,
vector theSize)
49 #define strcpy(this, s) MACRO_BEGIN \ 56 #define strfree(this) MACRO_BEGIN \ 69 int years = (M <= 2) ? Y - 1 : Y;
71 int leap_days =
floor(years / 4) -
floor(years / 100) +
floor(years / 400);
74 int months = (M <= 2) ? (M + 9) : (M - 3);
75 int leftover_days = (M <= 2) ? (M + 5) :
floor(0.58 * M - 1.1);
77 int month_days = 30 * months + leftover_days;
79 return 365 * years + month_days + D + leap_days;
82 #define DAYS_UP_TO_EPOCH 719469 // days_up_to_date(1970, 1, 1); 93 string date = strftime(
false,
"%Y-%m-%d %H:%M:%S");
109 int hundreds_of_seconds = days_since_epoch * 24 * 6 * 6;
110 hundreds_of_seconds +=
floor(seconds / 100);
113 string seconds_str =
ftos(seconds % 100);
114 if ((seconds % 100) < 10)
115 seconds_str =
strcat(
"0", seconds_str);
117 return strcat(
ftos(hundreds_of_seconds), seconds_str);
125 bool negative =
false;
130 if (
floor(seconds) != seconds)
133 int minutes =
floor(seconds / 60);
134 seconds -= minutes * 60;
136 return sprintf(
"-%d:%02d", minutes, seconds);
137 return sprintf(
"%d:%02d", minutes, seconds);
147 return strcat(
"0:00:0", hundredths ?
"0" :
"");
148 int acc = hundredths ? 6000 : 600;
149 int seconds =
floor(tm + 0.5);
150 int minutes =
floor(seconds / acc);
151 seconds -= minutes * acc;
153 string s =
ftos(acc * 10 + seconds);
157 #define mmsst(tm) clockedtime_tostring(tm, false) 158 #define mmssth(tm) clockedtime_tostring(tm, true) 163 seconds =
floor(seconds + 0.5);
164 float days =
floor(seconds / 864000);
165 seconds -= days * 864000;
166 float hours =
floor(seconds / 36000);
167 seconds -= hours * 36000;
168 float minutes =
floor(seconds / 600);
169 seconds -= minutes * 600;
170 if (days > 0)
return sprintf(_(
"%d days, %02d:%02d:%02d"), days, hours, minutes, seconds);
171 else return sprintf(_(
"%02d:%02d:%02d"), hours, minutes, seconds);
185 string autocvar_hud_colorset_foreground_1 =
"2";
186 string autocvar_hud_colorset_foreground_2 =
"3";
187 string autocvar_hud_colorset_foreground_3 =
"4";
188 string autocvar_hud_colorset_foreground_4 =
"1";
190 string autocvar_hud_colorset_kill_1 =
"1";
191 string autocvar_hud_colorset_kill_2 =
"3";
192 string autocvar_hud_colorset_kill_3 =
"4";
194 string autocvar_hud_colorset_background =
"7";
197 string CCR(
string input)
200 input = strreplace(
"^F1",
strcat(
"^", autocvar_hud_colorset_foreground_1), input);
201 input = strreplace(
"^F2",
strcat(
"^", autocvar_hud_colorset_foreground_2), input);
202 input = strreplace(
"^F3",
strcat(
"^", autocvar_hud_colorset_foreground_3), input);
203 input = strreplace(
"^F4",
strcat(
"^", autocvar_hud_colorset_foreground_4), input);
206 input = strreplace(
"^K1",
strcat(
"^", autocvar_hud_colorset_kill_1), input);
207 input = strreplace(
"^K2",
strcat(
"^", autocvar_hud_colorset_kill_2), input);
208 input = strreplace(
"^K3",
strcat(
"^", autocvar_hud_colorset_kill_3), input);
211 input = strreplace(
"^BG",
strcat(
"^", autocvar_hud_colorset_background), input);
212 input = strreplace(
"^N",
"^7", input);
217 #define startsWith(haystack, needle) (strstrofs(haystack, needle, 0) == 0) 226 #define endsWith(this, suffix) (_endsWith_suffix = suffix, substring(this, -strlen(_endsWith_suffix), -1) == _endsWith_suffix) 233 string sc =
strcat(s,
"");
257 string cons(
string a,
string b)
259 if (a ==
"")
return b;
260 if (b ==
"")
return a;
267 if (a ==
"")
return b;
268 if (b ==
"")
return a;
282 string s1,
s2, s3, s4, s5;
283 float si, ei, sj, ej, s0, en;
296 return strcat(s1, s4, s3, s2, s5);
324 for (
int i = 0; i < len; ++i)
330 if (s ==
"n") str =
strcat(str,
"\n");
331 else if (s ==
"\\") str =
strcat(str,
"\\");
346 for ( ; w && endpos >= 0; --w)
348 if (endpos < 0)
return s;
352 #define strhasword(s, w) (strstrofs(strcat(" ", s, " "), strcat(" ", w, " "), 0) >= 0) 358 for (
int i = 0, c; (c =
str2chr(s, i)) > 0; ++i, ++l)
371 s = strdecolorize(s);
372 bool utf8 =
cvar(
"utf8_enable");
373 for (
int i = 0, n =
strlen(s); i < n; ++i)
421 if (buf < 0)
return -1;
429 for (
int i = 0; (l =
fgets(fh)); ++i)
430 bufstr_set(buf, i, l);
439 if (fh < 0)
error(
strcat(
"Can't write buf to ", pFilename));
440 int n = buf_getsize(buf);
441 for (
int i = 0; i < n; ++i)
453 if (number == 0) number = 0;
454 return sprintf(
"%.*f", decimals, number);
464 if (number == 0) number = 0;
465 return sprintf(
"%.7g", number);
473 string s1 = (dot1 == -1) ? v1 :
substring(v1, 0, dot1);
474 string s2 = (dot2 == -1) ? v2 :
substring(v2, 0, dot2);
478 if (r != 0)
return r;
481 if (r != 0)
return r;
483 if (dot1 == -1)
return (dot2 == -1) ? 0 : -1;
493 if (v1 ==
"git")
return 1;
494 if (v2 ==
"git")
return -1;
500 const string HEXDIGITS =
"0123456789ABCDEF0123456789abcdef";
501 #define HEXDIGIT_TO_DEC_RAW(d) (strstrofs(HEXDIGITS, (d), 0)) 502 #define HEXDIGIT_TO_DEC(d) ((HEXDIGIT_TO_DEC_RAW(d) | 0x10) - 0x10) 503 #define DEC_TO_HEXDIGIT(d) (substring(HEXDIGITS_MINSET, (d), 1)) 504 #define IS_HEXDIGIT(d) (strstrofs(HEXDIGITS_MINSET, (d), 0) >= 0) 507 #define IS_DIGIT(d) (strstrofs(DIGITS, (d), 0) >= 0) 515 while(pos - carets >= 1 &&
substring(theText, pos - carets - 1, 1) ==
"^")
543 text_len =
strlen(theText);
544 string tag_type =
"^";
548 LABEL(check_color_tag)
551 if (!check_at_the_end)
553 for (; ofs >= 1; ofs--)
555 if (!(pos >= ofs && text_len >= pos + (cc_len - ofs)))
557 if(
substring(theText, pos - ofs, tag_len) == tag_type)
560 return eX * cc_len +
eY * ofs;
568 goto check_color_tag;
ERASEABLE string ftos_decimals(float number, int decimals)
converts a number to a string with the indicated number of decimals
ERASEABLE int buf_load(string pFilename)
ERASEABLE int u8_strsize(string s)
spree_inf s1 s2 s3loc s2 s1
spree_inf s1 s2 s3loc s2 spree_inf s1 s2 s3loc s2 spree_inf s1 s2 s3loc s2 s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2 f1 f1points s1 s2
const string HEXDIGITS_MINSET
ERASEABLE string swapwords(string str, float i, float j)
ERASEABLE bool isCaretEscaped(string theText, float pos)
ERASEABLE string ftos_mindecimals(float number)
converts a number to a string with the minimum number of decimals
ERASEABLE string cdr(string s)
returns all but first word
noref string _endsWith_suffix
ERASEABLE void buf_save(float buf, string pFilename)
ERASEABLE string clockedtime_tostring(int tm, bool hundredths)
ERASEABLE string shufflewords(string str)
ERASEABLE string car(string s)
returns first word
ERASEABLE string unescape(string in)
ERASEABLE void shuffle(float n, swapfunc_t swap, entity pass)
ERASEABLE int days_up_to_date(int Y, int M, int D)
ERASEABLE string substring_range(string s, float b, float e)
ERASEABLE string cons_mid(string a, string mid, string b)
ERASEABLE void _shufflewords_swapfunc(float i, float j, entity pass)
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
ERASEABLE int vercmp_recursive(string v1, string v2)
ERASEABLE string ColorTranslateRGB(string s)
ERASEABLE int vercmp(string v1, string v2)
ERASEABLE bool isValidColorCodeValue(string theText, int cc_len, int tag_start)
ERASEABLE string fstrunzone(string s)
unzone the string, and return it as tempstring.
ERASEABLE bool startsWithNocase(string haystack, string needle)
vector(float skel, float bonenum) _skel_get_boneabs_hidden
ERASEABLE vector checkColorCode(string theText, int text_len, int pos, bool check_at_the_end)
#define tokenizebyseparator
ERASEABLE string strwords(string s, int w)
ERASEABLE string cons(string a, string b)
#define pass(name, colormin, colormax)
ERASEABLE bool isInvisibleString(string s)
ERASEABLE string strftime_s()
ERASEABLE string format_time(float seconds)
ERASEABLE string seconds_tostring(float seconds)