]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/util.qc
Introduce the shared function write_String_To_File that can be used by all the dump...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / util.qc
index 183302b3a1e0460c246c9c1c8357edfbace43c53..74e337f7498a6249291aa6bb80c245b46e043393 100644 (file)
@@ -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;
                }
        }
@@ -1298,11 +1299,19 @@ float matchacl(string acl, string str)
                if(s == t)
                {
                        r = d;
+                       break; // if we found a killing case, apply it! other settings may be allowed in the future, but this one is caught
                }
        }
        return r;
 }
 
+ERASEABLE
+void write_String_To_File(int fh, string str, bool alsoprint)
+{
+       fputs(fh, str);
+       if (alsoprint) LOG_INFO(str);
+}
+
 string get_model_datafilename(string m, float sk, string fil)
 {
        if(m)