]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Kill more setself
authorMario <mario@smbclan.net>
Sun, 22 May 2016 02:48:11 +0000 (12:48 +1000)
committerMario <mario@smbclan.net>
Sun, 22 May 2016 02:48:11 +0000 (12:48 +1000)
qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc
qcsrc/common/mutators/mutator/superspec/superspec.qc
qcsrc/common/triggers/platforms.qc
qcsrc/common/triggers/subs.qc
qcsrc/common/turrets/turret/phaser_weapon.qc
qcsrc/common/turrets/util.qc
qcsrc/common/turrets/util.qh
qcsrc/common/vehicles/sv_vehicles.qc
qcsrc/common/vehicles/vehicle/bumblebee.qc

index 726dd52d62cef40ef99ef882fccdb54f3a4e0268..d2e85cf68734ccd6aa5746566de67b7f20a74f44 100644 (file)
@@ -850,16 +850,13 @@ void ons_DelayedControlPoint_Setup(entity this)
        onslaught_updatelinks();
 
        // captureshield setup
-       ons_CaptureShield_Spawn(self, false);
+       ons_CaptureShield_Spawn(this, false);
 
-       CSQCMODEL_AUTOINIT(self);
+       CSQCMODEL_AUTOINIT(this);
 }
 
 void ons_ControlPoint_Setup(entity cp)
-{SELFPARAM();
-       // declarations
-       setself(cp); // for later usage with droptofloor()
-
+{
        // main setup
        cp.ons_worldcpnext = ons_worldcplist; // link control point into ons_worldcplist
        ons_worldcplist = cp;
@@ -892,14 +889,13 @@ void ons_ControlPoint_Setup(entity cp)
        {
                setorigin(cp, cp.origin + '0 0 20');
                cp.noalign = false;
-               setself(cp);
-               droptofloor();
+               WITHSELF(cp, droptofloor());
                cp.movetype = MOVETYPE_TOSS;
        }
 
        // waypointsprites
-       WaypointSprite_SpawnFixed(WP_Null, self.origin + CPGEN_WAYPOINT_OFFSET, self, sprite, RADARICON_NONE);
-       WaypointSprite_UpdateRule(self.sprite, self.team, SPRITERULE_TEAMPLAY);
+       WaypointSprite_SpawnFixed(WP_Null, cp.origin + CPGEN_WAYPOINT_OFFSET, cp, sprite, RADARICON_NONE);
+       WaypointSprite_UpdateRule(cp.sprite, cp.team, SPRITERULE_TEAMPLAY);
 
        InitializeEntity(cp, ons_DelayedControlPoint_Setup, INITPRIO_SETLOCATION);
 }
@@ -1098,10 +1094,9 @@ void onslaught_generator_touch()
 }
 
 void ons_GeneratorSetup(entity gen) // called when spawning a generator entity on the map as a spawnfunc
