]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
remove unknown format strings
authorMartin Taibr <taibr.martin@gmail.com>
Thu, 22 Dec 2016 23:24:30 +0000 (00:24 +0100)
committerMartin Taibr <taibr.martin@gmail.com>
Thu, 22 Dec 2016 23:24:30 +0000 (00:24 +0100)
qcsrc/common/mutators/mutator/damagetext/damagetext.qc

index fd873efb9b2bcade276324d22ca62c7df14cd4d5..d68feda3a2b221e3f327214b2a365b148108f138 100644 (file)
@@ -128,6 +128,20 @@ CLASS(DamageText, Object)
                 ? sprintf("%d",      total)
                 : sprintf("%d (%d)", total, potential)
             ), s);
+
+        // futureproofing: remove any remaining (unknown) format strings in case we add new ones in the future
+        // so players can use them on new servers and still have working damagetext on old ones
+        while (true) {
+            int opening_pos = strstrofs(s, "{", 0);
+            if (opening_pos == -1) break;
+            int closing_pos = strstrofs(s, "}", opening_pos);
+            if (closing_pos == -1 || closing_pos <= opening_pos) break;
+            s = strcat(
+                substring(s, 0, opening_pos),
+                substring(s, closing_pos + 1, strlen(s))
+            );
+        }
+
         if (this.text) strunzone(this.text);
         this.text = strzone(s);