]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Kill more setself
authorTimePath <andrew.hardaker1995@gmail.com>
Sun, 22 May 2016 04:44:26 +0000 (14:44 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Sun, 22 May 2016 04:44:26 +0000 (14:44 +1000)
qcsrc/common/turrets/sv_turrets.qc
qcsrc/common/turrets/targettrigger.qc

index 2578c1e6dba117bc781648eb08e6bfa94f5aeccc..f8101535e242b6b82b698fb9d9a2eea11815ad32 100644 (file)
@@ -499,39 +499,33 @@ entity turret_projectile(Sound _snd, float _size, float _health, float _death, f
 ** and updated aim<->predict impact distance.
 **/
 void turret_do_updates(entity t_turret)
-{SELFPARAM();
-       vector enemy_pos;
-
-       setself(t_turret);
-
-       enemy_pos = real_origin(self.enemy);
+{
+       vector enemy_pos = real_origin(t_turret.enemy);
 
-       turret_tag_fire_update();
+       WITHSELF(t_turret, turret_tag_fire_update());
 
-       self.tur_shotdir_updated = v_forward;
-       self.tur_dist_enemy = vlen(self.tur_shotorg - enemy_pos);
-       self.tur_dist_aimpos = vlen(self.tur_shotorg - self.tur_aimpos);
+       t_turret.tur_shotdir_updated = v_forward;
+       t_turret.tur_dist_enemy = vlen(t_turret.tur_shotorg - enemy_pos);
+       t_turret.tur_dist_aimpos = vlen(t_turret.tur_shotorg - t_turret.tur_aimpos);
 
-       /*if((self.firecheck_flags & TFL_FIRECHECK_VERIFIED) && (self.enemy))
+       /*if((t_turret.firecheck_flags & TFL_FIRECHECK_VERIFIED) && (t_turret.enemy))
        {
-               oldpos = self.enemy.origin;
-               setorigin(self.enemy, self.tur_aimpos);
-               tracebox(self.tur_shotorg, '-1 -1 -1', '1 1 1', self.tur_shotorg + (self.tur_shotdir_updated * self.tur_dist_aimpos), MOVE_NORMAL,self);
-               setorigin(self.enemy, oldpos);
+               oldpos = t_turret.enemy.origin;
+               setorigin(t_turret.enemy, t_turret.tur_aimpos);
+               tracebox(t_turret.tur_shotorg, '-1 -1 -1', '1 1 1', t_turret.tur_shotorg + (t_turret.tur_shotdir_updated * t_turret.tur_dist_aimpos), MOVE_NORMAL,t_turret);
+               setorigin(t_turret.enemy, oldpos);
 
-               if(trace_ent == self.enemy)
-                       self.tur_dist_impact_to_aimpos = 0;
+               if(trace_ent == t_turret.enemy)
+                       t_turret.tur_dist_impact_to_aimpos = 0;
                else
-                       self.tur_dist_impact_to_aimpos = vlen(trace_endpos - self.tur_aimpos);
+                       t_turret.tur_dist_impact_to_aimpos = vlen(trace_endpos - t_turret.tur_aimpos);
        }
        else*/
-               tracebox(self.tur_shotorg, '-1 -1 -1','1 1 1', self.tur_shotorg + (self.tur_shotdir_updated * self.tur_dist_aimpos), MOVE_NORMAL,self);
-
-       self.tur_dist_impact_to_aimpos = vlen(trace_endpos - self.tur_aimpos) - (vlen(self.enemy.maxs - self.enemy.mins) * 0.5);
-       self.tur_impactent                       = trace_ent;
-       self.tur_impacttime                     = vlen(self.tur_shotorg - trace_endpos) / self.shot_speed;
+               tracebox(t_turret.tur_shotorg, '-1 -1 -1','1 1 1', t_turret.tur_shotorg + (t_turret.tur_shotdir_updated * t_turret.tur_dist_aimpos), MOVE_NORMAL,t_turret);
 
-       setself(this);
+       t_turret.tur_dist_impact_to_aimpos = vlen(trace_endpos - t_turret.tur_aimpos) - (vlen(t_turret.enemy.maxs - t_turret.enemy.mins) * 0.5);
+       t_turret.tur_impactent                   = trace_ent;
+       t_turret.tur_impacttime                 = vlen(t_turret.tur_shotorg - trace_endpos) / t_turret.shot_speed;
 }
 
 /**
index d3deda07019320256a88295d3b0d3f38b388f9a7..aa1322c4411b7d5d37339afa57e3b95afce5f884 100644 (file)
@@ -3,26 +3,13 @@ void turret_targettrigger_touch();
 
 void turret_targettrigger_touch()
 {SELFPARAM();
-    entity e;
-    if (self.cnt > time) return;
-    entity oldself = this;
-
-    e = find(world, targetname, self.target);
-    while (e)
-    {
-        if (e.turret_flags & TUR_FLAG_RECIEVETARGETS)
-        {
-            setself(e);
-            if(e.turret_addtarget)
-                e.turret_addtarget(other,oldself);
-        }
-
-        e = find(e, targetname, oldself.target);
-    }
-
-    oldself.cnt = time + 0.5;
-
-    setself(this);
+    if (this.cnt > time) return;
+    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));
+    });
+    this.cnt = time + 0.5;
 }
 
 /*QUAKED turret_targettrigger (.5 .5 .5) ?