From: Martin Taibr Date: Sun, 11 Dec 2016 16:04:28 +0000 (+0100) Subject: bound() instead of ifs X-Git-Tag: xonotic-v0.8.2~169^2~8 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=713bc4a163ab1f0a41dcf375576d64a4e1ed4793;p=xonotic%2Fxonotic-data.pk3dir.git bound() instead of ifs --- diff --git a/qcsrc/common/mutators/mutator/damagetext/damagetext.qc b/qcsrc/common/mutators/mutator/damagetext/damagetext.qc index 0ac58c7c3..3d293d8f8 100644 --- a/qcsrc/common/mutators/mutator/damagetext/damagetext.qc +++ b/qcsrc/common/mutators/mutator/damagetext/damagetext.qc @@ -126,16 +126,13 @@ CLASS(DamageText, Object) if (this.text) strunzone(this.text); this.text = strzone(s); - if (potential < autocvar_cl_damagetext_size_min_damage) { - this.m_size = autocvar_cl_damagetext_size_min; - } else if (potential > autocvar_cl_damagetext_size_max_damage) { - this.m_size = autocvar_cl_damagetext_size_max; - } else { - float size_range = autocvar_cl_damagetext_size_max - autocvar_cl_damagetext_size_min; - float damage_range = autocvar_cl_damagetext_size_max_damage - autocvar_cl_damagetext_size_min_damage; - float scale_factor = size_range / damage_range; - this.m_size = (potential - autocvar_cl_damagetext_size_min_damage) * scale_factor + autocvar_cl_damagetext_size_min; - } + float size_range = autocvar_cl_damagetext_size_max - autocvar_cl_damagetext_size_min; + float damage_range = autocvar_cl_damagetext_size_max_damage - autocvar_cl_damagetext_size_min_damage; + float scale_factor = size_range / damage_range; + this.m_size = bound( + autocvar_cl_damagetext_size_min, + (potential - autocvar_cl_damagetext_size_min_damage) * scale_factor + autocvar_cl_damagetext_size_min, + autocvar_cl_damagetext_size_max); } CONSTRUCTOR(DamageText, int _group, vector _origin, int _health, int _armor, int _potential_damage, int _deathtype, bool _friendlyfire) {