]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
bound() instead of ifs
authorMartin Taibr <taibr.martin@gmail.com>
Sun, 11 Dec 2016 16:04:28 +0000 (17:04 +0100)
committerMartin Taibr <taibr.martin@gmail.com>
Sun, 11 Dec 2016 16:07:22 +0000 (17:07 +0100)
qcsrc/common/mutators/mutator/damagetext/damagetext.qc

index 0ac58c7c3e56fbead94dfb337434d8ed68a51edf..3d293d8f8fd3090a761033f47accade0f62c9990 100644 (file)
@@ -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) {