Replace some more vlen checks with vdist and vlen2
authorMario <mario@smbclan.net>
Sun, 12 Jun 2016 06:05:43 +0000 (16:05 +1000)
committerMario <mario@smbclan.net>
Sun, 12 Jun 2016 06:05:43 +0000 (16:05 +1000)
13 files changed:
qcsrc/common/gamemodes/gamemode/nexball/nexball.qc
qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc
qcsrc/common/triggers/func/vectormamamam.qc
qcsrc/common/util.qc
qcsrc/common/weapons/weapon/crylink.qc
qcsrc/common/weapons/weapon/shockwave.qc
qcsrc/server/bot/havocbot/havocbot.qc
qcsrc/server/bot/navigation.qc
qcsrc/server/bot/waypoints.qc
qcsrc/server/cheats.qc
qcsrc/server/cl_client.qc
qcsrc/server/g_damage.qc
qcsrc/server/pathlib/main.qc

index 6ef9ca5..1c0fdaa 100644 (file)
@@ -278,7 +278,7 @@ void ResetBall(entity this)
        else     // step 4
        {
 //             dprint("Step 4: time: ", ftos(time), "\n");
-               if(vlen(this.origin - this.spawnorigin) > 10)  // should not happen anymore
+               if(vdist(this.origin - this.spawnorigin, >, 10)) // should not happen anymore
                        LOG_TRACE("The ball moved too far away from its spawn origin.\nOffset: ",
                                   vtos(this.origin - this.spawnorigin), " Velocity: ", vtos(this.velocity), "\n");
                this.velocity = '0 0 0';
@@ -314,7 +314,7 @@ void football_touch(entity this)
 
        if(autocvar_g_nexball_football_physics == -1)   // MrBougo try 1, before decompiling Rev's original
        {
-               if(vlen(other.velocity))
+               if(other.velocity)
                        this.velocity = other.velocity * 1.5 + '0 0 1' * autocvar_g_nexball_football_boost_up;
        }
        else if(autocvar_g_nexball_football_physics == 1)         // MrBougo's modded Rev style: partially independant of the height of the aiming point
@@ -352,7 +352,7 @@ void basketball_touch(entity this)
        else if(other.solid == SOLID_BSP)
        {
                _sound(this, CH_TRIGGER, this.noise, VOL_BASE, ATTEN_NORM);
-               if(vlen(this.velocity) && !this.cnt)
+               if(this.velocity && !this.cnt)
                        this.nextthink = min(time + autocvar_g_nexball_delay_idle, this.teamtime);
        }
 }
index a5ad94e..0b99ee0 100644 (file)
@@ -1322,7 +1322,7 @@ void havocbot_goalrating_ons_offenseitems(entity this, float ratingscale, vector
                // gather health and armor only
                if (head.solid)
                if ( ((head.health || head.armorvalue) && needarmor) || (head.weapons && needweapons ) )
-               if (vlen(head.origin - org) < sradius)
+               if (vdist(head.origin - org, <, sradius))
                {
                        t = head.bot_pickupevalfunc(this, head);
                        if (t > 0)
@@ -1825,7 +1825,7 @@ MUTATOR_HOOKFUNCTION(ons, PlayerSpawn)
                        if(SAME_TEAM(tmp_entity, player))
                        if(random_target)
                                RandomSelection_Add(tmp_entity, 0, string_null, 1, 1);
-                       else if(vlen(tmp_entity.origin - spawn_loc) <= vlen(closest_target.origin - spawn_loc) || closest_target == world)
+                       else if(vlen2(tmp_entity.origin - spawn_loc) <= vlen2(closest_target.origin - spawn_loc) || closest_target == world)
                                closest_target = tmp_entity;
                }
 
@@ -1875,7 +1875,7 @@ MUTATOR_HOOKFUNCTION(ons, PlayerSpawn)
                        else
                        {
                                if(SAME_TEAM(tmp_entity, player))
-                               if(vlen(tmp_entity.origin - spawn_loc) <= vlen(closest_target.origin - spawn_loc) || closest_target == world)
+                               if(vlen2(tmp_entity.origin - spawn_loc) <= vlen2(closest_target.origin - spawn_loc) || closest_target == world)
                                        closest_target = tmp_entity;
                        }
                }
