From: terencehill Date: Sun, 25 Sep 2011 22:51:23 +0000 (+0200) Subject: Fix misspelled variable name and make a check more intuitive X-Git-Tag: xonotic-v0.6.0~40^2~75^2~2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b642c7936b977a3d383418fdfcb6ab7c02b0be26;p=xonotic%2Fxonotic-data.pk3dir.git Fix misspelled variable name and make a check more intuitive --- diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc index 0b6ea4528..46cb0e82d 100644 --- a/qcsrc/common/util.qc +++ b/qcsrc/common/util.qc @@ -1291,7 +1291,7 @@ float textLengthUpToLength(string theText, float maxWidth, textLengthUpToLength_ string find_last_color_code(string s) { - float start, len, i, carrets; + float start, len, i, carets; start = strstrofs(s, "^", 0); if (start == -1) // no carret found return ""; @@ -1301,12 +1301,12 @@ string find_last_color_code(string s) if(substring(s, i, 1) != "^") continue; - carrets = 1; - while (i-carrets >= start && substring(s, i-carrets, 1) == "^") - ++carrets; + carets = 1; + while (i-carets >= start && substring(s, i-carets, 1) == "^") + ++carets; - // check if carrets aren't all escaped - if (!(carrets > 1 && mod(carrets, 2) == 0)) // first check is just an optimization + // check if carets aren't all escaped + if (carets == 1 || mod(carets, 2) == 1) // first check is just an optimization { if(i+1 <= len) if(strstrofs("0123456789", substring(s, i+1, 1), 0) >= 0) @@ -1319,7 +1319,7 @@ string find_last_color_code(string s) if(strstrofs("0123456789abcdefABCDEF", substring(s, i+4, 1), 0) >= 0) return substring(s, i, 5); } - i -= carrets; // this also skips one char before the carrets + i -= carets; // this also skips one char before the carets } return "";