if (carets & 1)
{
if(i+1 <= len)
- if(strstrofs("0123456789", substring(s, i+1, 1), 0) >= 0)
+ if(IS_DIGIT(substring(s, i+1, 1)))
return substring(s, i, 2);
if(i+4 <= len)
#define HEXDIGIT_TO_DEC(d) ((HEXDIGIT_TO_DEC_RAW(d) | 0x10) - 0x10)
#define DEC_TO_HEXDIGIT(d) (substring(HEXDIGITS_MINSET, (d), 1))
#define IS_HEXDIGIT(d) (strstrofs(HEXDIGITS_MINSET, (d), 0) >= 0)
+
+const string DIGITS = "0123456789";
+#define IS_DIGIT(d) (strstrofs(DIGITS, (d), 0) >= 0)
while (i - 2 - carets >= 0 && substring(me.controlledTextbox.text, i - 2 - carets, 1) == "^")
++carets;
if (carets & 1)
- if(strstrofs("0123456789", substring(me.controlledTextbox.text, i-1, 1), 0) >= 0)
+ if(IS_DIGIT(substring(me.controlledTextbox.text, i-1, 1)))
{
me.controlledTextbox.keyDown(me.controlledTextbox, K_BACKSPACE, 8, 0);
me.controlledTextbox.keyDown(me.controlledTextbox, K_BACKSPACE, 8, 0);
isv6 = true;
me.seenIPv6 += 1;
}
- else if(strstrofs("0123456789", substring(s, 0, 1), 0) >= 0)
+ else if(IS_DIGIT(substring(s, 0, 1)))
{
isv4 = true;
me.seenIPv4 += 1;
float bot_cmd_eval(entity this, string expr)
{
// Search for numbers
- if(strstrofs("0123456789", substring(expr, 0, 1), 0) >= 0)
- {
+ if(IS_DIGIT(substring(expr, 0, 1)))
return stof(expr);
- }
// Search for cvars
if(substring(expr, 0, 5)=="cvar.")
- {
return cvar(substring(expr, 5, strlen(expr)));
- }
// Search for fields
switch(expr)