From 2a6143b0855fce730e621e2ab7e2b8c24e959d8c Mon Sep 17 00:00:00 2001 From: Martin Taibr Date: Fri, 23 Dec 2016 00:24:30 +0100 Subject: [PATCH] remove unknown format strings --- .../mutators/mutator/damagetext/damagetext.qc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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); -- 2.39.2