]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add velocity_len to reduce calls of vlen
authorterencehill <piuntn@gmail.com>
Mon, 3 Jan 2011 17:50:56 +0000 (18:50 +0100)
committerterencehill <piuntn@gmail.com>
Mon, 3 Jan 2011 17:50:56 +0000 (18:50 +0100)
Remove maxspeed and use directly autocvar_g_maxspeed;

qcsrc/server/sv_main.qc

index c73f0355f8ad6ba1bd927e53c68e3e457e060d32..aebea7523f66fea9e67d93ee485024bffeb9ff36 100644 (file)
@@ -2,7 +2,7 @@
 void CreatureFrame (void)
 {
        local entity oldself;
-       local float dm, maxspeed;
+       local float dm;
        oldself = self;
        self = findfloat(world, iscreature, TRUE);
        while (self)
@@ -67,9 +67,10 @@ void CreatureFrame (void)
                                self.dmg = 2;
                        }
                        // check for falling damage
+                       float velocity_len = vlen(self.velocity);
                        if(!self.hook.state && !g_ca && !(g_cts && !autocvar_g_cts_selfdamage))
                        {
-                               dm = vlen(self.oldvelocity) - vlen(self.velocity); // dm is now the velocity DECREASE. Velocity INCREASE should never cause a sound or any damage.
+                               dm = vlen(self.oldvelocity) - velocity_len; // dm is now the velocity DECREASE. Velocity INCREASE should never cause a sound or any damage.
                                if (self.deadflag)
                                        dm = (dm - autocvar_g_balance_falldamage_deadminspeed) * autocvar_g_balance_falldamage_factor;
                                else
@@ -78,15 +79,14 @@ void CreatureFrame (void)
                                        Damage (self, world, world, dm, DEATH_FALL, self.origin, '0 0 0');
                        }
 
-                       maxspeed = autocvar_g_maxspeed;
-                       if(maxspeed > 0 && vlen(self.velocity) > maxspeed)
+                       if(autocvar_g_maxspeed > 0 && velocity_len > autocvar_g_maxspeed)
                                Damage (self, world, world, 100000, DEATH_SHOOTING_STAR, self.origin, '0 0 0');
 
                        // play stupid sounds
                        if (g_footsteps)
                        if (!gameover)
                        if (self.flags & FL_ONGROUND)
-                       if (vlen(self.velocity) > autocvar_sv_maxspeed * 0.6)
+                       if (velocity_len > autocvar_sv_maxspeed * 0.6)
                        if (!self.deadflag)
                        if (time < self.lastground + 0.2)
                        {