From: terencehill Date: Fri, 11 Nov 2016 17:41:13 +0000 (+0100) Subject: Improve code readability X-Git-Tag: xonotic-v0.8.2~448 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=fed9896fd711b250366f46cc42632960472916ae;p=xonotic%2Fxonotic-data.pk3dir.git Improve code readability --- diff --git a/qcsrc/common/mutators/mutator/damagetext/damagetext.qc b/qcsrc/common/mutators/mutator/damagetext/damagetext.qc index b9e1280be..b95cabb6a 100644 --- a/qcsrc/common/mutators/mutator/damagetext/damagetext.qc +++ b/qcsrc/common/mutators/mutator/damagetext/damagetext.qc @@ -68,22 +68,27 @@ CLASS(DamageText, Object) Weapon w = DEATH_WEAPONOF(this.m_deathtype); if (w != WEP_Null) rgb = w.wpcolor; } + int health = rint(this.m_damage / DAMAGETEXT_PRECISION_MULTIPLIER); + int total = rint((this.m_damage + this.m_armordamage) / DAMAGETEXT_PRECISION_MULTIPLIER); + int potential = rint(this.m_potential_damage / DAMAGETEXT_PRECISION_MULTIPLIER); + int potential_health = rint((this.m_potential_damage - this.m_armordamage) / DAMAGETEXT_PRECISION_MULTIPLIER); + string s = autocvar_cl_damagetext_format; - s = strreplace("{health}", sprintf("%d", rint(this.m_damage / DAMAGETEXT_PRECISION_MULTIPLIER)), s); + s = strreplace("{health}", sprintf("%d", health), s); s = strreplace("{armor}", sprintf("%d", rint(this.m_armordamage / DAMAGETEXT_PRECISION_MULTIPLIER)), s); - s = strreplace("{total}", sprintf("%d", rint((this.m_damage + this.m_armordamage) / DAMAGETEXT_PRECISION_MULTIPLIER)), s); - s = strreplace("{potential}", sprintf("%d", rint(this.m_potential_damage/DAMAGETEXT_PRECISION_MULTIPLIER)), s); - s = strreplace("{potential_health}", sprintf("%d", rint((this.m_potential_damage - this.m_armordamage)/DAMAGETEXT_PRECISION_MULTIPLIER)), s); + s = strreplace("{total}", sprintf("%d", total), s); + s = strreplace("{potential}", sprintf("%d", potential), s); + s = strreplace("{potential_health}", sprintf("%d", potential_health), s); s = strreplace("{health(ph)}", ( - (rint(this.m_damage / DAMAGETEXT_PRECISION_MULTIPLIER) == rint((this.m_potential_damage - this.m_armordamage) / DAMAGETEXT_PRECISION_MULTIPLIER)) - ? sprintf("%d", rint(this.m_damage / DAMAGETEXT_PRECISION_MULTIPLIER)) - : sprintf("%d (%d)", rint(this.m_damage / DAMAGETEXT_PRECISION_MULTIPLIER), rint((this.m_potential_damage - this.m_armordamage) / DAMAGETEXT_PRECISION_MULTIPLIER)) + (health == potential_health) + ? sprintf("%d", health) + : sprintf("%d (%d)", health, potential_health) ), s); s = strreplace("{total(p)}", ( - (rint((this.m_damage + this.m_armordamage) / DAMAGETEXT_PRECISION_MULTIPLIER) == rint(this.m_potential_damage / DAMAGETEXT_PRECISION_MULTIPLIER)) - ? sprintf("%d", rint((this.m_damage + this.m_armordamage) / DAMAGETEXT_PRECISION_MULTIPLIER)) - : sprintf("%d (%d)", rint((this.m_damage + this.m_armordamage) / DAMAGETEXT_PRECISION_MULTIPLIER), rint(this.m_potential_damage/DAMAGETEXT_PRECISION_MULTIPLIER)) + (total == potential) + ? sprintf("%d", total) + : sprintf("%d (%d)", total, potential) ), s); drawcolorcodedstring2_builtin(pos, s, this.m_size * '1 1 0', rgb, this.alpha, DRAWFLAG_NORMAL); }