-{SELFPARAM();
+{
        // declarations
        int teamnumber = gen.team;
-       setself(gen); // for later usage with droptofloor()
 
        // main setup
        gen.ons_worldgeneratornext = ons_worldgeneratorlist; // link generator into ons_worldgeneratorlist
@@ -1131,14 +1126,13 @@ void ons_GeneratorSetup(entity gen) // called when spawning a generator entity o
        gen.colormap = 1024 + (teamnumber - 1) * 17;
 
        // generator placement
-       setself(gen);
-       droptofloor();
+       WITHSELF(gen, droptofloor());
 
        // waypointsprites
-       WaypointSprite_SpawnFixed(WP_Null, self.origin + CPGEN_WAYPOINT_OFFSET, self, sprite, RADARICON_NONE);
-       WaypointSprite_UpdateRule(self.sprite, self.team, SPRITERULE_TEAMPLAY);
-       WaypointSprite_UpdateMaxHealth(self.sprite, self.max_health);
-       WaypointSprite_UpdateHealth(self.sprite, self.health);
+       WaypointSprite_SpawnFixed(WP_Null, gen.origin + CPGEN_WAYPOINT_OFFSET, gen, sprite, RADARICON_NONE);
+       WaypointSprite_UpdateRule(gen.sprite, gen.team, SPRITERULE_TEAMPLAY);
+       WaypointSprite_UpdateMaxHealth(gen.sprite, gen.max_health);
+       WaypointSprite_UpdateHealth(gen.sprite, gen.health);
 
        InitializeEntity(gen, ons_DelayedGeneratorSetup, INITPRIO_SETLOCATION);
 }
index 5471bcbae06fac3e3e8422442d61f98136ffa908..b3f39dc3d8f075edd102d71c19d12000e8b1dbfd 100644 (file)
@@ -104,50 +104,45 @@ MUTATOR_HOOKFUNCTION(superspec, ItemTouch)
        FOREACH_CLIENT(true, LAMBDA(
                if(!IS_SPEC(it) && !IS_OBSERVER(it))
                        continue;
-               setself(it);
-               if(self.superspec_flags & SSF_ITEMMSG)
-                       if(superspec_filteritem(self, _item))
+               if(it.superspec_flags & SSF_ITEMMSG)
+                       if(superspec_filteritem(it, _item))
                        {
-                               if(self.superspec_flags & SSF_VERBOSE)
-                                       superspec_msg("", "", self, sprintf("Player %s^7 just picked up ^3%s\n", other.netname, _item.netname), 1);
+                               if(it.superspec_flags & SSF_VERBOSE)
+                                       superspec_msg("", "", it, sprintf("Player %s^7 just picked up ^3%s\n", other.netname, _item.netname), 1);
                                else
-                                       superspec_msg("", "", self, sprintf("Player %s^7 just picked up ^3%s\n^8(%s^8)\n", other.netname, _item.netname, _item.classname), 1);
-                               if((self.autospec_flags & ASF_SSIM) && self.enemy != other)
+                                       superspec_msg("", "", it, sprintf("Player %s^7 just picked up ^3%s\n^8(%s^8)\n", other.netname, _item.netname, _item.classname), 1);
+                               if((it.autospec_flags & ASF_SSIM) && it.enemy != other)
                                {
-                                       superspec_Spectate(other);
-
-                                       setself(this);
+                                       WITHSELF(it, superspec_Spectate(other));
                                        return MUT_ITEMTOUCH_CONTINUE;
                                }
                        }
 
-               if((self.autospec_flags & ASF_SHIELD && _item.invincible_finished) ||
-                       (self.autospec_flags & ASF_STRENGTH && _item.strength_finished) ||
-                       (self.autospec_flags & ASF_MEGA_AR && _item.itemdef == ITEM_ArmorMega) ||
-                       (self.autospec_flags & ASF_MEGA_HP && _item.itemdef == ITEM_HealthMega) ||
-                       (self.autospec_flags & ASF_FLAG_GRAB && _item.classname == "item_flag_team"))
+               if((it.autospec_flags & ASF_SHIELD && _item.invincible_finished) ||
+                       (it.autospec_flags & ASF_STRENGTH && _item.strength_finished) ||
+                       (it.autospec_flags & ASF_MEGA_AR && _item.itemdef == ITEM_ArmorMega) ||
+                       (it.autospec_flags & ASF_MEGA_HP && _item.itemdef == ITEM_HealthMega) ||
+                       (it.autospec_flags & ASF_FLAG_GRAB && _item.classname == "item_flag_team"))
                {
 
-                       if((self.enemy != other) || IS_OBSERVER(self))
+                       if((it.enemy != other) || IS_OBSERVER(it))
                        {
-                               if(self.autospec_flags & ASF_OBSERVER_ONLY && !IS_OBSERVER(self))
+                               if(it.autospec_flags & ASF_OBSERVER_ONLY && !IS_OBSERVER(it))
                                {
-                                       if(self.superspec_flags & SSF_VERBOSE)
-                                               superspec_msg("", "", self, sprintf("^8Ignored that ^7%s^8 grabbed %s^8 since the observer_only option is ON\n", other.netname, _item.netname), 2);
+                                       if(it.superspec_flags & SSF_VERBOSE)
+                                               superspec_msg("", "", it, sprintf("^8Ignored that ^7%s^8 grabbed %s^8 since the observer_only option is ON\n", other.netname, _item.netname), 2);
                                }
                                else
                                {
-                                       if(self.autospec_flags & ASF_SHOWWHAT)
-                                               superspec_msg("", "", self, sprintf("^7Following %s^7 due to picking up %s\n", other.netname, _item.netname), 2);
+                                       if(it.autospec_flags & ASF_SHOWWHAT)
+                                               superspec_msg("", "", it, sprintf("^7Following %s^7 due to picking up %s\n", other.netname, _item.netname), 2);
 
-                                       superspec_Spectate(other);
+                                       WITHSELF(it, superspec_Spectate(other));
                                }
                        }
                }
        ));
 
-       setself(this);
-
        return MUT_ITEMTOUCH_CONTINUE;
 }
 
