X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmutators%2Fmutator%2Fdamagetext%2Fdamagetext.qc;h=f89b6caeb06756e014be79005d3eea8dffbfeb96;hb=b834eab77489d98d5d722d67c8a96cf6c3549436;hp=3d293d8f8fd3090a761033f47accade0f62c9990;hpb=713bc4a163ab1f0a41dcf375576d64a4e1ed4793;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/mutators/mutator/damagetext/damagetext.qc b/qcsrc/common/mutators/mutator/damagetext/damagetext.qc index 3d293d8f8..f89b6caeb 100644 --- a/qcsrc/common/mutators/mutator/damagetext/damagetext.qc +++ b/qcsrc/common/mutators/mutator/damagetext/damagetext.qc @@ -12,14 +12,20 @@ const int DTFLAG_NO_POTENTIAL = BIT(5); REGISTER_MUTATOR(damagetext, true); -#if defined(CSQC) || defined(MENUQC) +// || defined(MENUQC) +#if defined(CSQC) // no translatable cvar description please AUTOCVAR_SAVE(cl_damagetext, bool, true, "Draw damage dealt where you hit the enemy"); AUTOCVAR_SAVE(cl_damagetext_format, string, "-{total}", "How to format the damage text. {health}, {armor}, {total}, {potential}: full damage not capped to target's health, {potential_health}: health damage not capped to target's health"); AUTOCVAR_SAVE(cl_damagetext_format_verbose, bool, false, "{health} shows {potential_health} too when they differ; {total} shows {potential} too when they differ"); AUTOCVAR_SAVE(cl_damagetext_format_hide_redundant, bool, false, "hide {armor} if 0; hide {potential} and {potential_health} when same as actual"); STATIC_INIT(DamageText_LegacyFormat) { - if (strstrofs(autocvar_cl_damagetext_format, "{", 0) < 0) autocvar_cl_damagetext_format = "-{total}"; + // damagetext used to be off by default and the cvar got saved in people's configs along with the old format + // enable damagetext while updating the format for a one time effect + if (strstrofs(autocvar_cl_damagetext_format, "{", 0) < 0) { + localcmd("\nseta cl_damagetext 1\n"); + localcmd("\nseta cl_damagetext_format -{total}\n"); + }; } AUTOCVAR_SAVE(cl_damagetext_color, vector, '1 1 0', "Damage text color"); AUTOCVAR_SAVE(cl_damagetext_color_per_weapon, bool, false, "Damage text uses weapon color"); @@ -123,6 +129,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_range(s, closing_pos + 1, strlen(s)) + ); + } + if (this.text) strunzone(this.text); this.text = strzone(s); @@ -152,7 +172,7 @@ ENDCLASS(DamageText) REGISTER_NET_TEMP(damagetext) #ifdef SVQC -AUTOCVAR(sv_damagetext, int, 2, _("<= 0: disabled, >= 1: spectators, >= 2: players, >= 3: all players")); +AUTOCVAR(sv_damagetext, int, 2, "<= 0: disabled, >= 1: spectators, >= 2: players, >= 3: all players"); #define SV_DAMAGETEXT_DISABLED() (autocvar_sv_damagetext <= 0 /* disabled */) #define SV_DAMAGETEXT_SPECTATORS_ONLY() (autocvar_sv_damagetext >= 1 /* spectators only */) #define SV_DAMAGETEXT_PLAYERS() (autocvar_sv_damagetext >= 2 /* players */)