From: Martin Taibr Date: Thu, 22 Dec 2016 23:24:30 +0000 (+0100) Subject: remove unknown format strings X-Git-Tag: xonotic-v0.8.2~169^2~6 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2a6143b0855fce730e621e2ab7e2b8c24e959d8c;p=xonotic%2Fxonotic-data.pk3dir.git remove unknown format strings --- diff --git a/qcsrc/common/mutators/mutator/damagetext/damagetext.qc b/qcsrc/common/mutators/mutator/damagetext/damagetext.qc index fd873efb9..d68feda3a 100644 --- a/qcsrc/common/mutators/mutator/damagetext/damagetext.qc +++ b/qcsrc/common/mutators/mutator/damagetext/damagetext.qc @@ -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);