@@ -442,17 +437,15 @@ MUTATOR_HOOKFUNCTION(superspec, PlayerDies)
 {
     SELFPARAM();
        FOREACH_CLIENT(IS_SPEC(it), LAMBDA(
-               setself(it);
-               if(self.autospec_flags & ASF_FOLLOWKILLER && IS_PLAYER(frag_attacker) && self.enemy == frag_target)
+               if(it.autospec_flags & ASF_FOLLOWKILLER && IS_PLAYER(frag_attacker) && it.enemy == frag_target)
                {
-                       if(self.autospec_flags & ASF_SHOWWHAT)
-                               superspec_msg("", "", self, sprintf("^7Following %s^7 due to followkiller\n", frag_attacker.netname), 2);
+                       if(it.autospec_flags & ASF_SHOWWHAT)
+                               superspec_msg("", "", it, sprintf("^7Following %s^7 due to followkiller\n", frag_attacker.netname), 2);
 
-                       superspec_Spectate(frag_attacker);
+                       WITHSELF(it, superspec_Spectate(frag_attacker));
                }
        ));
 
-       setself(frag_target);
        return false;
 }
 
index 7429f2b3550bfbf95db857da277f7b9f45d8d5fc..710a6db3f573cf44d6eb54c11d397b4aa3bd74eb 100644 (file)
@@ -108,11 +108,10 @@ void plat_center_touch()
                return;
 #endif
 
-       setself(self.enemy);
-       if (self.state == 2)
-               plat_go_up ();
-       else if (self.state == 1)
-               self.SUB_NEXTTHINK = self.SUB_LTIME + 1;
+       if (self.enemy.state == 2)
+               WITHSELF(self.enemy, plat_go_up());
+       else if (self.enemy.state == 1)
+               self.enemy.SUB_NEXTTHINK = self.enemy.SUB_LTIME + 1;
 }
 
 void plat_outside_touch()
@@ -128,9 +127,8 @@ void plat_outside_touch()
                return;
 #endif
 
-       setself(self.enemy);
-       if (self.state == 1)
-               plat_go_down ();
+       if (self.enemy.state == 1)
+               WITHSELF(self.enemy, plat_go_down());
 }
 
 void plat_trigger_use(entity this, entity actor, entity trigger)
index 7d6ea9de981ce038ea9d9603e6cd1258e00946f1..c202d7125064e3931741cc3fc12958c83bcee3ac 100644 (file)
@@ -93,7 +93,6 @@ void SUB_CalcMoveDone ()
 .float platmovetype_turn;
 void SUB_CalcMove_controller_think ()
 {SELFPARAM();
-       entity oldself;
        float traveltime;
        float phasepos;
        float nexttick;
@@ -143,11 +142,10 @@ void SUB_CalcMove_controller_think ()
        else
        {
                // derivative: delta + 2 * delta2 (e.g. for angle positioning)
-               oldself = self;
-               self.owner.SUB_THINK = self.think1;
-               setself(self.owner);
-               remove(oldself);
-               self.SUB_THINK();
+               entity own = self.owner;
+               own.SUB_THINK = self.think1;
+               remove(self);
+               WITHSELF(own, own.SUB_THINK());
        }
 }
 
@@ -238,9 +236,7 @@ void SUB_CalcMove_Bezier (vector tcontrol, vector tdest, float tspeedtype, float
        self.SUB_NEXTTHINK = self.SUB_LTIME + traveltime;
 
        // invoke controller
-       setself(controller);
-       self.think();
-       setself(self.owner);
+       WITHSELF(controller, controller.think());
 }
 
 void SUB_CalcMove (vector tdest, float tspeedtype, float tspeed, void() func)
index 440bdf6a7299a6271363f3968b03a55d258d0db5..3adc6c6898557c37c19ec2d5ee599c45394a7e89 100644 (file)
@@ -76,8 +76,7 @@ void beam_think()
     self.nextthink = time + self.ticrate;
 
     self.owner.attack_finished_single[0] = time + frametime;
-    setself(self.owner);
-    FireImoBeam (   self.tur_shotorg,
+    FireImoBeam (   self.owner, self.tur_shotorg,
                     self.tur_shotorg + self.tur_shotdir_updated * self.target_range,
                     '-1 -1 -1' * self.shot_radius,
                     '1 1 1' * self.shot_radius,
@@ -85,7 +84,6 @@ void beam_think()
                     this.shot_dmg,
                     0.75,
                     DEATH_TURRET_PHASER.m_id);
-    setself(this);
     self.scale = vlen(self.owner.tur_shotorg - trace_endpos) / 256;
 
 }
index 17f42c8115edacd9b24b028c9a1a07ee578bb440..749bff94106d0b53439563802c0dc35b7be9b5bb 100644 (file)
@@ -20,10 +20,10 @@ float turret_tag_fire_update()
 /*
 * Railgun-like beam, but has thickness and suppots slowing of target
 */
