From: Mario Date: Sun, 3 Jan 2016 09:44:28 +0000 (+1000) Subject: Kill some uses of self in the vehicle code X-Git-Tag: xonotic-v0.8.2~1319 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=4185a0c6e8c791ca4695ba93be69eb018d79f555;p=xonotic%2Fxonotic-data.pk3dir.git Kill some uses of self in the vehicle code --- diff --git a/qcsrc/common/vehicles/sv_vehicles.qc b/qcsrc/common/vehicles/sv_vehicles.qc index 78a0dbc1f..a19e6d4b1 100644 --- a/qcsrc/common/vehicles/sv_vehicles.qc +++ b/qcsrc/common/vehicles/sv_vehicles.qc @@ -42,15 +42,15 @@ bool SendAuxiliaryXhair(entity this, entity to, int sf) WriteHeader(MSG_ENTITY, ENT_CLIENT_AUXILIARYXHAIR); - WriteByte(MSG_ENTITY, self.cnt); + WriteByte(MSG_ENTITY, this.cnt); - WriteCoord(MSG_ENTITY, self.origin_x); - WriteCoord(MSG_ENTITY, self.origin_y); - WriteCoord(MSG_ENTITY, self.origin_z); + WriteCoord(MSG_ENTITY, this.origin_x); + WriteCoord(MSG_ENTITY, this.origin_y); + WriteCoord(MSG_ENTITY, this.origin_z); - WriteByte(MSG_ENTITY, rint(self.colormod_x * 255)); - WriteByte(MSG_ENTITY, rint(self.colormod_y * 255)); - WriteByte(MSG_ENTITY, rint(self.colormod_z * 255)); + WriteByte(MSG_ENTITY, rint(this.colormod_x * 255)); + WriteByte(MSG_ENTITY, rint(this.colormod_y * 255)); + WriteByte(MSG_ENTITY, rint(this.colormod_z * 255)); return true; } @@ -91,36 +91,22 @@ void CSQCVehicleSetup(entity own, int vehicle_id) WriteByte(MSG_ONE, vehicle_id); } -vector targetdrone_getnewspot() -{SELFPARAM(); - vector spot; - int i; - for(i = 0; i < 100; ++i) - { - spot = self.origin + randomvec() * 1024; - tracebox(spot, self.mins, self.maxs, spot, MOVE_NORMAL, self); - if(trace_fraction == 1.0 && trace_startsolid == 0 && trace_allsolid == 0) - return spot; - } - return self.origin; -} - -void vehicles_locktarget(float incr, float decr, float _lock_time) -{SELFPARAM(); - if(self.lock_target && IS_DEAD(self.lock_target)) +void vehicles_locktarget(entity this, float incr, float decr, float _lock_time) +{ + if(this.lock_target && IS_DEAD(this.lock_target)) { - self.lock_target = world; - self.lock_strength = 0; - self.lock_time = 0; + this.lock_target = world; + this.lock_strength = 0; + this.lock_time = 0; } - if(self.lock_time > time) + if(this.lock_time > time) { - if(self.lock_target) - if(self.lock_soundtime < time) + if(this.lock_target) + if(this.lock_soundtime < time) { - self.lock_soundtime = time + 0.5; - play2(self.owner, "vehicles/locked.wav"); + this.lock_soundtime = time + 0.5; + play2(this.owner, "vehicles/locked.wav"); } return; @@ -128,7 +114,7 @@ void vehicles_locktarget(float incr, float decr, float _lock_time) if(trace_ent != world) { - if(SAME_TEAM(trace_ent, self)) + if(SAME_TEAM(trace_ent, this)) trace_ent = world; if(IS_DEAD(trace_ent)) @@ -141,48 +127,48 @@ void vehicles_locktarget(float incr, float decr, float _lock_time) trace_ent = world; // invisible } - if(self.lock_target == world && trace_ent != world) - self.lock_target = trace_ent; + if(this.lock_target == world && trace_ent != world) + this.lock_target = trace_ent; - if(self.lock_target && trace_ent == self.lock_target) + if(this.lock_target && trace_ent == this.lock_target) { - if(self.lock_strength != 1 && self.lock_strength + incr >= 1) + if(this.lock_strength != 1 && this.lock_strength + incr >= 1) { - play2(self.owner, "vehicles/lock.wav"); - self.lock_soundtime = time + 0.8; + play2(this.owner, "vehicles/lock.wav"); + this.lock_soundtime = time + 0.8; } - else if (self.lock_strength != 1 && self.lock_soundtime < time) + else if (this.lock_strength != 1 && this.lock_soundtime < time) { - play2(self.owner, "vehicles/locking.wav"); - self.lock_soundtime = time + 0.3; + play2(this.owner, "vehicles/locking.wav"); + this.lock_soundtime = time + 0.3; } } // Have a locking target // Trace hit current target - if(trace_ent == self.lock_target && trace_ent != world) + if(trace_ent == this.lock_target && trace_ent != world) { - self.lock_strength = min(self.lock_strength + incr, 1); - if(self.lock_strength == 1) - self.lock_time = time + _lock_time; + this.lock_strength = min(this.lock_strength + incr, 1); + if(this.lock_strength == 1) + this.lock_time = time + _lock_time; } else { if(trace_ent) - self.lock_strength = max(self.lock_strength - decr * 2, 0); + this.lock_strength = max(this.lock_strength - decr * 2, 0); else - self.lock_strength = max(self.lock_strength - decr, 0); + this.lock_strength = max(this.lock_strength - decr, 0); - if(self.lock_strength == 0) - self.lock_target = world; + if(this.lock_strength == 0) + this.lock_target = world; } } -vector vehicles_force_fromtag_hover(string tag_name, float spring_length, float max_power) -{SELFPARAM(); - force_fromtag_origin = gettaginfo(self, gettagindex(self, tag_name)); +vector vehicles_force_fromtag_hover(entity this, string tag_name, float spring_length, float max_power) +{ + force_fromtag_origin = gettaginfo(this, gettagindex(this, tag_name)); v_forward = normalize(v_forward) * -1; - traceline(force_fromtag_origin, force_fromtag_origin - (v_forward * spring_length), MOVE_NORMAL, self); + traceline(force_fromtag_origin, force_fromtag_origin - (v_forward * spring_length), MOVE_NORMAL, this); force_fromtag_power = (1 - trace_fraction) * max_power; force_fromtag_normpower = force_fromtag_power / max_power; @@ -190,12 +176,11 @@ vector vehicles_force_fromtag_hover(string tag_name, float spring_length, float return v_forward * force_fromtag_power; } -vector vehicles_force_fromtag_maglev(string tag_name, float spring_length, float max_power) -{SELFPARAM(); - - force_fromtag_origin = gettaginfo(self, gettagindex(self, tag_name)); +vector vehicles_force_fromtag_maglev(entity this, string tag_name, float spring_length, float max_power) +{ + force_fromtag_origin = gettaginfo(this, gettagindex(this, tag_name)); v_forward = normalize(v_forward) * -1; - traceline(force_fromtag_origin, force_fromtag_origin - (v_forward * spring_length), MOVE_NORMAL, self); + traceline(force_fromtag_origin, force_fromtag_origin - (v_forward * spring_length), MOVE_NORMAL, this); // TODO - this may NOT be compatible with wall/celing movement, unhardcode 0.25 (engine count multiplier) if(trace_fraction == 1.0) diff --git a/qcsrc/common/vehicles/vehicle/racer.qc b/qcsrc/common/vehicles/vehicle/racer.qc index ce3094091..d5057c30f 100644 --- a/qcsrc/common/vehicles/vehicle/racer.qc +++ b/qcsrc/common/vehicles/vehicle/racer.qc @@ -95,48 +95,48 @@ vector autocvar_g_vehicle_racer_bouncepain; .float racer_watertime; -var vector racer_force_from_tag(string tag_name, float spring_length, float max_power); +var vector racer_force_from_tag(entity this, string tag_name, float spring_length, float max_power); -void racer_align4point(float _delta) -{SELFPARAM(); +void racer_align4point(entity this, float _delta) +{ vector push_vector; float fl_push, fr_push, bl_push, br_push; - push_vector = racer_force_from_tag("tag_engine_fr", autocvar_g_vehicle_racer_springlength, autocvar_g_vehicle_racer_hoverpower); + push_vector = racer_force_from_tag(this, "tag_engine_fr", autocvar_g_vehicle_racer_springlength, autocvar_g_vehicle_racer_hoverpower); fr_push = force_fromtag_normpower; - //vehicles_sweap_collision(force_fromtag_origin, self.velocity, _delta, v_add, autocvar_g_vehicle_racer_collision_multiplier); + //vehicles_sweap_collision(force_fromtag_origin, this.velocity, _delta, v_add, autocvar_g_vehicle_racer_collision_multiplier); - push_vector += racer_force_from_tag("tag_engine_fl", autocvar_g_vehicle_racer_springlength, autocvar_g_vehicle_racer_hoverpower); + push_vector += racer_force_from_tag(this, "tag_engine_fl", autocvar_g_vehicle_racer_springlength, autocvar_g_vehicle_racer_hoverpower); fl_push = force_fromtag_normpower; - //vehicles_sweap_collision(force_fromtag_origin, self.velocity, _delta, v_add, autocvar_g_vehicle_racer_collision_multiplier); + //vehicles_sweap_collision(force_fromtag_origin, this.velocity, _delta, v_add, autocvar_g_vehicle_racer_collision_multiplier); - push_vector += racer_force_from_tag("tag_engine_br", autocvar_g_vehicle_racer_springlength, autocvar_g_vehicle_racer_hoverpower); + push_vector += racer_force_from_tag(this, "tag_engine_br", autocvar_g_vehicle_racer_springlength, autocvar_g_vehicle_racer_hoverpower); br_push = force_fromtag_normpower; - //vehicles_sweap_collision(force_fromtag_origin, self.velocity, _delta, v_add, autocvar_g_vehicle_racer_collision_multiplier); + //vehicles_sweap_collision(force_fromtag_origin, this.velocity, _delta, v_add, autocvar_g_vehicle_racer_collision_multiplier); - push_vector += racer_force_from_tag("tag_engine_bl", autocvar_g_vehicle_racer_springlength, autocvar_g_vehicle_racer_hoverpower); + push_vector += racer_force_from_tag(this, "tag_engine_bl", autocvar_g_vehicle_racer_springlength, autocvar_g_vehicle_racer_hoverpower); bl_push = force_fromtag_normpower; - //vehicles_sweap_collision(force_fromtag_origin, self.velocity, _delta, v_add, autocvar_g_vehicle_racer_collision_multiplier); + //vehicles_sweap_collision(force_fromtag_origin, this.velocity, _delta, v_add, autocvar_g_vehicle_racer_collision_multiplier); - self.velocity += push_vector * _delta; + this.velocity += push_vector * _delta; float uforce = autocvar_g_vehicle_racer_upforcedamper; - int cont = pointcontents(self.origin - '0 0 64'); + int cont = pointcontents(this.origin - '0 0 64'); if(cont == CONTENT_WATER || cont == CONTENT_LAVA || cont == CONTENT_SLIME) { uforce = autocvar_g_vehicle_racer_water_upforcedamper; - if(self.owner.BUTTON_CROUCH && time < self.air_finished) - self.velocity_z += 30; + if(this.owner.BUTTON_CROUCH && time < this.air_finished) + this.velocity_z += 30; else - self.velocity_z += 200; + this.velocity_z += 200; } // Anti ocilation - if(self.velocity_z > 0) - self.velocity_z *= 1 - uforce * _delta; + if(this.velocity_z > 0) + this.velocity_z *= 1 - uforce * _delta; push_vector_x = (fl_push - bl_push); push_vector_x += (fr_push - br_push); @@ -147,12 +147,12 @@ void racer_align4point(float _delta) push_vector_z *= 360; // Apply angle diffrance - self.angles_z += push_vector_z * _delta; - self.angles_x += push_vector_x * _delta; + this.angles_z += push_vector_z * _delta; + this.angles_x += push_vector_x * _delta; // Apply stabilizer - self.angles_x *= 1 - (autocvar_g_vehicle_racer_anglestabilizer * _delta); - self.angles_z *= 1 - (autocvar_g_vehicle_racer_anglestabilizer * _delta); + this.angles_x *= 1 - (autocvar_g_vehicle_racer_anglestabilizer * _delta); + this.angles_z *= 1 - (autocvar_g_vehicle_racer_anglestabilizer * _delta); } void racer_fire_rocket_aim(entity player, string tagname, entity trg) @@ -191,7 +191,7 @@ float racer_frame() return 1; } - racer_align4point(PHYS_INPUT_TIMELENGTH); + racer_align4point(self, PHYS_INPUT_TIMELENGTH); player.BUTTON_ZOOM = player.BUTTON_CROUCH = 0; @@ -329,7 +329,7 @@ float racer_frame() if(autocvar_g_vehicle_racer_rocket_locktarget) { - vehicles_locktarget((1 / autocvar_g_vehicle_racer_rocket_locking_time) * frametime, + vehicles_locktarget(self, (1 / autocvar_g_vehicle_racer_rocket_locking_time) * frametime, (1 / autocvar_g_vehicle_racer_rocket_locking_releasetime) * frametime, autocvar_g_vehicle_racer_rocket_locked_time); diff --git a/qcsrc/common/vehicles/vehicle/raptor.qc b/qcsrc/common/vehicles/vehicle/raptor.qc index 688d79385..41ecab4e9 100644 --- a/qcsrc/common/vehicles/vehicle/raptor.qc +++ b/qcsrc/common/vehicles/vehicle/raptor.qc @@ -342,7 +342,7 @@ float raptor_frame() else if(autocvar_g_vehicle_raptor_cannon_locktarget == 1) { - vehicles_locktarget((1 / autocvar_g_vehicle_raptor_cannon_locking_time) * frametime, + vehicles_locktarget(self, (1 / autocvar_g_vehicle_raptor_cannon_locking_time) * frametime, (1 / autocvar_g_vehicle_raptor_cannon_locking_releasetime) * frametime, autocvar_g_vehicle_raptor_cannon_locked_time);