From: Mario Date: Sun, 12 Jun 2016 06:05:43 +0000 (+1000) Subject: Replace some more vlen checks with vdist and vlen2 X-Git-Tag: xonotic-v0.8.2~816 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5111c4a32e3439a9d98dde5c2dc82e76a17af6d5;p=xonotic%2Fxonotic-data.pk3dir.git Replace some more vlen checks with vdist and vlen2 --- diff --git a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc index 6ef9ca5ab..1c0fdaa98 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc @@ -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); } } diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc index a5ad94e20..0b99ee022 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc @@ -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; } } diff --git a/qcsrc/common/triggers/func/vectormamamam.qc b/qcsrc/common/triggers/func/vectormamamam.qc index a336c8b7e..6eb65936b 100644 --- a/qcsrc/common/triggers/func/vectormamamam.qc +++ b/qcsrc/common/triggers/func/vectormamamam.qc @@ -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); diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc index 521101372..d98e80db8 100644 --- a/qcsrc/common/util.qc +++ b/qcsrc/common/util.qc @@ -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); diff --git a/qcsrc/common/weapons/weapon/crylink.qc b/qcsrc/common/weapons/weapon/crylink.qc index 51932f6fe..89a2cea42 100644 --- a/qcsrc/common/weapons/weapon/crylink.qc +++ b/qcsrc/common/weapons/weapon/crylink.qc @@ -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) diff --git a/qcsrc/common/weapons/weapon/shockwave.qc b/qcsrc/common/weapons/weapon/shockwave.qc index 9834dab6b..4e0b20fd9 100644 --- a/qcsrc/common/weapons/weapon/shockwave.qc +++ b/qcsrc/common/weapons/weapon/shockwave.qc @@ -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; } diff --git a/qcsrc/server/bot/havocbot/havocbot.qc b/qcsrc/server/bot/havocbot/havocbot.qc index 0d59fa6e4..ca95e9ebf 100644 --- a/qcsrc/server/bot/havocbot/havocbot.qc +++ b/qcsrc/server/bot/havocbot/havocbot.qc @@ -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) diff --git a/qcsrc/server/bot/navigation.qc b/qcsrc/server/bot/navigation.qc index 0d2f9988f..6eb872bb1 100644 --- a/qcsrc/server/bot/navigation.qc +++ b/qcsrc/server/bot/navigation.qc @@ -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)) { diff --git a/qcsrc/server/bot/waypoints.qc b/qcsrc/server/bot/waypoints.qc index ef8451efa..e60603879 100644 --- a/qcsrc/server/bot/waypoints.qc +++ b/qcsrc/server/bot/waypoints.qc @@ -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; diff --git a/qcsrc/server/cheats.qc b/qcsrc/server/cheats.qc index 987a86db4..19a1e25bd 100644 --- a/qcsrc/server/cheats.qc +++ b/qcsrc/server/cheats.qc @@ -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) { diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 8da1f1076..968a9899f 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -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)) diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index d0415c9e2..8a4414517 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -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); diff --git a/qcsrc/server/pathlib/main.qc b/qcsrc/server/pathlib/main.qc index c033f3f52..319960a93 100644 --- a/qcsrc/server/pathlib/main.qc +++ b/qcsrc/server/pathlib/main.qc @@ -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;