-void FireImoBeam (vector start, vector end, vector smin, vector smax,
+void FireImoBeam(entity this, vector start, vector end, vector smin, vector smax,
                                  float bforce, float f_dmg, float f_velfactor, int deathtype)
 
-{SELFPARAM();
+{
        vector hitloc, force, endpoint, dir;
        entity ent;
 
@@ -37,7 +37,7 @@ void FireImoBeam (vector start, vector end, vector smin, vector smax,
        // note down which entities were hit so we can damage them later
        while (1)
        {
-               tracebox(start, smin, smax, end, false, self);
+               tracebox(start, smin, smax, end, false, this);
 
                // if it is world we can't hurt it so stop now
                if (trace_ent == world || trace_fraction == 1)
@@ -81,7 +81,7 @@ void FireImoBeam (vector start, vector end, vector smin, vector smax,
                // apply the damage
                if (ent.takedamage)
                {
-                       Damage (ent, self, self, f_dmg, deathtype, hitloc, force);
+                       Damage (ent, this, this, f_dmg, deathtype, hitloc, force);
                        ent.velocity = ent.velocity * f_velfactor;
                        //ent.alpha = 0.25 + random() * 0.75;
                }
index dd9efec6b2b9f3b668c6cdf18de3f6598bb3509c..536af8703b9a7321eff1f0c410684865e8e06189 100644 (file)
@@ -7,6 +7,6 @@ float turret_tag_fire_update();
 vector shortangle_vxy(vector ang1, vector ang2);
 vector angleofs(entity from, entity to);
 vector angleofs3(vector from, vector from_a, entity to);
-void FireImoBeam (vector start, vector end, vector smin, vector smax, float bforce, float f_dmg, float f_velfactor, float deathtype);
+void FireImoBeam(entity this, vector start, vector end, vector smin, vector smax, float bforce, float f_dmg, float f_velfactor, float deathtype);
 
 #endif
index fc44613e5d111cbafd02f69700f9552b09fb7678..caa82e880217590208284bc7483f711add05ebd5 100644 (file)
@@ -478,46 +478,43 @@ void vehicles_showwp_goaway()
 
 void vehicles_showwp()
 {SELFPARAM();
-       entity oldself = world;
        vector rgb;
 
-       if(self.cnt)
+       entity ent = this;
+
+       if(ent.cnt)
        {
-               self.think        = vehicles_return;
-               self.nextthink  = self.cnt;
+               ent.think = vehicles_return;
+               ent.nextthink = ent.cnt;
        }
        else
        {
-               self.think        = vehicles_return;
-               self.nextthink  = time +1;
-
-               oldself = self;
-               setself(spawn());
-               setmodel(self, MDL_Null);
-               self.team = oldself.wp00.team;
-               self.wp00 = oldself.wp00;
-               setorigin(self, oldself.wp00.pos1);
-
-               self.nextthink = time + 5;
-               self.think = vehicles_showwp_goaway;
+               ent.think         = vehicles_return;
+               ent.nextthink  = time + 1;
+
+               ent = spawn();
+               setmodel(ent, MDL_Null);
+               ent.team = this.wp00.team;
+               ent.wp00 = this.wp00;
+               setorigin(ent, this.wp00.pos1);
+
+               ent.nextthink = time + 5;
+               ent.think = vehicles_showwp_goaway;
        }
 
-       if(teamplay && self.team)
-               rgb = Team_ColorRGB(self.team);
+       if(teamplay && ent.team)
+               rgb = Team_ColorRGB(ent.team);
        else
                rgb = '1 1 1';
-       entity wp = WaypointSprite_Spawn(WP_Vehicle, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_Vehicle);
+       entity wp = WaypointSprite_Spawn(WP_Vehicle, 0, 0, ent, '0 0 64', world, 0, ent, waypointsprite_attached, true, RADARICON_Vehicle);
        wp.colormod = rgb;
-       if(self.waypointsprite_attached)
+       if(ent.waypointsprite_attached)
        {
-               WaypointSprite_UpdateRule(self.waypointsprite_attached, self.wp00.team, SPRITERULE_DEFAULT);
+               WaypointSprite_UpdateRule(ent.waypointsprite_attached, ent.wp00.team, SPRITERULE_DEFAULT);
                if(this == NULL)
-                       WaypointSprite_UpdateBuildFinished(self.waypointsprite_attached, self.nextthink);
-               WaypointSprite_Ping(self.waypointsprite_attached);
+                       WaypointSprite_UpdateBuildFinished(ent.waypointsprite_attached, ent.nextthink);
+               WaypointSprite_Ping(ent.waypointsprite_attached);
        }
-
-       if(this)
-               setself(this);
 }
 
 void vehicles_setreturn(entity veh)
index aa69550a2be32d6d85622c429f26c63bc4f3c606..724d23d74af68ab1a776e0e0dd2b848378a924d6 100644 (file)
@@ -744,7 +744,6 @@ METHOD(Bumblebee, vr_think, void(Bumblebee thisveh, entity instance))
 
     if(!self.owner)
     {
-        entity oldself = self;
         if(self.gunner1)
         {
                entity e = self.gunner1;