From: Mario Date: Fri, 10 Jun 2016 10:44:11 +0000 (+1000) Subject: Purge SELFPARAM from the turret code X-Git-Tag: xonotic-v0.8.2~853 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8ba27c81940e6b29b1ab38f5da4ee4635229bdd5;p=xonotic%2Fxonotic-data.pk3dir.git Purge SELFPARAM from the turret code --- diff --git a/qcsrc/common/turrets/sv_turrets.qh b/qcsrc/common/turrets/sv_turrets.qh index 14b5b8853..29d08c629 100644 --- a/qcsrc/common/turrets/sv_turrets.qh +++ b/qcsrc/common/turrets/sv_turrets.qh @@ -92,7 +92,7 @@ bool turret_initialize(entity this, Turret tur); /// Function to use for target evaluation. usualy turret_targetscore_generic .float(entity _turret, entity _target) turret_score_target; -.float(entity e_target,entity e_sender) turret_addtarget; +.bool(entity this, entity e_target,entity e_sender) turret_addtarget; .entity pathcurrent; diff --git a/qcsrc/common/turrets/targettrigger.qc b/qcsrc/common/turrets/targettrigger.qc index 4828bf0b3..362cd0883 100644 --- a/qcsrc/common/turrets/targettrigger.qc +++ b/qcsrc/common/turrets/targettrigger.qc @@ -7,7 +7,7 @@ void turret_targettrigger_touch(entity this) FOREACH_ENTITY_STRING_ORDERED(targetname, this.target, { if (!(it.turret_flags & TUR_FLAG_RECIEVETARGETS)) continue; if (!it.turret_addtarget) continue; - WITHSELF(it, it.turret_addtarget(other, this)); + it.turret_addtarget(it, other, this); }); this.cnt = time + 0.5; } diff --git a/qcsrc/common/turrets/turret/hk.qc b/qcsrc/common/turrets/turret/hk.qc index e7fc07030..da107922f 100644 --- a/qcsrc/common/turrets/turret/hk.qc +++ b/qcsrc/common/turrets/turret/hk.qc @@ -39,7 +39,7 @@ METHOD(HunterKiller, tr_think, void(HunterKiller thistur, entity it)) it.tur_head.frame = 0; } -float turret_hk_addtarget(entity e_target,entity e_sender); +bool turret_hk_addtarget(entity this, entity e_target,entity e_sender); METHOD(HunterKiller, tr_setup, void(HunterKiller this, entity it)) { it.ammo_flags = TFL_AMMO_ROCKETS | TFL_AMMO_RECHARGE; @@ -52,18 +52,18 @@ METHOD(HunterKiller, tr_setup, void(HunterKiller this, entity it)) it.turret_addtarget = turret_hk_addtarget; } -float turret_hk_addtarget(entity e_target,entity e_sender) -{SELFPARAM(); +bool turret_hk_addtarget(entity this, entity e_target,entity e_sender) +{ if (e_target) { - if (turret_validate_target(self,e_target,self.target_validate_flags) > 0) + if (turret_validate_target(this,e_target,this.target_validate_flags) > 0) { - self.enemy = e_target; - return 1; + this.enemy = e_target; + return true; } } - return 0; + return false; } #endif // SVQC diff --git a/qcsrc/common/turrets/turret/hk_weapon.qc b/qcsrc/common/turrets/turret/hk_weapon.qc index 7d14757a1..b1658923e 100644 --- a/qcsrc/common/turrets/turret/hk_weapon.qc +++ b/qcsrc/common/turrets/turret/hk_weapon.qc @@ -44,7 +44,7 @@ METHOD(HunterKillerAttack, wr_think, void(entity thiswep, entity actor, .entity } } -bool hk_is_valid_target(entity e_target); +bool hk_is_valid_target(entity this, entity e_target); void turret_hk_missile_think(entity this) { vector vu, vd, vf, vl, vr, ve; // Vector (direction) @@ -72,7 +72,7 @@ void turret_hk_missile_think(entity this) e = findradius(self.origin, 5000); while (e) { - if (hk_is_valid_target(e)) + if (hk_is_valid_target(this, e)) { if (!self.enemy) self.enemy = e; @@ -246,38 +246,38 @@ void turret_hk_missile_think(entity this) UpdateCSQCProjectile(self); } -bool hk_is_valid_target(entity e_target) -{SELFPARAM(); +bool hk_is_valid_target(entity this, entity e_target) +{ if (e_target == world) - return 0; + return false; // If only this was used more.. if (e_target.flags & FL_NOTARGET) - return 0; + return false; // Cant touch this if ((e_target.takedamage == DAMAGE_NO) || (e_target.health < 0)) - return 0; + return false; // player if (IS_CLIENT(e_target)) { - if (self.owner.target_select_playerbias < 0) - return 0; + if (this.owner.target_select_playerbias < 0) + return false; if (IS_DEAD(e_target)) - return 0; + return false; } // Missile - if ((e_target.flags & FL_PROJECTILE) && (self.owner.target_select_missilebias < 0)) - return 0; + if ((e_target.flags & FL_PROJECTILE) && (this.owner.target_select_missilebias < 0)) + return false; // Team check - if ((e_target.team == self.owner.team) || (self.owner.team == e_target.owner.team)) - return 0; + if ((e_target.team == this.owner.team) || (this.owner.team == e_target.owner.team)) + return false; - return 1; + return true; } #endif diff --git a/qcsrc/common/turrets/turret/tesla_weapon.qc b/qcsrc/common/turrets/turret/tesla_weapon.qc index a283a738f..a2d11d53c 100644 --- a/qcsrc/common/turrets/turret/tesla_weapon.qc +++ b/qcsrc/common/turrets/turret/tesla_weapon.qc @@ -4,7 +4,7 @@ #ifdef SVQC -entity toast(entity from, float range, float damage); +entity toast(entity actor, entity from, float range, float damage); SOUND(TeslaCoilTurretAttack_FIRE, W_Sound("electro_fire")); METHOD(TeslaCoilTurretAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) { bool isPlayer = IS_PLAYER(actor); @@ -26,7 +26,7 @@ METHOD(TeslaCoilTurretAttack, wr_think, void(entity thiswep, entity actor, .enti actor.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_MISSILES | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK; - entity t = toast(e,r,d); + entity t = toast(actor, e,r,d); remove(e); if (t == NULL) return; @@ -37,7 +37,7 @@ METHOD(TeslaCoilTurretAttack, wr_think, void(entity thiswep, entity actor, .enti for (int i = 0; i < 10; ++i) { d *= 0.75; r *= 0.85; - t = toast(t, r, d); + t = toast(actor, t, r, d); if (t == world) break; } @@ -51,8 +51,8 @@ METHOD(TeslaCoilTurretAttack, wr_think, void(entity thiswep, entity actor, .enti } } -entity toast(entity from, float range, float damage) -{SELFPARAM(); +entity toast(entity actor, entity from, float range, float damage) +{ entity e; entity etarget = world; float d,dd; @@ -65,7 +65,7 @@ entity toast(entity from, float range, float damage) { if ((e.railgunhit != 1) && (e != from)) { - r = turret_validate_target(self,e,self.target_validate_flags); + r = turret_validate_target(actor,e,actor.target_validate_flags); if (r > 0) { traceline(from.origin,0.5 * (e.absmin + e.absmax),MOVE_WORLDONLY,from); @@ -86,7 +86,7 @@ entity toast(entity from, float range, float damage) if (etarget) { te_csqc_lightningarc(from.origin,etarget.origin); - Damage(etarget, self, self, damage, DEATH_TURRET_TESLA.m_id, etarget.origin, '0 0 0'); + Damage(etarget, actor, actor, damage, DEATH_TURRET_TESLA.m_id, etarget.origin, '0 0 0'); etarget.railgunhit = 1; } diff --git a/qcsrc/common/turrets/util.qc b/qcsrc/common/turrets/util.qc index 0d178a5cb..805e13012 100644 --- a/qcsrc/common/turrets/util.qc +++ b/qcsrc/common/turrets/util.qc @@ -93,21 +93,21 @@ void FireImoBeam(entity this, vector start, vector end, vector smin, vector smax } #ifdef TURRET_DEBUG -void marker_think() -{SELFPARAM(); - if(self.cnt) - if(self.cnt < time) +void marker_think(entity this, ) +{ + if(this.cnt) + if(this.cnt < time) { - setthink(self, SUB_Remove); - self.nextthink = time; + setthink(this, SUB_Remove); + this.nextthink = time; return; } - self.frame += 1; - if(self.frame > 29) - self.frame = 0; + this.frame += 1; + if(this.frame > 29) + this.frame = 0; - self.nextthink = time; + this.nextthink = time; } void mark_error(vector where,float lifetime)