]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
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 6ef9ca5ab66fec9fcd082ff0a5333a69622b894f..1c0fdaa9839b2bbce3c98d341f5529a5bd84c6cf 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 a5ad94e2055fe9d4cf197451778c9853bb99619e..0b99ee022706c10f0baf38ed5f7b0bd9a06afca1 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 a336c8b7e289e146b506f2100aa950c4c4d52c1f..6eb65936b9feb210804a4a16bf92080a8af1270b 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 52110137253b224511204353637be62d99d7d36c..d98e80db853d22f317a196bda2515afd5e58d23d 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 51932f6fef07869cf352896bec553d3ccaccb0c0..89a2cea429202d5227a56c92aed268d45cecc843 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 9834dab6ba62bf3554eb045b4746c32c6d960e95..4e0b20fd9ac2f7d5658a09179a21c76eef467d52 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 0d59fa6e4251f1fad85259692af0062e519113d1..ca95e9ebfe6db164047eadbbf32ac9b2f10e68fa 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 0d2f9988f92461ed5c321b33588b92d0ae20933a..6eb872bb16fd91887f70b7149a0bd6c869423113 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 ef8451efac92beea85914831f58ae0ad8a9433eb..e606038792fd6ab3eacecf92ad7217c96070afed 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 987a86db4f128f6a841b396847bb449961a6278c..19a1e25bdd73d1d601a1e6efd7cdfb075151176b 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 8da1f1076401d702f97d8b1a2cfbf7efd62c3372..968a9899f20262d29f6c3c665de738b00b9732e2 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 d0415c9e2c8da6ffbb10c092087de3d46b00f079..8a4414517c38f4cf4edabaf3cf2243b5e647d18c 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 c033f3f52a6c4f9955becffb46ba20d4aed9e5a6..319960a938b85b0d80905bb42c94885f01225d1c 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;