index a336c8b..6eb6593 100644 (file)
@@ -117,16 +117,16 @@ spawnfunc(func_vectormamamam)
        if(!this.target4factor)
                this.target4factor = 1;
 
-       if(vlen(this.targetnormal))
+       if(this.targetnormal)
                this.targetnormal = normalize(this.targetnormal);
 
-       if(vlen(this.target2normal))
+       if(this.target2normal)
                this.target2normal = normalize(this.target2normal);
 
-       if(vlen(this.target3normal))
+       if(this.target3normal)
                this.target3normal = normalize(this.target3normal);
 
-       if(vlen(this.target4normal))
+       if(this.target4normal)
                this.target4normal = normalize(this.target4normal);
 
        setblocked(this, generic_plat_blocked);
index 5211013..d98e80d 100644 (file)
@@ -297,7 +297,7 @@ float compressShortVector(vector vec)
 {
        vector ang;
        float p, y, len;
-       if(vlen(vec) == 0)
+       if(vec == '0 0 0')
                return 0;
        //print("compress: ", vtos(vec), "\n");
        ang = vectoangles(vec);
index 51932f6..89a2cea 100644 (file)
@@ -237,11 +237,11 @@ void W_Crylink_LinkJoinEffect_Think(entity this)
        n = 0;
        if(e)
        {
-               if(vlen(e.origin - this.origin) < vlen(e.velocity) * frametime)
+               if(vlen2(e.origin - this.origin) < vlen2(e.velocity) * frametime)
                        ++n;
                for(p = e; (p = p.queuenext) != e; )
                {
-                       if(vlen(p.origin - this.origin) < vlen(p.velocity) * frametime)
+                       if(vlen2(p.origin - this.origin) < vlen2(p.velocity) * frametime)
                                ++n;
                }
                if(n >= 2)
index 9834dab..4e0b20f 100644 (file)
@@ -328,7 +328,7 @@ float W_Shockwave_Attack_CheckHit(
        {
                if(shockwave_hit[i] == head)
                {
-                       if(vlen(final_force) > vlen(shockwave_hit_force[i])) { shockwave_hit_force[i] = final_force; }
+                       if(vlen2(final_force) > vlen2(shockwave_hit_force[i])) { shockwave_hit_force[i] = final_force; }
                        if(final_damage > shockwave_hit_damage[i]) { shockwave_hit_damage[i] = final_damage; }
                        return false;
                }
index 0d59fa6..ca95e9e 100644 (file)
@@ -737,7 +737,7 @@ void havocbot_movetogoal(entity this)
                        traceline(this.origin + this.view_ofs, dst_ahead, true, world);
 
                        // Check head-banging against walls
-                       if(vlen(this.origin + this.view_ofs - trace_endpos) < 25 && !(this.aistatus & AI_STATUS_OUT_WATER))
+                       if(vdist(this.origin + this.view_ofs - trace_endpos, <, 25) && !(this.aistatus & AI_STATUS_OUT_WATER))
                        {
                                PHYS_INPUT_BUTTON_JUMP(this) = true;
                                if(this.facingwalltime && time > this.facingwalltime)
index 0d2f998..6eb872b 100644 (file)
@@ -925,7 +925,7 @@ void navigation_poptouchedgoals(entity this)
 
        // If for some reason the bot is closer to the next goal, pop the current one
        if(this.goalstack01)
-       if(vlen(this.goalcurrent.origin - this.origin) > vlen(this.goalstack01.origin - this.origin))
+       if(vlen2(this.goalcurrent.origin - this.origin) > vlen2(this.goalstack01.origin - this.origin))
        if(checkpvs(this.origin + this.view_ofs, this.goalstack01))
        if(tracewalk(this, this.origin, this.mins, this.maxs, (this.goalstack01.absmin + this.goalstack01.absmax) * 0.5, bot_navigation_movemode))
        {
index ef8451e..e606038 100644 (file)
@@ -410,7 +410,7 @@ float waypoint_load_links()
                        found = false;
                        while(wp_from)
                        {
-                               if(vlen(wp_from.origin-wp_from_pos)<1)
+                               if(vdist(wp_from.origin - wp_from_pos, <, 1))
                                if(wp_from.classname == "waypoint")
                                {
                                        found = true;
@@ -432,7 +432,7 @@ float waypoint_load_links()
                found = false;
                while(wp_to)
                {
-                       if(vlen(wp_to.origin-wp_to_pos)<1)
+                       if(vdist(wp_to.origin - wp_to_pos, <, 1))
                        if(wp_to.classname == "waypoint")
                        {
                                found = true;
@@ -500,7 +500,7 @@ void waypoint_load_links_hardwired()
                        found = false;
                        while(wp_from)
                        {
-                               if(vlen(wp_from.origin-wp_from_pos)<5)
+                               if(vdist(wp_from.origin - wp_from_pos, <, 5))
                                if(wp_from.classname == "waypoint")
                                {
                                        found = true;
@@ -521,7 +521,7 @@ void waypoint_load_links_hardwired()
                found = false;
                while(wp_to)
                {
-                       if(vlen(wp_to.origin-wp_to_pos)<5)
+                       if(vdist(wp_to.origin - wp_to_pos, <, 5))
                        if(wp_to.classname == "waypoint")
                        {
                                found = true;
index 987a86d..19a1e25 100644 (file)
@@ -819,7 +819,7 @@ float Drag(entity this, float force_allow_pick, float ischeat)
                                                        // This also makes sure that an object can only pe picked up if in range, but does not get dropped if
                                                        // it goes out of range while slinging it around.
 
-                                                       if(vlen(this.origin - e.origin) <= autocvar_g_grab_range)
+                                                       if(vdist(this.origin - e.origin, <=, autocvar_g_grab_range))
                                                        {
                                                                switch(e.grab)
                                                                {
index 8da1f10..968a989 100644 (file)
@@ -2038,7 +2038,7 @@ void PlayerUseKey(entity this)
                                {
                                        if(closest_target)
                                        {
-                                               if(vlen(this.origin - head.origin) < vlen(this.origin - closest_target.origin))
+                                               if(vlen2(this.origin - head.origin) < vlen2(this.origin - closest_target.origin))
                                                { closest_target = head; }
                                        }
                                        else { closest_target = head; }
@@ -2165,7 +2165,7 @@ void PlayerPreThink ()
        {
                entity veh;
                for(veh = world; (veh = findflags(veh, vehicle_flags, VHF_ISVEHICLE)); )
-               if(vlen(veh.origin - this.origin) < autocvar_g_vehicles_enter_radius)
+               if(vdist(veh.origin - this.origin, <, autocvar_g_vehicles_enter_radius))
                if(!IS_DEAD(veh))
                if(veh.takedamage != DAMAGE_NO)
                if((veh.vehicle_flags & VHF_MULTISLOT) && SAME_TEAM(veh.owner, this))
index d0415c9..8a44145 100644 (file)
@@ -903,7 +903,7 @@ float RadiusDamageForSource (entity inflictor, vector inflictororigin, vector in
                if(DEATH_WEAPONOF(deathtype) != WEP_TUBA) // do not send tuba damage (bandwidth hog)
                {
                        force = inflictorvelocity;
-                       if(vlen(force) == 0)
+                       if(force == '0 0 0')
                                force = '0 0 -1';
                        else
                                force = normalize(force);
index c033f3f..319960a 100644 (file)
@@ -327,7 +327,7 @@ float buildpath_nodefilter_directional(vector n,vector c,vector p)
     d2 = normalize(p - c);
     d1 = normalize(c - n);
 
-    if(vlen(d1-d2) < 0.25)
+    if(vdist(d1 - d2, <, 0.25))
     {
         //mark_error(c,30);
         return 1;