X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Futil.qc;h=66cd016c0ae90746bb584339f65400e41114c1f8;hp=a7e9c42104d222e04d7b6d1d5884c6376eb7b060;hb=ca43a51345c0e7d23b862eac0f7ea292800f9aa8;hpb=d7ecf0b99095f97132ddb1252268ff7d7fb8597b diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc index a7e9c42104..66cd016c0a 100644 --- a/qcsrc/common/util.qc +++ b/qcsrc/common/util.qc @@ -217,7 +217,8 @@ void wordwrap_cb(string s, float l, void(string) callback) s = strzone(s); lleft = l; - for (i = 0;i < strlen(s);++i) + int len = strlen(s); + for (i = 0; i < len; ++i) { if (substring(s, i, 2) == "\\n") { @@ -235,12 +236,12 @@ void wordwrap_cb(string s, float l, void(string) callback) if (lleft > 0) { callback(" "); - lleft = lleft - 1; + --lleft; } } else { - for (j = i+1;j < strlen(s);++j) + for (j = i+1; j < len; ++j) // ^^ this skips over the first character of a word, which // is ALWAYS part of the word // this is safe since if i+1 == strlen(s), i will become @@ -268,7 +269,7 @@ void wordwrap_cb(string s, float l, void(string) callback) lleft = l; } callback(substring(s, i, wlen)); - lleft = lleft - wlen; + lleft -= wlen; i = j - 1; } }