]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into TimePath/global_self
authorTimePath <andrew.hardaker1995@gmail.com>
Sat, 5 Sep 2015 02:07:13 +0000 (12:07 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Sat, 5 Sep 2015 02:07:13 +0000 (12:07 +1000)
# Conflicts:
# qcsrc/server/mutators/mutator_instagib.qc
# qcsrc/server/mutators/mutator_instagib_items.qc

256 files changed:
qcsrc/client/announcer.qc
qcsrc/client/command/cl_cmd.qc
qcsrc/client/controlpoint.qc
qcsrc/client/csqcmodel_hooks.qc
qcsrc/client/damage.qc
qcsrc/client/generator.qc
qcsrc/client/gibs.qc
qcsrc/client/hook.qc
qcsrc/client/hud.qc
qcsrc/client/main.qc
qcsrc/client/modeleffects.qc
qcsrc/client/mutators/events.qh
qcsrc/client/player_skeleton.qc
qcsrc/client/rubble.qc
qcsrc/client/scoreboard.qc
qcsrc/client/teamradar.qc
qcsrc/client/tuba.qc
qcsrc/client/view.qc
qcsrc/client/wall.qc
qcsrc/client/weapons/projectile.qc
qcsrc/common/buffs.qh
qcsrc/common/csqcmodel_settings.qh
qcsrc/common/effects.qc
qcsrc/common/items/inventory.qh
qcsrc/common/minigames/cl_minigames.qc
qcsrc/common/minigames/cl_minigames_hud.qc
qcsrc/common/minigames/minigame/nmm.qc
qcsrc/common/minigames/minigame/pong.qc
qcsrc/common/minigames/sv_minigames.qc
qcsrc/common/monsters/monster/mage.qc
qcsrc/common/monsters/monster/shambler.qc
qcsrc/common/monsters/monster/spider.qc
qcsrc/common/monsters/monster/wyvern.qc
qcsrc/common/monsters/monster/zombie.qc
qcsrc/common/monsters/spawn.qc
qcsrc/common/monsters/sv_monsters.qc
qcsrc/common/movetypes/follow.qc
qcsrc/common/movetypes/movetypes.qc
qcsrc/common/movetypes/push.qc
qcsrc/common/movetypes/step.qc
qcsrc/common/movetypes/toss.qc
qcsrc/common/movetypes/walk.qc
qcsrc/common/mutators/mutator/casings.qc
qcsrc/common/mutators/mutator/damagetext.qc
qcsrc/common/mutators/mutator/itemstime.qc
qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc
qcsrc/common/nades.qc
qcsrc/common/net_notice.qc
qcsrc/common/notifications.qc
qcsrc/common/physics.qc
qcsrc/common/triggers/func/bobbing.qc
qcsrc/common/triggers/func/breakable.qc
qcsrc/common/triggers/func/button.qc
qcsrc/common/triggers/func/conveyor.qc
qcsrc/common/triggers/func/door.qc
qcsrc/common/triggers/func/door_rotating.qc
qcsrc/common/triggers/func/door_secret.qc
qcsrc/common/triggers/func/fourier.qc
qcsrc/common/triggers/func/ladder.qc
qcsrc/common/triggers/func/pendulum.qc
qcsrc/common/triggers/func/plat.qc
qcsrc/common/triggers/func/pointparticles.qc
qcsrc/common/triggers/func/rainsnow.qc
qcsrc/common/triggers/func/rotating.qc
qcsrc/common/triggers/func/stardust.qc
qcsrc/common/triggers/func/train.qc
qcsrc/common/triggers/func/vectormamamam.qc
qcsrc/common/triggers/misc/corner.qc
qcsrc/common/triggers/misc/follow.qc
qcsrc/common/triggers/misc/laser.qc
qcsrc/common/triggers/misc/teleport_dest.qc
qcsrc/common/triggers/platforms.qc
qcsrc/common/triggers/subs.qc
qcsrc/common/triggers/subs.qh
qcsrc/common/triggers/target/changelevel.qc
qcsrc/common/triggers/target/location.qc
qcsrc/common/triggers/target/music.qc
qcsrc/common/triggers/target/spawn.qc
qcsrc/common/triggers/target/speaker.qc
qcsrc/common/triggers/target/voicescript.qc
qcsrc/common/triggers/teleporters.qc
qcsrc/common/triggers/trigger/counter.qc
qcsrc/common/triggers/trigger/delay.qc
qcsrc/common/triggers/trigger/disablerelay.qc
qcsrc/common/triggers/trigger/flipflop.qc
qcsrc/common/triggers/trigger/gamestart.qc
qcsrc/common/triggers/trigger/gravity.qc
qcsrc/common/triggers/trigger/heal.qc
qcsrc/common/triggers/trigger/hurt.qc
qcsrc/common/triggers/trigger/impulse.qc
qcsrc/common/triggers/trigger/jumppads.qc
qcsrc/common/triggers/trigger/keylock.qc
qcsrc/common/triggers/trigger/magicear.qc
qcsrc/common/triggers/trigger/monoflop.qc
qcsrc/common/triggers/trigger/multi.qc
qcsrc/common/triggers/trigger/multivibrator.qc
qcsrc/common/triggers/trigger/relay.qc
qcsrc/common/triggers/trigger/relay_activators.qc
qcsrc/common/triggers/trigger/relay_if.qc
qcsrc/common/triggers/trigger/relay_teamcheck.qc
qcsrc/common/triggers/trigger/secret.qc
qcsrc/common/triggers/trigger/swamp.qc
qcsrc/common/triggers/trigger/teleport.qc
qcsrc/common/triggers/trigger/viewloc.qc
qcsrc/common/triggers/triggers.qc
qcsrc/common/turrets/checkpoint.qc
qcsrc/common/turrets/cl_turrets.qc
qcsrc/common/turrets/sv_turrets.qc
qcsrc/common/turrets/targettrigger.qc
qcsrc/common/turrets/unit/ewheel.qc
qcsrc/common/turrets/unit/flac.qc
qcsrc/common/turrets/unit/fusionreactor.qc
qcsrc/common/turrets/unit/hellion.qc
qcsrc/common/turrets/unit/hk.qc
qcsrc/common/turrets/unit/machinegun.qc
qcsrc/common/turrets/unit/mlrs.qc
qcsrc/common/turrets/unit/phaser.qc
qcsrc/common/turrets/unit/plasma.qc
qcsrc/common/turrets/unit/plasma_dual.qc
qcsrc/common/turrets/unit/tesla.qc
qcsrc/common/turrets/unit/walker.qc
qcsrc/common/turrets/util.qc
qcsrc/common/util-post.qh
qcsrc/common/util.qc
qcsrc/common/vehicles/cl_vehicles.qc
qcsrc/common/vehicles/sv_vehicles.qc
qcsrc/common/vehicles/unit/bumblebee.qc
qcsrc/common/vehicles/unit/racer.qc
qcsrc/common/vehicles/unit/raptor.qc
qcsrc/common/vehicles/unit/spiderbot.qc
qcsrc/common/viewloc.qc
qcsrc/common/weapons/weapon/arc.qc
qcsrc/common/weapons/weapon/blaster.qc
qcsrc/common/weapons/weapon/crylink.qc
qcsrc/common/weapons/weapon/devastator.qc
qcsrc/common/weapons/weapon/electro.qc
qcsrc/common/weapons/weapon/fireball.qc
qcsrc/common/weapons/weapon/hagar.qc
qcsrc/common/weapons/weapon/hlac.qc
qcsrc/common/weapons/weapon/hmg.qc
qcsrc/common/weapons/weapon/hook.qc
qcsrc/common/weapons/weapon/machinegun.qc
qcsrc/common/weapons/weapon/minelayer.qc
qcsrc/common/weapons/weapon/mortar.qc
qcsrc/common/weapons/weapon/porto.qc
qcsrc/common/weapons/weapon/rifle.qc
qcsrc/common/weapons/weapon/rpc.qc
qcsrc/common/weapons/weapon/seeker.qc
qcsrc/common/weapons/weapon/shockwave.qc
qcsrc/common/weapons/weapon/shotgun.qc
qcsrc/common/weapons/weapon/tuba.qc
qcsrc/common/weapons/weapon/vaporizer.qc
qcsrc/common/weapons/weapon/vortex.qc
qcsrc/csqcmodellib/cl_model.qc
qcsrc/csqcmodellib/cl_player.qc
qcsrc/csqcmodellib/interpolate.qc
qcsrc/csqcmodellib/sv_model.qc
qcsrc/csqcmodellib/sv_model.qh
qcsrc/lib/Defer.qh
qcsrc/lib/Log.qh
qcsrc/server/anticheat.qc
qcsrc/server/bot/aim.qc
qcsrc/server/bot/bot.qc
qcsrc/server/bot/havocbot/havocbot.qc
qcsrc/server/bot/havocbot/role_keyhunt.qc
qcsrc/server/bot/havocbot/roles.qc
qcsrc/server/bot/navigation.qc
qcsrc/server/bot/scripting.qc
qcsrc/server/bot/waypoints.qc
qcsrc/server/cheats.qc
qcsrc/server/cl_client.qc
qcsrc/server/cl_impulse.qc
qcsrc/server/cl_player.qc
qcsrc/server/command/cmd.qc
qcsrc/server/command/common.qc
qcsrc/server/command/radarmap.qc
qcsrc/server/command/sv_cmd.qc
qcsrc/server/command/vote.qc
qcsrc/server/controlpoint.qc
qcsrc/server/ent_cs.qc
qcsrc/server/g_damage.qc
qcsrc/server/g_hook.qc
qcsrc/server/g_models.qc
qcsrc/server/g_subs.qc
qcsrc/server/g_violence.qc
qcsrc/server/g_world.qc
qcsrc/server/generator.qc
qcsrc/server/ipban.qc
qcsrc/server/item_key.qc
qcsrc/server/mapvoting.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/movelib.qc
qcsrc/server/mutators/events.qh
qcsrc/server/mutators/gamemode_assault.qc
qcsrc/server/mutators/gamemode_ca.qc
qcsrc/server/mutators/gamemode_ctf.qc
qcsrc/server/mutators/gamemode_cts.qc
qcsrc/server/mutators/gamemode_domination.qc
qcsrc/server/mutators/gamemode_freezetag.qc
qcsrc/server/mutators/gamemode_invasion.qc
qcsrc/server/mutators/gamemode_keepaway.qc
qcsrc/server/mutators/gamemode_keyhunt.qc
qcsrc/server/mutators/gamemode_lms.qc
qcsrc/server/mutators/gamemode_nexball.qc
qcsrc/server/mutators/gamemode_onslaught.qc
qcsrc/server/mutators/gamemode_race.qc
qcsrc/server/mutators/gamemode_tdm.qc
qcsrc/server/mutators/mutator_bloodloss.qc
qcsrc/server/mutators/mutator_buffs.qc
qcsrc/server/mutators/mutator_campcheck.qc
qcsrc/server/mutators/mutator_dodging.qc
qcsrc/server/mutators/mutator_instagib.qc
qcsrc/server/mutators/mutator_melee_only.qc
qcsrc/server/mutators/mutator_midair.qc
qcsrc/server/mutators/mutator_multijump.qc
qcsrc/server/mutators/mutator_nades.qc
qcsrc/server/mutators/mutator_new_toys.qc
qcsrc/server/mutators/mutator_nix.qc
qcsrc/server/mutators/mutator_overkill.qc
qcsrc/server/mutators/mutator_physical_items.qc
qcsrc/server/mutators/mutator_pinata.qc
qcsrc/server/mutators/mutator_spawn_near_teammate.qc
qcsrc/server/mutators/mutator_superspec.qc
qcsrc/server/mutators/mutator_touchexplode.qc
qcsrc/server/mutators/mutator_vampirehook.qc
qcsrc/server/mutators/sandbox.qc
qcsrc/server/pathlib/debug.qc
qcsrc/server/pathlib/main.qc
qcsrc/server/pathlib/movenode.qc
qcsrc/server/pathlib/path_waypoint.qc
qcsrc/server/pathlib/utility.qc
qcsrc/server/playerdemo.qc
qcsrc/server/portals.qc
qcsrc/server/race.qc
qcsrc/server/round_handler.qc
qcsrc/server/scores.qc
qcsrc/server/spawnpoints.qc
qcsrc/server/steerlib.qc
qcsrc/server/sv_main.qc
qcsrc/server/t_items.qc
qcsrc/server/t_quake.qc
qcsrc/server/t_quake3.qc
qcsrc/server/teamplay.qc
qcsrc/server/weapons/accuracy.qc
qcsrc/server/weapons/common.qc
qcsrc/server/weapons/csqcprojectile.qc
qcsrc/server/weapons/selection.qc
qcsrc/server/weapons/spawning.qc
qcsrc/server/weapons/throwing.qc
qcsrc/server/weapons/tracing.qc
qcsrc/server/weapons/weaponsystem.qc
qcsrc/server/weapons/weaponsystem.qh
qcsrc/warpzonelib/client.qc
qcsrc/warpzonelib/common.qc
qcsrc/warpzonelib/server.qc
qcsrc/warpzonelib/util_server.qc

index 19e51cedc6b98f2611c274476fba9cc0430300d2..8f477171cec19286cf96efafc40b5517f97fdfe4 100644 (file)
@@ -8,7 +8,7 @@
 bool announcer_1min;
 bool announcer_5min;
 void Announcer_Countdown()
-{
+{SELFPARAM();
        float starttime = getstatf(STAT_GAMESTARTTIME);
        float roundstarttime = getstatf(STAT_ROUNDSTARTTIME);
        if(roundstarttime == -1)
index 2d6093868cc1ea496e5822880e0c69f5900c4f00..8b0a33e6c2c77a951e038cc0c20b4db167dccd02 100644 (file)
@@ -21,7 +21,7 @@
 #include "../../common/command/generic.qh"
 
 void DrawDebugModel()
-{
+{SELFPARAM();
        if(time - floor(time) > 0.5)
        {
                PolyDrawModel(self);
index 3b8901cf37695abafb9873d6daf55fd561c14a0b..83ee0316bdbda31b3cda8ac612b3d1577743004b 100644 (file)
@@ -35,7 +35,7 @@ void cpicon_precache()
 }
 
 void cpicon_draw()
-{
+{SELFPARAM();
        if(time < self.move_time) { return; }
 
        if(self.cp_bob_dmg_z > 0)
@@ -99,7 +99,7 @@ void cpicon_draw()
 }
 
 void cpicon_damage(float hp)
-{
+{SELFPARAM();
        if(!self.iscaptured) { return; }
 
        if(hp < self.max_health * 0.25)
@@ -121,7 +121,7 @@ void cpicon_damage(float hp)
 }
 
 void cpicon_construct()
-{
+{SELFPARAM();
        self.netname = "Control Point Icon";
 
        setmodel(self, "models/onslaught/controlpoint_icon.md3");
@@ -155,7 +155,7 @@ void cpicon_construct()
 
 .vector glowmod;
 void cpicon_changeteam()
-{
+{SELFPARAM();
        if(self.team)
        {
                self.glowmod = Team_ColorRGB(self.team - 1);
@@ -171,7 +171,7 @@ void cpicon_changeteam()
 }
 
 void ent_cpicon()
-{
+{SELFPARAM();
        int sf = ReadByte();
 
        if(sf & CPSF_SETUP)
index d8c44d660c022dc49d5cf5f481fd4aedfde2bc94..7e36cabec6ee48cc7ae88127f15e2b81d3785c89 100644 (file)
@@ -31,7 +31,7 @@ void CSQCModel_Hook_PreDraw(bool isplayer);
 .int lodmodelindex1;
 .int lodmodelindex2;
 void CSQCPlayer_LOD_Apply(void)
-{
+{SELFPARAM();
        // LOD model loading
        if(self.lodmodelindex0 != self.modelindex)
        {
@@ -120,14 +120,14 @@ int forceplayermodels_goodmodelindex;
 .vector old_glowmod;
 
 void CSQCPlayer_ModelAppearance_PreUpdate(void)
-{
+{SELFPARAM();
        self.model = self.forceplayermodels_savemodel;
        self.modelindex = self.forceplayermodels_savemodelindex;
        self.skin = self.forceplayermodels_saveskin;
        self.colormap = self.forceplayermodels_savecolormap;
 }
 void CSQCPlayer_ModelAppearance_PostUpdate(void)
-{
+{SELFPARAM();
        self.forceplayermodels_savemodel = self.model;
        self.forceplayermodels_savemodelindex = self.modelindex;
        self.forceplayermodels_saveskin = self.skin;
@@ -142,7 +142,7 @@ void CSQCPlayer_ModelAppearance_PostUpdate(void)
        }
 }
 void CSQCPlayer_ModelAppearance_Apply(bool islocalplayer)
-{
+{SELFPARAM();
        // FORCEMODEL
        // which one is ALWAYS good?
        if (!forceplayermodels_goodmodel)
@@ -325,7 +325,7 @@ void CSQCPlayer_ModelAppearance_Apply(bool islocalplayer)
 
 #define IS_DEAD_FRAME(f) ((f) == 0 || (f) == 1)
 void CSQCPlayer_FallbackFrame_PreUpdate(void)
-{
+{SELFPARAM();
        self.frame = self.csqcmodel_saveframe;
        self.frame2 = self.csqcmodel_saveframe2;
 #ifdef CSQCMODEL_HAVE_TWO_FRAMES
@@ -334,7 +334,7 @@ void CSQCPlayer_FallbackFrame_PreUpdate(void)
 #endif
 }
 void CSQCPlayer_FallbackFrame_PostUpdate(bool isnew)
-{
+{SELFPARAM();
        self.csqcmodel_saveframe = self.frame;
        self.csqcmodel_saveframe2 = self.frame2;
 #ifdef CSQCMODEL_HAVE_TWO_FRAMES
@@ -360,11 +360,11 @@ void CSQCPlayer_FallbackFrame_PostUpdate(bool isnew)
        self.csqcmodel_isdead = IS_DEAD_FRAME(self.frame);
 }
 void CSQCPlayer_AnimDecide_PostUpdate(bool isnew)
-{
+{SELFPARAM();
        self.csqcmodel_isdead = !!(self.anim_state & (ANIMSTATE_DEAD1 | ANIMSTATE_DEAD2));
 }
 int CSQCPlayer_FallbackFrame(int f)
-{
+{SELFPARAM();
        if(frameduration(self.modelindex, f) > 0)
                return f; // goooooood
        if(frameduration(self.modelindex, 1) <= 0)
@@ -384,7 +384,7 @@ int CSQCPlayer_FallbackFrame(int f)
        return f;
 }
 void CSQCPlayer_FallbackFrame_Apply(void)
-{
+{SELFPARAM();
        self.frame = CSQCPlayer_FallbackFrame(self.frame);
        self.frame2 = CSQCPlayer_FallbackFrame(self.frame2);
 #ifdef CSQCMODEL_HAVE_TWO_FRAMES
@@ -398,7 +398,7 @@ void CSQCPlayer_FallbackFrame_Apply(void)
 .int tag_entity_lastmodelindex;
 .int tag_index;
 void CSQCModel_AutoTagIndex_Apply(void)
-{
+{SELFPARAM();
        if(self.tag_entity && wasfreed(self.tag_entity))
                self.tag_entity = world;
 
@@ -423,10 +423,7 @@ void CSQCModel_AutoTagIndex_Apply(void)
                // recursive predraw call to fix issues with forcemodels and LOD if bone indexes mismatch
                if(self.tag_entity.classname == "csqcmodel")
                {
-                       entity oldself = self;
-                       self = self.tag_entity;
-                       CSQCModel_Hook_PreDraw((self.entnum >= 1 && self.entnum <= maxclients));
-                       self = oldself;
+                       WITH(entity, self, self.tag_entity, CSQCModel_Hook_PreDraw((self.entnum >= 1 && self.entnum <= maxclients)));
                }
 
                if(self.tag_entity.modelindex != self.tag_entity_lastmodelindex)
@@ -499,13 +496,13 @@ const int MF_TRACER3 = 128; // purple trail
 .int csqcmodel_effects;
 .int csqcmodel_modelflags;
 void CSQCModel_Effects_PreUpdate(void)
-{
+{SELFPARAM();
        self.effects = self.csqcmodel_effects;
        self.modelflags = self.csqcmodel_modelflags;
 }
 void Reset_ArcBeam(void);
 void CSQCModel_Effects_PostUpdate(void)
-{
+{SELFPARAM();
        if (self == csqcplayer) {
                if (self.csqcmodel_teleported) {
                        Reset_ArcBeam();
@@ -520,7 +517,7 @@ void CSQCModel_Effects_PostUpdate(void)
 }
 .int snd_looping;
 void CSQCModel_Effects_Apply(void)
-{
+{SELFPARAM();
        int eff = self.csqcmodel_effects & ~CSQCMODEL_EF_RESPAWNGHOST;
 
        self.renderflags &= ~(RF_DEPTHHACK | RF_ADDITIVE | RF_FULLBRIGHT | EF_NOSHADOW | RF_USEAXIS);
@@ -625,7 +622,7 @@ void CSQCPlayer_Precache()
 .int anim_saveframe2time;
 .int anim_prev_pmove_flags;
 void CSQCModel_Hook_PreDraw(bool isplayer)
-{
+{SELFPARAM();
        if(self.csqcmodel_predraw_run == framecount)
                return;
        self.csqcmodel_predraw_run = framecount;
@@ -724,7 +721,7 @@ void CSQCModel_Hook_PreDraw(bool isplayer)
 }
 
 void CSQCModel_Hook_PreUpdate(bool isnew, bool isplayer, bool islocalplayer)
-{
+{SELFPARAM();
        // interpolate v_angle
        self.iflags |= IFLAG_V_ANGLE_X;
        // revert to values from server
@@ -738,7 +735,7 @@ void CSQCModel_Hook_PreUpdate(bool isnew, bool isplayer, bool islocalplayer)
 }
 
 void CSQCModel_Hook_PostUpdate(bool isnew, bool isplayer, bool islocalplayer)
-{
+{SELFPARAM();
        // is it a player model? (shared state)
        self.isplayermodel = (substring(self.model, 0, 14) == "models/player/" || substring(self.model, 0, 17) == "models/ok_player/" || (substring(self.model, 0, 16) == "models/monsters/" && (self.entnum >= 1 && self.entnum <= maxclients)));
 
index 32d236fba4db7a23194ec99e26cc08b38e331e65..ec03281163fccdc569b5a258f57658876e99a3db 100644 (file)
@@ -20,7 +20,7 @@
 .bool isplayermodel;
 
 void DamageEffect_Think()
-{
+{SELFPARAM();
        // if particle distribution is enabled, slow ticrate by total number of damages
        if(autocvar_cl_damageeffect_distribute)
                self.nextthink = time + autocvar_cl_damageeffect_ticrate * self.owner.total_damages;
@@ -53,7 +53,7 @@ void DamageEffect_Think()
 }
 
 void DamageEffect(vector hitorg, float thedamage, int type, int specnum)
-{
+{SELFPARAM();
        // particle effects for players and objects damaged by weapons (eg: flames coming out of victims shot with rockets)
 
        int nearestbone = 0;
@@ -125,14 +125,11 @@ void DamageEffect(vector hitorg, float thedamage, int type, int specnum)
 }
 
 void Ent_DamageInfo(float isNew)
-{
+{SELFPARAM();
        float thedamage, rad, edge, thisdmg;
        bool hitplayer = false;
        int species, forcemul;
        vector force, thisforce;
-       entity oldself;
-
-       oldself = self;
 
        w_deathtype = ReadShort();
        w_issilent = (w_deathtype & 0x8000);
@@ -159,8 +156,9 @@ void Ent_DamageInfo(float isNew)
        else
                forcemul = 1;
 
-       for(self = findradius(w_org, rad + MAX_DAMAGEEXTRARADIUS); self; self = self.chain)
+       for(entity e = findradius(w_org, rad + MAX_DAMAGEEXTRARADIUS); e; e = e.chain)
        {
+               setself(e);
                // attached ents suck
                if(self.tag_entity)
                        continue;
@@ -211,8 +209,7 @@ void Ent_DamageInfo(float isNew)
                if(self.isplayermodel)
                        hitplayer = true; // this impact damaged a player
        }
-
-       self = oldself;
+       setself(this);
 
        if(DEATH_ISVEHICLE(w_deathtype))
        {
index 80ccc441bcf01cf0188f4be4cf7b0bd9a7d4205e..710ed01f5b6c513b8bf1d4f3cfd0bf276d994ca1 100644 (file)
@@ -32,7 +32,7 @@ void generator_precache()
 }
 
 void ons_generator_ray_draw()
-{
+{SELFPARAM();
        if(time < self.move_time)
                return;
 
@@ -71,7 +71,7 @@ void ons_generator_ray_spawn(vector org)
 }
 
 void generator_draw()
-{
+{SELFPARAM();
        if(time < self.move_time)
                return;
 
@@ -144,7 +144,7 @@ void generator_draw()
 }
 
 void generator_damage(float hp)
-{
+{SELFPARAM();
        if(hp <= 0)
                setmodel(self, "models/onslaught/generator_dead.md3");
        else if(hp < self.max_health * 0.10)
@@ -172,7 +172,7 @@ void generator_damage(float hp)
 }
 
 void generator_construct()
-{
+{SELFPARAM();
        self.netname = "Generator";
        self.classname = "onslaught_generator";
 
@@ -192,7 +192,7 @@ void generator_construct()
 
 .vector glowmod;
 void generator_changeteam()
-{
+{SELFPARAM();
        if(self.team)
        {
                self.glowmod = Team_ColorRGB(self.team - 1);
@@ -208,7 +208,7 @@ void generator_changeteam()
 }
 
 void ent_generator()
-{
+{SELFPARAM();
        int sf = ReadByte();
 
        if(sf & GSF_SETUP)
index b59cd4ff3d50c4d4b80a1722e3a02953ec9bb9ee..3c46ea9288179b5d79b61115f014762d375b7c76 100644 (file)
@@ -13,7 +13,7 @@
 .float gravity;
 
 void Gib_Delete()
-{
+{SELFPARAM();
        remove(self);
 }
 
@@ -75,7 +75,7 @@ void SUB_RemoveOnNoImpact()
 }
 
 void Gib_Touch()
-{
+{SELFPARAM();
        // TODO maybe bounce of walls, make more gibs, etc.
 
        if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
@@ -92,7 +92,7 @@ void Gib_Touch()
 }
 
 void Gib_Draw()
-{
+{SELFPARAM();
        vector oldorg;
        oldorg = self.origin;
 
@@ -164,7 +164,7 @@ void TossGib (string mdlname, vector safeorg, vector org, vector vconst, vector
 }
 
 void Ent_GibSplash(bool isNew)
-{
+{SELFPARAM();
        int amount, type, specnum;
        vector org, vel;
        string specstr;
index a30ab73c16e357a3972d923c87a43aa5a6623bc4..781681cf73b9b95abc0096dc7f6c3ecaeb867d20 100644 (file)
@@ -32,7 +32,7 @@ void Draw_GrapplingHook_trace_callback(vector start, vector hit, vector end)
 
 class(Hook) .float teleport_time;
 void Draw_GrapplingHook()
-{
+{SELFPARAM();
        vector a, b, atrans;
        string tex;
        vector rgb;
@@ -167,12 +167,12 @@ void Draw_GrapplingHook()
 }
 
 void Remove_GrapplingHook()
-{
+{SELFPARAM();
        sound (self, CH_SHOTS_SINGLE, "misc/null.wav", VOL_BASE, ATTEN_NORM);
 }
 
 void Ent_ReadHook(float bIsNew, float type)
-{
+{SELFPARAM();
        self.HookType = type;
 
        int sf = ReadByte();
index eb50ebc094090437a069d5a7fcc87ae368b583b0..9a0f87b944a56dfe49d3ce222976c748e6efa0ca 100644 (file)
@@ -352,7 +352,7 @@ int weaponorder_cmp(int i, int j, entity pass)
 }
 
 void HUD_Weapons(void)
-{
+{SELFPARAM();
        // declarations
        WepSet weapons_stat = WepSet_GetFromStat();
        int i;
@@ -413,7 +413,7 @@ void HUD_Weapons(void)
                weapon_cnt = 0;
                for(i = WEP_FIRST; i <= WEP_LAST; ++i)
                {
-                       self = get_weaponinfo(i);
+                       setself(get_weaponinfo(i));
                        if(self.impulse >= 0)
                        {
                                weaponorder[weapon_cnt] = self;
@@ -673,7 +673,7 @@ void HUD_Weapons(void)
        for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
        {
                // retrieve information about the current weapon to be drawn
-               self = weaponorder[i];
+               setself(weaponorder[i]);
                weapon_id = self.impulse;
                isCurrent = (self.weapon == switchweapon);
 
index 31e0256d3062d8cdf802b027c46156356c1c6a8d..3603fab1e1042983929507f6ba6c208702230704 100644 (file)
@@ -304,7 +304,7 @@ float SetTeam(entity o, int Team)
 }
 
 void Playerchecker_Think()
-{
+{SELFPARAM();
     int i;
        entity e;
        for(i = 0; i < maxclients; ++i)
@@ -398,11 +398,11 @@ float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
 // BEGIN OPTIONAL CSQC FUNCTIONS
 
 void Ent_RemoveEntCS()
-{
+{SELFPARAM();
        entcs_receiver[self.sv_entnum] = world;
 }
 void Ent_ReadEntCS()
-{
+{SELFPARAM();
     int sf;
        InterpolateOrigin_Undo();
 
@@ -438,7 +438,7 @@ void Ent_ReadEntCS()
 void Ent_Remove();
 
 void Ent_RemovePlayerScore()
-{
+{SELFPARAM();
        if(self.owner) {
                SetTeam(self.owner, -1);
                self.owner.gotscores = 0;
@@ -449,7 +449,7 @@ void Ent_RemovePlayerScore()
 }
 
 void Ent_ReadPlayerScore()
-{
+{SELFPARAM();
        int i, n;
        bool isNew;
        entity o;
@@ -507,7 +507,7 @@ void Ent_ReadPlayerScore()
 }
 
 void Ent_ReadTeamScore()
-{
+{SELFPARAM();
        int i;
        entity o;
 
@@ -699,12 +699,12 @@ void Ent_ReadAccuracy(void)
 }
 
 void Spawn_Draw(void)
-{
+{SELFPARAM();
        pointparticles(self.cnt, self.origin + '0 0 28', '0 0 2', bound(0, frametime, 0.1));
 }
 
 void Ent_ReadSpawnPoint(float is_new) // entity for spawnpoint
-{
+{SELFPARAM();
        float teamnum = (ReadByte() - 1);
        vector spn_origin;
        spn_origin.x = ReadShort();
@@ -750,7 +750,7 @@ void Ent_ReadSpawnPoint(float is_new) // entity for spawnpoint
 }
 
 void Ent_ReadSpawnEvent(float is_new)
-{
+{SELFPARAM();
        // If entnum is 0, ONLY do the local spawn actions
        // this way the server can disable the sending of
        // spawn origin or such to clients if wanted.
@@ -806,7 +806,7 @@ void Ent_RadarLink();
 void Ent_Init();
 void Ent_ScoresInfo();
 void CSQC_Ent_Update(float bIsNewEntity)
-{
+{SELFPARAM();
        float t;
        float savetime;
        t = ReadByte();
@@ -924,7 +924,7 @@ void CSQC_Ent_Update(float bIsNewEntity)
 // used when an entity changes its type. For an entity that someone interacts
 // with others, make sure it can no longer do so.
 void Ent_Remove()
-{
+{SELFPARAM();
        if(self.entremove)
                self.entremove();
 
@@ -948,7 +948,7 @@ void Ent_Remove()
 }
 // CSQC_Ent_Remove : Called when the server requests a SSQC / CSQC entity to be removed.  Essentially call remove(self) as well.
 void CSQC_Ent_Remove()
-{
+{SELFPARAM();
        if(autocvar_developer_csqcentities)
                LOG_INFOF("CSQC_Ent_Remove() with self=%i self.entnum=%d self.enttype=%d\n", self, self.entnum, self.enttype);
 
@@ -1011,7 +1011,7 @@ void Fog_Force()
 
 void Gamemode_Init();
 void Ent_ScoresInfo()
-{
+{SELFPARAM();
     int i;
        self.classname = "ent_client_scores_info";
        gametype = ReadInt24_t();
@@ -1035,7 +1035,7 @@ void Ent_ScoresInfo()
 }
 
 void Ent_Init()
-{
+{SELFPARAM();
        self.classname = "ent_client_init";
 
        nb_pb_period = ReadByte() / 32; //Accuracy of 1/32th
index c44fbe4dca452dfe702d72e96135a04212284a78..fa7044fc29e4a7db03026565310335b71e5bee81 100644 (file)
@@ -6,7 +6,7 @@
 .float alpha;
 
 void ModelEffect_Draw()
-{
+{SELFPARAM();
        self.angles = self.angles + frametime * self.avelocity;
        setorigin(self, self.origin + frametime * self.velocity);
        self.scale = self.scale1 + (self.scale2 - self.scale1) * (time - self.teleport_time) / (self.lifetime + self.fadetime - self.teleport_time);
@@ -25,7 +25,7 @@ void ModelEffect_Draw()
 }
 
 void Ent_ModelEffect(bool isNew)
-{
+{SELFPARAM();
        self.classname = "modeleffect_spawner";
 
        int f = ReadByte();
index fe2e3fd33ffb6f915b06e160b171d88927ffd116..a79e0b4712eef8ade9c5573967e5833a61629128 100644 (file)
@@ -64,13 +64,13 @@ MUTATOR_HOOKABLE(CSQC_Ent_Update, EV_CSQC_Ent_Update);
 
 /** Called when a projectile is linked with CSQC */
 #define EV_Ent_Projectile(i, o) \
-    /** entity id */ i(entity, self) \
+    /** entity id */ i(entity, __self) \
     /**/
 MUTATOR_HOOKABLE(Ent_Projectile, EV_Ent_Projectile);
 
 /** Called when a projectile's properties are being modified */
 #define EV_EditProjectile(i, o) \
-    /** entity id */ i(entity, self) \
+    /** entity id */ i(entity, __self) \
     /**/
 MUTATOR_HOOKABLE(EditProjectile, EV_EditProjectile);
 
@@ -79,25 +79,25 @@ MUTATOR_HOOKABLE(PrecacheProjectiles, EV_NO_ARGS);
 
 /** Called when updating the attached tags index */
 #define EV_TagIndex_Update(i, o) \
-    /** entity id */ i(entity, self) \
+    /** entity id */ i(entity, __self) \
     /**/
 MUTATOR_HOOKABLE(TagIndex_Update, EV_TagIndex_Update);
 
 /** Called when setting the attached tags */
 #define EV_TagIndex_Apply(i, o) \
-    /** entity id */ i(entity, self) \
+    /** entity id */ i(entity, __self) \
     /**/
 MUTATOR_HOOKABLE(TagIndex_Apply, EV_TagIndex_Apply);
 
 /** Called when setting up skeleton bones */
 #define EV_Skeleton_CheckBones(i, o) \
-    /** entity id */ i(entity, self) \
+    /** entity id */ i(entity, __self) \
     /**/
 MUTATOR_HOOKABLE(Skeleton_CheckBones, EV_Skeleton_CheckBones);
 
 /** Called when setting up bones from the loaded model */
 #define EV_Skeleton_CheckModel(i, o) \
-    /** entity id */ i(entity, self) \
+    /** entity id */ i(entity, __self) \
     /**/
 MUTATOR_HOOKABLE(Skeleton_CheckModel, EV_Skeleton_CheckModel);
 
@@ -125,7 +125,7 @@ MUTATOR_HOOKABLE(PlayerJump, EV_PlayerJump);
 
 /** Called checking if 3rd person mode should be forced on */
 #define EV_WantEventchase(i, o) \
-    /** entity id */ i(entity, self) \
+    /** entity id */ i(entity, __self) \
     /**/
 MUTATOR_HOOKABLE(WantEventchase, EV_WantEventchase);
 
index 00f9543717f39c5f19c5c6e09cd7667d2f99e620..584a1978015222c3e4604cec92bb2b2666706e29 100644 (file)
@@ -107,7 +107,7 @@ void free_skeleton_from_frames(entity e)
 }
 
 void skeleton_from_frames(entity e, float is_dead)
-{
+{SELFPARAM();
        float m = e.modelindex;
        if(!e.skeletonindex)
        {
index 4e32c0c45490fc9451c17504c5bafb7483368701..5af2e235070f7c5d7b63f2fc3d30353f0f206cfd 100644 (file)
@@ -3,15 +3,12 @@
 // LordHavoc: rewrote this file, it was really bad code
 
 void RubbleLimit(string cname, float limit, void() deleteproc)
-{
+{SELFPARAM();
        entity e;
        entity oldest;
-       entity oldself;
        float c;
        float oldesttime;
 
-       oldself = self;
-
        // remove rubble of the same type if it's at the limit
        // remove multiple rubble if the limit has been decreased
        while(1)
@@ -42,9 +39,7 @@ void RubbleLimit(string cname, float limit, void() deleteproc)
                        break;
 
                // delete this oldest one and search again
-               self = oldest;
-               deleteproc();
-               self = oldself;
+               WITH(entity, self, oldest, deleteproc());
        }
 }
 
index da5a7b2a771ab9cdb85a5101be323089fb21d9f7..407c087470ab8dfde6f9d21db71fed1169ba8ff8 100644 (file)
@@ -975,7 +975,7 @@ float HUD_WouldDrawScoreboard() {
 
 float average_accuracy;
 vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
-{
+{SELFPARAM();
        WepSet weapons_stat = WepSet_GetFromStat();
        WepSet weapons_inmap = WepSet_GetFromStat_InMap();
        float initial_posx = pos.x;
@@ -984,7 +984,7 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
        int disownedcnt = 0;
        for(i = WEP_FIRST; i <= WEP_LAST; ++i)
        {
-               self = get_weaponinfo(i);
+               setself(get_weaponinfo(i));
                if(!self.weapon)
                        continue;
 
@@ -1052,7 +1052,7 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
        int column;
        for(i = WEP_FIRST, column = 0; i <= WEP_LAST; ++i)
        {
-               self = get_weaponinfo(i);
+               setself(get_weaponinfo(i));
                if (!self.weapon)
                        continue;
                weapon_stats = weapon_accuracy[i-WEP_FIRST];
index ab6129e782cd214de6e72b33d7731b6ef7960962..8eaf7e4c2206fe7d000e3d5f6b9aef87421fb966 100644 (file)
@@ -202,7 +202,7 @@ void teamradar_loadcvars()
 // radar links
 
 void Ent_RadarLink()
-{
+{SELFPARAM();
        int sendflags = ReadByte();
 
        InterpolateOrigin_Undo();
index b95dd99e324773ab5f437e5ddcc7a5fe446aae48..1acfbd7eb7b1aee14fc43e40dd8507bfe7379fe2 100644 (file)
@@ -70,7 +70,7 @@ void tubasound(entity e, bool restart)
 }
 
 void Ent_TubaNote_Think()
-{
+{SELFPARAM();
        float f = autocvar_g_balance_tuba_fadetime;
        if (f > 0) {
                self.tuba_volume -= frametime * self.tuba_volume_initial / f;
@@ -91,7 +91,7 @@ void Ent_TubaNote_Think()
 }
 
 void Ent_TubaNote_UpdateSound()
-{
+{SELFPARAM();
        self.enemy.tuba_volume = bound(0, VOL_BASE * autocvar_g_balance_tuba_volume, 1);
        self.enemy.tuba_volume_initial = self.enemy.tuba_volume;
        self.enemy.note = self.note;
@@ -100,13 +100,13 @@ void Ent_TubaNote_UpdateSound()
 }
 
 void Ent_TubaNote_StopSound()
-{
+{SELFPARAM();
        self.enemy.nextthink = time;
        self.enemy = world;
 }
 
 void Ent_TubaNote(bool isNew)
-{
+{SELFPARAM();
        bool upd = false;
        int f = ReadByte();
        if (f & 1) {
index 701eb9f1e7419bb5328bcdd6e0651bd94b86e1c0..1e4d666e9cb64c28f2399fb52ebdb5da05d2cf18 100644 (file)
@@ -427,7 +427,7 @@ vector liquidcolor_prev;
 float eventchase_current_distance;
 float eventchase_running;
 bool WantEventchase()
-{
+{SELFPARAM();
        if(autocvar_cl_orthoview)
                return false;
        if(intermission)
@@ -533,7 +533,7 @@ void UpdateHitsound()
 }
 
 void UpdateCrosshair()
-{
+{SELFPARAM();
        static float rainbow_last_flicker;
     static vector rainbow_prev_color;
        entity e = self;
@@ -1022,7 +1022,7 @@ int lasthud;
 float vh_notice_time;
 void WaypointSprite_Load();
 void CSQC_UpdateView(float w, float h)
-{
+{SELFPARAM();
        entity e;
        float fov;
        float f;
@@ -1466,11 +1466,9 @@ void CSQC_UpdateView(float w, float h)
           mousepos = mousepos*0.5 + getmousepos();
         */
 
-       e = self;
-       for(self = world; (self = nextent(self)); )
-               if(self.draw)
-                       self.draw();
-       self = e;
+       for(entity e = NULL; (e = nextent(e)); ) if (e.draw) {
+               WITH(entity, self, e, e.draw());
+       }
 
        addentities(MASK_NORMAL | MASK_ENGINE | MASK_ENGINEVIEWMODELS);
        renderscene();
@@ -1805,11 +1803,9 @@ void CSQC_UpdateView(float w, float h)
          } else */
 
        // draw 2D entities
-       e = self;
-       for(self = world; (self = nextent(self)); )
-               if(self.draw2d)
-                       self.draw2d();
-       self = e;
+       for (entity e = NULL; (e = nextent(e)); ) if (e.draw2d) {
+               WITH(entity, self, e, e.draw2d());
+       }
        Draw_ShowNames_All();
 
        scoreboard_active = HUD_WouldDrawScoreboard();
index 92c142435636a8113f973e486f3ec8ec406a084b..7d79f7756500dad7b06478bd6104b64ee816a51c 100644 (file)
@@ -12,7 +12,7 @@
 .vector movedir;
 
 void Ent_Wall_PreDraw()
-{
+{SELFPARAM();
        if (self.inactive)
        {
                self.alpha = 0;
@@ -52,7 +52,7 @@ void Ent_Wall_PreDraw()
 }
 
 void Ent_Wall_Draw()
-{
+{SELFPARAM();
        float f;
        var .vector fld;
 
@@ -110,14 +110,14 @@ void Ent_Wall_Draw()
 }
 
 void Ent_Wall_Remove()
-{
+{SELFPARAM();
        if(self.bgmscript)
                strunzone(self.bgmscript);
        self.bgmscript = string_null;
 }
 
 void Ent_Wall()
-{
+{SELFPARAM();
        int f;
        var .vector fld;
 
index 668228b649828dae983f200969d209a477b633d0..7f13ab5dfe5455c31baa259cfe9a5feb8bd88510 100644 (file)
 .vector colormod;
 
 void SUB_Stop()
-{
+{SELFPARAM();
        self.move_velocity = self.move_avelocity = '0 0 0';
        self.move_movetype = MOVETYPE_NONE;
 }
 
 void Projectile_ResetTrail(vector to)
-{
+{SELFPARAM();
        self.trail_oldorigin = to;
        self.trail_oldtime = time;
 }
 
 void Projectile_DrawTrail(vector to)
-{
+{SELFPARAM();
        vector from;
        float t0;
 
@@ -52,7 +52,7 @@ void Projectile_DrawTrail(vector to)
 }
 
 void Projectile_Draw()
-{
+{SELFPARAM();
        vector rot;
        vector trailorigin;
        int f;
@@ -166,7 +166,7 @@ void Projectile_Draw()
 }
 
 void loopsound(entity e, int ch, string samp, float vol, float attn)
-{
+{SELFPARAM();
        if(self.silent)
                return;
 
@@ -175,7 +175,7 @@ void loopsound(entity e, int ch, string samp, float vol, float attn)
 }
 
 void Ent_RemoveProjectile()
-{
+{SELFPARAM();
        if(self.count & 0x80)
        {
                tracebox(self.origin, self.mins, self.maxs, self.origin + self.velocity * 0.05, MOVE_NORMAL, self);
@@ -184,7 +184,7 @@ void Ent_RemoveProjectile()
 }
 
 void Ent_Projectile()
-{
+{SELFPARAM();
        int f;
 
        // projectile properties:
index f1ef589eedffdf8616a5302614019dce2582fb34..eeaba7371d94ed86394f3a34ea49eaa981f932fc 100644 (file)
@@ -146,6 +146,7 @@ void buff_Init(entity ent);
 void buff_Init_Compat(entity ent, entity replacement);
 
 #define BUFF_SPAWNFUNC(e, b, t) void spawnfunc_item_buff_##e() { \
+       SELFPARAM(); \
        self.buffs = b.m_itemid; \
        self.team = t; \
        buff_Init(self); \
@@ -156,7 +157,7 @@ void buff_Init_Compat(entity ent, entity replacement);
                BUFF_SPAWNFUNC(e##_team2,   b,  NUM_TEAM_2) \
                BUFF_SPAWNFUNC(e##_team3,   b,  NUM_TEAM_3) \
                BUFF_SPAWNFUNC(e##_team4,   b,  NUM_TEAM_4)
-#define BUFF_SPAWNFUNC_Q3TA_COMPAT(o, r) void spawnfunc_item_##o() { buff_Init_Compat(self, r); }
+#define BUFF_SPAWNFUNC_Q3TA_COMPAT(o, r) void spawnfunc_item_##o() { SELFPARAM(); buff_Init_Compat(self, r); }
 
 BUFF_SPAWNFUNCS(resistance,            BUFF_RESISTANCE)
 BUFF_SPAWNFUNCS(ammo,                  BUFF_AMMO)
index e11604aae3da6b8e2847cb05891bc8c5e40b815d..d356ff76d072d7b4c8a670f4ef6118197801687f 100644 (file)
@@ -86,8 +86,8 @@
 //vector PL_CROUCH_VIEW_OFS  = ...;
 
 #ifdef SVQC
-# define CSQCMODEL_AUTOINIT() CSQCModel_LinkEntity()
-# define CSQCMODEL_AUTOUPDATE() CSQCModel_CheckUpdate()
+# define CSQCMODEL_AUTOINIT(e) CSQCModel_LinkEntity(e)
+# define CSQCMODEL_AUTOUPDATE(e) CSQCModel_CheckUpdate(e)
 #endif
 
 #define CSQCMODEL_EF_RESPAWNGHOST EF_SELECTABLE
index e1707021ea2f8231f46ad0a3c993b221a04bb9fb..242145f0bac3abc6bedde2b6cd3933ae78e6521e 100644 (file)
@@ -39,7 +39,7 @@ void Read_Effect(bool is_new)
 
 #ifdef SVQC
 bool Net_Write_Effect(entity client, int sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_EFFECT);
 #if EFFECTS_COUNT >= 255
        WriteShort(MSG_ENTITY, self.m_id);
index 9b4013405d6740e7db8b23ac5a463a2bcc0e6e51..2ec8837d48e16d527114973be62f1c75b5e3c516 100644 (file)
@@ -41,7 +41,7 @@ void Inventory_Write(Inventory data)
 
 #ifdef SVQC
 bool Inventory_Send(entity to, int sf)
-{
+{SELFPARAM();
     WriteByte(MSG_ENTITY, ENT_CLIENT_INVENTORY);
     entity e = self.owner;
     if (IS_SPEC(e)) e = e.enemy;
index 3a1cc86744c16f9ea93f40c0a3ce22801cd874d6..83150d7d262df73076e607e5b45ad43fc9499eab 100644 (file)
@@ -88,7 +88,7 @@ string minigame_texture(string name)
 #define MSLE_CLEAN_Vector2D(x)
 
 #define MSLE(Name,Fields) \
-       void msle_entremove_##Name() { strunzone(self.netname); Fields }
+       void msle_entremove_##Name() { SELFPARAM(); strunzone(self.netname); Fields }
 MINIGAME_SIMPLELINKED_ENTITIES
 #undef MSLE
 #undef FIELD
@@ -127,7 +127,7 @@ void deactivate_minigame()
 }
 
 void minigame_entremove()
-{
+{SELFPARAM();
        if ( self == active_minigame )
                deactivate_minigame();
 }
@@ -169,7 +169,7 @@ void activate_minigame(entity minigame)
 }
 
 void minigame_player_entremove()
-{
+{SELFPARAM();
        if ( self.owner == active_minigame && self.minigame_playerslot == player_localentnum )
                deactivate_minigame();
 }
@@ -190,7 +190,7 @@ string ReadString_Zoned() { return strzone(ReadString_Raw()); }
                Fields \
        }
 void minigame_read_owner()
-{
+{SELFPARAM();
        string owner_name = ReadString_Raw();
        self.owner = world;
        do
@@ -200,7 +200,7 @@ void minigame_read_owner()
                LOG_TRACE("Got a minigame entity without a minigame!\n");
 }
 void ent_read_minigame()
-{
+{SELFPARAM();
        float sf = ReadByte();
        if ( sf & MINIG_SF_CREATE )
        {
index b7b7df128a501174a4faf43a220b3826d449e9b8..51155f236fffaf0357b4615a3e0123c91cc1cd97 100644 (file)
@@ -104,13 +104,10 @@ entity HUD_MinigameMenu_activeitem;
 
 // Click the given item
 void HUD_MinigameMenu_Click(entity menuitem)
-{
+{SELFPARAM();
        if ( menuitem )
        {
-               entity e = self;
-               self = menuitem;
-               menuitem.use();
-               self = e;
+               WITH(entity, self, menuitem, menuitem.use());
        }
 }
 
@@ -167,14 +164,14 @@ entity HUD_MinigameMenu_SpawnSubEntry(string s, void() click, entity parent)
 
 // Click action for Create sub-entries
 void HUD_MinigameMenu_ClickCreate_Entry()
-{
+{SELFPARAM();
        minigame_cmd("create ",self.netname);
 }
 
 // Helper click action for collapsible entries
 // returns true when you have to create the sub-entries
 bool HUD_MinigameMenu_Click_ExpandCollapse()
-{
+{SELFPARAM();
        entity e;
        if ( self.flags & 2 )
        {
@@ -211,7 +208,7 @@ bool HUD_MinigameMenu_Click_ExpandCollapse()
 
 // Click action for the Create menu
 void HUD_MinigameMenu_ClickCreate()
-{
+{SELFPARAM();
        if ( HUD_MinigameMenu_Click_ExpandCollapse() )
        {
                entity e;
@@ -231,14 +228,14 @@ void HUD_MinigameMenu_ClickCreate()
 
 // Click action for Join sub-entries
 void HUD_MinigameMenu_ClickJoin_Entry()
-{
+{SELFPARAM();
        minigame_cmd("join ",self.netname);
        HUD_MinigameMenu_EraseEntry(self);
 }
 
 // Click action for the Join menu
 void HUD_MinigameMenu_ClickJoin()
-{
+{SELFPARAM();
        if ( HUD_MinigameMenu_Click_ExpandCollapse() )
        {
                entity e = world;
@@ -274,13 +271,13 @@ void HUD_MinigameMenu_ClickQuit()
 
 // Click action for Invite sub-entries
 void HUD_MinigameMenu_ClickInvite_Entry()
-{
+{SELFPARAM();
        minigame_cmd("invite #",self.netname);
 }
 
 // Click action for the Invite menu
 void HUD_MinigameMenu_ClickInvite()
-{
+{SELFPARAM();
        if ( HUD_MinigameMenu_Click_ExpandCollapse() )
        {
                entity e;
@@ -304,7 +301,7 @@ void HUD_MinigameMenu_ClickInvite()
 }
 
 void HUD_MinigameMenu_ClickCustomEntry()
-{
+{SELFPARAM();
        if ( active_minigame )
                active_minigame.minigame_event(active_minigame,"menu_click",self.netname);
 }
@@ -321,7 +318,7 @@ void HUD_MinigameMenu_CustomEntry(entity parent, string menumessage, string even
 
 // Click action for the Current Game menu
 void HUD_MinigameMenu_ClickCurrentGame()
-{
+{SELFPARAM();
        if ( HUD_MinigameMenu_Click_ExpandCollapse() )
        {
                HUD_MinigameMenu_InsertEntry( HUD_MinigameMenu_SpawnSubEntry(
index b7ad467b8c2728ec128d8835c23157007540121f..5b9dd1ffe6df79dee9c7c50087a619cd847fe943 100644 (file)
@@ -617,7 +617,7 @@ string nmm_turn_to_string(int turnflags)
 
 // Required function, handle client events
 int nmm_client_event(entity minigame, string event, ...)
-{
+{SELFPARAM();
        if ( event == "activate" )
        {
                nmm_fromtile = world;
index 6aca04cf95f4675f90e318b02af6c479080d0e9f..0049fc93f984980199ac8beec899f40a08c7f82e 100644 (file)
@@ -53,7 +53,7 @@ void pong_ball_throw(entity ball)
 
 // Think equivalent of pong_ball_throw, used to delay throws
 void pong_ball_throwthink()
-{
+{SELFPARAM();
        pong_ball_throw(self);
 }
 
@@ -144,7 +144,7 @@ bool pong_goal(entity ball, int pteam)
 
 // Moves the ball around
 void pong_ball_think()
-{
+{SELFPARAM();
        float think_speed = autocvar_sys_ticrate;
        self.nextthink = time + think_speed;
        
@@ -200,7 +200,7 @@ void pong_ball_think()
 
 // AI action
 void pong_ai_think()
-{
+{SELFPARAM();
        float think_speed = autocvar_sv_minigames_pong_ai_thinkspeed;
        self.nextthink = time + think_speed;
        
@@ -265,7 +265,7 @@ entity pong_ai_spawn(entity paddle)
 
 // Moves the paddle
 void pong_paddle_think()
-{
+{SELFPARAM();
        float think_speed = autocvar_sys_ticrate;
        self.nextthink = time + think_speed;
 
index feb4b02944874bc692c0672b90881d6dee8094b9..44653ae9410436f70860fc5d831ab05e1ccb1548 100644 (file)
@@ -61,7 +61,7 @@ void minigame_rmplayer(entity minigame_session, entity player)
 // Send an entity to a client
 // only use on minigame entities or entities with a minigame owner
 bool minigame_SendEntity(entity to, int sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_MINIGAME);
        WriteByte(MSG_ENTITY, sf);
        
@@ -115,7 +115,7 @@ void minigame_resend(entity minigame)
 }
 
 bool minigame_CheckSend()
-{
+{SELFPARAM();
        entity e;
        for ( e = self.owner.minigame_players; e != world; e = e.list_next )
                if ( e.minigame_players == other )
@@ -124,7 +124,7 @@ bool minigame_CheckSend()
 }
 
 int minigame_addplayer(entity minigame_session, entity player)
-{
+{SELFPARAM();
        if ( player.active_minigame )
        {
                if ( player.active_minigame == minigame_session )
@@ -150,10 +150,7 @@ int minigame_addplayer(entity minigame_session, entity player)
 
                if ( !IS_OBSERVER(player) && autocvar_sv_minigames_observer )
                {
-                       entity e = self;
-                       self = player;
-                       PutObserverInServer();
-                       self = e;
+                       WITH(entity, self, player, PutObserverInServer());
                }
                if ( autocvar_sv_minigames_observer == 2 )
                        player.team_forced = -1;
@@ -317,7 +314,7 @@ entity minigame_find_player(entity client)
 }
 
 bool MinigameImpulse(int imp)
-{
+{SELFPARAM();
        entity e = minigame_find_player(self);
        if ( imp && self.active_minigame && e )
        {
@@ -329,7 +326,7 @@ bool MinigameImpulse(int imp)
 
 
 void ClientCommand_minigame(int request, int argc, string command)
-{
+{SELFPARAM();
        if ( !autocvar_sv_minigames )
        {
                sprint(self,"Minigames are not enabled!\n");
index 8f92d693a6e614fbf2422f36722a8484b84d9b06..8e26b9c1f348a2c575e17b97626b7b3300a6186e 100644 (file)
@@ -62,7 +62,7 @@ void() M_Mage_Defend_Shield;
 .float mage_shield_time;
 
 float M_Mage_Defend_Heal_Check(entity e)
-{
+{SELFPARAM();
        if(e == world)
                return false;
        if(e.health <= 0)
@@ -88,7 +88,7 @@ float M_Mage_Defend_Heal_Check(entity e)
 }
 
 void M_Mage_Attack_Spike_Explode()
-{
+{SELFPARAM();
        self.event_damage = func_null;
 
        sound(self, CH_SHOTS, W_Sound("grenade_impact"), VOL_BASE, ATTEN_NORM);
@@ -110,7 +110,7 @@ void M_Mage_Attack_Spike_Touch()
 
 // copied from W_Seeker_Think
 void M_Mage_Attack_Spike_Think()
-{
+{SELFPARAM();
        entity e;
        vector desireddir, olddir, newdir, eorg;
        float turnrate;
@@ -173,7 +173,7 @@ void M_Mage_Attack_Spike_Think()
 }
 
 void M_Mage_Attack_Spike()
-{
+{SELFPARAM();
        entity missile;
        vector dir = normalize((self.enemy.origin + '0 0 10') - self.origin);
 
@@ -200,7 +200,7 @@ void M_Mage_Attack_Spike()
 }
 
 void M_Mage_Defend_Heal()
-{
+{SELFPARAM();
        entity head;
        float washealed = false;
 
@@ -257,7 +257,7 @@ void M_Mage_Defend_Heal()
 }
 
 void M_Mage_Attack_Push()
-{
+{SELFPARAM();
        sound(self, CH_SHOTS, W_Sound("tagexp1"), 1, ATTEN_NORM);
        RadiusDamage (self, self, (autocvar_g_monster_mage_attack_push_damage), (autocvar_g_monster_mage_attack_push_damage), (autocvar_g_monster_mage_attack_push_radius), world, world, (autocvar_g_monster_mage_attack_push_force), DEATH_MONSTER_MAGE, self.enemy);
        Send_Effect(EFFECT_TE_EXPLOSION, self.origin, '0 0 0', 1);
@@ -267,7 +267,7 @@ void M_Mage_Attack_Push()
 }
 
 void M_Mage_Attack_Teleport()
-{
+{SELFPARAM();
        if(vlen(self.enemy.origin - self.origin) >= 500)
                return;
 
@@ -284,13 +284,13 @@ void M_Mage_Attack_Teleport()
 }
 
 void M_Mage_Defend_Shield_Remove()
-{
+{SELFPARAM();
        self.effects &= ~(EF_ADDITIVE | EF_BLUE);
        self.armorvalue = autocvar_g_monsters_armor_blockpercent;
 }
 
 void M_Mage_Defend_Shield()
-{
+{SELFPARAM();
        self.effects |= (EF_ADDITIVE | EF_BLUE);
        self.mage_shield_delay = time + (autocvar_g_monster_mage_shield_delay);
        self.armorvalue = (autocvar_g_monster_mage_shield_blockpercent);
@@ -301,7 +301,7 @@ void M_Mage_Defend_Shield()
 }
 
 float M_Mage_Attack(float attack_type)
-{
+{SELFPARAM();
        switch(attack_type)
        {
                case MONSTER_ATTACK_MELEE:
@@ -348,7 +348,7 @@ void spawnfunc_monster_mage() { Monster_Spawn(MON_MAGE.monsterid); }
 #endif // SVQC
 
 bool M_Mage(int req)
-{
+{SELFPARAM();
        switch(req)
        {
                #ifdef SVQC
index 4640fe945bcf33f6e9ea8744bdf0d79303334d2f..0a77342f62289f44df5bae349a1a7e5f66456a11 100644 (file)
@@ -47,7 +47,7 @@ const float shambler_anim_death               = 8;
 .float shambler_lastattack; // delay attacks separately
 
 void M_Shambler_Attack_Smash()
-{
+{SELFPARAM();
        makevectors(self.angles);
        Send_Effect(EFFECT_EXPLOSION_MEDIUM, (self.origin + (v_forward * 150)) - ('0 0 1' * self.maxs.z), '0 0 0', 1);
        sound(self, CH_SHOTS, W_Sound("rocket_impact"), VOL_BASE, ATTEN_NORM);
@@ -61,7 +61,7 @@ void M_Shambler_Attack_Smash()
 }
 
 void M_Shambler_Attack_Swing()
-{
+{SELFPARAM();
        float r = (random() < 0.5);
        if(r && Monster_Attack_Melee(self.enemy, (autocvar_g_monster_shambler_attack_claw_damage), ((r) ? self.anim_melee2 : self.anim_melee3), self.attack_range, 0.8, DEATH_MONSTER_SHAMBLER_CLAW, true))
        {
@@ -72,7 +72,7 @@ void M_Shambler_Attack_Swing()
 }
 
 void M_Shambler_Attack_Lightning_Explode()
-{
+{SELFPARAM();
        entity head;
 
        sound(self, CH_SHOTS, W_Sound("electro_impact"), VOL_BASE, ATTEN_NORM);
@@ -99,7 +99,7 @@ void M_Shambler_Attack_Lightning_Explode()
 }
 
 void M_Shambler_Attack_Lightning_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        if (self.health <= 0)
                return;
 
@@ -113,14 +113,14 @@ void M_Shambler_Attack_Lightning_Damage(entity inflictor, entity attacker, float
 }
 
 void M_Shambler_Attack_Lightning_Touch()
-{
+{SELFPARAM();
        PROJECTILE_TOUCH;
 
        self.use ();
 }
 
 void M_Shambler_Attack_Lightning_Think()
-{
+{SELFPARAM();
        self.nextthink = time;
        if (time > self.cnt)
        {
@@ -131,7 +131,7 @@ void M_Shambler_Attack_Lightning_Think()
 }
 
 void M_Shambler_Attack_Lightning()
-{
+{SELFPARAM();
        entity gren;
 
        monster_makevectors(self.enemy);
@@ -169,7 +169,7 @@ void M_Shambler_Attack_Lightning()
 }
 
 float M_Shambler_Attack(float attack_type)
-{
+{SELFPARAM();
        switch(attack_type)
        {
                case MONSTER_ATTACK_MELEE:
@@ -215,7 +215,7 @@ void spawnfunc_monster_shambler() { Monster_Spawn(MON_SHAMBLER.monsterid); }
 #endif // SVQC
 
 bool M_Shambler(int req)
-{
+{SELFPARAM();
        switch(req)
        {
                #ifdef SVQC
index 0179c66b9add72b73c2a165e64fbd0f4e9fd996d..7c9d31b2f717f3078dd7d9fed34dbc091f910a13 100644 (file)
@@ -38,7 +38,7 @@ const float spider_anim_attack2               = 3;
 .float spider_web_delay;
 
 void M_Spider_Attack_Web_Explode()
-{
+{SELFPARAM();
        entity e;
        if(self)
        {
@@ -60,7 +60,7 @@ void M_Spider_Attack_Web_Touch()
 }
 
 void M_Spider_Attack_Web()
-{
+{SELFPARAM();
        monster_makevectors(self.enemy);
 
        sound(self, CH_SHOTS, W_Sound("electro_fire2"), VOL_BASE, ATTEN_NORM);
@@ -98,7 +98,7 @@ void M_Spider_Attack_Web()
 }
 
 bool M_Spider_Attack(int attack_type)
-{
+{SELFPARAM();
        switch(attack_type)
        {
                case MONSTER_ATTACK_MELEE:
@@ -128,7 +128,7 @@ void spawnfunc_monster_spider() { Monster_Spawn(MON_SPIDER.monsterid); }
 #endif // SVQC
 
 bool M_Spider(int req)
-{
+{SELFPARAM();
        switch(req)
        {
                #ifdef SVQC
index 9bdc4c63afa57ed7bd000df7894ace290844d187..f1160fb52e70886fb7abcd4a6897be7bd80ea0f3 100644 (file)
@@ -37,7 +37,7 @@ const float wyvern_anim_death = 4;
 */
 
 void M_Wyvern_Attack_Fireball_Explode()
-{
+{SELFPARAM();
        entity e;
        if(self)
        {
@@ -60,7 +60,7 @@ void M_Wyvern_Attack_Fireball_Touch()
 }
 
 void M_Wyvern_Attack_Fireball()
-{
+{SELFPARAM();
        entity missile = spawn();
        vector dir = normalize((self.enemy.origin + '0 0 10') - self.origin);
 
@@ -83,7 +83,7 @@ void M_Wyvern_Attack_Fireball()
 }
 
 float M_Wyvern_Attack(float attack_type)
-{
+{SELFPARAM();
        switch(attack_type)
        {
                case MONSTER_ATTACK_MELEE:
@@ -105,7 +105,7 @@ void spawnfunc_monster_wyvern() { Monster_Spawn(MON_WYVERN.monsterid); }
 #endif // SVQC
 
 bool M_Wyvern(int req)
-{
+{SELFPARAM();
        switch(req)
        {
                #ifdef SVQC
index 780cf74b381dadb7fc5db70ee4f45bef5fa63e11..fe7c384ca96c2dfc9dcc8f6e7f15b9d8be12116a 100644 (file)
@@ -63,7 +63,7 @@ const float zombie_anim_spawn                         = 30;
 */
 
 void M_Zombie_Attack_Leap_Touch()
-{
+{SELFPARAM();
        if (self.health <= 0)
                return;
 
@@ -86,7 +86,7 @@ void M_Zombie_Attack_Leap_Touch()
 }
 
 void M_Zombie_Defend_Block_End()
-{
+{SELFPARAM();
        if(self.health <= 0)
                return;
 
@@ -95,7 +95,7 @@ void M_Zombie_Defend_Block_End()
 }
 
 float M_Zombie_Defend_Block()
-{
+{SELFPARAM();
        self.armorvalue = 0.9;
        self.state = MONSTER_ATTACK_MELEE; // freeze monster
        self.attack_finished_single = time + 2.1;
@@ -108,7 +108,7 @@ float M_Zombie_Defend_Block()
 }
 
 float M_Zombie_Attack(float attack_type)
-{
+{SELFPARAM();
        switch(attack_type)
        {
                case MONSTER_ATTACK_MELEE:
@@ -142,7 +142,7 @@ void spawnfunc_monster_zombie() { Monster_Spawn(MON_ZOMBIE.monsterid); }
 #endif // SVQC
 
 bool M_Zombie(int req)
-{
+{SELFPARAM();
        switch(req)
        {
                #ifdef SVQC
index 4a84f943584499708acab79e9a387ab8909f7dc5..dfa318fe3acd92224dcd5e35367b0fc006eeabdc 100644 (file)
@@ -10,7 +10,7 @@
     #include "../../server/defs.qh"
 #endif
 entity spawnmonster (string monster, float monster_id, entity spawnedby, entity own, vector orig, float respwn, float invincible, float moveflag)
-{
+{SELFPARAM();
        float i;
        entity e = spawn();
 
@@ -64,10 +64,7 @@ entity spawnmonster (string monster, float monster_id, entity spawnedby, entity
        }
        
        // Monster_Spawn checks if monster is valid
-       entity oldself = self;
-       self = e;
-       Monster_Spawn(monster_id);
-       self = oldself;
+       WITH(entity, self, e, Monster_Spawn(monster_id));
 
        return e;
 }
index d0b39828d1acbcf1da0b7ff5706ae558ab0d066b..d4e1691f0ce1a1dd5ba73880bb9c709f7bedb7cf 100644 (file)
 #endif
 
 void monsters_setstatus()
-{
+{SELFPARAM();
        self.stat_monsters_total = monsters_total;
        self.stat_monsters_killed = monsters_killed;
 }
 
 void monster_dropitem()
-{
+{SELFPARAM();
        if(!self.candrop || !self.monster_loot)
                return;
 
        vector org = self.origin + ((self.mins + self.maxs) * 0.5);
-       entity e = spawn(), oldself = self;
+       entity e = spawn();
 
        e.monster_loot = self.monster_loot;
 
@@ -47,7 +47,7 @@ void monster_dropitem()
 
        if(e && e.monster_loot)
        {
-               self = e;
+               setself(e);
                e.noalign = true;
                e.monster_loot();
                e.gravity = 1;
@@ -58,12 +58,12 @@ void monster_dropitem()
                e.item_spawnshieldtime = time + 0.7;
                e.classname = "droppedweapon"; // use weapon handling to remove it on touch
                SUB_SetFade(e, time + autocvar_g_monsters_drop_time, 1);
-               self = oldself;
+               setself(this);
        }
 }
 
 void monster_makevectors(entity e)
-{
+{SELFPARAM();
        if(IS_MONSTER(self))
        {
                vector v;
@@ -81,7 +81,7 @@ void monster_makevectors(entity e)
 // ===============
 
 bool Monster_ValidTarget(entity mon, entity player)
-{
+{SELFPARAM();
        // ensure we're not checking nonexistent monster/target
        if(!mon || !player) { return false; }
 
@@ -196,9 +196,9 @@ void monster_changeteam(entity ent, float newteam)
 }
 
 void Monster_Delay_Action()
-{
+{SELFPARAM();
        entity oldself = self;
-       self = self.owner;
+       setself(self.owner);
        if(Monster_ValidTarget(self, self.enemy)) { oldself.use(); }
 
        if(oldself.cnt > 0)
@@ -215,7 +215,7 @@ void Monster_Delay_Action()
 }
 
 void Monster_Delay(float repeat_count, float repeat_defer, float defer_amnt, void() func)
-{
+{SELFPARAM();
        // deferred attacking, checks if monster is still alive and target is still valid before attacking
        entity e = spawn();
 
@@ -266,7 +266,7 @@ void Monster_Sound_Precache(string f)
 }
 
 void Monster_Sounds_Precache()
-{
+{SELFPARAM();
        string m = (get_monsterinfo(self.monsterid)).model;
        float globhandle, n, i;
        string f;
@@ -285,7 +285,7 @@ void Monster_Sounds_Precache()
 }
 
 void Monster_Sounds_Clear()
-{
+{SELFPARAM();
 #define _MSOUND(m) if(self.monstersound_##m) { strunzone(self.monstersound_##m); self.monstersound_##m = string_null; }
        ALLMONSTERSOUNDS
 #undef _MSOUND
@@ -305,7 +305,7 @@ void Monster_Sounds_Clear()
 }
 
 bool Monster_Sounds_Load(string f, int first)
-{
+{SELFPARAM();
        float fh;
        string s;
        var .string field;
@@ -332,7 +332,7 @@ bool Monster_Sounds_Load(string f, int first)
 
 .int skin_for_monstersound;
 void Monster_Sounds_Update()
-{
+{SELFPARAM();
        if(self.skin == self.skin_for_monstersound) { return; }
 
        self.skin_for_monstersound = self.skin;
@@ -342,7 +342,7 @@ void Monster_Sounds_Update()
 }
 
 void Monster_Sound(.string samplefield, float sound_delay, float delaytoo, float chan)
-{
+{SELFPARAM();
        if(!autocvar_g_monsters_sounds) { return; }
 
        if(delaytoo)
@@ -359,7 +359,7 @@ void Monster_Sound(.string samplefield, float sound_delay, float delaytoo, float
 // =======================
 
 float Monster_Attack_Melee(entity targ, float damg, vector anim, float er, float animtime, int deathtype, float dostop)
-{
+{SELFPARAM();
        if(dostop && (self.flags & FL_MONSTER)) { self.state = MONSTER_ATTACK_MELEE; }
 
        setanim(self, anim, false, true, false);
@@ -380,7 +380,7 @@ float Monster_Attack_Melee(entity targ, float damg, vector anim, float er, float
 }
 
 float Monster_Attack_Leap_Check(vector vel)
-{
+{SELFPARAM();
        if(self.state && (self.flags & FL_MONSTER))
                return false; // already attacking
        if(!(self.flags & FL_ONGROUND))
@@ -402,7 +402,7 @@ float Monster_Attack_Leap_Check(vector vel)
 }
 
 bool Monster_Attack_Leap(vector anm, void() touchfunc, vector vel, float animtime)
-{
+{SELFPARAM();
        if(!Monster_Attack_Leap_Check(vel))
                return false;
 
@@ -457,7 +457,7 @@ void Monster_Attack_Check(entity e, entity targ)
 // ======================
 
 void Monster_UpdateModel()
-{
+{SELFPARAM();
        // assume some defaults
        /*self.anim_idle   = animfixfps(self, '0 1 0.01', '0 0 0');
        self.anim_walk   = animfixfps(self, '1 1 0.01', '0 0 0');
@@ -475,7 +475,7 @@ void Monster_UpdateModel()
 }
 
 void Monster_Touch()
-{
+{SELFPARAM();
        if(other == world) { return; }
 
        if(other.monster_attack)
@@ -486,7 +486,7 @@ void Monster_Touch()
 }
 
 void Monster_Miniboss_Check()
-{
+{SELFPARAM();
        if(MUTATOR_CALLHOOK(MonsterCheckBossFlag))
                return;
 
@@ -503,7 +503,7 @@ void Monster_Miniboss_Check()
 }
 
 bool Monster_Respawn_Check()
-{
+{SELFPARAM();
        if(self.deadflag == DEAD_DEAD) // don't call when monster isn't dead
        if(MUTATOR_CALLHOOK(MonsterRespawn, self))
                return true; // enabled by a mutator
@@ -517,10 +517,10 @@ bool Monster_Respawn_Check()
        return true;
 }
 
-void Monster_Respawn() { Monster_Spawn(self.monsterid); }
+void Monster_Respawn() { SELFPARAM(); Monster_Spawn(self.monsterid); }
 
 void Monster_Dead_Fade()
-{
+{SELFPARAM();
        if(Monster_Respawn_Check())
        {
                self.spawnflags |= MONSTERFLAG_RESPAWNED;
@@ -550,12 +550,12 @@ void Monster_Dead_Fade()
 }
 
 void Monster_Use()
-{
+{SELFPARAM();
        if(Monster_ValidTarget(self, activator)) { self.enemy = activator; }
 }
 
 vector Monster_Move_Target(entity targ)
-{
+{SELFPARAM();
        // enemy is always preferred target
        if(self.enemy)
        {
@@ -664,7 +664,7 @@ vector Monster_Move_Target(entity targ)
 }
 
 void Monster_CalculateVelocity(entity mon, vector to, vector from, float turnrate, float movespeed)
-{
+{SELFPARAM();
        float current_distance = vlen((('1 0 0' * to.x) + ('0 1 0' * to.y)) - (('1 0 0' * from.x) + ('0 1 0' * from.y))); // for the sake of this check, exclude Z axis
        float initial_height = 0; //min(50, (targ_distance * tanh(20)));
        float current_height = (initial_height * min(1, (self.pass_distance) ? (current_distance / self.pass_distance) : current_distance));
@@ -698,7 +698,7 @@ void Monster_CalculateVelocity(entity mon, vector to, vector from, float turnrat
 }
 
 void Monster_Move(float runspeed, float walkspeed, float stpspeed)
-{
+{SELFPARAM();
        if(self.target2) { self.goalentity = find(world, targetname, self.target2); }
 
        entity targ;
@@ -924,7 +924,7 @@ void Monster_Remove(entity mon)
 }
 
 void Monster_Dead_Think()
-{
+{SELFPARAM();
        self.nextthink = time + self.ticrate;
 
        if(self.monster_lifetime != 0)
@@ -936,7 +936,7 @@ void Monster_Dead_Think()
 }
 
 void Monster_Appear()
-{
+{SELFPARAM();
        self.enemy = activator;
        self.spawnflags &= ~MONSTERFLAG_APPEAR; // otherwise, we get an endless loop
        Monster_Spawn(self.monsterid);
@@ -957,7 +957,7 @@ float Monster_Appear_Check(entity ent, float monster_id)
 }
 
 void Monster_Reset()
-{
+{SELFPARAM();
        setorigin(self, self.pos1);
        self.angles = self.pos2;
 
@@ -972,7 +972,7 @@ void Monster_Reset()
 }
 
 void Monster_Dead_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        self.health -= damage;
 
        Violence_GibSplash_At(hitloc, force, 2, bound(0, damage, 200) / 16, self, attacker);
@@ -991,7 +991,7 @@ void Monster_Dead_Damage(entity inflictor, entity attacker, float damage, int de
 }
 
 void Monster_Dead(entity attacker, float gibbed)
-{
+{SELFPARAM();
        self.think = Monster_Dead_Think;
        self.nextthink = time;
        self.monster_lifetime = time + 5;
@@ -1044,7 +1044,7 @@ void Monster_Dead(entity attacker, float gibbed)
 }
 
 void Monster_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        if((self.spawnflags & MONSTERFLAG_INVINCIBLE) && deathtype != DEATH_KILL)
                return;
 
@@ -1128,7 +1128,7 @@ void Monster_Damage(entity inflictor, entity attacker, float damage, int deathty
 
 // don't check for enemies, just keep walking in a straight line
 void Monster_Move_2D(float mspeed, float allow_jumpoff)
-{
+{SELFPARAM();
        if(gameover || (round_handler_IsActive() && !round_handler_IsRoundStarted()) || self.draggedby != world || time < game_starttime || (autocvar_g_campaign && !campaign_bots_may_start) || time < self.spawn_time)
        {
                mspeed = 0;
@@ -1183,7 +1183,7 @@ void Monster_Move_2D(float mspeed, float allow_jumpoff)
 }
 
 void Monster_Anim()
-{
+{SELFPARAM();
        int deadbits = (self.anim_state & (ANIMSTATE_DEAD1 | ANIMSTATE_DEAD2));
        if(self.deadflag)
        {
@@ -1220,7 +1220,7 @@ void Monster_Anim()
 }
 
 void Monster_Think()
-{
+{SELFPARAM();
        self.think = Monster_Think;
        self.nextthink = self.ticrate;
 
@@ -1236,11 +1236,11 @@ void Monster_Think()
 
        Monster_Anim();
 
-       CSQCMODEL_AUTOUPDATE();
+       CSQCMODEL_AUTOUPDATE(self);
 }
 
 float Monster_Spawn_Setup()
-{
+{SELFPARAM();
        MON_ACTION(self.monsterid, MR_SETUP);
 
        // ensure some basic needs are met
@@ -1300,7 +1300,7 @@ float Monster_Spawn_Setup()
 }
 
 bool Monster_Spawn(int mon_id)
-{
+{SELFPARAM();
        // setup the basic required properties for a monster
        entity mon = get_monsterinfo(mon_id);
        if(!mon.monsterid) { return false; } // invalid monster
@@ -1400,7 +1400,7 @@ bool Monster_Spawn(int mon_id)
        if(!(self.spawnflags & MONSTERFLAG_RESPAWNED))
                monster_setupcolors(self);
 
-       CSQCMODEL_AUTOINIT();
+       CSQCMODEL_AUTOINIT(self);
 
        return true;
 }
index 6cf28d6f1724bf6d1342c487cb10b6fe2848c973..b636772687ebdc66113ffec3ad69fdabe7995082 100644 (file)
@@ -1,5 +1,5 @@
 void _Movetype_Physics_Follow() // SV_Physics_Follow
-{
+{SELFPARAM();
        entity e = self.move_aiment; // TODO: networking?
 
        // LordHavoc: implemented rotation on MOVETYPE_FOLLOW objects
index ac2f9034ea7c7e47e5d782b8d0b183d5d49dd010..cfa6346dc44178904f2003208d28e4a63198bb1e 100644 (file)
@@ -33,7 +33,7 @@ void _Movetype_WallFriction(vector stepnormal)  // SV_WallFriction
 
 vector planes[MAX_CLIP_PLANES];
 int _Movetype_FlyMove(float dt, bool applygravity, vector stepnormal, float stepheight) // SV_FlyMove
-{
+{SELFPARAM();
        int blocked = 0, bumpcount;
        int i, j, numplanes = 0;
        float time_left = dt, grav = 0;
@@ -317,8 +317,7 @@ void _Movetype_CheckWaterTransition(entity ent)  // SV_CheckWaterTransition
 }
 
 void _Movetype_Impact(entity oth)  // SV_Impact
-{
-       entity oldself = self;
+{SELFPARAM();
        entity oldother = other;
 
        if(self.move_touch)
@@ -333,26 +332,23 @@ void _Movetype_Impact(entity oth)  // SV_Impact
        if(oth.move_touch)
        {
                other = self;
-               self = oth;
 
-               self.move_touch();
+               WITH(entity, self, oth, oth.move_touch());
 
-               self = oldself;
                other = oldother;
        }
 }
 
 void _Movetype_LinkEdict_TouchAreaGrid()  // SV_LinkEdict_TouchAreaGrid
-{
-       entity oldself = self;
+{SELFPARAM();
        entity oldother = other;
 
        for (entity e = findradius(0.5 * (self.absmin + self.absmax), 0.5 * vlen(self.absmax - self.absmin)); e; e = e.chain)
        {
-               if(e.move_touch && boxesoverlap(e.absmin, e.absmax, oldself.absmin, oldself.absmax))
+               if(e.move_touch && boxesoverlap(e.absmin, e.absmax, this.absmin, this.absmax))
                {
-                       self = e;
-                       other = oldself;
+                       setself(e);
+                       other = this;
 
                        trace_allsolid = false;
                        trace_startsolid = false;
@@ -362,18 +358,18 @@ void _Movetype_LinkEdict_TouchAreaGrid()  // SV_LinkEdict_TouchAreaGrid
                        trace_endpos = e.origin;
                        trace_plane_normal = '0 0 1';
                        trace_plane_dist = 0;
-                       trace_ent = oldself;
+                       trace_ent = this;
 
                        e.move_touch();
                }
        }
 
        other = oldother;
-       self = oldself;
+       setself(this);
 }
 
 void _Movetype_LinkEdict(bool touch_triggers)  // SV_LinkEdict
-{
+{SELFPARAM();
        vector mi, ma;
        if(self.solid == SOLID_BSP)
        {
@@ -416,7 +412,7 @@ void _Movetype_LinkEdict(bool touch_triggers)  // SV_LinkEdict
 }
 
 bool _Movetype_TestEntityPosition(vector ofs)  // SV_TestEntityPosition
-{
+{SELFPARAM();
 //     vector org = self.move_origin + ofs;
 
        int cont = self.dphitcontentsmask;
@@ -433,7 +429,7 @@ bool _Movetype_TestEntityPosition(vector ofs)  // SV_TestEntityPosition
 }
 
 bool _Movetype_UnstickEntity()  // SV_UnstickEntity
-{
+{SELFPARAM();
        if(!_Movetype_TestEntityPosition('0 0 0')) return true;
        if(!_Movetype_TestEntityPosition('-1 0 0')) goto success;
        if(!_Movetype_TestEntityPosition('1 0 0')) goto success;
@@ -470,7 +466,7 @@ vector _Movetype_ClipVelocity(vector vel, vector norm, float f)  // SV_ClipVeloc
 }
 
 void _Movetype_PushEntityTrace(vector push)
-{
+{SELFPARAM();
        vector end = self.move_origin + push;
        int type;
        if(self.move_nomonsters)
@@ -486,7 +482,7 @@ void _Movetype_PushEntityTrace(vector push)
 }
 
 float _Movetype_PushEntity(vector push, bool failonstartsolid)  // SV_PushEntity
-{
+{SELFPARAM();
        _Movetype_PushEntityTrace(push);
 
        if(trace_startsolid && failonstartsolid)
@@ -560,7 +556,7 @@ void makevectors_matrix(vector myangles)  // AngleVectorsFLU
 }
 
 void _Movetype_Physics_Frame(float movedt)
-{
+{SELFPARAM();
        self.move_didgravity = -1;
        switch (self.move_movetype)
        {
@@ -596,7 +592,7 @@ void _Movetype_Physics_Frame(float movedt)
 }
 
 void Movetype_Physics_NoMatchServer()  // optimized
-{
+{SELFPARAM();
        float movedt = time - self.move_time;
        self.move_time = time;
 
@@ -616,7 +612,7 @@ void Movetype_Physics_MatchServer(bool sloppy)
 }
 
 void Movetype_Physics_MatchTicrate(float tr, bool sloppy)  // SV_Physics_Entity
-{
+{SELFPARAM();
        if(tr <= 0)
        {
                Movetype_Physics_NoMatchServer();
index 954033edbe9f59256914958a0963b2fd29f6b90b..aeb75ded3053773acb45263e9fb46fe86636079b 100644 (file)
@@ -1,5 +1,5 @@
 void _Movetype_PushMove(float dt)  // SV_PushMove
-{
+{SELFPARAM();
        if (self.move_velocity == '0 0 0' && self.move_avelocity == '0 0 0')
        {
                self.move_ltime += dt;
@@ -93,26 +93,23 @@ void _Movetype_PushMove(float dt)  // SV_PushMove
                        if (check.move_movetype == 32)  // MOVETYPE_PHYSICS
                        {
                                check.move_origin = check.move_origin + move;
-                               entity oldself = self;
-                               self = check;
-                               _Movetype_LinkEdict(true);
-                               self = oldself;
+                               WITH(entity, self, check, _Movetype_LinkEdict(true));
                                continue;
                        }
 
                        // try moving the contacted entity
                        self.solid = SOLID_NOT;
-                       entity oldself = self;
-                       self = check;
-                       if (!_Movetype_PushEntity(move, true))
+                       bool flag;
+                       WITH(entity, self, check, {
+                               flag = _Movetype_PushEntity(move, true);
+                       });
+                       if (!flag)
                        {
-                               self = oldself;
                                // entity "check" got teleported
                                check.move_angles_y += trace_fraction * moveangle.y;
                                self.solid = savesolid;
                                continue;  // pushed enough
                        }
-                       self = oldself;
                        // FIXME: turn players specially
                        check.move_angles_y += trace_fraction * moveangle.y;
                        self.solid = savesolid;
@@ -131,7 +128,7 @@ void _Movetype_PushMove(float dt)  // SV_PushMove
 }
 
 void _Movetype_Physics_Pusher(float dt)  // SV_Physics_Pusher
-{
+{SELFPARAM();
        float oldltime = self.move_ltime;
        float thinktime = self.move_nextthink;
        float movetime;
index 822bf093511606dc3faacd664f9984c07ae746d2..f4884ba27a23a5137af32c369dade827dc06d282 100644 (file)
@@ -1,5 +1,5 @@
 void _Movetype_Physics_Step(float dt) // SV_Physics_Step
-{
+{SELFPARAM();
        if(self.move_flags & FL_ONGROUND)
        {
                if(self.velocity_z >= (1.0 / 32.0) && UPWARD_VELOCITY_CLEARS_ONGROUND)
index 6ed0407eb30f80c2776e34551191d636efe37da3..32ce9ca31223f4afd2b42c00259ec2fce1e3f214 100644 (file)
@@ -1,7 +1,7 @@
 #include "../physics.qh"
 
 void _Movetype_Physics_Toss(float dt)  // SV_Physics_Toss
-{
+{SELFPARAM();
        if (self.move_flags & FL_ONGROUND)
        {
                if (self.move_velocity.z >= 1 / 32)
index bd01be4e747fdf2f5b47079aeee6db5715ff0ec7..0f18a47bfc6ee4bcc487f464ddd6eeb625e615ef 100644 (file)
@@ -1,5 +1,5 @@
 void _Movetype_Physics_Walk(float dt)  // SV_WalkMove
-{
+{SELFPARAM();
        vector stepnormal = '0 0 0';
 
        // if frametime is 0 (due to client sending the same timestamp twice), don't move
index a9a86f81f1984e331a60ccc541b5f89c9af4de4d..e93ed49a4b8775beb4fdaec8b4a069dba769655e 100644 (file)
@@ -9,7 +9,7 @@ REGISTER_MUTATOR(casings, true);
 
 #ifdef SVQC
 void SpawnCasing(vector vel, float randomvel, vector ang, vector avel, float randomavel, int casingtype, entity casingowner)
-{
+{SELFPARAM();
     vector org = self.origin + self.view_ofs + self.weaponentity.spawnorigin.x * v_forward - self.weaponentity.spawnorigin.y * v_right + self.weaponentity.spawnorigin.z * v_up;
 
     if (!sound_allowed(MSG_BROADCAST, casingowner))
@@ -36,12 +36,12 @@ class(Casing) .int state;
 class(Casing) .float cnt;
 
 void Casing_Delete()
-{
+{SELFPARAM();
     remove(self);
 }
 
 void Casing_Draw()
-{
+{SELFPARAM();
     if (self.move_flags & FL_ONGROUND)
     {
         self.move_angles_x = 0;
@@ -64,7 +64,7 @@ void Casing_Draw()
 }
 
 void Casing_Touch()
-{
+{SELFPARAM();
     if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
     {
         Casing_Delete();
@@ -100,7 +100,7 @@ void Casing_Touch()
 }
 
 void Casing_Damage(float thisdmg, int hittype, vector org, vector thisforce)
-{
+{SELFPARAM();
     if (thisforce.z < 0)
         thisforce.z = 0;
     self.move_velocity = self.move_velocity + thisforce + '0 0 100';
index eec2d356b01b72ca3f9ef6509b2e026a872a0227..8d21f17057a1da4baf5770f618d73f720fb0bccb 100644 (file)
@@ -25,7 +25,7 @@ CLASS(DamageText, Object)
     ATTRIB(DamageText, time_prev, float, time)
 
     void DamageText_draw() {
-        entity this = self;
+        SELFPARAM();
         float dt = time - this.time_prev;
         this.time_prev = time;
         setorigin(this, this.origin + dt * this.velocity);
index c3a025080d39315274a0676db7812d682001fc47..d7ca5a3351585f82148d90d6457d184ff13f3b8c 100644 (file)
@@ -149,24 +149,28 @@ float Item_ItemsTime_UpdateTime(entity e, float t)
     return t;
 }
 
-MUTATOR_HOOKFUNCTION(itemstime, reset_map_global) {
+MUTATOR_HOOKFUNCTION(itemstime, reset_map_global)
+{SELFPARAM();
     Item_ItemsTime_ResetTimes();
     // ALL the times need to be reset before .reset()ing each item
     // since Item_Reset schedules respawn of superweapons and powerups
-    for (self = world; (self = nextent(self)); )
-    if (IS_NOT_A_CLIENT(self))
+    for (entity e = NULL; (e = nextent(e)); )
+    if (IS_NOT_A_CLIENT(e))
     {
+        setself(e);
         if (self.reset)
             Item_ItemsTime_SetTime(self, 0);
     }
     Item_ItemsTime_SetTimesForAllPlayers();
 }
 
-MUTATOR_HOOKFUNCTION(itemstime, MakePlayerObserver) {
+MUTATOR_HOOKFUNCTION(itemstime, MakePlayerObserver)
+{SELFPARAM();
     Item_ItemsTime_SetTimesForPlayer(self);
 }
 
-MUTATOR_HOOKFUNCTION(itemstime, PlayerSpawn) {
+MUTATOR_HOOKFUNCTION(itemstime, PlayerSpawn)
+{SELFPARAM();
     if (warmup_stage) return;
     Item_ItemsTime_ResetTimesForPlayer(self);
 }
index c9858830b670f94c58ac002516713f6f477ae6e2..2015acb5f8cda0d73408d9794465873fbf1b5aa6 100644 (file)
@@ -5,7 +5,7 @@ REGISTER_MUTATOR(waypointsprites, true);
 #ifdef SVQC
 /** flags origin [team displayrule] [spritename] [spritename2] [spritename3] [lifetime maxdistance hideable] */
 float WaypointSprite_SendEntity(entity to, float sendflags)
-{
+{SELFPARAM();
     WriteMutator(MSG_ENTITY, waypointsprites);
 
     sendflags = sendflags & 0x7F;
@@ -118,7 +118,7 @@ MUTATOR_HOOKFUNCTION(waypointsprites, CSQC_Ent_Update) {
 }
 
 void Ent_RemoveWaypointSprite()
-{
+{SELFPARAM();
     if (self.netname) strunzone(self.netname);
     if (self.netname2) strunzone(self.netname2);
     if (self.netname3) strunzone(self.netname3);
@@ -126,7 +126,7 @@ void Ent_RemoveWaypointSprite()
 
 /** flags origin [team displayrule] [spritename] [spritename2] [spritename3] [lifetime maxdistance hideable] */
 void Ent_WaypointSprite()
-{
+{SELFPARAM();
     int sendflags = ReadByte();
     self.wp_extra = ReadByte();
 
@@ -232,7 +232,7 @@ void Ent_WaypointSprite()
 
 #ifdef CSQC
 float spritelookupblinkvalue(string s)
-{
+{SELFPARAM();
     if (s == WP_Weapon.netname) {
         if (get_weaponinfo(self.wp_extra).spawnflags & WEP_FLAG_SUPERWEAPON)
             return 2;
@@ -243,7 +243,7 @@ float spritelookupblinkvalue(string s)
 }
 
 vector spritelookupcolor(string s, vector def)
-{
+{SELFPARAM();
     if (s == WP_Weapon.netname) return get_weaponinfo(self.wp_extra).wpcolor;
     if (s == WP_Item.netname) return ITEMS[self.wp_extra].m_color;
     if (s == WP_Buff.netname) return BUFFS[self.wp_extra].m_color;
@@ -251,7 +251,7 @@ vector spritelookupcolor(string s, vector def)
 }
 
 string spritelookuptext(string s)
-{
+{SELFPARAM();
     if (s == WP_RaceStartFinish.netname) return (race_checkpointtime || race_mycheckpointtime) ? _("Finish") : _("Start");
     if (s == WP_Weapon.netname) return get_weaponinfo(self.wp_extra).message;
     if (s == WP_Item.netname) return ITEMS[self.wp_extra].m_waypoint;
@@ -456,7 +456,7 @@ vector fixrgbexcess(vector rgb)
 }
 
 void Draw_WaypointSprite()
-{
+{SELFPARAM();
     if (self.lifetime)
         self.alpha = pow(bound(0, (self.fadetime - time) / self.lifetime, 1), waypointsprite_timealphaexponent);
     else
@@ -912,7 +912,7 @@ void WaypointSprite_Disown(entity wp, float fadetime)
 }
 
 void WaypointSprite_Think()
-{
+{SELFPARAM();
     bool doremove = false;
 
     if (self.fade_time && time >= self.teleport_time)
@@ -930,7 +930,7 @@ void WaypointSprite_Think()
 }
 
 float WaypointSprite_visible_for_player(entity e)
-{
+{SELFPARAM();
     // personal waypoints
     if (self.enemy && self.enemy != e)
         return false;
@@ -972,7 +972,7 @@ float WaypointSprite_isteammate(entity e, entity e2)
 }
 
 float WaypointSprite_Customize()
-{
+{SELFPARAM();
     // this is not in SendEntity because it shall run every frame, not just every update
 
     // make spectators see what the player would see
@@ -987,7 +987,7 @@ float WaypointSprite_Customize()
 float WaypointSprite_SendEntity(entity to, float sendflags);
 
 void WaypointSprite_Reset()
-{
+{SELFPARAM();
     // if a WP wants to time out, let it time out immediately; other WPs ought to be reset/killed by their owners
 
     if (self.fade_time) // there was there before: || g_keyhunt, do we really need this?
@@ -1056,7 +1056,7 @@ entity WaypointSprite_DeployFixed(
     vector ofs,
     float icon // initial icon
 )
-{
+{SELFPARAM();
     float t;
     if (teamplay)
         t = self.team;
@@ -1075,7 +1075,7 @@ entity WaypointSprite_DeployPersonal(
     vector ofs,
     float icon // initial icon
 )
-{
+{SELFPARAM();
     return WaypointSprite_Spawn(spr, 0, 0, world, ofs, world, 0, self, waypointsprite_deployed_personal, false, icon);
 }
 
@@ -1084,7 +1084,7 @@ entity WaypointSprite_Attach(
     float limited_range,
     float icon // initial icon
 )
-{
+{SELFPARAM();
     float t;
     if (self.waypointsprite_attachedforcarrier)
         return world; // can't attach to FC
@@ -1122,25 +1122,25 @@ void WaypointSprite_DetachCarrier(entity carrier)
 }
 
 void WaypointSprite_ClearPersonal()
-{
+{SELFPARAM();
     WaypointSprite_Kill(self.waypointsprite_deployed_personal);
 }
 
 void WaypointSprite_ClearOwned()
-{
+{SELFPARAM();
     WaypointSprite_Kill(self.waypointsprite_deployed_fixed);
     WaypointSprite_Kill(self.waypointsprite_deployed_personal);
     WaypointSprite_Kill(self.waypointsprite_attached);
 }
 
 void WaypointSprite_PlayerDead()
-{
+{SELFPARAM();
     WaypointSprite_Disown(self.waypointsprite_attached, waypointsprite_deadlifetime);
     WaypointSprite_DetachCarrier(self);
 }
 
 void WaypointSprite_PlayerGone()
-{
+{SELFPARAM();
     WaypointSprite_Disown(self.waypointsprite_deployed_fixed, waypointsprite_deadlifetime);
     WaypointSprite_Kill(self.waypointsprite_deployed_personal);
     WaypointSprite_Disown(self.waypointsprite_attached, waypointsprite_deadlifetime);
index f9ddb8e99153d0f60b06cea63ba491589d35a3c8..08f579b275e3c16477dc7c3155be9e088a518e9c 100644 (file)
@@ -17,7 +17,7 @@
 
 #ifdef SVQC
 float healer_send(entity to, int sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_HEALING_ORB);
        WriteByte(MSG_ENTITY, sf);
 
@@ -41,7 +41,7 @@ float healer_send(entity to, int sf)
 #ifdef CSQC
 .float ltime;
 void healer_draw()
-{
+{SELFPARAM();
        float dt = time - self.move_time;
        self.move_time = time;
        if(dt <= 0)
@@ -53,7 +53,7 @@ void healer_draw()
 }
 
 void healer_setup()
-{
+{SELFPARAM();
        setmodel(self, "models/ctf/shield.md3");
 
        setorigin(self, self.origin);
@@ -75,7 +75,7 @@ void healer_setup()
 }
 
 void ent_healer()
-{
+{SELFPARAM();
        int sf = ReadByte();
 
        if(sf & TNSF_SETUP)
index fb9958b08fcbd186fd151b65afb89462d442a357..f748f9903825ad96ec0073a99af653e533717278 100644 (file)
@@ -2,7 +2,7 @@
 
 #ifdef SVQC
 void sv_notice_join_think()
-{
+{SELFPARAM();
     //NextLevel();
     float argc = tokenizebyseparator(autocvar_sv_join_notices, "|");
     if(argc > 0)
@@ -15,7 +15,7 @@ void sv_notice_join_think()
 }
 
 void sv_notice_join()
-{
+{SELFPARAM();
     // to-do: make sv_join_notices support per-entry times
     if(autocvar_sv_join_notices == "")
         return;
index 5145e5340cff8f3a78748bb88c1d107e90ac8e08..b040a536894fd62eb4d147d6dedb6648e18826ca 100644 (file)
@@ -1756,7 +1756,7 @@ void Read_Notification(float is_new)
 
 #ifdef SVQC
 void Net_Notification_Remove()
-{
+{SELFPARAM();
        if (!self) { backtrace(sprintf("Net_Notification_Remove() at %f: Missing self!?\n", time)); return; }
 
        #ifdef NOTIFICATIONS_DEBUG
@@ -1774,7 +1774,7 @@ void Net_Notification_Remove()
 }
 
 float Net_Write_Notification(entity client, int sf)
-{
+{SELFPARAM();
        if(Notification_ShouldSend(self.nent_broadcast, client, self.nent_client))
        {
                WriteByte(MSG_ENTITY, ENT_CLIENT_NOTIFICATION);
index b53696b987b18ad7604406bde27eac5763560db3..b3db77143b375f4bdb315e22a1a3c0d057aecd38 100644 (file)
@@ -116,7 +116,7 @@ void Physics_AddStats()
 }
 
 void Physics_UpdateStats(float maxspd_mod)
-{
+{SELFPARAM();
        // blah
        self.stat_pl_view_ofs = PL_VIEW_OFS;
        self.stat_pl_crouch_view_ofs = PL_CROUCH_VIEW_OFS;
@@ -222,7 +222,7 @@ vector unstick_offsets[unstick_count] =
 };
 
 void PM_ClientMovement_Unstick()
-{
+{SELFPARAM();
        float i;
        for (i = 0; i < unstick_count; i++)
        {
@@ -237,7 +237,7 @@ void PM_ClientMovement_Unstick()
 }
 
 void PM_ClientMovement_UpdateStatus(bool ground)
-{
+{SELFPARAM();
        // make sure player is not stuck
        PM_ClientMovement_Unstick();
 
@@ -308,7 +308,7 @@ void PM_ClientMovement_UpdateStatus(bool ground)
 }
 
 void PM_ClientMovement_Move()
-{
+{SELFPARAM();
 #ifdef CSQC
        int bump;
        float t;
@@ -397,7 +397,7 @@ void PM_ClientMovement_Move()
 }
 
 void CPM_PM_Aircontrol(vector wishdir, float wishspeed)
-{
+{SELFPARAM();
        float k = 32 * (2 * IsMoveInDirection(self.movement, 0) - 1);
        if (k <= 0)
                return;
@@ -434,7 +434,7 @@ float AdjustAirAccelQW(float accelqw, float factor)
 //   prvm_globalset server speedclamp_mode 1
 //     (or 2)
 void PM_Accelerate(vector wishdir, float wishspeed, float wishspeed0, float accel, float accelqw, float stretchfactor, float sidefric, float speedlimit)
-{
+{SELFPARAM();
        float speedclamp = stretchfactor > 0 ? stretchfactor
        : accelqw < 0 ? 1 // full clamping, no stretch
        : -1; // no clamping
@@ -498,7 +498,7 @@ void PM_Accelerate(vector wishdir, float wishspeed, float wishspeed0, float acce
 }
 
 void PM_AirAccelerate(vector wishdir, float wishspeed)
-{
+{SELFPARAM();
        if (wishspeed == 0)
                return;
 
@@ -541,7 +541,7 @@ returns true if handled
 =============
 */
 bool PlayerJump (void)
-{
+{SELFPARAM();
        if (PHYS_FROZEN(self))
                return true; // no jumping in freezetag when frozen
 
@@ -657,7 +657,7 @@ bool PlayerJump (void)
 }
 
 void CheckWaterJump()
-{
+{SELFPARAM();
 // check for a jump-out-of-water
        makevectors(self.v_angle);
        vector start = self.origin;
@@ -697,7 +697,7 @@ void CheckWaterJump()
 // Hack: shouldn't need to know about this
 .float multijump_count;
 void CheckPlayerJump()
-{
+{SELFPARAM();
 #ifdef SVQC
        float was_flying = ITEMS_STAT(self) & IT_USING_JETPACK;
 #endif
@@ -757,7 +757,7 @@ float racecar_angle(float forward, float down)
 }
 
 void RaceCarPhysics()
-{
+{SELFPARAM();
 #ifdef SVQC
        // using this move type for "big rigs"
        // the engine does not push the entity!
@@ -977,7 +977,7 @@ void SpecialCommand()
 }
 
 void PM_check_race_movetime(void)
-{
+{SELFPARAM();
 #ifdef SVQC
        self.race_movetime_frac += PHYS_INPUT_TIMELENGTH;
        float f = floor(self.race_movetime_frac);
@@ -988,7 +988,7 @@ void PM_check_race_movetime(void)
 }
 
 float PM_check_specialcommand(float buttons)
-{
+{SELFPARAM();
 #ifdef SVQC
        string c;
        if (!buttons)
@@ -1025,7 +1025,7 @@ float PM_check_specialcommand(float buttons)
 }
 
 void PM_check_nickspam(void)
-{
+{SELFPARAM();
 #ifdef SVQC
        if (time >= self.nickspamtime)
                return;
@@ -1047,7 +1047,7 @@ void PM_check_nickspam(void)
 }
 
 void PM_check_punch()
-{
+{SELFPARAM();
 #ifdef SVQC
        if (self.punchangle != '0 0 0')
        {
@@ -1070,7 +1070,7 @@ void PM_check_punch()
 }
 
 void PM_check_spider(void)
-{
+{SELFPARAM();
 #ifdef SVQC
        if (time >= self.spider_slowness)
                return;
@@ -1083,7 +1083,7 @@ void PM_check_spider(void)
 
 // predict frozen movement, as frozen players CAN move in some cases
 void PM_check_frozen(void)
-{
+{SELFPARAM();
        if (!PHYS_FROZEN(self))
                return;
        if (PHYS_DODGING_FROZEN
@@ -1110,7 +1110,7 @@ void PM_check_frozen(void)
 }
 
 void PM_check_hitground()
-{
+{SELFPARAM();
 #ifdef SVQC
        if (IS_ONGROUND(self))
        if (IS_PLAYER(self)) // no fall sounds for observers thank you very much
@@ -1137,7 +1137,7 @@ void PM_check_hitground()
 }
 
 void PM_check_blocked(void)
-{
+{SELFPARAM();
 #ifdef SVQC
        if (!self.player_blocked)
                return;
@@ -1151,7 +1151,7 @@ float speedaward_lastsent;
 float speedaward_lastupdate;
 #endif
 void PM_check_race(void)
-{
+{SELFPARAM();
 #ifdef SVQC
        if(!(g_cts || g_race))
                return;
@@ -1181,7 +1181,7 @@ void PM_check_race(void)
 }
 
 void PM_check_vortex(void)
-{
+{SELFPARAM();
 #ifdef SVQC
        // WEAPONTODO
        float xyspeed = vlen(vec2(self.velocity));
@@ -1197,7 +1197,7 @@ void PM_check_vortex(void)
 }
 
 void PM_fly(float maxspd_mod)
-{
+{SELFPARAM();
        // noclipping or flying
        UNSET_ONGROUND(self);
 
@@ -1218,7 +1218,7 @@ void PM_fly(float maxspd_mod)
 }
 
 void PM_swim(float maxspd_mod)
-{
+{SELFPARAM();
        // swimming
        UNSET_ONGROUND(self);
 
@@ -1301,7 +1301,7 @@ void PM_swim(float maxspd_mod)
 }
 
 void PM_ladder(float maxspd_mod)
-{
+{SELFPARAM();
        // on a spawnfunc_func_ladder or swimming in spawnfunc_func_water
        UNSET_ONGROUND(self);
 
@@ -1354,7 +1354,7 @@ void PM_ladder(float maxspd_mod)
 }
 
 void PM_jetpack(float maxspd_mod)
-{
+{SELFPARAM();
        //makevectors(self.v_angle.y * '0 1 0');
        makevectors(self.v_angle);
        vector wishvel = v_forward * self.movement_x
@@ -1470,7 +1470,7 @@ void PM_jetpack(float maxspd_mod)
 }
 
 void PM_walk(float buttons_prev, float maxspd_mod)
-{
+{SELFPARAM();
        if (!WAS_ONGROUND(self))
        {
 #ifdef SVQC
@@ -1555,7 +1555,7 @@ void PM_walk(float buttons_prev, float maxspd_mod)
 }
 
 void PM_air(float buttons_prev, float maxspd_mod)
-{
+{SELFPARAM();
        makevectors(self.v_angle.y * '0 1 0');
        vector wishvel = v_forward * self.movement.x
                                        + v_right * self.movement.y;
@@ -1641,7 +1641,7 @@ bool IsFlying(entity a)
 }
 
 void PM_Main()
-{
+{SELFPARAM();
        int buttons = PHYS_INPUT_BUTTON_MASK(self);
 #ifdef CSQC
        self.items = getstati(STAT_ITEMS, 0, 24);
@@ -1923,7 +1923,7 @@ void SV_PlayerPhysics(void)
 #elif defined(CSQC)
 void CSQC_ClientMovement_PlayerMove_Frame(void)
 #endif
-{
+{SELFPARAM();
        PM_Main();
 
 #ifdef CSQC
index 9fb2f56c9d7ee322c457dfbd25699f8c61350e02..298043bb573ae1b07e410ea3d3d8bac9c613cb20 100644 (file)
@@ -1,7 +1,7 @@
 #ifdef SVQC
 .float height;
 void func_bobbing_controller_think()
-{
+{SELFPARAM();
        vector v;
        self.nextthink = time + 0.1;
 
@@ -29,7 +29,7 @@ dmg : Do this mutch dmg every .dmgtime intervall when blocked
 dmgtime : See above.
 */
 void spawnfunc_func_bobbing()
-{
+{SELFPARAM();
        entity controller;
        if (self.noise != "")
        {
index b70d8b600938f5e8ac1fc253aad1083310c00806..d705f842fba17a692b59995763c67e517de685fe 100644 (file)
@@ -50,7 +50,7 @@ void func_breakable_damage(entity inflictor, entity attacker, float damage, int
 // - basically func_assault_destructible for general gameplay use
 //
 void LaunchDebris (string debrisname, vector force)
-{
+{SELFPARAM();
        entity dbr = spawn();
        setorigin(dbr, self.absmin
                   + '1 0 0' * random() * (self.absmax.x - self.absmin.x)
@@ -78,7 +78,7 @@ void LaunchDebris (string debrisname, vector force)
 }
 
 void func_breakable_colormod()
-{
+{SELFPARAM();
        float h;
        if (!(self.spawnflags & 2))
                return;
@@ -90,11 +90,11 @@ void func_breakable_colormod()
        else
                self.colormod = '1 1 1';
 
-       CSQCMODEL_AUTOUPDATE();
+       CSQCMODEL_AUTOUPDATE(self);
 }
 
 void func_breakable_look_destroyed()
-{
+{SELFPARAM();
        float floorZ;
 
        if(self.solid == SOLID_BSP) // in case a misc_follow moved me, save the current origin first
@@ -112,26 +112,26 @@ void func_breakable_look_destroyed()
                self.effects &= ~EF_NODRAW;
        }
 
-       CSQCMODEL_AUTOUPDATE();
+       CSQCMODEL_AUTOUPDATE(self);
 
        self.solid = SOLID_NOT;
 }
 
 void func_breakable_look_restore()
-{
+{SELFPARAM();
        setmodel(self, self.mdl);
        self.effects &= ~EF_NODRAW;
 
        if(self.mdl_dead != "") // only do this if we use mdl_dead, to behave better with misc_follow
                setorigin(self, self.dropped_origin);
 
-       CSQCMODEL_AUTOUPDATE();
+       CSQCMODEL_AUTOUPDATE(self);
 
        self.solid = SOLID_BSP;
 }
 
 void func_breakable_behave_destroyed()
-{
+{SELFPARAM();
        self.health = self.max_health;
        self.takedamage = DAMAGE_NO;
        self.bot_attack = false;
@@ -145,7 +145,7 @@ void func_breakable_behave_destroyed()
 }
 
 void func_breakable_behave_restore()
-{
+{SELFPARAM();
        self.health = self.max_health;
        if(self.sprite)
        {
@@ -166,7 +166,7 @@ void func_breakable_behave_restore()
 }
 
 void func_breakable_init_for_player(entity player)
-{
+{SELFPARAM();
        if (self.noise1 && self.state == 0 && clienttype(player) == CLIENTTYPE_REAL)
        {
                msg_entity = player;
@@ -175,23 +175,24 @@ void func_breakable_init_for_player(entity player)
 }
 
 void func_breakable_destroyed()
-{
+{SELFPARAM();
        func_breakable_look_destroyed();
        func_breakable_behave_destroyed();
 
-       CSQCMODEL_AUTOUPDATE();
+       CSQCMODEL_AUTOUPDATE(self);
 }
 
 void func_breakable_restore()
-{
+{SELFPARAM();
        func_breakable_look_restore();
        func_breakable_behave_restore();
 
-       CSQCMODEL_AUTOUPDATE();
+       CSQCMODEL_AUTOUPDATE(self);
 }
 
 vector debrisforce; // global, set before calling this
-void func_breakable_destroy() {
+void func_breakable_destroy()
+{SELFPARAM();
        float n, i;
        string oldmsg;
 
@@ -227,7 +228,7 @@ void func_breakable_destroy() {
 }
 
 void func_breakable_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        if(self.state == 1)
                return;
        if(self.spawnflags & DOOR_NOSPLASH)
@@ -253,7 +254,7 @@ void func_breakable_damage(entity inflictor, entity attacker, float damage, int
 }
 
 void func_breakable_reset()
-{
+{SELFPARAM();
        self.team = self.team_saved;
        func_breakable_look_restore();
        if(self.spawnflags & 1)
@@ -261,12 +262,12 @@ void func_breakable_reset()
        else
                func_breakable_behave_restore();
 
-       CSQCMODEL_AUTOUPDATE();
+       CSQCMODEL_AUTOUPDATE(self);
 }
 
 // destructible walls that can be used to trigger target_objective_decrease
 void spawnfunc_func_breakable()
-{
+{SELFPARAM();
        float n, i;
        if(!self.health)
                self.health = 100;
@@ -330,7 +331,7 @@ void spawnfunc_func_breakable()
        self.init_for_player_needed = 1;
        self.init_for_player = func_breakable_init_for_player;
 
-       CSQCMODEL_AUTOINIT();
+       CSQCMODEL_AUTOINIT(self);
 }
 
 // for use in maps with a "model" key set
index bb8875b4221ace9b5bd83c25fac38d3fc3be7b27..228b3f810aa5c3b62b91a8508cbd9a545ddcfcf4 100644 (file)
@@ -5,7 +5,7 @@ void() button_wait;
 void() button_return;
 
 void button_wait()
-{
+{SELFPARAM();
        self.state = STATE_TOP;
        self.SUB_NEXTTHINK = self.SUB_LTIME + self.wait;
        self.SUB_THINK = button_return;
@@ -15,12 +15,12 @@ void button_wait()
 }
 
 void button_done()
-{
+{SELFPARAM();
        self.state = STATE_BOTTOM;
 }
 
 void button_return()
-{
+{SELFPARAM();
        self.state = STATE_DOWN;
        SUB_CalcMove (self.pos1, TSPEED_LINEAR, self.speed, button_done);
        self.frame = 0;                 // use normal textures
@@ -36,7 +36,7 @@ void button_blocked()
 
 
 void button_fire()
-{
+{SELFPARAM();
        self.health = self.max_health;
        self.takedamage = DAMAGE_NO;    // will be reset upon return
 
@@ -51,7 +51,7 @@ void button_fire()
 }
 
 void button_reset()
-{
+{SELFPARAM();
        self.health = self.max_health;
        setorigin(self, self.pos1);
        self.frame = 0;                 // use normal textures
@@ -61,7 +61,7 @@ void button_reset()
 }
 
 void button_use()
-{
+{SELFPARAM();
        if(self.active != ACTIVE_ACTIVE)
                return;
 
@@ -70,7 +70,7 @@ void button_use()
 }
 
 void button_touch()
-{
+{SELFPARAM();
        if (!other)
                return;
        if (!other.iscreature)
@@ -84,7 +84,7 @@ void button_touch()
 }
 
 void button_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        if(self.spawnflags & DOOR_NOSPLASH)
                if(!(DEATH_ISSPECIAL(deathtype)) && (deathtype & HITTYPE_SPLASH))
                        return;
@@ -113,7 +113,7 @@ When a button is touched, it moves some distance in the direction of it's angle,
 3) in-out
 */
 void spawnfunc_func_button()
-{
+{SELFPARAM();
        SetMovedir ();
 
        if (!InitMovingBrushTrigger())
index 6ed01b0c59c91f7e47ee88f45b97b2d47e91de7a..4f5a7d6ea591f50b5ffbbf9bca9a3cb6874874a1 100644 (file)
@@ -1,5 +1,5 @@
 void conveyor_think()
-{
+{SELFPARAM();
 #ifdef CSQC
        // TODO: check if this is what is causing the glitchiness when switching between them
        float dt = time - self.move_time;
@@ -57,21 +57,21 @@ void conveyor_think()
 #ifdef SVQC
 
 void conveyor_use()
-{
+{SELFPARAM();
        self.state = !self.state;
 
        self.SendFlags |= 2;
 }
 
 void conveyor_reset()
-{
+{SELFPARAM();
        self.state = (self.spawnflags & 1);
 
        self.SendFlags |= 2;
 }
 
 bool conveyor_send(entity to, int sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_CONVEYOR);
        WriteByte(MSG_ENTITY, sf);
 
@@ -107,7 +107,7 @@ bool conveyor_send(entity to, int sf)
 }
 
 void conveyor_init()
-{
+{SELFPARAM();
        if (!self.speed)
                self.speed = 200;
        self.movedir = self.movedir * self.speed;
@@ -137,7 +137,7 @@ void spawnfunc_trigger_conveyor()
 }
 
 void spawnfunc_func_conveyor()
-{
+{SELFPARAM();
        SetMovedir();
        InitMovingBrushTrigger();
        self.movetype = MOVETYPE_NONE;
@@ -147,7 +147,7 @@ void spawnfunc_func_conveyor()
 #elif defined(CSQC)
 
 void conveyor_init()
-{
+{SELFPARAM();
        self.draw = conveyor_think;
        self.drawmask = MASK_NORMAL;
 
@@ -159,7 +159,7 @@ void conveyor_init()
 }
 
 void ent_conveyor()
-{
+{SELFPARAM();
        float sf = ReadByte();
 
        if(sf & 1)
index 4c56815d2ffc3488a089a23c27ab56b26d6176a8..053f0f5f669111264279bd9978756cf276fb92ea 100644 (file)
@@ -26,7 +26,7 @@ void() door_rotating_go_down;
 void() door_rotating_go_up;
 
 void door_blocked()
-{
+{SELFPARAM();
        if((self.spawnflags & 8)
 #ifdef SVQC
                && (other.takedamage != DAMAGE_NO)
@@ -85,7 +85,7 @@ void door_blocked()
 }
 
 void door_hit_top()
-{
+{SELFPARAM();
        if (self.noise1 != "")
                sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
        self.state = STATE_TOP;
@@ -102,14 +102,14 @@ void door_hit_top()
 }
 
 void door_hit_bottom()
-{
+{SELFPARAM();
        if (self.noise1 != "")
                sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
        self.state = STATE_BOTTOM;
 }
 
 void door_go_down()
-{
+{SELFPARAM();
        if (self.noise2 != "")
                sound (self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
        if (self.max_health)
@@ -123,7 +123,7 @@ void door_go_down()
 }
 
 void door_go_up()
-{
+{SELFPARAM();
        if (self.state == STATE_UP)
                return;         // already going up
 
@@ -155,7 +155,7 @@ ACTIVATION FUNCTIONS
 */
 
 float door_check_keys(void)
-{
+{SELFPARAM();
        local entity door;
 
 
@@ -212,15 +212,12 @@ float door_check_keys(void)
 }
 
 void door_fire()
-{
-       entity  oself;
+{SELFPARAM();
        entity  starte;
 
        if (self.owner != self)
                objerror ("door_fire: self.owner != self");
 
-       oself = self;
-
        if (self.spawnflags & DOOR_TOGGLE)
        {
                if (self.state == STATE_UP || self.state == STATE_TOP)
@@ -236,9 +233,9 @@ void door_fire()
                                {
                                        door_rotating_go_down ();
                                }
-                               self = self.enemy;
+                               setself(self.enemy);
                        } while ( (self != starte) && (self != world) );
-                       self = oself;
+                       setself(this);
                        return;
                }
        }
@@ -265,29 +262,23 @@ void door_fire()
                                door_rotating_go_up ();
                        }
                }
-               self = self.enemy;
+               setself(self.enemy);
        } while ( (self != starte) && (self != world) );
-       self = oself;
+       setself(this);
 }
 
 void door_use()
-{
-       entity oself;
-
+{SELFPARAM();
        //dprint("door_use (model: ");dprint(self.model);dprint(")\n");
 
        if (self.owner)
        {
-               oself = self;
-               self = self.owner;
-               door_fire ();
-               self = oself;
+               WITH(entity, self, self.owner, door_fire());
        }
 }
 
 void door_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
-       entity oself;
+{SELFPARAM();
        if(self.spawnflags & DOOR_NOSPLASH)
                if(!(DEATH_ISSPECIAL(deathtype)) && (deathtype & HITTYPE_SPLASH))
                        return;
@@ -301,12 +292,9 @@ void door_damage(entity inflictor, entity attacker, float damage, int deathtype,
 
        if (self.health <= 0)
        {
-               oself = self;
-               self = self.owner;
-               self.health = self.max_health;
-               self.takedamage = DAMAGE_NO;    // wil be reset upon return
-               door_use ();
-               self = oself;
+               self.owner.health = self.owner.max_health;
+               self.owner.takedamage = DAMAGE_NO;      // wil be reset upon return
+               WITH(entity, self, self.owner, door_use());
        }
 }
 
@@ -320,7 +308,7 @@ Prints messages
 */
 
 void door_touch()
-{
+{SELFPARAM();
        if (!IS_PLAYER(other))
                return;
        if (self.owner.attack_finished_single > time)
@@ -339,7 +327,7 @@ void door_touch()
 }
 
 void door_generic_plat_blocked()
-{
+{SELFPARAM();
 
        if((self.spawnflags & 8) && (other.takedamage != DAMAGE_NO)) { // KIll Kill Kill!!
 #ifdef SVQC
@@ -377,7 +365,7 @@ void door_generic_plat_blocked()
 }
 
 void door_rotating_hit_top()
-{
+{SELFPARAM();
        if (self.noise1 != "")
                sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
        self.state = STATE_TOP;
@@ -388,7 +376,7 @@ void door_rotating_hit_top()
 }
 
 void door_rotating_hit_bottom()
-{
+{SELFPARAM();
        if (self.noise1 != "")
                sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
        if (self.lip==666) // self.lip is used to remember reverse opening direction for door_rotating
@@ -400,7 +388,7 @@ void door_rotating_hit_bottom()
 }
 
 void door_rotating_go_down()
-{
+{SELFPARAM();
        if (self.noise2 != "")
                sound (self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
        if (self.max_health)
@@ -414,7 +402,7 @@ void door_rotating_go_down()
 }
 
 void door_rotating_go_up()
-{
+{SELFPARAM();
        if (self.state == STATE_UP)
                return;         // already going up
 
@@ -445,7 +433,7 @@ Spawned if a door lacks a real activator
 */
 
 void door_trigger_touch()
-{
+{SELFPARAM();
        if (other.health < 1)
 #ifdef SVQC
                if (!((other.iscreature || (other.flags & FL_PROJECTILE)) && !PHYS_DEAD(other)))
@@ -465,12 +453,12 @@ void door_trigger_touch()
 
        activator = other;
 
-       self = self.owner;
+       setself(self.owner);
        door_use ();
 }
 
 void spawn_field(vector fmins, vector fmaxs)
-{
+{SELFPARAM();
        entity  trigger;
        vector  t1 = fmins, t2 = fmaxs;
 
@@ -500,7 +488,7 @@ LinkDoors
 */
 
 entity LinkDoors_nextent(entity cur, entity near, entity pass)
-{
+{SELFPARAM();
        while((cur = find(cur, classname, self.classname)) && ((cur.spawnflags & 4) || cur.enemy))
        {
        }
@@ -524,7 +512,7 @@ bool LinkDoors_isconnected(entity e1, entity e2, entity pass)
 void door_link();
 #endif
 void LinkDoors()
-{
+{SELFPARAM();
        entity  t;
        vector  cmins, cmaxs;
 
@@ -647,7 +635,7 @@ FIXME: only one sound set available at the time being
 */
 
 float door_send(entity to, float sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_DOOR);
        WriteByte(MSG_ENTITY, sf);
 
@@ -709,7 +697,7 @@ void door_link()
 #endif
 
 void door_init_startopen()
-{
+{SELFPARAM();
        SUB_SETORIGIN(self, self.pos2);
        self.pos2 = self.pos1;
        self.pos1 = self.origin;
@@ -720,7 +708,7 @@ void door_init_startopen()
 }
 
 void door_reset()
-{
+{SELFPARAM();
        SUB_SETORIGIN(self, self.pos1);
        self.SUB_VELOCITY = '0 0 0';
        self.state = STATE_BOTTOM;
@@ -736,7 +724,7 @@ void door_reset()
 
 // spawnflags require key (for now only func_door)
 void spawnfunc_func_door()
-{
+{SELFPARAM();
        // Quake 1 keys compatibility
        if (self.spawnflags & SPAWNFLAGS_GOLD_KEY)
                self.itemkeys |= ITEM_KEY_BIT(0);
@@ -815,7 +803,7 @@ void door_draw()
 }
 
 void ent_door()
-{
+{SELFPARAM();
        float sf = ReadByte();
 
        if(sf & SF_TRIGGER_INIT)
index bdf05a00936b48e2fe3c12d8b5c8f54c29c25094..fbe579c1361805da9d34027a20040c9df64f59aa 100644 (file)
@@ -28,7 +28,7 @@ FIXME: only one sound set available at the time being
 */
 
 void door_rotating_reset()
-{
+{SELFPARAM();
        self.angles = self.pos1;
        self.avelocity = '0 0 0';
        self.state = STATE_BOTTOM;
@@ -37,7 +37,7 @@ void door_rotating_reset()
 }
 
 void door_rotating_init_startopen()
-{
+{SELFPARAM();
        self.angles = self.movedir;
        self.pos2 = '0 0 0';
        self.pos1 = self.movedir;
@@ -45,7 +45,7 @@ void door_rotating_init_startopen()
 
 
 void spawnfunc_func_door_rotating()
-{
+{SELFPARAM();
 
        //if (!self.deathtype) // map makers can override this
        //      self.deathtype = " got in the way";
index a0a44bbb92d417dcad7a46b4f63c9bf4475bbc9f..b793228784822068ec579e1b29924c95c5c5a789 100644 (file)
@@ -14,7 +14,7 @@ const float SECRET_NO_SHOOT = 8;              // only opened by trigger
 const float SECRET_YES_SHOOT = 16;     // shootable even if targeted
 
 void fd_secret_use()
-{
+{SELFPARAM();
        float temp;
        string message_save;
 
@@ -70,7 +70,7 @@ void fd_secret_damage(entity inflictor, entity attacker, float damage, int death
 
 // Wait after first movement...
 void fd_secret_move1()
-{
+{SELFPARAM();
        self.SUB_NEXTTHINK = self.SUB_LTIME + 1.0;
        self.think = fd_secret_move2;
        if (self.noise3 != "")
@@ -79,7 +79,7 @@ void fd_secret_move1()
 
 // Start moving sideways w/sound...
 void fd_secret_move2()
-{
+{SELFPARAM();
        if (self.noise2 != "")
                sound(self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
        SUB_CalcMove(self.dest2, TSPEED_LINEAR, self.speed, fd_secret_move3);
@@ -87,7 +87,7 @@ void fd_secret_move2()
 
 // Wait here until time to go back...
 void fd_secret_move3()
-{
+{SELFPARAM();
        if (self.noise3 != "")
                sound(self, CH_TRIGGER_SINGLE, self.noise3, VOL_BASE, ATTEN_NORM);
        if (!(self.spawnflags & SECRET_OPEN_ONCE))
@@ -99,7 +99,7 @@ void fd_secret_move3()
 
 // Move backward...
 void fd_secret_move4()
-{
+{SELFPARAM();
        if (self.noise2 != "")
                sound(self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
        SUB_CalcMove(self.dest1, TSPEED_LINEAR, self.speed, fd_secret_move5);
@@ -107,7 +107,7 @@ void fd_secret_move4()
 
 // Wait 1 second...
 void fd_secret_move5()
-{
+{SELFPARAM();
        self.SUB_NEXTTHINK = self.SUB_LTIME + 1.0;
        self.think = fd_secret_move6;
        if (self.noise3 != "")
@@ -115,14 +115,14 @@ void fd_secret_move5()
 }
 
 void fd_secret_move6()
-{
+{SELFPARAM();
        if (self.noise2 != "")
                sound(self, CH_TRIGGER_SINGLE, self.noise2, VOL_BASE, ATTEN_NORM);
        SUB_CalcMove(self.oldorigin, TSPEED_LINEAR, self.speed, fd_secret_done);
 }
 
 void fd_secret_done()
-{
+{SELFPARAM();
        if (self.spawnflags&SECRET_YES_SHOOT)
        {
                self.health = 10000;
@@ -134,7 +134,7 @@ void fd_secret_done()
 }
 
 void secret_blocked()
-{
+{SELFPARAM();
        if (time < self.attack_finished_single)
                return;
        self.attack_finished_single = time + 0.5;
@@ -149,7 +149,7 @@ Prints messages
 ================
 */
 void secret_touch()
-{
+{SELFPARAM();
        if (!other.iscreature)
                return;
        if (self.attack_finished_single > time)
@@ -166,7 +166,7 @@ void secret_touch()
 }
 
 void secret_reset()
-{
+{SELFPARAM();
        if (self.spawnflags&SECRET_YES_SHOOT)
        {
                self.health = 10000;
@@ -195,7 +195,7 @@ If a secret door has a targetname, it will only be opened by it's botton or trig
 */
 
 void spawnfunc_func_door_secret()
-{
+{SELFPARAM();
        /*if (!self.deathtype) // map makers can override this
                self.deathtype = " got in the way";*/
 
index 19dceef25307b68d623ee388fd255cb21401fb35..552fffe5a11deae6142a74b2e82a71bd0a4fe72c 100644 (file)
@@ -11,7 +11,7 @@ dmgtime: See above.
 */
 
 void func_fourier_controller_think()
-{
+{SELFPARAM();
        vector v;
        float n, i, t;
 
@@ -40,7 +40,7 @@ void func_fourier_controller_think()
 }
 
 void spawnfunc_func_fourier()
-{
+{SELFPARAM();
        entity controller;
        if (self.noise != "")
        {
index 5a96b9bb6e68f05f02162e3f2a64e353946064f2..fc3d47210e7e3c76d4d43b42e50da36202d7484b 100644 (file)
@@ -1,5 +1,5 @@
 void func_ladder_touch()
-{
+{SELFPARAM();
 #ifdef SVQC
        if (!other.iscreature)
                return;
@@ -19,7 +19,7 @@ void func_ladder_touch()
 
 #ifdef SVQC
 float func_ladder_send(entity to, float sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_LADDER);
 
        WriteString(MSG_ENTITY, self.classname);
@@ -40,7 +40,7 @@ void func_ladder_link()
 }
 
 void spawnfunc_func_ladder()
-{
+{SELFPARAM();
        self.mdl = self.model;
        EXACTTRIGGER_INIT;
        self.touch = func_ladder_touch;
@@ -49,7 +49,7 @@ void spawnfunc_func_ladder()
 }
 
 void spawnfunc_func_water()
-{
+{SELFPARAM();
        self.mdl = self.model;
        EXACTTRIGGER_INIT;
        self.touch = func_ladder_touch;
@@ -61,7 +61,7 @@ void spawnfunc_func_water()
 .float speed;
 
 void ent_func_ladder()
-{
+{SELFPARAM();
        self.classname = strzone(ReadString());
        self.skin = ReadByte();
        self.speed = ReadByte();
index 7d3eff7c9f474a25b62975a0602e05367039598a..b23541e03a479986afea7255282f5e0290b07103 100644 (file)
@@ -1,7 +1,7 @@
 #ifdef SVQC
 .float freq;
 void func_pendulum_controller_think()
-{
+{SELFPARAM();
        float v;
        self.nextthink = time + 0.1;
 
@@ -22,7 +22,7 @@ void func_pendulum_controller_think()
 }
 
 void spawnfunc_func_pendulum()
-{
+{SELFPARAM();
        entity controller;
        if (self.noise != "")
        {
index d36b1c6a372daa44c8c8f3f970e87b74f6ba83ef..8fc95bf48bd2ebdc0d7ea7a62554ab86cf395c7a 100644 (file)
@@ -8,7 +8,7 @@ void plat_delayedinit()
 }
 
 float plat_send(entity to, float sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_PLAT);
        WriteByte(MSG_ENTITY, sf);
 
@@ -60,7 +60,7 @@ void plat_link()
 }
 
 void spawnfunc_func_plat()
-{
+{SELFPARAM();
        if (self.sounds == 0)
                self.sounds = 2;
 
@@ -134,7 +134,7 @@ void plat_draw()
 }
 
 void ent_plat()
-{
+{SELFPARAM();
        float sf = ReadByte();
 
        if(sf & SF_TRIGGER_INIT)
index 654db0f72ae1ba4cf979572e93718a7a5af7f692..f303ca9f2bfefa88f94cc49d611d88759128fca8 100644 (file)
@@ -6,7 +6,7 @@
 // NOTE: also contains func_sparks
 
 float pointparticles_SendEntity(entity to, float fl)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_POINTPARTICLES);
 
        // optional features to save space
@@ -89,13 +89,13 @@ float pointparticles_SendEntity(entity to, float fl)
 }
 
 void pointparticles_use()
-{
+{SELFPARAM();
        self.state = !self.state;
        self.SendFlags |= 2;
 }
 
 void pointparticles_think()
-{
+{SELFPARAM();
        if(self.origin != self.oldorigin)
        {
                self.SendFlags |= 4;
@@ -105,7 +105,7 @@ void pointparticles_think()
 }
 
 void pointparticles_reset()
-{
+{SELFPARAM();
        if(self.spawnflags & 1)
                self.state = 1;
        else
@@ -113,7 +113,7 @@ void pointparticles_reset()
 }
 
 void spawnfunc_func_pointparticles()
-{
+{SELFPARAM();
        if(self.model != "")
                setmodel(self, self.model);
        if(self.noise != "")
@@ -158,7 +158,7 @@ void spawnfunc_func_pointparticles()
 }
 
 void spawnfunc_func_sparks()
-{
+{SELFPARAM();
        // self.cnt is the amount of sparks that one burst will spawn
        if(self.cnt < 1) {
                self.cnt = 25.0; // nice default value
@@ -184,7 +184,7 @@ void spawnfunc_func_sparks()
 #elif defined(CSQC)
 
 void Draw_PointParticles()
-{
+{SELFPARAM();
        float n, i, fail;
        vector p;
        vector sz;
@@ -244,7 +244,7 @@ void Draw_PointParticles()
 }
 
 void Ent_PointParticles_Remove()
-{
+{SELFPARAM();
        if(self.noise)
                strunzone(self.noise);
        self.noise = string_null;
@@ -254,7 +254,7 @@ void Ent_PointParticles_Remove()
 }
 
 void Ent_PointParticles()
-{
+{SELFPARAM();
        float i;
        vector v;
        int f = ReadByte();
index deb5ee58bfd94e3598ffad20c21444111e6dfe7b..8c00f9ce21fc2c8c828fdee03e66370fd22b1cdb 100644 (file)
@@ -1,6 +1,6 @@
 #ifdef SVQC
 float rainsnow_SendEntity(entity to, float sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_RAINSNOW);
        WriteByte(MSG_ENTITY, self.state);
        WriteCoord(MSG_ENTITY, self.origin_x + self.mins_x);
@@ -27,7 +27,7 @@ Keys:
  adjusts density, this many particles fall every second for a 1024x1024 area, default is 2000
 */
 void spawnfunc_func_rain()
-{
+{SELFPARAM();
        self.dest = self.velocity;
        self.velocity = '0 0 0';
        if (!self.dest)
@@ -65,7 +65,7 @@ Keys:
  adjusts density, this many particles fall every second for a 1024x1024 area, default is 2000
 */
 void spawnfunc_func_snow()
-{
+{SELFPARAM();
        self.dest = self.velocity;
        self.velocity = '0 0 0';
        if (!self.dest)
@@ -91,17 +91,17 @@ void spawnfunc_func_snow()
 }
 #elif defined(CSQC)
 void Draw_Rain()
-{
+{SELFPARAM();
     te_particlerain(self.origin + self.mins, self.origin + self.maxs, self.velocity, floor(self.count * drawframetime + random()), self.glow_color);
 }
 
 void Draw_Snow()
-{
+{SELFPARAM();
     te_particlesnow(self.origin + self.mins, self.origin + self.maxs, self.velocity, floor(self.count * drawframetime + random()), self.glow_color);
 }
 
 void Ent_RainOrSnow()
-{
+{SELFPARAM();
        self.impulse = ReadByte(); // Rain, Snow, or Whatever
        self.origin_x = ReadCoord();
        self.origin_y = ReadCoord();
index 93d4a30cedaa14ee2de8078890f9e29a8cc025d3..2e3c7851a8f9090f926aa4d0cdc804e479d0a4b6 100644 (file)
@@ -1,6 +1,6 @@
 #ifdef SVQC
 void func_rotating_setactive(float astate)
-{
+{SELFPARAM();
 
        if (astate == ACTIVE_TOGGLE)
        {
@@ -27,7 +27,7 @@ dmgtime : See above.
 */
 
 void spawnfunc_func_rotating()
-{
+{SELFPARAM();
        if (self.noise != "")
        {
                precache_sound(self.noise);
index 30c406f61e46d94f10640757ab691d351128ff2f..0c329cdb273eeb0e8166d41c36032ff436c774e0 100644 (file)
@@ -1,8 +1,8 @@
 #ifdef SVQC
 void spawnfunc_func_stardust()
-{
+{SELFPARAM();
        self.effects = EF_STARDUST;
 
-       CSQCMODEL_AUTOINIT();
+       CSQCMODEL_AUTOINIT(self);
 }
 #endif
index 0de3489381fa2dba5b27b8b6f58fed55f44a1f55..6469d17e6045b5d87d9a225b7db4cc83d894c0c6 100644 (file)
@@ -1,12 +1,8 @@
 .float train_wait_turning;
 void() train_next;
 void train_wait()
-{
-       entity oldself;
-       oldself = self;
-       self = self.enemy;
-       SUB_UseTargets();
-       self = oldself;
+{SELFPARAM();
+       WITH(entity, self, self.enemy, SUB_UseTargets());
        self.enemy = world;
 
        // if turning is enabled, the train will turn toward the next point while waiting
@@ -53,7 +49,7 @@ void train_wait()
 }
 
 void train_next()
-{
+{SELFPARAM();
        entity targ, cp = world;
        vector cp_org = '0 0 0';
 
@@ -107,7 +103,7 @@ void train_next()
 
 #ifdef SVQC
 float train_send(entity to, float sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_TRAIN);
        WriteByte(MSG_ENTITY, sf);
 
@@ -166,7 +162,7 @@ void train_link()
 }
 
 void func_train_find()
-{
+{SELFPARAM();
        entity targ;
        targ = find(world, targetname, self.target);
        self.target = targ.target;
@@ -188,7 +184,7 @@ target : targetname of first spawnfunc_path_corner (starts here)
 */
 #ifdef SVQC
 void spawnfunc_func_train()
-{
+{SELFPARAM();
        if (self.noise != "")
                precache_sound(self.noise);
 
@@ -236,7 +232,7 @@ void train_draw()
 }
 
 void ent_train()
-{
+{SELFPARAM();
        float sf = ReadByte();
 
        if(sf & SF_TRIGGER_INIT)
index 521ac8780e73300df8099ee7208b8e8035296690..32355004bed1d33ba21648cbf62f2196ecaa0d99 100644 (file)
@@ -58,7 +58,7 @@ vector func_vectormamamam_origin(entity o, float t)
 }
 
 void func_vectormamamam_controller_think()
-{
+{SELFPARAM();
        self.nextthink = time + 0.1;
 
        if(self.owner.active != ACTIVE_ACTIVE)
@@ -72,7 +72,7 @@ void func_vectormamamam_controller_think()
 }
 
 void func_vectormamamam_findtarget()
-{
+{SELFPARAM();
        if(self.target != "")
                self.wp00 = find(world, targetname, self.target);
 
@@ -99,7 +99,7 @@ void func_vectormamamam_findtarget()
 }
 
 void spawnfunc_func_vectormamamam()
-{
+{SELFPARAM();
        if (self.noise != "")
        {
                precache_sound(self.noise);
index 4294eac2aad6f2f577e5a46cb63d2548557b5f6d..390fd2c79c2949871b0e66a6b1aed731b098e922 100644 (file)
@@ -1,6 +1,6 @@
 #ifdef SVQC
 bool corner_send(entity to, int sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_CORNER);
 
        WriteString(MSG_ENTITY, self.platmovetype);
@@ -27,7 +27,7 @@ void corner_link()
 }
 
 void spawnfunc_path_corner()
-{
+{SELFPARAM();
        // setup values for overriding train movement
        // if a second value does not exist, both start and end speeds are the single value specified
        set_platmovetype(self, self.platmovetype);
@@ -37,7 +37,7 @@ void spawnfunc_path_corner()
 #elif defined(CSQC)
 
 void corner_remove()
-{
+{SELFPARAM();
        if(self.target) { strunzone(self.target); }
        self.target = string_null;
 
@@ -58,7 +58,7 @@ void corner_remove()
 }
 
 void ent_corner()
-{
+{SELFPARAM();
        self.platmovetype = strzone(ReadString());
 
        self.origin_x = ReadCoord();
index bfeb865c1df47187ecd458688c297af5da7a3a28..02c9dcc277c740dd41852ce16d69338cce7bd161 100644 (file)
@@ -2,7 +2,7 @@
 
 #ifdef SVQC
 void follow_init()
-{
+{SELFPARAM();
        entity src, dst;
        src = world;
        dst = world;
@@ -63,7 +63,7 @@ void follow_init()
 }
 
 void spawnfunc_misc_follow()
-{
+{SELFPARAM();
        InitializeEntity(self, follow_init, INITPRIO_FINDTARGET);
 }
 #endif
index a7fb07815356973eee23bdee3c88a0878f312434..52d2caf65aada325c89e45404952dc4dde407b90 100644 (file)
@@ -11,7 +11,7 @@
 #ifdef SVQC
 .float modelscale;
 void misc_laser_aim()
-{
+{SELFPARAM();
        vector a;
        if(self.enemy)
        {
@@ -50,16 +50,15 @@ void misc_laser_aim()
 }
 
 void misc_laser_init()
-{
+{SELFPARAM();
        if(self.target != "")
                self.enemy = find(world, targetname, self.target);
 }
 
 .entity pusher;
 void misc_laser_think()
-{
+{SELFPARAM();
        vector o;
-       entity oldself;
        entity hitent;
        vector hitloc;
 
@@ -98,11 +97,8 @@ void misc_laser_think()
                        {
                                self.count = 1;
 
-                               oldself = self;
-                               self = self.enemy;
-                               activator = self.pusher;
-                               SUB_UseTargets();
-                               self = oldself;
+                               activator = self.enemy.pusher;
+                               WITH(entity, self, self.enemy, SUB_UseTargets());
                        }
                }
                else
@@ -111,11 +107,8 @@ void misc_laser_think()
                        {
                                self.count = 0;
 
-                               oldself = self;
-                               self = self.enemy;
-                               activator = self.pusher;
-                               SUB_UseTargets();
-                               self = oldself;
+                               activator = self.enemy.pusher;
+                               WITH(entity, self, self.enemy, SUB_UseTargets());
                        }
                }
        }
@@ -131,7 +124,7 @@ void misc_laser_think()
 }
 
 float laser_SendEntity(entity to, float fl)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_LASER);
        fl = fl - (fl & 0xF0); // use that bit to indicate finite length laser
        if(self.spawnflags & 2)
@@ -196,14 +189,14 @@ Keys:
  damage per second (-1 for a laser that kills immediately)
 */
 void laser_use()
-{
+{SELFPARAM();
        self.state = !self.state;
        self.SendFlags |= 4;
        misc_laser_aim();
 }
 
 void laser_reset()
-{
+{SELFPARAM();
        if(self.spawnflags & 1)
                self.state = 1;
        else
@@ -211,7 +204,7 @@ void laser_reset()
 }
 
 void spawnfunc_misc_laser()
-{
+{SELFPARAM();
        if(self.mdl)
        {
                if(self.mdl == "none")
@@ -280,7 +273,7 @@ class(Laser) .float scale; // scaling factor of the thickness
 class(Laser) .float modelscale; // scaling factor of the dlight
 
 void Draw_Laser()
-{
+{SELFPARAM();
        if(!self.state)
                return;
        InterpolateOrigin_Do();
@@ -331,7 +324,7 @@ void Draw_Laser()
 }
 
 void Ent_Laser()
-{
+{SELFPARAM();
        InterpolateOrigin_Undo();
 
        // 30 bytes, or 13 bytes for just moving
index b80ce827d7dbf54da3b263764fbe1748e12747e4..a3c9783537bb9632d691def050eeedb8bf8fa220 100644 (file)
@@ -1,7 +1,7 @@
 #ifdef SVQC
 
 void spawnfunc_info_teleport_destination (void)
-{
+{SELFPARAM();
        self.classname = "info_teleport_destination";
 
        self.mangle = self.angles;
index b837d7c5a8788c43d36d019e08919dfe4d9966e4..b4f387470c64bea1c3e1e47fd17dbab141293e7d 100644 (file)
@@ -1,5 +1,5 @@
 void generic_plat_blocked()
-{
+{SELFPARAM();
 #ifdef SVQC
        if(self.dmg && other.takedamage != DAMAGE_NO)
        {
@@ -17,7 +17,7 @@ void generic_plat_blocked()
 }
 
 void plat_spawn_inside_trigger()
-{
+{SELFPARAM();
        entity trigger;
        vector tmin, tmax;
 
@@ -64,7 +64,7 @@ void plat_spawn_inside_trigger()
 }
 
 void plat_hit_top()
-{
+{SELFPARAM();
        sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
        self.state = 1;
 
@@ -73,27 +73,27 @@ void plat_hit_top()
 }
 
 void plat_hit_bottom()
-{
+{SELFPARAM();
        sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
        self.state = 2;
 }
 
 void plat_go_down()
-{
+{SELFPARAM();
        sound (self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_NORM);
        self.state = 3;
        SUB_CalcMove (self.pos2, TSPEED_LINEAR, self.speed, plat_hit_bottom);
 }
 
 void plat_go_up()
-{
+{SELFPARAM();
        sound (self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_NORM);
        self.state = 4;
        SUB_CalcMove (self.pos1, TSPEED_LINEAR, self.speed, plat_hit_top);
 }
 
 void plat_center_touch()
-{
+{SELFPARAM();
 #ifdef SVQC
        if (!other.iscreature)
                return;
@@ -107,7 +107,7 @@ void plat_center_touch()
                return;
 #endif
 
-       self = self.enemy;
+       setself(self.enemy);
        if (self.state == 2)
                plat_go_up ();
        else if (self.state == 1)
@@ -115,7 +115,7 @@ void plat_center_touch()
 }
 
 void plat_outside_touch()
-{
+{SELFPARAM();
 #ifdef SVQC
        if (!other.iscreature)
                return;
@@ -127,13 +127,13 @@ void plat_outside_touch()
                return;
 #endif
 
-       self = self.enemy;
+       setself(self.enemy);
        if (self.state == 1)
                plat_go_down ();
 }
 
 void plat_trigger_use()
-{
+{SELFPARAM();
 #ifdef SVQC
        if (self.think)
                return;         // already activated
@@ -146,7 +146,7 @@ void plat_trigger_use()
 
 
 void plat_crush()
-{
+{SELFPARAM();
        if((self.spawnflags & 4) && (other.takedamage != DAMAGE_NO))
        { // KIll Kill Kill!!
 #ifdef SVQC
@@ -176,7 +176,7 @@ void plat_crush()
 }
 
 void plat_use()
-{
+{SELFPARAM();
        self.use = func_null;
        if (self.state != 4)
                objerror ("plat_use: not in up state");
@@ -186,7 +186,7 @@ void plat_use()
 .string sound1, sound2;
 
 void plat_reset()
-{
+{SELFPARAM();
        IFTARGETED
        {
                setorigin (self, self.pos1);
index fa7c1c5e451b28f67a41eab1068c8d8c49cfa35f..b313c49996046e1dec57d08169a891a44fdff6c9 100644 (file)
@@ -13,7 +13,7 @@ Applies some friction to self
 */
 .float friction;
 void SUB_Friction (void)
-{
+{SELFPARAM();
        self.SUB_NEXTTHINK = time;
        if(self.SUB_FLAGS & FL_ONGROUND)
                self.SUB_VELOCITY = self.SUB_VELOCITY * (1 - frametime * self.friction);
@@ -46,7 +46,7 @@ void SUB_VanishOrRemove (entity ent)
 }
 
 void SUB_SetFade_Think (void)
-{
+{SELFPARAM();
        if(self.alpha == 0)
                self.alpha = 1;
        self.SUB_THINK = SUB_SetFade_Think;
@@ -81,7 +81,7 @@ self.SUB_ORIGIN traveling at speed
 ===============
 */
 void SUB_CalcMoveDone (void)
-{
+{SELFPARAM();
        // After moving, set origin to exact final destination
 
        SUB_SETORIGIN (self, self.finaldest);
@@ -93,7 +93,7 @@ void SUB_CalcMoveDone (void)
 
 .float platmovetype_turn;
 void SUB_CalcMove_controller_think (void)
-{
+{SELFPARAM();
        entity oldself;
        float traveltime;
        float phasepos;
@@ -144,7 +144,7 @@ void SUB_CalcMove_controller_think (void)
                // derivative: delta + 2 * delta2 (e.g. for angle positioning)
                oldself = self;
                self.owner.SUB_THINK = self.think1;
-               self = self.owner;
+               setself(self.owner);
                remove(oldself);
                self.SUB_THINK();
        }
@@ -185,7 +185,7 @@ float TSPEED_END = 2;
 // TODO average too?
 
 void SUB_CalcMove_Bezier (vector tcontrol, vector tdest, float tspeedtype, float tspeed, void() func)
-{
+{SELFPARAM();
        float   traveltime;
        entity controller;
 
@@ -238,13 +238,13 @@ void SUB_CalcMove_Bezier (vector tcontrol, vector tdest, float tspeedtype, float
        self.SUB_NEXTTHINK = self.SUB_LTIME + traveltime;
 
        // invoke controller
-       self = controller;
+       setself(controller);
        self.think();
-       self = self.owner;
+       setself(self.owner);
 }
 
 void SUB_CalcMove (vector tdest, float tspeedtype, float tspeed, void() func)
-{
+{SELFPARAM();
        vector  delta;
        float   traveltime;
 
@@ -293,15 +293,8 @@ void SUB_CalcMove (vector tdest, float tspeedtype, float tspeed, void() func)
 }
 
 void SUB_CalcMoveEnt (entity ent, vector tdest, float tspeedtype, float tspeed, void() func)
-{
-       entity  oldself;
-
-       oldself = self;
-       self = ent;
-
-       SUB_CalcMove (tdest, tspeedtype, tspeed, func);
-
-       self = oldself;
+{SELFPARAM();
+       WITH(entity, self, ent, SUB_CalcMove(tdest, tspeedtype, tspeed, func));
 }
 
 /*
@@ -315,7 +308,7 @@ The calling function should make sure self.SUB_THINK is valid
 ===============
 */
 void SUB_CalcAngleMoveDone (void)
-{
+{SELFPARAM();
        // After rotating, set angle to exact final angle
        self.angles = self.finalangle;
        self.SUB_AVELOCITY = '0 0 0';
@@ -326,7 +319,7 @@ void SUB_CalcAngleMoveDone (void)
 
 // FIXME: I fixed this function only for rotation around the main axes
 void SUB_CalcAngleMove (vector destangle, float tspeedtype, float tspeed, void() func)
-{
+{SELFPARAM();
        vector  delta;
        float   traveltime;
 
@@ -368,13 +361,6 @@ void SUB_CalcAngleMove (vector destangle, float tspeedtype, float tspeed, void()
 }
 
 void SUB_CalcAngleMoveEnt (entity ent, vector destangle, float tspeedtype, float tspeed, void() func)
-{
-       entity  oldself;
-
-       oldself = self;
-       self = ent;
-
-       SUB_CalcAngleMove (destangle, tspeedtype, tspeed, func);
-
-       self = oldself;
+{SELFPARAM();
+       WITH(entity, self, ent, SUB_CalcAngleMove (destangle, tspeedtype, tspeed, func));
 }
index ea8ef3057425b28b9e260785a314da659bfbad7a..98491820f215da9636d2ce8cd72e7bbffc2e7aaa 100644 (file)
        #define SUB_FLAGS               move_flags
 
        void SUB_SETORIGIN(entity s, vector v)
-       {
+       {SELFPARAM();
                s.move_origin = v;
-               entity oldself = self;
-               self = s;
-               _Movetype_LinkEdict(true);
-               self = oldself;
+               WITH(entity, self, s, _Movetype_LinkEdict(true));
        }
 
 #endif
index 8e5c31bfea8a43ec01ea5b1ac53c4d0933e8cf0a..8dc694e621e918e8e5a8049736f608f02da3950b 100644 (file)
@@ -4,7 +4,7 @@
 
 
 void spawnfunc_target_changelevel_use()
-{
+{SELFPARAM();
        if(self.spawnflags & 2)
        {
                // simply don't react if a non-player triggers it
@@ -36,7 +36,7 @@ void spawnfunc_target_changelevel_use()
 }
 
 void spawnfunc_target_changelevel()
-{
+{SELFPARAM();
        self.use = spawnfunc_target_changelevel_use;
 
        if(!self.count) { self.count = 0.7; }
index 1430cabd81ee3364a9998ff3721aca30a7a47627..554032ee60cc7221b129b36e7b880aaca60cc60a 100644 (file)
@@ -1,13 +1,13 @@
 #ifdef SVQC
 void spawnfunc_target_location()
-{
+{SELFPARAM();
     self.classname = "target_location";
     // location name in netname
     // eventually support: count, teamgame selectors, line of sight?
 }
 
 void spawnfunc_info_location()
-{
+{SELFPARAM();
     self.classname = "target_location";
     self.message = self.netname;
 }
index b3a5a24330763d13152eb088cecb0dfd9ff445df..488ed0999b094cbcbeb015452b09d58728d065bb 100644 (file)
@@ -19,7 +19,7 @@
 // when triggered, the music is overridden for activator until lifetime (or forever, if lifetime is 0)
 // when targetname is not set, THIS ONE is default
 void target_music_sendto(float to, float is)
-{
+{SELFPARAM();
        WriteByte(to, SVC_TEMPENTITY);
        WriteByte(to, TE_CSQC_TARGET_MUSIC);
        WriteShort(to, num_for_edict(self));
@@ -30,7 +30,7 @@ void target_music_sendto(float to, float is)
        WriteString(to, self.noise);
 }
 void target_music_reset()
-{
+{SELFPARAM();
        if(self.targetname == "")
                target_music_sendto(MSG_ALL, 1);
 }
@@ -47,7 +47,7 @@ void target_music_use()
        FOR_EACH_SPEC(head) if(head.enemy == activator) { msg_entity = head; target_music_sendto(MSG_ONE, 1); }
 }
 void spawnfunc_target_music()
-{
+{SELFPARAM();
        self.use = target_music_use;
        self.reset = target_music_reset;
        if(!self.volume)
@@ -58,9 +58,10 @@ void spawnfunc_target_music()
                target_music_sendto(MSG_INIT, 0);
 }
 void TargetMusic_RestoreGame()
-{
-       for(self = world; (self = find(self, classname, "target_music")); )
+{SELFPARAM();
+       for(entity e = world; (e = find(e, classname, "target_music")); )
        {
+               setself(e);
                if(self.targetname == "")
                        target_music_sendto(MSG_INIT, 1);
                else
@@ -76,7 +77,7 @@ void TargetMusic_RestoreGame()
 //   1 = START_OFF
 // when triggered, it is disabled/enabled for everyone
 float trigger_music_SendEntity(entity to, float sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_TRIGGER_MUSIC);
        sf &= ~0x80;
        if(self.cnt)
@@ -115,17 +116,17 @@ float trigger_music_SendEntity(entity to, float sf)
        return 1;
 }
 void trigger_music_reset()
-{
+{SELFPARAM();
        self.cnt = !(self.spawnflags & 1);
        self.SendFlags |= 0x80;
 }
 void trigger_music_use()
-{
+{SELFPARAM();
        self.cnt = !self.cnt;
        self.SendFlags |= 0x80;
 }
 void spawnfunc_trigger_music()
-{
+{SELFPARAM();
        if(self.model != "")
                setmodel(self, self.model);
        if(!self.volume)
@@ -255,7 +256,7 @@ void Net_TargetMusic()
 }
 
 void Ent_TriggerMusic_Think()
-{
+{SELFPARAM();
        if(WarpZoneLib_BoxTouchesBrush(view_origin, view_origin, self, world))
        {
                music_trigger = self;
@@ -264,14 +265,14 @@ void Ent_TriggerMusic_Think()
 }
 
 void Ent_TriggerMusic_Remove()
-{
+{SELFPARAM();
        if(self.noise)
                strunzone(self.noise);
        self.noise = string_null;
 }
 
 void Ent_ReadTriggerMusic()
-{
+{SELFPARAM();
        int f = ReadByte();
        if(f & 4)
        {
index da7aeda71e9c628055b7223b9299eb9ba87d0625..6572221f75a9e008d6c7668e2ff15758a0fb32a7 100644 (file)
@@ -23,22 +23,21 @@ float target_spawn_spawnfunc_field;
 float target_spawn_count;
 
 void target_spawn_helper_setmodel()
-{
+{SELFPARAM();
        setmodel(self, self.model);
 }
 
 void target_spawn_helper_setsize()
-{
+{SELFPARAM();
        setsize(self, self.mins, self.maxs);
 }
 
 void target_spawn_edit_entity(entity e, string msg, entity kt, entity t2, entity t3, entity t4, entity act)
-{
+{SELFPARAM();
        float i, n, valuefieldpos;
        string key, value, valuefield, valueoffset, valueoffsetrandom;
        entity valueent;
        vector data, data2;
-       entity oldself;
        entity oldactivator;
 
        n = tokenize_console(msg);
@@ -220,15 +219,10 @@ void target_spawn_edit_entity(entity e, string msg, entity kt, entity t2, entity
                                value = strcat("target_spawn_helper", value);
                        putentityfieldstring(target_spawn_spawnfunc_field, e, value);
 
-                       oldself = self;
                        oldactivator = activator;
 
-                       self = e;
                        activator = act;
-
-                       self.target_spawn_spawnfunc();
-
-                       self = oldself;
+                       WITH(entity, self, e, e.target_spawn_spawnfunc());
                        activator = oldactivator;
 
                        // We called an external function, so we have to re-tokenize msg.
@@ -244,7 +238,7 @@ void target_spawn_edit_entity(entity e, string msg, entity kt, entity t2, entity
 }
 
 void target_spawn_useon(entity e)
-{
+{SELFPARAM();
        self.target_spawn_activator = activator;
        target_spawn_edit_entity(
                e,
@@ -258,7 +252,7 @@ void target_spawn_useon(entity e)
 }
 
 float target_spawn_cancreate()
-{
+{SELFPARAM();
        float c;
        entity e;
 
@@ -277,7 +271,7 @@ float target_spawn_cancreate()
 }
 
 void target_spawn_use()
-{
+{SELFPARAM();
        entity e;
 
        if(self.target == "")
@@ -304,7 +298,7 @@ void target_spawn_use()
 }
 
 void target_spawn_spawnfirst()
-{
+{SELFPARAM();
        activator = self.target_spawn_activator;
        if(self.spawnflags & 2)
                target_spawn_use();
@@ -339,7 +333,7 @@ void initialize_field_db()
 }
 
 void spawnfunc_target_spawn()
-{
+{SELFPARAM();
        initialize_field_db();
        self.use = target_spawn_use;
        self.message = strzone(strreplace("'", "\"", self.message));
index 7be8b91b4c2920cabe64093d1500ed0360cae748..058ffd52639950f15cdff70fa12586880c6a3661 100644 (file)
@@ -2,7 +2,7 @@
 // TODO add a way to do looped sounds with sound(); then complete this entity
 void target_speaker_use_off();
 void target_speaker_use_activator()
-{
+{SELFPARAM();
        if (!IS_REAL_CLIENT(activator))
                return;
        string snd;
@@ -31,7 +31,7 @@ void target_speaker_use_activator()
        soundto(MSG_ONE, self, CH_TRIGGER, snd, VOL_BASE * self.volume, self.atten);
 }
 void target_speaker_use_on()
-{
+{SELFPARAM();
        string snd;
        if(substring(self.noise, 0, 1) == "*")
        {
@@ -59,12 +59,12 @@ void target_speaker_use_on()
                self.use = target_speaker_use_off;
 }
 void target_speaker_use_off()
-{
+{SELFPARAM();
        sound(self, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_BASE * self.volume, self.atten);
        self.use = target_speaker_use_on;
 }
 void target_speaker_reset()
-{
+{SELFPARAM();
        if(self.spawnflags & 1) // LOOPED_ON
        {
                if(self.use == target_speaker_use_on)
@@ -78,7 +78,7 @@ void target_speaker_reset()
 }
 
 void spawnfunc_target_speaker()
-{
+{SELFPARAM();
        // TODO: "*" prefix to sound file name
        // TODO: wait and random (just, HOW? random is not a field)
        if(self.noise)
index c173d80eefe6867261105b427a509ea850ba2c51..35d84da8df64de4a95e82f2debc9847bec413764 100644 (file)
@@ -10,7 +10,7 @@ void target_voicescript_clear(entity pl)
 }
 
 void target_voicescript_use()
-{
+{SELFPARAM();
        if(activator.voicescript != self)
        {
                activator.voicescript = self;
@@ -74,7 +74,7 @@ void target_voicescript_next(entity pl)
 }
 
 void spawnfunc_target_voicescript()
-{
+{SELFPARAM();
        // netname: directory of the sound files
        // message: list of "sound file" duration "sound file" duration, a *, and again a list
        //          foo1 4.1 foo2 4.0 foo3 -3.1 * fool1 1.1 fool2 7.1 fool3 9.1 fool4 3.7
index 3421311691863f31a23274c4bf73a02fe8af7372..bc4398601920968c61cfd7fd9d25f879569461bc 100644 (file)
@@ -63,7 +63,7 @@ void spawn_tdeath(vector v0, entity e, vector v)
 }
 
 void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angles, vector to_velocity, vector telefragmin, vector telefragmax, float tflags)
-{
+{SELFPARAM();
        entity telefragger;
        vector from;
 
@@ -179,7 +179,7 @@ entity Simple_TeleportPlayer(entity teleporter, entity player)
 }
 
 void teleport_findtarget (void)
-{
+{SELFPARAM();
        entity e;
        float n;
 
@@ -224,15 +224,12 @@ entity Teleport_Find(vector mi, vector ma)
 }
 
 void WarpZone_PostTeleportPlayer_Callback(entity pl)
-{
+{SELFPARAM();
        makevectors(pl.angles);
        Reset_ArcBeam(pl, v_forward);
        UpdateCSQCProjectileAfterTeleport(pl);
        {
-               entity oldself = self;
-               self = pl;
-               anticheat_fixangle();
-               self = oldself;
+               WITH(entity, self, pl, anticheat_fixangle());
        }
        // "disown" projectiles after teleport
        if(pl.owner)
index bf1d9b2da76f672c4f554ed9d262e3cb1624cbd1..9eb7eb072bb3f2fa61d0048a12c127f8e7c34b2b 100644 (file)
@@ -1,6 +1,6 @@
 #ifdef SVQC
 void counter_use()
-{
+{SELFPARAM();
        self.count -= 1;
        if (self.count < 0)
                return;
@@ -24,7 +24,7 @@ void counter_use()
 }
 
 void counter_reset()
-{
+{SELFPARAM();
        self.count = self.cnt;
        multi_reset();
 }
@@ -37,7 +37,7 @@ If nomessage is not set, t will print "1 more.. " etc when triggered and "sequen
 After the counter has been triggered "count" times (default 2), it will fire all of it's targets and remove itself.
 */
 void spawnfunc_trigger_counter()
-{
+{SELFPARAM();
        self.wait = -1;
        if (!self.count)
                self.count = 2;
index b01efe3bba0737df4059022ad5390e5ca0866235..a3e08e4d81f9f522a17008b82ee21e1a787c43aa 100644 (file)
@@ -1,18 +1,18 @@
 #ifdef SVQC
 void delay_use()
-{
+{SELFPARAM();
     self.think = SUB_UseTargets;
    self.nextthink = self.wait;
 }
 
 void delay_reset()
-{
+{SELFPARAM();
        self.think = func_null;
        self.nextthink = 0;
 }
 
 void spawnfunc_trigger_delay()
-{
+{SELFPARAM();
     if(!self.wait)
         self.wait = 1;
 
index 2a0432c97827790b3a6a0a483f4e86a830a26851..4545df19575afe5e4c17015c7feedc258e1908b7 100644 (file)
@@ -1,6 +1,6 @@
 #ifdef SVQC
 void trigger_disablerelay_use()
-{
+{SELFPARAM();
        entity e;
 
        float a, b;
@@ -25,7 +25,7 @@ void trigger_disablerelay_use()
 }
 
 void spawnfunc_trigger_disablerelay()
-{
+{SELFPARAM();
        self.use = trigger_disablerelay_use;
 }
 #endif
index 12d8a5940a245a7b6f55a11626df815803c1b39c..b5a2eb8b292d2120abe5dfc798ebd0b81b567c04 100644 (file)
@@ -3,14 +3,14 @@
 "Flip-flop" trigger gate... lets only every second trigger event through
 */
 void flipflop_use()
-{
+{SELFPARAM();
     self.state = !self.state;
     if(self.state)
         SUB_UseTargets();
 }
 
 void spawnfunc_trigger_flipflop()
-{
+{SELFPARAM();
     if(self.spawnflags & 1)
         self.state = 1;
     self.use = flipflop_use;
index 3ad419d22fc287388949f7a5c0ba2842a13d4216..1b72780e51c9f5cec6245a8dac5e456856153913 100644 (file)
@@ -1,13 +1,13 @@
 #ifdef SVQC
 void gamestart_use()
-{
+{SELFPARAM();
        activator = self;
        SUB_UseTargets();
        remove(self);
 }
 
 void spawnfunc_trigger_gamestart()
-{
+{SELFPARAM();
        self.use = gamestart_use;
        self.reset2 = spawnfunc_trigger_gamestart;
 
index a709a1f2a7cb22d91a132a20707193baec3ccbaf..659a336901e26665bb0ce56e14e1ee04327a252f 100644 (file)
@@ -13,7 +13,7 @@ void trigger_gravity_remove(entity own)
        own.trigger_gravity_check = world;
 }
 void trigger_gravity_check_think()
-{
+{SELFPARAM();
        // This spawns when a player enters the gravity zone and checks if he left.
        // Each frame, self.count is set to 2 by trigger_gravity_touch() and decreased by 1 here.
        // It the player has left the gravity trigger, this will be allowed to reach 0 and indicate that.
@@ -33,12 +33,12 @@ void trigger_gravity_check_think()
 }
 
 void trigger_gravity_use()
-{
+{SELFPARAM();
        self.state = !self.state;
 }
 
 void trigger_gravity_touch()
-{
+{SELFPARAM();
        float g;
 
        if(self.state != true)
@@ -86,7 +86,7 @@ void trigger_gravity_touch()
 }
 
 void spawnfunc_trigger_gravity()
-{
+{SELFPARAM();
        if(self.gravity == 1)
                return;
 
index 6d68610b5cf8ddb5afb7c2101a0b3ffacdb83f5b..323a4a160d2fb64cf36523fdfd58f3a624259219 100644 (file)
@@ -1,7 +1,7 @@
 #ifdef SVQC
 .float triggerhealtime;
 void trigger_heal_touch()
-{
+{SELFPARAM();
        if (self.active != ACTIVE_ACTIVE)
                return;
 
@@ -26,7 +26,7 @@ void trigger_heal_touch()
 }
 
 void spawnfunc_trigger_heal()
-{
+{SELFPARAM();
        self.active = ACTIVE_ACTIVE;
 
        EXACTTRIGGER_INIT;
index 3a15a77ff4d4c3ff69fb1813c3d25886378684a6..7a12011931497bb4c141cecb0c7e7f1152aa1c5e 100644 (file)
@@ -1,6 +1,6 @@
 #ifdef SVQC
 void trigger_hurt_use()
-{
+{SELFPARAM();
        if(IS_PLAYER(activator))
                self.enemy = activator;
        else
@@ -9,7 +9,7 @@ void trigger_hurt_use()
 
 .float triggerhurttime;
 void trigger_hurt_touch()
-{
+{SELFPARAM();
        if (self.active != ACTIVE_ACTIVE)
                return;
 
@@ -58,7 +58,7 @@ defalt dmg = 5
 entity trigger_hurt_last;
 entity trigger_hurt_first;
 void spawnfunc_trigger_hurt()
-{
+{SELFPARAM();
        EXACTTRIGGER_INIT;
        self.active = ACTIVE_ACTIVE;
        self.touch = trigger_hurt_touch;
index 7b8ebcfde91e67627c4ca76b6494441d87fc59a5..2b3bb5729a1461dae21a775b71a87f64ae9e0189 100644 (file)
@@ -1,6 +1,6 @@
 // targeted (directional) mode
 void trigger_impulse_touch1()
-{
+{SELFPARAM();
        entity targ;
        float pushdeltatime;
        float str;
@@ -54,7 +54,7 @@ void trigger_impulse_touch1()
 
 // Directionless (accelerator/decelerator) mode
 void trigger_impulse_touch2()
-{
+{SELFPARAM();
        float pushdeltatime;
 
        if (self.active != ACTIVE_ACTIVE)
@@ -79,7 +79,7 @@ void trigger_impulse_touch2()
 
 // Spherical (gravity/repulsor) mode
 void trigger_impulse_touch3()
-{
+{SELFPARAM();
        float pushdeltatime;
        float str;
 
@@ -132,7 +132,7 @@ in directional and sperical mode. For damper/accelerator mode this is not nesses
 */
 #ifdef SVQC
 bool trigger_impulse_send(entity to, int sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_TRIGGER_IMPULSE);
 
        WriteCoord(MSG_ENTITY, self.radius);
@@ -151,7 +151,7 @@ void trigger_impulse_link()
 }
 
 void spawnfunc_trigger_impulse()
-{
+{SELFPARAM();
        self.active = ACTIVE_ACTIVE;
 
        EXACTTRIGGER_INIT;
@@ -181,7 +181,7 @@ void spawnfunc_trigger_impulse()
 }
 #elif defined(CSQC)
 void ent_trigger_impulse()
-{
+{SELFPARAM();
        self.radius = ReadCoord();
        self.strength = ReadCoord();
        self.falloff = ReadByte();
index 47f08d3acb321a0a50a2404d8d0cd2a34c519eb1..5eb25221821def3f73fb5b13d22994f3fb337cd8 100644 (file)
@@ -5,7 +5,7 @@
 #include "../../movetypes/movetypes.qh"
 
 void trigger_push_use()
-{
+{SELFPARAM();
        if(teamplay)
        {
                self.team = activator.team;
@@ -128,7 +128,7 @@ vector trigger_push_calculatevelocity(vector org, entity tgt, float ht)
 }
 
 void trigger_push_touch()
-{
+{SELFPARAM();
        if (self.active == ACTIVE_NOT)
                return;
 
@@ -218,12 +218,8 @@ void trigger_push_touch()
 
        if(self.enemy.target)
        {
-               entity oldself;
-               oldself = self;
                activator = other;
-               self = self.enemy;
-               SUB_UseTargets();
-               self = oldself;
+               WITH(entity, self, self.enemy, SUB_UseTargets());
        }
 
        if (other.flags & FL_PROJECTILE)
@@ -257,7 +253,7 @@ void trigger_push_link();
 void trigger_push_updatelink();
 #endif
 void trigger_push_findtarget()
-{
+{SELFPARAM();
        entity t;
        vector org;
 
@@ -321,7 +317,7 @@ void trigger_push_findtarget()
 
 #ifdef SVQC
 float trigger_push_send(entity to, float sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_TRIGGER_PUSH);
        WriteByte(MSG_ENTITY, sf);
 
@@ -345,7 +341,7 @@ float trigger_push_send(entity to, float sf)
 }
 
 void trigger_push_updatelink()
-{
+{SELFPARAM();
        self.SendFlags |= 1;
 }
 
@@ -368,7 +364,7 @@ void trigger_push_link()
  *   movedir: if target is not set, this * speed * 10 is the velocity to be reached.
  */
 void spawnfunc_trigger_push()
-{
+{SELFPARAM();
        SetMovedir ();
 
        EXACTTRIGGER_INIT;
@@ -392,7 +388,7 @@ void spawnfunc_trigger_push()
 
 
 float target_push_send(entity to, float sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_TARGET_PUSH);
 
        WriteByte(MSG_ENTITY, self.cnt);
@@ -405,7 +401,7 @@ float target_push_send(entity to, float sf)
 }
 
 void target_push_link()
-{
+{SELFPARAM();
        Net_LinkEntity(self, false, 0, target_push_send);
        self.SendFlags |= 1; // update
 }
@@ -419,7 +415,7 @@ void spawnfunc_target_position() { target_push_link(); }
 #ifdef CSQC
 
 void ent_trigger_push()
-{
+{SELFPARAM();
        float sf = ReadByte();
 
        if(sf & 1)
@@ -449,7 +445,7 @@ void ent_trigger_push()
 }
 
 void target_push_remove()
-{
+{SELFPARAM();
        if(self.classname)
                strunzone(self.classname);
        self.classname = string_null;
@@ -460,7 +456,7 @@ void target_push_remove()
 }
 
 void ent_target_push()
-{
+{SELFPARAM();
        self.classname = "push_target";
        self.cnt = ReadByte();
        self.targetname = strzone(ReadString());
index ec27d4b77fb9348363153f8ca81214e4867c695f..17313f0aa85de43dda806660633a4055dcf10a73 100644 (file)
@@ -2,8 +2,7 @@
  * trigger given targets
  */
 void trigger_keylock_trigger(string s)
-{
-       entity stemp = self;
+{SELFPARAM();
        entity otemp = other;
        entity atemp = activator;
 
@@ -11,13 +10,13 @@ void trigger_keylock_trigger(string s)
        for(t = world; (t = find(t, targetname, s)); )
                if(t.use)
                {
-                       self = t;
-                       other = stemp;
+                       setself(t);
+                       other = this;
                        activator = atemp;
                        self.use();
                }
 
-       self = stemp;
+       setself(this);
        other = otemp;
        activator = atemp;
 }
@@ -33,7 +32,7 @@ void trigger_keylock_kill(string s)
 }
 
 void trigger_keylock_touch()
-{
+{SELFPARAM();
        bool key_used = false;
        bool started_delay = false;
 
@@ -97,7 +96,7 @@ void trigger_keylock_touch()
 
 #ifdef SVQC
 bool trigger_keylock_send(entity to, int sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_KEYLOCK);
 
        WriteInt24_t(MSG_ENTITY, self.itemkeys);
@@ -134,7 +133,7 @@ If spawned without any key specified in itemkeys, this trigger will display an e
 message2 and noise2 will be resent to the player every 2 seconds while he is in the trigger zone.
 */
 void spawnfunc_trigger_keylock(void)
-{
+{SELFPARAM();
        if(!self.itemkeys) { remove(self); return; }
 
        // set unlocked message
@@ -176,7 +175,7 @@ void spawnfunc_trigger_keylock(void)
 }
 #elif defined(CSQC)
 void keylock_remove()
-{
+{SELFPARAM();
        if(self.target) { strunzone(self.target); }
        self.target = string_null;
 
@@ -197,7 +196,7 @@ void keylock_remove()
 }
 
 void ent_keylock()
-{
+{SELFPARAM();
        self.itemkeys = ReadInt24_t();
        self.height = ReadByte();
 
index f14b75c3124b983856400b620faf2af7dbc517ce..0c8a7d359decbc8299181ea208087fea26761c82 100644 (file)
@@ -2,10 +2,9 @@
 float magicear_matched;
 float W_Tuba_HasPlayed(entity pl, string melody, float instrument, float ignorepitch, float mintempo, float maxtempo);
 string trigger_magicear_processmessage(entity ear, entity source, float teamsay, entity privatesay, string msgin)
-{
+{SELFPARAM();
        float domatch, dotrigger, matchstart, l;
        string s, msg;
-       entity oldself;
        string savemessage;
 
        magicear_matched = false;
@@ -29,14 +28,13 @@ string trigger_magicear_processmessage(entity ear, entity source, float teamsay,
 
                if(dotrigger)
                {
-                       oldself = self;
                        activator = source;
-                       self = ear;
+                       setself(ear);
                        savemessage = self.message;
                        self.message = string_null;
                        SUB_UseTargets();
                        self.message = savemessage;
-                       self = oldself;
+                       setself(this);
                }
 
                if(ear.netname != "")
@@ -120,14 +118,13 @@ string trigger_magicear_processmessage(entity ear, entity source, float teamsay,
 
        if(dotrigger)
        {
-               oldself = self;
                activator = source;
-               self = ear;
+               setself(ear);
                savemessage = self.message;
                self.message = string_null;
                SUB_UseTargets();
                self.message = savemessage;
-               self = oldself;
+               setself(this);
        }
 
        if(ear.spawnflags & 16)
@@ -166,7 +163,7 @@ string trigger_magicear_processmessage_forallears(entity source, float teamsay,
 }
 
 void spawnfunc_trigger_magicear()
-{
+{SELFPARAM();
        self.enemy = magicears;
        magicears = self;
 
index 45ce761e035d85a5b344828e26170458b1b514c5..5129ce35cdf11d20dfd2b567ca2b6f1efbb9d26c 100644 (file)
@@ -3,7 +3,7 @@
 "Mono-flop" trigger gate... turns one trigger event into one "on" and one "off" event, separated by a delay of "wait"
 */
 void monoflop_use()
-{
+{SELFPARAM();
        self.nextthink = time + self.wait;
        self.enemy = activator;
        if(self.state)
@@ -12,7 +12,7 @@ void monoflop_use()
        SUB_UseTargets();
 }
 void monoflop_fixed_use()
-{
+{SELFPARAM();
        if(self.state)
                return;
        self.nextthink = time + self.wait;
@@ -22,20 +22,20 @@ void monoflop_fixed_use()
 }
 
 void monoflop_think()
-{
+{SELFPARAM();
        self.state = 0;
        activator = self.enemy;
        SUB_UseTargets();
 }
 
 void monoflop_reset()
-{
+{SELFPARAM();
        self.state = 0;
        self.nextthink = 0;
 }
 
 void spawnfunc_trigger_monoflop()
-{
+{SELFPARAM();
        if(!self.wait)
                self.wait = 1;
        if(self.spawnflags & 1)
index 0e9a02016ca4fd7109561683785891a32e227444..007e6da2f5e980cfc89a807b338e907edeeba296 100644 (file)
@@ -3,7 +3,7 @@
 #ifdef SVQC
 // the wait time has passed, so set back up for another activation
 void multi_wait()
-{
+{SELFPARAM();
        if (self.max_health)
        {
                self.health = self.max_health;
@@ -17,7 +17,7 @@ void multi_wait()
 // self.enemy should be set to the activator so it can be held through a delay
 // so wait for the delay time before firing
 void multi_trigger()
-{
+{SELFPARAM();
        if (self.nextthink > time)
        {
                return;         // allready been triggered
@@ -58,14 +58,14 @@ void multi_trigger()
 }
 
 void multi_use()
-{
+{SELFPARAM();
        self.goalentity = other;
        self.enemy = activator;
        multi_trigger();
 }
 
 void multi_touch()
-{
+{SELFPARAM();
        if(!(self.spawnflags & 2))
        if(!other.iscreature)
                        return;
@@ -96,7 +96,7 @@ void multi_touch()
 }
 
 void multi_eventdamage (entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        if (!self.takedamage)
                return;
        if(self.spawnflags & DOOR_NOSPLASH)
@@ -112,7 +112,7 @@ void multi_eventdamage (entity inflictor, entity attacker, float damage, int dea
 }
 
 void multi_reset()
-{
+{SELFPARAM();
        if ( !(self.spawnflags & SPAWNFLAG_NOTOUCH) )
                self.touch = multi_touch;
        if (self.max_health)
@@ -140,7 +140,7 @@ sounds
 set "message" to text string
 */
 void spawnfunc_trigger_multiple()
-{
+{SELFPARAM();
        self.reset = multi_reset;
        if (self.sounds == 1)
        {
@@ -203,7 +203,7 @@ sounds
 set "message" to text string
 */
 void spawnfunc_trigger_once()
-{
+{SELFPARAM();
        self.wait = -1;
        spawnfunc_trigger_multiple();
 }
index 02a258e87f13a92a942f70f5c2427129f4457928..d9c6c2e60c582fd18fce1ea67234e5af840cb074 100644 (file)
@@ -1,6 +1,6 @@
 #ifdef SVQC
 void multivibrator_send()
-{
+{SELFPARAM();
        float newstate;
        float cyclestart;
 
@@ -20,7 +20,7 @@ void multivibrator_send()
 }
 
 void multivibrator_toggle()
-{
+{SELFPARAM();
        if(self.nextthink == 0)
        {
                multivibrator_send();
@@ -37,7 +37,7 @@ void multivibrator_toggle()
 }
 
 void multivibrator_reset()
-{
+{SELFPARAM();
        if(!(self.spawnflags & 1))
                self.nextthink = 0; // wait for a trigger event
        else
@@ -56,7 +56,7 @@ respawntime: "off" cycle time (default: same as wait)
 START_ON: assume it is already turned on (when targeted)
 */
 void spawnfunc_trigger_multivibrator()
-{
+{SELFPARAM();
        if(!self.wait)
                self.wait = 1;
        if(!self.respawntime)
index e037028aee59990cc514a8f374805ed5c30a0977..20962cd495d9de4cc3ce25eb4a30e396db6e16f3 100644 (file)
@@ -3,7 +3,7 @@
 This fixed size trigger cannot be touched, it can only be fired by other events.  It can contain killtargets, targets, delays, and messages.
 */
 void spawnfunc_trigger_relay()
-{
+{SELFPARAM();
        self.use = SUB_UseTargets;
        self.reset = spawnfunc_trigger_relay; // this spawnfunc resets fully
 }
index 83c0103d09fe4ad2a2d61eaad361e49c48ac0e98..b765151fd123faa685786bb3f3f66b1b4730ecab 100644 (file)
@@ -1,44 +1,40 @@
 #ifdef SVQC
 void relay_activators_use()
-{
-       entity trg, os;
-
-       os = self;
-
-       for(trg = world; (trg = find(trg, targetname, os.target)); )
+{SELFPARAM();
+       for(entity trg = world; (trg = find(trg, targetname, this.target)); )
        {
-               self = trg;
+               setself(trg);
                if (trg.setactive)
-                       trg.setactive(os.cnt);
+                       trg.setactive(this.cnt);
                else
                {
                        //bprint("Not using setactive\n");
-                       if(os.cnt == ACTIVE_TOGGLE)
+                       if(this.cnt == ACTIVE_TOGGLE)
                                if(trg.active == ACTIVE_ACTIVE)
                                        trg.active = ACTIVE_NOT;
                                else
                                        trg.active = ACTIVE_ACTIVE;
                        else
-                               trg.active = os.cnt;
+                               trg.active = this.cnt;
                }
        }
-       self = os;
+       setself(this);
 }
 
 void spawnfunc_relay_activate()
-{
+{SELFPARAM();
        self.cnt = ACTIVE_ACTIVE;
        self.use = relay_activators_use;
 }
 
 void spawnfunc_relay_deactivate()
-{
+{SELFPARAM();
        self.cnt = ACTIVE_NOT;
        self.use = relay_activators_use;
 }
 
 void spawnfunc_relay_activatetoggle()
-{
+{SELFPARAM();
        self.cnt = ACTIVE_TOGGLE;
        self.use = relay_activators_use;
 }
index ade56c1e8b48fe4ec78b3515668980ffd21f191f..cadd95e5840abd319b53af727505d19a05cc9cc4 100644 (file)
@@ -1,6 +1,6 @@
 #ifdef SVQC
 void trigger_relay_if_use()
-{
+{SELFPARAM();
        float n;
        n = self.count;
 
@@ -14,7 +14,7 @@ void trigger_relay_if_use()
 }
 
 void spawnfunc_trigger_relay_if()
-{
+{SELFPARAM();
        self.use = trigger_relay_if_use;
 }
 #endif
index 8a77cef0515afe654cf5621dc90e9ed80ac2b268..f93287a920f4ad2c5a5187d17a03fad951e4b361 100644 (file)
@@ -1,6 +1,6 @@
 #ifdef SVQC
 void trigger_relay_teamcheck_use()
-{
+{SELFPARAM();
        if(activator.team)
        {
                if(self.spawnflags & 2)
@@ -22,12 +22,12 @@ void trigger_relay_teamcheck_use()
 }
 
 void trigger_relay_teamcheck_reset()
-{
+{SELFPARAM();
        self.team = self.team_saved;
 }
 
 void spawnfunc_trigger_relay_teamcheck()
-{
+{SELFPARAM();
        self.team_saved = self.team;
        self.use = trigger_relay_teamcheck_use;
        self.reset = trigger_relay_teamcheck_reset;
index b93ab03d0a4ded5fcb90f76e2cef41c1963bb195..27347d9e83ea1e63d2138446e1e4b4031329cc4a 100644 (file)
@@ -9,7 +9,8 @@
 
 #ifdef SVQC
 
-void secrets_setstatus() {
+void secrets_setstatus()
+{SELFPARAM();
        self.stat_secrets_total = secrets_total;
        self.stat_secrets_found = secrets_found;
 }
@@ -17,7 +18,8 @@ void secrets_setstatus() {
 /**
  * A secret has been found (maybe :P)
  */
-void trigger_secret_touch() {
+void trigger_secret_touch()
+{SELFPARAM();
        // only a player can trigger this
        if (!IS_PLAYER(other))
                return;
@@ -49,7 +51,8 @@ killtarget: remove all entities with this targetname when triggered
 You should create a common/trigger textured brush covering the entrance to a secret room/area.
 Trigger secret can only be trigger by a player's touch and can not be a target itself.
 */
-void spawnfunc_trigger_secret() {
+void spawnfunc_trigger_secret()
+{SELFPARAM();
        // FIXME: should it be disabled in most modes?
 
        // update secrets count
index b99332b984533c9853a79b0618c859e4c5a78eff..b9a4acd1a411934b3a90500afdff44dbeafd77c5 100644 (file)
@@ -38,7 +38,7 @@ void swampslug_think();
 * I do it this way becuz there is no "untouch" event.
 */
 void swampslug_think(void)
-{
+{SELFPARAM();
        //Slowly kill the slug
        self.health = self.health - 1;
 
@@ -62,7 +62,7 @@ void swampslug_think(void)
 }
 
 void swamp_touch(void)
-{
+{SELFPARAM();
        // If whatever thats touching the swamp is not a player
        // or if its a dead player, just dont care abt it.
        if(!IS_PLAYER(other) || PHYS_DEAD(other))
@@ -95,7 +95,7 @@ void swamp_touch(void)
 
 #ifdef SVQC
 float swamp_send(entity to, float sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_LADDER);
 
        WriteByte(MSG_ENTITY, self.dmg); // can probably get away with using a single byte here
@@ -108,7 +108,7 @@ float swamp_send(entity to, float sf)
 }
 
 void swamp_link()
-{
+{SELFPARAM();
        Net_LinkEntity(self, false, 0, func_ladder_send);
 }
 
@@ -117,7 +117,7 @@ Players gettin into the swamp will
 get slowd down and damaged
 */
 void spawnfunc_trigger_swamp(void)
-{
+{SELFPARAM();
        // Init stuff
        EXACTTRIGGER_INIT;
        self.touch = swamp_touch;
@@ -136,7 +136,7 @@ void spawnfunc_trigger_swamp(void)
 #elif defined(CSQC)
 
 void ent_swamp()
-{
+{SELFPARAM();
        self.dmg = ReadByte();
        self.swamp_slowdown = ReadByte();
        self.swamp_interval = ReadByte();
index d983cf3aec1d23842ef0f5367e268f4b86fa3fb9..129f4e387cbab7ca43b3e9ec93e3fca1b0ff4973 100644 (file)
@@ -1,6 +1,6 @@
 #ifdef SVQC
 void trigger_teleport_use()
-{
+{SELFPARAM();
        if(teamplay)
                self.team = activator.team;
 #ifdef SVQC
@@ -9,8 +9,7 @@ void trigger_teleport_use()
 }
 
 void Teleport_Touch (void)
-{
-       entity oldself;
+{SELFPARAM();
        string s;
 
        if (self.active != ACTIVE_ACTIVE)
@@ -38,22 +37,18 @@ void Teleport_Touch (void)
        if(IS_PLAYER(other))
                RemoveGrapplingHook(other);
 
-       entity e;
-       e = Simple_TeleportPlayer(self, other);
+       entity e = Simple_TeleportPlayer(self, other);
 
        activator = other;
        s = self.target; self.target = string_null;
        SUB_UseTargets();
        if (!self.target) self.target = s;
 
-       oldself = self;
-       self = e;
-       SUB_UseTargets();
-       self = oldself;
+       WITH(entity, self, e, SUB_UseTargets());
 }
 
 void spawnfunc_trigger_teleport()
-{
+{SELFPARAM();
        self.angles = '0 0 0';
 
        EXACTTRIGGER_INIT;
index 62c37a0f49630664ccbe8a7209b58f2082abd4ff..de2d3aac287ef32783b120cd57a28ea49f0211aa 100644 (file)
@@ -9,7 +9,7 @@
 #ifdef SVQC
 
 void viewloc_think()
-{
+{SELFPARAM();
        entity e;
 
        // we abuse this method, rather than using normal .touch, because touch isn't reliable with multiple clients inside the same trigger, and can't "untouch" entities
@@ -39,7 +39,7 @@ void viewloc_think()
 }
 
 bool trigger_viewloc_send(entity to, int sf)
-{
+{SELFPARAM();
        // CSQC doesn't need to know our origin (yet), as we're only available for referencing
        WriteByte(MSG_ENTITY, ENT_CLIENT_VIEWLOC_TRIGGER);
 
@@ -54,7 +54,7 @@ bool trigger_viewloc_send(entity to, int sf)
 }
 
 void viewloc_init()
-{
+{SELFPARAM();
        entity e;
        for(e = world; (e = find(e, targetname, self.target)); )
                if(e.classname == "target_viewlocation_start")
@@ -81,7 +81,7 @@ void viewloc_init()
 }
 
 void spawnfunc_trigger_viewlocation()
-{
+{SELFPARAM();
        // we won't check target2 here yet, as it may not even need to exist
        if(self.target == "") { LOG_INFO("^1FAIL!\n"); remove(self); return; }
 
@@ -90,7 +90,7 @@ void spawnfunc_trigger_viewlocation()
 }
 
 bool viewloc_send(entity to, int sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_VIEWLOC);
 
        WriteByte(MSG_ENTITY, self.cnt);
@@ -108,20 +108,20 @@ bool viewloc_send(entity to, int sf)
 
 .float angle;
 void viewloc_link()
-{
+{SELFPARAM();
        if(self.angle)
                self.angles_y = self.angle;
        Net_LinkEntity(self, false, 0, viewloc_send);
 }
 
 void spawnfunc_target_viewlocation_start()
-{
+{SELFPARAM();
        self.classname = "target_viewlocation_start";
        self.cnt = 1;
        viewloc_link();
 }
 void spawnfunc_target_viewlocation_end()
-{
+{SELFPARAM();
        self.classname = "target_viewlocation_end";
        self.cnt = 2;
        viewloc_link();
@@ -133,13 +133,13 @@ void spawnfunc_target_viewlocation() { spawnfunc_target_viewlocation_start(); }
 #elif defined(CSQC)
 
 void trigger_viewloc_updatelink()
-{
+{SELFPARAM();
        self.enemy = findfloat(world, entnum, self.cnt);
        self.goalentity = findfloat(world, entnum, self.count);
 }
 
 void ent_viewloc_trigger()
-{
+{SELFPARAM();
        float point1 = ReadShort();
        float point2 = ReadShort();
 
@@ -162,7 +162,7 @@ void ent_viewloc_trigger()
 }
 
 void ent_viewloc()
-{
+{SELFPARAM();
        self.cnt = ReadByte();
 
        self.origin_x = ReadCoord();
index 1e7715a91b58a70ef8472f980ea8a9a094c16214..a44c688ed9544fb16c2e27647a8dd952807a39e3 100644 (file)
@@ -3,7 +3,7 @@ void SUB_DontUseTargets() { }
 void() SUB_UseTargets;
 
 void DelayThink()
-{
+{SELFPARAM();
        activator = self.enemy;
        SUB_UseTargets ();
        remove(self);
@@ -22,7 +22,7 @@ void FixSize(entity e)
 
 #ifdef SVQC
 void trigger_common_write(bool withtarget)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, self.warpzone_isboxy);
        WriteByte(MSG_ENTITY, self.scale);
 
@@ -59,7 +59,7 @@ void trigger_common_write(bool withtarget)
 #elif defined(CSQC)
 
 void trigger_common_read(bool withtarget)
-{
+{SELFPARAM();
        self.warpzone_isboxy = ReadByte();
        self.scale = ReadByte();
 
@@ -96,7 +96,7 @@ void trigger_common_read(bool withtarget)
 }
 
 void trigger_remove_generic()
-{
+{SELFPARAM();
        if(self.target) { strunzone(self.target); }
        self.target = string_null;
 
@@ -137,8 +137,8 @@ match (string)self.target and call their .use function
 ==============================
 */
 void SUB_UseTargets()
-{
-       entity t, stemp, otemp, act;
+{SELFPARAM();
+       entity t, otemp, act;
        string s;
        float i;
 
@@ -191,10 +191,9 @@ void SUB_UseTargets()
 // fire targets
 //
        act = activator;
-       stemp = self;
        otemp = other;
 
-       if(stemp.target_random)
+       if(this.target_random)
                RandomSelection_Init();
 
        for(i = 0; i < 4; ++i)
@@ -202,10 +201,10 @@ void SUB_UseTargets()
                switch(i)
                {
                        default:
-                       case 0: s = stemp.target; break;
-                       case 1: s = stemp.target2; break;
-                       case 2: s = stemp.target3; break;
-                       case 3: s = stemp.target4; break;
+                       case 0: s = this.target; break;
+                       case 1: s = this.target2; break;
+                       case 2: s = this.target3; break;
+                       case 3: s = this.target4; break;
                }
                if (s != "")
                {
@@ -215,7 +214,7 @@ void SUB_UseTargets()
                        for(t = world; (t = find(t, targetname, s)); )
                        if(t.use)
                        {
-                               if(stemp.target_random)
+                               if(this.target_random)
                                {
                                        RandomSelection_Add(t, 0, string_null, 1, 0);
                                }
@@ -223,8 +222,8 @@ void SUB_UseTargets()
                                {
                                        if (t.classname == "func_clientwall" || t.classname == "func_clientillusionary")
                                                t.antiwall_flag = aw_flag;
-                                       self = t;
-                                       other = stemp;
+                                       setself(t);
+                                       other = this;
                                        activator = act;
                                        self.use();
                                }
@@ -232,22 +231,22 @@ void SUB_UseTargets()
                }
        }
 
-       if(stemp.target_random && RandomSelection_chosen_ent)
+       if(this.target_random && RandomSelection_chosen_ent)
        {
-               self = RandomSelection_chosen_ent;
-               other = stemp;
+               setself(RandomSelection_chosen_ent);
+               other = this;
                activator = act;
                self.use();
        }
 
        activator = act;
-       self = stemp;
+       setself(this);
        other = otemp;
 }
 
 #ifdef CSQC
 void trigger_touch_generic(void() touchfunc)
-{
+{SELFPARAM();
        entity e;
        for(e = findradius((self.absmin + self.absmax) * 0.5, vlen(self.absmax - self.absmin) * 0.5 + 1); e; e = e.chain)
        if(e.isplayermodel || e.classname == "csqcprojectile")
@@ -267,7 +266,7 @@ void trigger_touch_generic(void() touchfunc)
        }
 }
 void trigger_draw_generic()
-{
+{SELFPARAM();
        float dt = time - self.move_time;
        self.move_time = time;
        if(dt <= 0) { return; }
index 924ba7ecf008fc1c8f53b384e9e9893a304c60bf..2b0bd6f6763b338b8a3144f960c54348e7310b29 100644 (file)
@@ -34,7 +34,7 @@ void turret_checkpoint_use()
 
 #if 0
 void turret_checkpoint_think()
-{
+{SELFPARAM();
     if(self.enemy)
         te_lightning1(self,self.origin, self.enemy.origin);
 
@@ -52,7 +52,7 @@ If the checkpoint chain in not looped, the unit will go "Roaming" when the last
 */
 //float tc_acum;
 void turret_checkpoint_init()
-{
+{SELFPARAM();
     traceline(self.origin + '0 0 16', self.origin - '0 0 1024', MOVE_WORLDONLY, self);
     setorigin(self, trace_endpos + '0 0 32');
 
@@ -68,7 +68,7 @@ void turret_checkpoint_init()
 }
 
 void spawnfunc_turret_checkpoint()
-{
+{SELFPARAM();
     setorigin(self,self.origin);
     self.think = turret_checkpoint_init;
     self.nextthink = time + 0.2;
@@ -76,7 +76,7 @@ void spawnfunc_turret_checkpoint()
 
 // Compat.
 void spawnfunc_walker_checkpoint()
-{
+{SELFPARAM();
     self.classname = "turret_checkpoint";
     spawnfunc_turret_checkpoint();
 }
index f083e80d619e780c9afd4d7f0999753717160457..174e0ea7d4337a6980e16dd5bda1342a04dace92 100644 (file)
@@ -1,5 +1,5 @@
 void turret_remove()
-{
+{SELFPARAM();
        remove(self.tur_head);
        //remove(self.enemy);
        self.tur_head = world;
@@ -7,7 +7,7 @@ void turret_remove()
 
 .vector glowmod;
 void turret_changeteam()
-{
+{SELFPARAM();
        self.glowmod = Team_ColorRGB(self.team - 1) * 2;
        self.teamradar_color = Team_ColorRGB(self.team - 1);
 
@@ -20,12 +20,12 @@ void turret_changeteam()
 }
 
 void turret_head_draw()
-{
+{SELFPARAM();
        self.drawmask = MASK_NORMAL;
 }
 
 void turret_draw()
-{
+{SELFPARAM();
        float dt;
 
        dt = time - self.move_time;
@@ -54,7 +54,7 @@ void turret_draw()
 }
 
 void turret_draw2d()
-{
+{SELFPARAM();
        if(self.netname == "")
                return;
 
@@ -202,7 +202,7 @@ void turret_draw2d()
 }
 
 void turret_construct()
-{
+{SELFPARAM();
        entity tur = get_turretinfo(self.turretid);
 
        if(self.tur_head == world)
@@ -247,7 +247,7 @@ void turret_construct()
 entity turret_gibtoss(string _model, vector _from, vector _to, vector _cmod, float _explode);
 void turret_gibboom();
 void turret_gib_draw()
-{
+{SELFPARAM();
        Movetype_Physics_MatchTicrate(autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
 
        self.drawmask = MASK_NORMAL;
@@ -269,7 +269,7 @@ void turret_gib_draw()
 }
 
 void turret_gibboom()
-{
+{SELFPARAM();
        float i;
 
        sound (self, CH_SHOTS, W_Sound("rocket_impact"), VOL_BASE, ATTEN_NORM);
@@ -317,7 +317,7 @@ entity turret_gibtoss(string _model, vector _from, vector _to, vector _cmod, flo
 }
 
 void turret_die()
-{
+{SELFPARAM();
        sound (self, CH_SHOTS, W_Sound("rocket_impact"), VOL_BASE, ATTEN_NORM);
        pointparticles(particleeffectnum(EFFECT_ROCKET_EXPLODE), self.origin, '0 0 0', 1);
        if (!autocvar_cl_nogibs)
@@ -356,7 +356,7 @@ void turret_die()
 }
 
 void ent_turret()
-{
+{SELFPARAM();
        float sf;
        sf = ReadByte();
 
index 5b8ffede8791a463549b9a4ddeb40671166f1b2e..92971878370ae1b205fd8c6a27ba61c1ab2a46d1 100644 (file)
@@ -3,7 +3,7 @@
 
 // Generic aiming
 vector turret_aim_generic()
-{
+{SELFPARAM();
 
        vector pre_pos, prep;
        float distance, impact_time = 0, i, mintime;
@@ -165,14 +165,14 @@ float turret_targetscore_generic(entity _turret, entity _target)
 
 // Generic damage handling
 void turret_hide()
-{
+{SELFPARAM();
        self.effects   |= EF_NODRAW;
        self.nextthink = time + self.respawntime - 0.2;
        self.think       = turret_respawn;
 }
 
 void turret_die()
-{
+{SELFPARAM();
        self.deadflag             = DEAD_DEAD;
        self.tur_head.deadflag = self.deadflag;
 
@@ -207,7 +207,7 @@ void turret_die()
 }
 
 void turret_damage (entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector vforce)
-{
+{SELFPARAM();
        // Enough already!
        if(self.deadflag == DEAD_DEAD)
                return;
@@ -252,7 +252,7 @@ void turret_damage (entity inflictor, entity attacker, float damage, int deathty
 
 void() turret_think;
 void turret_respawn()
-{
+{SELFPARAM();
        // Make sure all parts belong to the same team since
        // this function doubles as "teamchange" function.
        self.tur_head.team      = self.team;
@@ -283,7 +283,7 @@ void turret_respawn()
 #define cvar_base "g_turrets_unit_"
 .float clientframe;
 void turrets_setframe(float _frame, float client_only)
-{
+{SELFPARAM();
        if((client_only ? self.clientframe : self.frame ) != _frame)
        {
                self.SendFlags |= TNSF_ANIM;
@@ -298,7 +298,7 @@ void turrets_setframe(float _frame, float client_only)
 }
 
 float turret_send(entity to, float sf)
-{
+{SELFPARAM();
 
        WriteByte(MSG_ENTITY, ENT_CLIENT_TURRET);
        WriteByte(MSG_ENTITY, sf);
@@ -359,7 +359,7 @@ float turret_send(entity to, float sf)
 }
 
 void load_unit_settings(entity ent, string unitname, float is_reload)
-{
+{SELFPARAM();
        string sbase;
 
        if (ent == world)
@@ -423,7 +423,7 @@ void load_unit_settings(entity ent, string unitname, float is_reload)
 }
 
 void turret_projectile_explode()
-{
+{SELFPARAM();
 
        self.takedamage = DAMAGE_NO;
        self.event_damage = func_null;
@@ -445,7 +445,7 @@ void turret_projectile_touch()
 }
 
 void turret_projectile_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector vforce)
-{
+{SELFPARAM();
        self.velocity  += vforce;
        self.health     -= damage;
        //self.realowner = attacker; // Dont change realowner, it does not make much sense for turrets
@@ -454,7 +454,7 @@ void turret_projectile_damage(entity inflictor, entity attacker, float damage, i
 }
 
 entity turret_projectile(string _snd, float _size, float _health, float _death, float _proj_type, float _cull, float _cli_anim)
-{
+{SELFPARAM();
        entity proj;
 
        sound (self, CH_WEAPON_A, _snd, VOL_BASE, ATTEN_NORM);
@@ -493,12 +493,10 @@ entity turret_projectile(string _snd, float _size, float _health, float _death,
 ** and updated aim<->predict impact distance.
 **/
 void turret_do_updates(entity t_turret)
-{
+{SELFPARAM();
        vector enemy_pos;
-       entity oldself;
 
-       oldself = self;
-       self = t_turret;
+       setself(t_turret);
 
        enemy_pos = real_origin(self.enemy);
 
@@ -527,7 +525,7 @@ void turret_do_updates(entity t_turret)
        self.tur_impactent                       = trace_ent;
        self.tur_impacttime                     = vlen(self.tur_shotorg - trace_endpos) / self.shot_speed;
 
-       self = oldself;
+       setself(this);
 }
 
 /**
@@ -536,7 +534,7 @@ void turret_do_updates(entity t_turret)
 **/
 .float turret_framecounter;
 void turret_track()
-{
+{SELFPARAM();
        vector target_angle; // This is where we want to aim
        vector move_angle;   // This is where we can aim
        float f_tmp;
@@ -834,7 +832,7 @@ float turret_validate_target(entity e_turret, entity e_target, float validate_fl
 }
 
 entity turret_select_target()
-{
+{SELFPARAM();
        entity e;               // target looper entity
        float  score;   // target looper entity score
        entity e_enemy;  // currently best scoreing target
@@ -901,7 +899,7 @@ entity turret_select_target()
 ** Preforms pre-fire checks based on the uints firecheck_flags
 **/
 float turret_firecheck()
-{
+{SELFPARAM();
        // This one just dont care =)
        if (self.firecheck_flags & TFL_FIRECHECK_NO)
                return 1;
@@ -975,7 +973,7 @@ float turret_firecheck()
 }
 
 bool turret_checkfire()
-{
+{SELFPARAM();
        bool ret = false; // dummy
        if(MUTATOR_CALLHOOK(Turret_CheckFire, ret))
                return ret_bool;
@@ -984,7 +982,7 @@ bool turret_checkfire()
 }
 
 void turret_fire()
-{
+{SELFPARAM();
        if (autocvar_g_turrets_nofire != 0)
                return;
 
@@ -1014,7 +1012,7 @@ void turret_fire()
 }
 
 void turret_think()
-{
+{SELFPARAM();
        entity e;
 
        self.nextthink = time + self.ticrate;
@@ -1188,7 +1186,7 @@ void turret_think()
        If activator is world, the turret go inactive.
 */
 void turret_use()
-{
+{SELFPARAM();
        LOG_TRACE("Turret ",self.netname, " used by ", activator.classname, "\n");
 
        self.team = activator.team;
@@ -1201,7 +1199,7 @@ void turret_use()
 }
 
 void turret_link()
-{
+{SELFPARAM();
        Net_LinkEntity(self, true, 0, turret_send);
        self.think       = turret_think;
        self.nextthink = time;
@@ -1209,7 +1207,7 @@ void turret_link()
 }
 
 void turrets_manager_think()
-{
+{SELFPARAM();
        self.nextthink = time + 1;
 
        entity e;
@@ -1231,7 +1229,7 @@ void turrets_manager_think()
 }
 
 float turret_initialize(float tur_id)
-{
+{SELFPARAM();
        if(!autocvar_g_turrets)
                return false;
 
index 65510645b130a9d5968cd7bee6fa273fd5e1d152..98c23c4584df4e98a4707c33f3121aee48ad55a5 100644 (file)
@@ -2,18 +2,17 @@ void spawnfunc_turret_targettrigger();
 void turret_targettrigger_touch();
 
 void turret_targettrigger_touch()
-{
+{SELFPARAM();
     entity e;
     if (self.cnt > time) return;
-    entity oldself;
-    oldself = self;
+    entity oldself = this;
 
     e = find(world, targetname, self.target);
     while (e)
     {
         if (e.turret_flags & TUR_FLAG_RECIEVETARGETS)
         {
-            self = e;
+            setself(e);
             if(e.turret_addtarget)
                 e.turret_addtarget(other,oldself);
         }
@@ -23,13 +22,13 @@ void turret_targettrigger_touch()
 
     oldself.cnt = time + 0.5;
 
-    self = oldself;
+    setself(this);
 }
 
 /*QUAKED turret_targettrigger (.5 .5 .5) ?
 */
 void spawnfunc_turret_targettrigger()
-{
+{SELFPARAM();
     if(!autocvar_g_turrets) { remove(self); return; }
 
     InitTrigger ();
index 1a09611da0bad5a414cd10973362139af581ac42..716a70ceffa3d34ff6e5ff13cf576c1542094bc0 100644 (file)
@@ -25,7 +25,7 @@ const float ewheel_anim_bck_fast = 4;
 
 //#define EWHEEL_FANCYPATH
 void ewheel_move_path()
-{
+{SELFPARAM();
 #ifdef EWHEEL_FANCYPATH
     // Are we close enougth to a path node to switch to the next?
     if (vlen(self.origin  - self.pathcurrent.origin) < 64)
@@ -68,7 +68,7 @@ void ewheel_move_path()
 }
 
 void ewheel_move_enemy()
-{
+{SELFPARAM();
     float newframe;
 
     self.steerto = steerlib_arrive(self.enemy.origin,self.target_range_optimal);
@@ -109,7 +109,7 @@ void ewheel_move_enemy()
 }
 
 void ewheel_move_idle()
-{
+{SELFPARAM();
     if(self.frame != 0)
     {
         self.SendFlags |= TNSF_ANIM;
@@ -121,10 +121,10 @@ void ewheel_move_idle()
         movelib_beak_simple((autocvar_g_turrets_unit_ewheel_speed_stop));
 }
 
-void spawnfunc_turret_ewheel() { if(!turret_initialize(TUR_EWHEEL)) remove(self); }
+void spawnfunc_turret_ewheel() { SELFPARAM(); if(!turret_initialize(TUR_EWHEEL)) remove(self); }
 
 float t_ewheel(float req)
-{
+{SELFPARAM();
     switch(req)
     {
         case TR_ATTACK:
@@ -265,7 +265,7 @@ float t_ewheel(float req)
 #ifdef CSQC
 
 void ewheel_draw()
-{
+{SELFPARAM();
     float dt;
 
     dt = time - self.move_time;
@@ -284,7 +284,7 @@ void ewheel_draw()
 }
 
 float t_ewheel(float req)
-{
+{SELFPARAM();
     switch(req)
     {
         case TR_SETUP:
index 3b834e4775078a1ebf766f16652ab9b8165a2bed..eff6a5801e5741f7fc0b1f2b16f4c267eef0628e 100644 (file)
@@ -12,7 +12,7 @@ REGISTER_TURRET(
 #else
 #ifdef SVQC
 void turret_flac_projectile_think_explode()
-{
+{SELFPARAM();
     if(self.enemy != world)
     if(vlen(self.origin - self.enemy.origin) < self.owner.shot_radius * 3)
         setorigin(self,self.enemy.origin + randomvec() * self.owner.shot_radius);
@@ -28,10 +28,10 @@ void turret_flac_projectile_think_explode()
     remove(self);
 }
 
-void spawnfunc_turret_flac() { if(!turret_initialize(TUR_FLAC)) remove(self); }
+void spawnfunc_turret_flac() { SELFPARAM(); if(!turret_initialize(TUR_FLAC)) remove(self); }
 
 float t_flac(float req)
-{
+{SELFPARAM();
     switch(req)
     {
         case TR_ATTACK:
index ca4c3e2de0c92d6f0c9bd304fdd29868358a1865..25cddf006e55da5171743b5161f0801f3e7289ee 100644 (file)
@@ -12,7 +12,7 @@ REGISTER_TURRET(
 #else
 #ifdef SVQC
 bool turret_fusionreactor_firecheck()
-{
+{SELFPARAM();
     if (self.attack_finished_single > time)
         return false;
 
@@ -40,10 +40,10 @@ bool turret_fusionreactor_firecheck()
     return true;
 }
 
-void spawnfunc_turret_fusionreactor() { if(!turret_initialize(TUR_FUSIONREACTOR)) remove(self); }
+void spawnfunc_turret_fusionreactor() { SELFPARAM(); if(!turret_initialize(TUR_FUSIONREACTOR)) remove(self); }
 
 float t_fusionreactor(float req)
-{
+{SELFPARAM();
     switch(req)
     {
         case TR_ATTACK:
index 882f852bc283c3c5fe4397e60e00c841129c6086..66b9907998385578c561585b5af6a5e9432193f0 100644 (file)
@@ -15,7 +15,7 @@ float autocvar_g_turrets_unit_hellion_shot_speed_gain;
 float autocvar_g_turrets_unit_hellion_shot_speed_max;
 
 void turret_hellion_missile_think()
-{
+{SELFPARAM();
     vector olddir,newdir;
     vector pre_pos;
     float itime;
@@ -76,10 +76,10 @@ void turret_hellion_missile_think()
     UpdateCSQCProjectile(self);
 }
 
-void spawnfunc_turret_hellion() { if(!turret_initialize(TUR_HELLION)) remove(self); }
+void spawnfunc_turret_hellion() { SELFPARAM(); if(!turret_initialize(TUR_HELLION)) remove(self); }
 
 float t_hellion(float req)
-{
+{SELFPARAM();
     switch(req)
     {
         case TR_ATTACK:
index fec2a69366caf8d9e6099c56f66be89bda823589..8a78e976ad55c4372538f1b0646beb897963f154 100644 (file)
@@ -25,7 +25,7 @@ float autocvar_g_turrets_unit_hk_shot_speed_turnrate;
 #endif
 
 float hk_is_valid_target(entity e_target)
-{
+{SELFPARAM();
     if (e_target == world)
         return 0;
 
@@ -59,7 +59,7 @@ float hk_is_valid_target(entity e_target)
 }
 
 void turret_hk_missile_think()
-{
+{SELFPARAM();
     vector vu, vd, vf, vl, vr, ve;  // Vector (direction)
     float  fu, fd, ff, fl, fr, fe;  // Fraction to solid
     vector olddir,wishdir,newdir;   // Final direction
@@ -260,7 +260,7 @@ void turret_hk_missile_think()
 }
 
 float turret_hk_addtarget(entity e_target,entity e_sender)
-{
+{SELFPARAM();
     if (e_target)
     {
         if (turret_validate_target(self,e_target,self.target_validate_flags) > 0)
@@ -273,10 +273,10 @@ float turret_hk_addtarget(entity e_target,entity e_sender)
     return 0;
 }
 
-void spawnfunc_turret_hk() { if(!turret_initialize(TUR_HK)) remove(self); }
+void spawnfunc_turret_hk() { SELFPARAM(); if(!turret_initialize(TUR_HK)) remove(self); }
 
 float t_hk(float req)
-{
+{SELFPARAM();
     switch(req)
     {
         case TR_ATTACK:
index 5d5d62c8326e4fbad695a0b8c0925eb6028362ce..8b580af0a9cdf973a4f2703bd3a1063c1b3587de 100644 (file)
@@ -11,12 +11,12 @@ REGISTER_TURRET(
 );
 #else
 #ifdef SVQC
-void spawnfunc_turret_machinegun() { if(!turret_initialize(TUR_MACHINEGUN)) remove(self); }
+void spawnfunc_turret_machinegun() { SELFPARAM(); if(!turret_initialize(TUR_MACHINEGUN)) remove(self); }
 
 void W_MachineGun_MuzzleFlash(void);
 
 float t_machinegun(float req)
-{
+{SELFPARAM();
     switch(req)
     {
         case TR_ATTACK:
index fca6a5b718ead3e93f203cf1acacf667b3a02f33..548ca8fc80a850b4b524c816e47af9ae940cc27a 100644 (file)
@@ -11,10 +11,10 @@ REGISTER_TURRET(
 );
 #else
 #ifdef SVQC
-void spawnfunc_turret_mlrs() { if(!turret_initialize(TUR_MLRS)) remove(self); }
+void spawnfunc_turret_mlrs() { SELFPARAM(); if(!turret_initialize(TUR_MLRS)) remove(self); }
 
 float t_mlrs(float req)
-{
+{SELFPARAM();
     switch(req)
     {
         case TR_ATTACK:
index 7d377174f7be15bea68fb2a3fb74d5d0543217a6..c83b34056d223878b6a9b1ae0dcf09dddbe41722 100644 (file)
@@ -14,13 +14,13 @@ REGISTER_TURRET(
 .float fireflag;
 
 float turret_phaser_firecheck()
-{
+{SELFPARAM();
     if (self.fireflag != 0) return 0;
     return turret_firecheck();
 }
 
 void beam_think()
-{
+{SELFPARAM();
     if ((time > self.cnt) || (self.owner.deadflag != DEAD_NO))
     {
         self.owner.attack_finished_single = time + self.owner.shot_refire;
@@ -43,26 +43,24 @@ void beam_think()
     self.nextthink = time + self.ticrate;
 
     self.owner.attack_finished_single = time + frametime;
-    entity oldself;
-    oldself = self;
-    self = self.owner;
+    setself(self.owner);
     FireImoBeam (   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,
                     self.shot_force,
-                    oldself.shot_dmg,
+                    this.shot_dmg,
                     0.75,
                     DEATH_TURRET_PHASER);
-    self = oldself;
+    setself(this);
     self.scale = vlen(self.owner.tur_shotorg - trace_endpos) / 256;
 
 }
 
-void spawnfunc_turret_phaser() { if(!turret_initialize(TUR_PHASER)) remove(self); }
+void spawnfunc_turret_phaser() { SELFPARAM(); if(!turret_initialize(TUR_PHASER)) remove(self); }
 
 float t_phaser(float req)
-{
+{SELFPARAM();
     switch(req)
     {
         case TR_ATTACK:
index dda66f72c570bb3309a8eee79dc0431ce30c1a28..ff882d18c927e356f0c7969a92d49c64177d4eed 100644 (file)
@@ -11,10 +11,10 @@ REGISTER_TURRET(
 );
 #else
 #ifdef SVQC
-void spawnfunc_turret_plasma() { if(!turret_initialize(TUR_PLASMA)) remove(self); }
+void spawnfunc_turret_plasma() { SELFPARAM(); if(!turret_initialize(TUR_PLASMA)) remove(self); }
 
 float t_plasma(float req)
-{
+{SELFPARAM();
     switch(req)
     {
         case TR_ATTACK:
index ef762387b89d5e68731baaa03e1cc56a2df0270c..47dd34ae8969e52fed7509b002f5e037d8c0a5be 100644 (file)
@@ -11,10 +11,10 @@ REGISTER_TURRET(
 );
 #else
 #ifdef SVQC
-void spawnfunc_turret_plasma_dual() { if(!turret_initialize(TUR_PLASMA_DUAL)) remove(self); }
+void spawnfunc_turret_plasma_dual() { SELFPARAM(); if(!turret_initialize(TUR_PLASMA_DUAL)) remove(self); }
 
 float t_plasma_dual(float req)
-{
+{SELFPARAM();
     switch(req)
     {
         case TR_ATTACK:
index 05dbffbcbbf7559e057c0ccf9b4854026f5011a6..8f80abea75e59a50482ecc08bda65bdb8f258172 100644 (file)
@@ -12,7 +12,7 @@ REGISTER_TURRET(
 #else
 #ifdef SVQC
 entity toast(entity from, float range, float damage)
-{
+{SELFPARAM();
     entity e;
     entity etarget = world;
     float d,dd;
@@ -54,7 +54,7 @@ entity toast(entity from, float range, float damage)
 }
 
 float turret_tesla_firecheck()
-{
+{SELFPARAM();
     // g_turrets_targetscan_maxdelay forces a target re-scan at least this often
     float do_target_scan = 0;
 
@@ -89,10 +89,10 @@ float turret_tesla_firecheck()
     return 0;
 }
 
-void spawnfunc_turret_tesla() { if(!turret_initialize(TUR_TESLA)) remove(self); }
+void spawnfunc_turret_tesla() { SELFPARAM(); if(!turret_initialize(TUR_TESLA)) remove(self); }
 
 float t_tesla(float req)
-{
+{SELFPARAM();
     switch(req)
     {
         case TR_ATTACK:
index 4a9ca77afe1b4e34e15b408f034ab928e6b8ca7d..58c1be198dcbe3cf75232d0f16737566ef4dbc9f 100644 (file)
@@ -53,7 +53,7 @@ float autocvar_g_turrets_unit_walker_turn_run;
 #define WALKER_PATH(s,e) pathlib_astar(s,e)
 
 float walker_firecheck()
-{
+{SELFPARAM();
     if (self.animflag == ANIM_MELEE)
         return 0;
 
@@ -61,7 +61,7 @@ float walker_firecheck()
 }
 
 void walker_melee_do_dmg()
-{
+{SELFPARAM();
     vector where;
     entity e;
 
@@ -80,18 +80,18 @@ void walker_melee_do_dmg()
 }
 
 void walker_setnoanim()
-{
+{SELFPARAM();
     turrets_setframe(ANIM_NO, false);
     self.animflag = self.frame;
 }
 void walker_rocket_explode()
-{
+{SELFPARAM();
     RadiusDamage (self, self.owner, (autocvar_g_turrets_unit_walker_rocket_damage), 0, (autocvar_g_turrets_unit_walker_rocket_radius), self, world, (autocvar_g_turrets_unit_walker_rocket_force), DEATH_TURRET_WALK_ROCKET, world);
     remove (self);
 }
 
 void walker_rocket_damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector vforce)
-{
+{SELFPARAM();
     self.health = self.health - damage;
     self.velocity = self.velocity + vforce;
 
@@ -102,7 +102,7 @@ void walker_rocket_damage (entity inflictor, entity attacker, float damage, floa
 #define WALKER_ROCKET_MOVE movelib_move_simple(newdir, (autocvar_g_turrets_unit_walker_rocket_speed), (autocvar_g_turrets_unit_walker_rocket_turnrate)); UpdateCSQCProjectile(self)
 void walker_rocket_loop();
 void walker_rocket_think()
-{
+{SELFPARAM();
     vector newdir;
     float edist;
     float itime;
@@ -157,7 +157,7 @@ void walker_rocket_think()
 }
 
 void walker_rocket_loop3()
-{
+{SELFPARAM();
     vector newdir;
     self.nextthink = time;
 
@@ -180,7 +180,7 @@ void walker_rocket_loop3()
 }
 
 void walker_rocket_loop2()
-{
+{SELFPARAM();
     vector newdir;
 
     self.nextthink = time;
@@ -203,7 +203,7 @@ void walker_rocket_loop2()
 }
 
 void walker_rocket_loop()
-{
+{SELFPARAM();
     self.nextthink = time;
     self.tur_shotorg = self.origin + '0 0 300';
     self.think = walker_rocket_loop2;
@@ -211,7 +211,7 @@ void walker_rocket_loop()
 }
 
 void walker_fire_rocket(vector org)
-{
+{SELFPARAM();
     entity rocket;
 
     fixedmakevectors(self.angles);
@@ -258,7 +258,7 @@ void walker_fire_rocket(vector org)
 .vector enemy_last_loc;
 .float enemy_last_time;
 void walker_move_to(vector _target, float _dist)
-{
+{SELFPARAM();
     switch (self.waterlevel)
     {
         case WATERLEVEL_NONE:
@@ -290,7 +290,7 @@ void walker_move_to(vector _target, float _dist)
 //#define WALKER_FANCYPATHING
 
 void walker_move_path()
-{
+{SELFPARAM();
 #ifdef WALKER_FANCYPATHING
     // Are we close enougth to a path node to switch to the next?
     if (vlen(self.origin  - self.pathcurrent.origin) < 64)
@@ -334,10 +334,10 @@ void walker_move_path()
 #endif
 }
 
-void spawnfunc_turret_walker() { if(!turret_initialize(TUR_WALKER)) remove(self); }
+void spawnfunc_turret_walker() { SELFPARAM(); if(!turret_initialize(TUR_WALKER)) remove(self); }
 
 float t_walker(float req)
-{
+{SELFPARAM();
     switch(req)
     {
         case TR_ATTACK:
@@ -651,7 +651,7 @@ float t_walker(float req)
 #include "../../../server/movelib.qh"
 
 void walker_draw()
-{
+{SELFPARAM();
     float dt;
 
     dt = time - self.move_time;
@@ -671,7 +671,7 @@ void walker_draw()
 }
 
 float t_walker(float req)
-{
+{SELFPARAM();
     switch(req)
     {
         case TR_SETUP:
index 477df7b6808a4ef80eefa7bf08544ac71290a539..8fa223aef1725d04c9d6b1f6b7898ae0def3c1e0 100644 (file)
@@ -114,7 +114,7 @@ vector angleofs3(vector from, vector from_a, entity to)
 * NOTICE this func overwrites the global v_forward, v_right and v_up vectors.
 */
 float turret_tag_fire_update()
-{
+{SELFPARAM();
        if(!self.tur_head)
        {
                error("Call to turret_tag_fire_update with self.tur_head missing!\n");
@@ -134,7 +134,7 @@ float turret_tag_fire_update()
 void FireImoBeam (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;
 
@@ -206,7 +206,7 @@ void FireImoBeam (vector start, vector end, vector smin, vector smax,
 #ifdef TURRET_DEBUG
 void SUB_Remove();
 void marker_think()
-{
+{SELFPARAM();
        if(self.cnt)
        if(self.cnt < time)
        {
index 6b43f34bf2aefedfdc40aa65012a09d2f8befe54..f796b6ebda6109c169700f78dae37989464819d6 100644 (file)
@@ -1,6 +1,47 @@
 #ifndef UTIL_POST_H
 #define UTIL_POST_H
 
+[[alias("self")]] entity __self;
+
+// Can't wrap with do-while as block may contain continue or break
+#define WITH(type, name, value, block) { \
+    type __with_save = (name); \
+    name = (value); \
+    LAMBDA(block) \
+    name = __with_save; \
+} do { } while (0)
+
+// Transition from global 'self' to local 'this'
+
+// Step 1: auto oldself
+#if 1
+#define SELFPARAM() noref entity this = __self
+#define setself(s) (__self = s)
+#define self __self
+#endif
+
+// Step 2: check SELFPARAM() is present for functions that use self
+#if 0
+#define SELFPARAM() [[alias("__self")]] noref entity this = __self
+#define setself(s) (__self = s)
+#define self this
+#endif
+
+// Step 3: const self
+#if 0
+#define SELFPARAM() noref const entity this = __self
+entity setself(entity e) { return self = e; }
+entity getself() { return self; }
+#define self getself()
+#endif
+
+// Step 4: enable when possible
+// TODO: Remove SELFPARAM in favor of a parameter
+#if 0
+#define SELFPARAM() noref const entity this = __self
+#define self this
+#endif
+
 #define spawn() new(entity)
 
 #endif
index 439f0bffa0f9b77485362c12815b4e26ce75ac7b..a054edde8a56748c5d10fcd4e8d5640ce4882a5a 100644 (file)
@@ -41,7 +41,7 @@ string wordwrap(string s, float l)
 #ifndef MENUQC
 #ifndef CSQC
 void wordwrap_buffer_sprint(string s)
-{
+{SELFPARAM();
        wordwrap_buffer = strcat(wordwrap_buffer, s);
        if(s == "\n")
        {
@@ -51,7 +51,7 @@ void wordwrap_buffer_sprint(string s)
 }
 
 void wordwrap_sprint(string s, float l)
-{
+{SELFPARAM();
        wordwrap_buffer = "";
        wordwrap_cb(s, l, wordwrap_buffer_sprint);
        if(wordwrap_buffer != "")
index 141f8fc42d59b5362e4e8bfad7712cc27c8c22fb..b6c8844abd8028920814b047c0b3b62202fa7326 100644 (file)
@@ -27,7 +27,7 @@ void vehicle_alarm(entity e, int ch, string s0und)
 }
 
 void AuxiliaryXhair_Draw2D()
-{
+{SELFPARAM();
        if (scoreboard_showscores)
                return;
 
@@ -73,7 +73,7 @@ void Net_AuXair2(bool bIsNew)
 }
 
 void Net_VehicleSetup()
-{
+{SELFPARAM();
        int hud_id = ReadByte();
 
        // hud_id == 0 means we exited a vehicle, so stop alarm sound/s
@@ -119,7 +119,7 @@ void Vehicles_drawHUD(
        string iconAmmo2,
        vector colorAmmo2,
        string crosshair)
-{
+{SELFPARAM();
        if(autocvar_r_letterbox)
                return;
 
index 523156006d9c9067315533bb68a34c7fa67430a8..bc8399b09fcda3c2f1322ebf7bfbf58c831e678f 100644 (file)
@@ -39,7 +39,7 @@ bool vehicle_send(entity to, int sf)
 #endif
 
 bool SendAuxiliaryXhair(entity to, int sf)
-{
+{SELFPARAM();
 
        WriteByte(MSG_ENTITY, ENT_CLIENT_AUXILIARYXHAIR);
 
@@ -94,7 +94,7 @@ void CSQCVehicleSetup(entity own, int vehicle_id)
 }
 
 vector targetdrone_getnewspot()
-{
+{SELFPARAM();
        vector spot;
        int i;
        for(i = 0; i < 100; ++i)
@@ -108,7 +108,7 @@ vector targetdrone_getnewspot()
 }
 
 void vehicles_locktarget(float incr, float decr, float _lock_time)
-{
+{SELFPARAM();
        if(self.lock_target && self.lock_target.deadflag != DEAD_NO)
        {
                self.lock_target        = world;
@@ -181,7 +181,7 @@ void vehicles_locktarget(float incr, float decr, float _lock_time)
 }
 
 vector vehicles_force_fromtag_hover(string tag_name, float spring_length, float max_power)
-{
+{SELFPARAM();
        force_fromtag_origin = gettaginfo(self, gettagindex(self, tag_name));
        v_forward  = normalize(v_forward) * -1;
        traceline(force_fromtag_origin, force_fromtag_origin - (v_forward  * spring_length), MOVE_NORMAL, self);
@@ -193,7 +193,7 @@ vector vehicles_force_fromtag_hover(string tag_name, float spring_length, float
 }
 
 vector vehicles_force_fromtag_maglev(string tag_name, float spring_length, float max_power)
-{
+{SELFPARAM();
 
        force_fromtag_origin = gettaginfo(self, gettagindex(self, tag_name));
        v_forward  = normalize(v_forward) * -1;
@@ -214,7 +214,7 @@ vector vehicles_force_fromtag_maglev(string tag_name, float spring_length, float
 
 // projectile handling
 void vehicles_projectile_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        // Ignore damage from oterh projectiles from my owner (dont mess up volly's)
        if(inflictor.owner == self.owner)
                return;
@@ -231,7 +231,7 @@ void vehicles_projectile_damage(entity inflictor, entity attacker, float damage,
 }
 
 void vehicles_projectile_explode()
-{
+{SELFPARAM();
        if(self.owner && other != world)
        {
                if(other == self.owner.vehicle)
@@ -254,7 +254,7 @@ entity vehicles_projectile(string _mzlfx, string _mzlsound,
                                                   float _dmg, float _radi, float _force,  float _size,
                                                   int _deahtype, float _projtype, float _health,
                                                   bool _cull, bool _clianim, entity _owner)
-{
+{SELFPARAM();
        entity proj;
 
        proj = spawn();
@@ -302,7 +302,7 @@ entity vehicles_projectile(string _mzlfx, string _mzlsound,
 }
 
 void vehicles_gib_explode()
-{
+{SELFPARAM();
        sound (self, CH_SHOTS, W_Sound("rocket_impact"), VOL_BASE, ATTEN_NORM);
        Send_Effect(EFFECT_EXPLOSION_SMALL, randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
        Send_Effect(EFFECT_EXPLOSION_SMALL, self.wp00.origin + '0 0 64', '0 0 0', 1);
@@ -310,7 +310,7 @@ void vehicles_gib_explode()
 }
 
 void vehicles_gib_think()
-{
+{SELFPARAM();
        self.alpha -= 0.1;
        if(self.cnt >= time)
                remove(self);
@@ -319,7 +319,7 @@ void vehicles_gib_think()
 }
 
 entity vehicle_tossgib(entity _template, vector _vel, string _tag, bool _burn, bool _explode, float _maxtime, vector _rot)
-{
+{SELFPARAM();
        entity _gib = spawn();
        setmodel(_gib, _template.model);
        setorigin(_gib, gettaginfo(self, gettagindex(self, _tag)));
@@ -397,7 +397,7 @@ vector vehicle_aimturret(entity _vehic, vector _target, entity _turrret, string
 }
 
 void vehicles_reset_colors()
-{
+{SELFPARAM();
        entity e;
        float _effects = 0, _colormap;
        vector _glowmod, _colormod;
@@ -478,7 +478,7 @@ void vehicles_clearreturn(entity veh)
 
 void vehicles_spawn();
 void vehicles_return()
-{
+{SELFPARAM();
        Send_Effect(EFFECT_TELEPORT, self.wp00.origin + '0 0 64', '0 0 0', 1);
 
        self.wp00.think  = vehicles_spawn;
@@ -491,7 +491,7 @@ void vehicles_return()
 }
 
 void vehicles_showwp_goaway()
-{
+{SELFPARAM();
        if(self.waypointsprite_attached)
                WaypointSprite_Kill(self.waypointsprite_attached);
 
@@ -500,7 +500,7 @@ void vehicles_showwp_goaway()
 }
 
 void vehicles_showwp()
-{
+{SELFPARAM();
        entity oldself = world;
        vector rgb;
 
@@ -515,7 +515,7 @@ void vehicles_showwp()
                self.nextthink  = time +1;
 
                oldself = self;
-               self = spawn();
+               setself(spawn());
                setmodel(self, "null");
                self.team = oldself.wp00.team;
                self.wp00 = oldself.wp00;
@@ -534,13 +534,13 @@ void vehicles_showwp()
        if(self.waypointsprite_attached)
        {
                WaypointSprite_UpdateRule(self.waypointsprite_attached, self.wp00.team, SPRITERULE_DEFAULT);
-               if(oldself == world)
+               if(this == NULL)
                        WaypointSprite_UpdateBuildFinished(self.waypointsprite_attached, self.nextthink);
                WaypointSprite_Ping(self.waypointsprite_attached);
        }
 
-       if(oldself != world)
-               self = oldself;
+       if(this)
+               setself(this);
 }
 
 void vehicles_setreturn(entity veh)
@@ -571,7 +571,7 @@ void vehicles_setreturn(entity veh)
 }
 
 void vehicle_use()
-{
+{SELFPARAM();
        LOG_TRACE("vehicle ",self.netname, " used by ", activator.classname, "\n");
 
        self.tur_head.team = activator.team;
@@ -598,7 +598,7 @@ void vehicle_use()
 }
 
 void vehicles_regen(float timer, .float regen_field, float field_max, float rpause, float regen, float delta_time, float _healthscale)
-{
+{SELFPARAM();
        if(self.regen_field < field_max)
        if(timer + rpause < time)
        {
@@ -613,7 +613,7 @@ void vehicles_regen(float timer, .float regen_field, float field_max, float rpau
 }
 
 void shieldhit_think()
-{
+{SELFPARAM();
        self.alpha -= 0.1;
        if (self.alpha <= 0)
        {
@@ -628,7 +628,7 @@ void shieldhit_think()
 }
 
 void vehicles_painframe()
-{
+{SELFPARAM();
        if(self.owner.vehicle_health <= 50)
        if(self.pain_frame < time)
        {
@@ -650,7 +650,7 @@ void vehicles_painframe()
 }
 
 void vehicles_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        self.dmg_time = time;
 
        // WEAPONTODO
@@ -754,7 +754,7 @@ float vehicles_crushable(entity e)
 }
 
 void vehicles_impact(float _minspeed, float _speedfac, float _maxpain)
-{
+{SELFPARAM();
        if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
                return;
 
@@ -777,7 +777,7 @@ void vehicles_impact(float _minspeed, float _speedfac, float _maxpain)
 
 // vehicle enter/exit handling
 vector vehicles_findgoodexit(vector prefer_spot)
-{
+{SELFPARAM();
        //vector exitspot;
        float mysize;
 
@@ -825,10 +825,9 @@ vector vehicles_findgoodexit(vector prefer_spot)
 }
 
 void vehicles_exit(bool eject)
-{
+{SELFPARAM();
        entity _vehicle;
        entity _player;
-       entity _oldself = self;
 
        if(vehicles_exit_running)
        {
@@ -844,7 +843,7 @@ void vehicles_exit(bool eject)
                if (_vehicle.vehicle_flags & VHF_PLAYERSLOT)
                {
                        _vehicle.vehicle_exit(eject);
-                       self = _oldself;
+                       setself(this);
                        vehicles_exit_running = false;
                        return;
                }
@@ -854,7 +853,7 @@ void vehicles_exit(bool eject)
 
        _player = _vehicle.owner;
 
-       self = _vehicle;
+       setself(_vehicle);
 
        if (_player)
        {
@@ -918,15 +917,14 @@ void vehicles_exit(bool eject)
        vehicles_reset_colors();
        _vehicle.owner = world;
 
-       CSQCMODEL_AUTOINIT();
-
-       self = _oldself;
+       CSQCMODEL_AUTOINIT(self);
 
+       setself(this);
        vehicles_exit_running = false;
 }
 
 void vehicles_touch()
-{
+{SELFPARAM();
        if(MUTATOR_CALLHOOK(VehicleTouch, self, other))
                return;
 
@@ -957,7 +955,7 @@ void vehicles_touch()
 }
 
 bool vehicle_impulse(int imp)
-{
+{SELFPARAM();
        switch(imp)
        {
                case 17:
@@ -971,7 +969,7 @@ bool vehicle_impulse(int imp)
 }
 
 void vehicles_enter(entity pl, entity veh)
-{
+{SELFPARAM();
    // Remove this when bots know how to use vehicles
        if((IS_BOT_CLIENT(pl) && !autocvar_g_vehicles_allow_bots))
                return;
@@ -988,8 +986,7 @@ void vehicles_enter(entity pl, entity veh)
        if(veh.vehicle_flags & VHF_MULTISLOT)
        if(veh.owner)
        {
-               entity oldself = self;
-               self = veh;
+               setself(veh);
                other = pl; // TODO: fix
 
                if(!veh.gunner1)
@@ -997,7 +994,7 @@ void vehicles_enter(entity pl, entity veh)
                if(veh.gun1.vehicle_enter)
                if(veh.gun1.vehicle_enter())
                {
-                       self = oldself;
+                       setself(this);
                        return;
                }
 
@@ -1006,11 +1003,11 @@ void vehicles_enter(entity pl, entity veh)
                if(veh.gun2.vehicle_enter)
                if(veh.gun2.vehicle_enter())
                {
-                       self = oldself;
+                       setself(this);
                        return;
                }
 
-               self = oldself;
+               setself(this);
        }
 
        if(teamplay)
@@ -1114,17 +1111,16 @@ void vehicles_enter(entity pl, entity veh)
 
        MUTATOR_CALLHOOK(VehicleEnter, pl, veh);
 
-       entity oldself = self;
-       self = veh;
+       setself(veh);
        CSQCModel_UnlinkEntity();
        VEH_ACTION(veh.vehicleid, VR_ENTER);
-       self = oldself;
+       setself(this);
 
        antilag_clear(pl);
 }
 
 void vehicles_think()
-{
+{SELFPARAM();
        self.nextthink = time;
 
        if(self.owner)
@@ -1132,12 +1128,12 @@ void vehicles_think()
 
        VEH_ACTION(self.vehicleid, VR_THINK);
 
-       CSQCMODEL_AUTOUPDATE();
+       CSQCMODEL_AUTOUPDATE(self);
 }
 
 // initialization
 void vehicles_spawn()
-{
+{SELFPARAM();
        LOG_TRACE("Spawning vehicle: ", self.classname, "\n");
 
        // disown & reset
@@ -1183,11 +1179,11 @@ void vehicles_spawn()
 
        VEH_ACTION(self.vehicleid, VR_SPAWN);
 
-       CSQCMODEL_AUTOINIT();
+       CSQCMODEL_AUTOINIT(self);
 }
 
 bool vehicle_initialize(entity veh, bool nodrop)
-{
+{SELFPARAM();
        if(!autocvar_g_vehicles)
                return false;
 
index 7ace8225bb5965a9874ed19c29208ac89777d764..d88e3dfc064cf3b3d937466407a172c481bea877 100644 (file)
@@ -111,11 +111,11 @@ void bumblebee_fire_cannon(entity _gun, string _tagname, entity _owner)
 }
 
 float bumblebee_gunner_frame()
-{
+{SELFPARAM();
        entity vehic    = self.vehicle.owner;
        entity gun      = self.vehicle;
        entity gunner   = self;
-       self = vehic;
+       setself(vehic);
 
        vehic.solid = SOLID_NOT;
        //setorigin(gunner, vehic.origin);
@@ -216,7 +216,7 @@ float bumblebee_gunner_frame()
        gunner.BUTTON_ATCK = gunner.BUTTON_ATCK2 = gunner.BUTTON_CROUCH = 0;
        gunner.vehicle_energy = (gun.vehicle_energy / autocvar_g_vehicle_bumblebee_cannon_ammo) * 100;
 
-       self = gunner;
+       setself(gunner);
        return 1;
 }
 
@@ -247,7 +247,7 @@ vector bumblebee_gunner_findgoodexit(vector prefer_spot, entity gunner, entity p
 }
 
 void bumblebee_gunner_exit(int _exitflag)
-{
+{SELFPARAM();
        entity player = self;
        entity gunner = player.vehicle;
        entity vehic = gunner.owner;
@@ -303,7 +303,7 @@ void bumblebee_gunner_exit(int _exitflag)
 }
 
 bool bumblebee_gunner_enter()
-{
+{SELFPARAM();
        entity vehic = self;
        entity player = other;
        entity gunner = world;
@@ -370,7 +370,7 @@ bool bumblebee_gunner_enter()
 }
 
 bool vehicles_valid_pilot()
-{
+{SELFPARAM();
        if(IS_BOT_CLIENT(other) && !autocvar_g_vehicles_allow_bots)
                return false;
 
@@ -384,7 +384,7 @@ bool vehicles_valid_pilot()
 }
 
 void bumblebee_touch()
-{
+{SELFPARAM();
        if(autocvar_g_vehicles_enter) { return; }
 
        if(self.gunner1 != world && self.gunner2 != world)
@@ -406,7 +406,7 @@ void bumblebee_touch()
 }
 
 void bumblebee_regen()
-{
+{SELFPARAM();
        if(self.gun1.delay + autocvar_g_vehicle_bumblebee_cannon_ammo_regen_pause < time)
                self.gun1.vehicle_energy = min(autocvar_g_vehicle_bumblebee_cannon_ammo,
                                                                           self.gun1.vehicle_energy + autocvar_g_vehicle_bumblebee_cannon_ammo_regen * frametime);
@@ -427,7 +427,7 @@ void bumblebee_regen()
 }
 
 float bumblebee_pilot_frame()
-{
+{SELFPARAM();
        entity pilot, vehic;
        vector newvel;
 
@@ -440,11 +440,11 @@ float bumblebee_pilot_frame()
 
        pilot = self;
        vehic = self.vehicle;
-       self   = vehic;
+       setself(vehic);
 
        if(vehic.deadflag != DEAD_NO)
        {
-               self = pilot;
+               setself(pilot);
                pilot.BUTTON_ATCK = pilot.BUTTON_ATCK2 = 0;
                return 1;
        }
@@ -643,13 +643,13 @@ float bumblebee_pilot_frame()
        setorigin(pilot, vehic.origin + v_up * 48 + v_forward * 160);
 
        pilot.BUTTON_ATCK = pilot.BUTTON_ATCK2 = pilot.BUTTON_CROUCH = 0;
-       self = pilot;
+       setself(pilot);
 
        return 1;
 }
 
 void bumblebee_land()
-{
+{SELFPARAM();
        float hgt;
 
        hgt = raptor_altitude(512);
@@ -662,11 +662,11 @@ void bumblebee_land()
 
        self.nextthink = time;
 
-       CSQCMODEL_AUTOUPDATE();
+       CSQCMODEL_AUTOUPDATE(self);
 }
 
 void bumblebee_exit(float eject)
-{
+{SELFPARAM();
        if(self.owner.vehicleid == VEH_BUMBLEBEE.vehicleid)
        {
                bumblebee_gunner_exit(eject);
@@ -709,7 +709,7 @@ void bumblebee_exit(float eject)
 }
 
 void bumblebee_blowup()
-{
+{SELFPARAM();
        RadiusDamage(self, self.enemy, autocvar_g_vehicle_bumblebee_blowup_coredamage,
                                 autocvar_g_vehicle_bumblebee_blowup_edgedamage,
                                 autocvar_g_vehicle_bumblebee_blowup_radius, self, world,
@@ -726,7 +726,7 @@ void bumblebee_blowup()
 }
 
 void bumblebee_diethink()
-{
+{SELFPARAM();
        if(time >= self.wait)
                self.think = bumblebee_blowup;
 
@@ -740,7 +740,7 @@ void bumblebee_diethink()
 }
 
 float bumble_raygun_send(entity to, float sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_BUMBLE_RAYGUN);
 
        WriteByte(MSG_ENTITY, sf);
@@ -769,13 +769,13 @@ float bumble_raygun_send(entity to, float sf)
 }
 
 void spawnfunc_vehicle_bumblebee()
-{
+{SELFPARAM();
        if(!autocvar_g_vehicle_bumblebee) { remove(self); return; }
        if(!vehicle_initialize(VEH_BUMBLEBEE, false)) { remove(self); return; }
 }
 
 float v_bumblebee(float req)
-{
+{SELFPARAM();
        switch(req)
        {
                case VR_IMPACT:
@@ -804,11 +804,11 @@ float v_bumblebee(float req)
                                entity oldself = self;
                                if(self.gunner1)
                                {
-                                       self = self.gunner1;
+                                       setself(self.gunner1);
                                        oldself.gun1.vehicle_exit(VHEF_EJECT);
                                        entity oldother = other;
                                        other = self;
-                                       self = oldself;
+                                       setself(oldself);
                                        self.phase = 0;
                                        self.touch();
                                        other = oldother;
@@ -817,11 +817,11 @@ float v_bumblebee(float req)
 
                                if(self.gunner2)
                                {
-                                       self = self.gunner2;
+                                       setself(self.gunner2);
                                        oldself.gun2.vehicle_exit(VHEF_EJECT);
                                        entity oldother = other;
                                        other = self;
-                                       self = oldself;
+                                       setself(oldself);
                                        self.phase = 0;
                                        self.touch();
                                        other = oldother;
@@ -843,16 +843,16 @@ float v_bumblebee(float req)
 
                        if(self.gunner1)
                        {
-                               self = self.gunner1;
+                               setself(self.gunner1);
                                oldself.gun1.vehicle_exit(VHEF_EJECT);
-                               self = oldself;
+                               setself(oldself);
                        }
 
                        if(self.gunner2)
                        {
-                               self = self.gunner2;
+                               setself(self.gunner2);
                                oldself.gun2.vehicle_exit(VHEF_EJECT);
-                               self = oldself;
+                               setself(oldself);
                        }
 
                        self.vehicle_exit(VHEF_EJECT);
@@ -1026,7 +1026,7 @@ void CSQC_BUMBLE_GUN_HUD()
 }
 
 void bumble_raygun_draw()
-{
+{SELFPARAM();
        float _len;
        vector _dir;
        vector _vtmp1, _vtmp2;
@@ -1064,7 +1064,7 @@ void bumble_raygun_draw()
 }
 
 void bumble_raygun_read(bool bIsNew)
-{
+{SELFPARAM();
        int sf = ReadByte();
 
        if(sf & BRG_SETUP)
index 38b06c3b3a80dd72fe182366622bfb9d9c4397b7..40dbfecb3c35d846dc37c583071d9af9854054d0 100644 (file)
@@ -111,7 +111,7 @@ vector autocvar_g_vehicle_racer_bouncepain;
 var vector racer_force_from_tag(string tag_name, float spring_length, float max_power);
 
 void racer_align4point(float _delta)
-{
+{SELFPARAM();
        vector push_vector;
        float fl_push, fr_push, bl_push, br_push;
 
@@ -169,7 +169,7 @@ void racer_align4point(float _delta)
 }
 
 void racer_fire_cannon(string tagname)
-{
+{SELFPARAM();
        vector v;
        entity bolt;
 
@@ -186,7 +186,7 @@ void racer_fire_cannon(string tagname)
 }
 
 void racer_rocket_groundhugger()
-{
+{SELFPARAM();
        vector olddir, newdir;
        float oldvel, newvel;
 
@@ -238,7 +238,7 @@ void racer_rocket_groundhugger()
 }
 
 void racer_rocket_tracker()
-{
+{SELFPARAM();
        vector olddir, newdir;
        float oldvel, newvel;
 
@@ -290,7 +290,7 @@ void racer_rocket_tracker()
 }
 
 void racer_fire_rocket(string tagname, entity trg)
-{
+{SELFPARAM();
        vector v = gettaginfo(self, gettagindex(self, tagname));
        entity rocket = vehicles_projectile(EFFECT_RACER_ROCKETLAUNCH.eent_eff_name, W_Sound("rocket_fire"),
                                                   v, v_forward * autocvar_g_vehicle_racer_rocket_speed,
@@ -310,7 +310,7 @@ void racer_fire_rocket(string tagname, entity trg)
 }
 
 float racer_frame()
-{
+{SELFPARAM();
        entity player, racer;
        vector df;
        float ftmp;
@@ -324,7 +324,7 @@ float racer_frame()
 
        player  = self;
        racer   = self.vehicle;
-       self    = racer;
+       setself(racer);
 
        vehicles_painframe();
 
@@ -333,7 +333,7 @@ float racer_frame()
 
        if(racer.deadflag != DEAD_NO)
        {
-               self = player;
+               setself(player);
                player.BUTTON_ATCK = player.BUTTON_ATCK2 = 0;
                return 1;
        }
@@ -545,12 +545,12 @@ float racer_frame()
        setorigin(player,racer.origin + '0 0 32');
        player.velocity = racer.velocity;
 
-       self = player;
+       setself(player);
        return 1;
 }
 
 void racer_think()
-{
+{SELFPARAM();
        self.nextthink = time;
 
        float pushdeltatime = time - self.lastpushtime;
@@ -579,11 +579,11 @@ void racer_think()
        self.angles_x *= 1 - (autocvar_g_vehicle_racer_anglestabilizer * pushdeltatime);
        self.angles_z *= 1 - (autocvar_g_vehicle_racer_anglestabilizer * pushdeltatime);
 
-       CSQCMODEL_AUTOUPDATE();
+       CSQCMODEL_AUTOUPDATE(self);
 }
 
 void racer_exit(float eject)
-{
+{SELFPARAM();
        vector spot;
 
        self.think        = racer_think;
@@ -627,7 +627,7 @@ void racer_exit(float eject)
 }
 
 void racer_blowup()
-{
+{SELFPARAM();
        self.deadflag   = DEAD_DEAD;
        self.vehicle_exit(VHEF_NORMAL);
 
@@ -650,17 +650,17 @@ void racer_blowup()
 }
 
 void racer_blowup_think()
-{
+{SELFPARAM();
        self.nextthink = time;
 
        if(time >= self.delay)
                racer_blowup();
 
-       CSQCMODEL_AUTOUPDATE();
+       CSQCMODEL_AUTOUPDATE(self);
 }
 
 void racer_deadtouch()
-{
+{SELFPARAM();
        self.avelocity_x *= 0.7;
        self.cnt -= 1;
        if(self.cnt <= 0)
@@ -668,7 +668,7 @@ void racer_deadtouch()
 }
 
 void spawnfunc_vehicle_racer()
-{
+{SELFPARAM();
        if(!autocvar_g_vehicle_racer) { remove(self); return; }
        if(!vehicle_initialize(VEH_RACER, false)) { remove(self); return; }
 }
@@ -678,7 +678,7 @@ void spawnfunc_vehicle_racer()
 #ifdef CSQC
 #if 0
 void racer_draw()
-{
+{SELFPARAM();
        float pushdeltatime = time - self.lastpushtime;
        if (pushdeltatime > 0.15) pushdeltatime = 0;
        self.lastpushtime = time;
@@ -711,7 +711,7 @@ void racer_draw()
 #endif
 
 bool v_racer(int req)
-{
+{SELFPARAM();
        switch(req)
        {
                case VR_IMPACT:
index d2ddea77316b0c83b7d974bc83b02fe3708ea950..263da161f0d197ce6d1bfaf8c9481d220613336c 100644 (file)
@@ -96,13 +96,13 @@ vector autocvar_g_vehicle_raptor_bouncepain;
 .entity bomb2;
 
 float raptor_altitude(float amax)
-{
+{SELFPARAM();
        tracebox(self.origin, self.mins, self.maxs, self.origin - ('0 0 1' * amax), MOVE_WORLDONLY, self);
        return vlen(self.origin - trace_endpos);
 }
 
 void raptor_bomblet_boom()
-{
+{SELFPARAM();
        RadiusDamage (self, self.realowner, autocvar_g_vehicle_raptor_bomblet_damage,
                                                                        autocvar_g_vehicle_raptor_bomblet_edgedamage,
                                                                        autocvar_g_vehicle_raptor_bomblet_radius, world, world,
@@ -111,7 +111,7 @@ void raptor_bomblet_boom()
 }
 
 void raptor_bomblet_touch()
-{
+{SELFPARAM();
        if(other == self.owner)
                return;
 
@@ -121,7 +121,7 @@ void raptor_bomblet_touch()
 }
 
 void raptor_bomb_burst()
-{
+{SELFPARAM();
        if(self.cnt > time)
        if(autocvar_g_vehicle_raptor_bomblet_alt)
        {
@@ -160,7 +160,7 @@ void raptor_bomb_burst()
 }
 
 void raptor_bombdrop()
-{
+{SELFPARAM();
        entity bomb_1, bomb_2;
 
        bomb_1 = spawn();
@@ -194,7 +194,7 @@ void raptor_bombdrop()
 
 
 void raptor_fire_cannon(entity gun, string tagname)
-{
+{SELFPARAM();
        vehicles_projectile(EFFECT_RAPTOR_MUZZLEFLASH.eent_eff_name, W_Sound("lasergun_fire"),
                                                   gettaginfo(gun, gettagindex(gun, tagname)), normalize(v_forward + randomvec() * autocvar_g_vehicle_raptor_cannon_spread) * autocvar_g_vehicle_raptor_cannon_speed,
                                                   autocvar_g_vehicle_raptor_cannon_damage, autocvar_g_vehicle_raptor_cannon_radius, autocvar_g_vehicle_raptor_cannon_force,  0,
@@ -202,7 +202,7 @@ void raptor_fire_cannon(entity gun, string tagname)
 }
 
 void raptor_land()
-{
+{SELFPARAM();
        float hgt;
 
        hgt = raptor_altitude(512);
@@ -226,11 +226,11 @@ void raptor_land()
 
        self.nextthink  = time;
 
-       CSQCMODEL_AUTOUPDATE();
+       CSQCMODEL_AUTOUPDATE(self);
 }
 
 void raptor_exit(float eject)
-{
+{SELFPARAM();
        vector spot;
        self.tur_head.exteriormodeltoclient = world;
 
@@ -277,19 +277,19 @@ void raptor_exit(float eject)
 }
 
 void raptor_flare_touch()
-{
+{SELFPARAM();
        remove(self);
 }
 
 void raptor_flare_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        self.health -= damage;
        if(self.health <= 0)
                remove(self);
 }
 
 void raptor_flare_think()
-{
+{SELFPARAM();
        self.nextthink = time + 0.1;
        entity _missile = findchainentity(enemy, self.owner);
        while(_missile)
@@ -306,7 +306,7 @@ void raptor_flare_think()
 }
 
 float raptor_frame()
-{
+{SELFPARAM();
        entity player, raptor;
        float ftmp = 0;
        vector df;
@@ -320,7 +320,7 @@ float raptor_frame()
 
        player = self;
        raptor = self.vehicle;
-       self   = raptor;
+       setself(raptor);
 
        vehicles_painframe();
        /*
@@ -349,7 +349,7 @@ float raptor_frame()
 
        if(raptor.deadflag != DEAD_NO)
        {
-               self = player;
+               setself(player);
                player.BUTTON_ATCK = player.BUTTON_ATCK2 = 0;
                return 1;
        }
@@ -642,20 +642,20 @@ float raptor_frame()
 
        player.BUTTON_ATCK = player.BUTTON_ATCK2 = player.BUTTON_CROUCH = 0;
 
-       self = player;
+       setself(player);
        return 1;
 }
 
 float raptor_takeoff()
-{
+{SELFPARAM();
        entity player, raptor;
 
        player = self;
        raptor = self.vehicle;
-       self   = raptor;
+       setself(raptor);
 
        self.nextthink = time;
-       CSQCMODEL_AUTOUPDATE();
+       CSQCMODEL_AUTOUPDATE(self);
        self.nextthink = 0; // will this work?
 
        if(self.sound_nexttime < time)
@@ -698,12 +698,12 @@ float raptor_takeoff()
                VEHICLE_UPDATE_PLAYER(player, shield, raptor);
 
        player.BUTTON_ATCK = player.BUTTON_ATCK2 = player.BUTTON_CROUCH = 0;
-       self = player;
+       setself(player);
        return 1;
 }
 
 void raptor_blowup()
-{
+{SELFPARAM();
        self.deadflag   = DEAD_DEAD;
        self.vehicle_exit(VHEF_NORMAL);
        RadiusDamage (self, self.enemy, 250, 15, 250, world, world, 250, DEATH_VH_RAPT_DEATH, world);
@@ -721,7 +721,7 @@ void raptor_blowup()
 }
 
 void raptor_diethink()
-{
+{SELFPARAM();
        if(time >= self.wait)
                self.think = raptor_blowup;
 
@@ -732,20 +732,20 @@ void raptor_diethink()
        }
        self.nextthink = time;
 
-       CSQCMODEL_AUTOUPDATE();
+       CSQCMODEL_AUTOUPDATE(self);
 }
 
 // If we dont do this ever now and then, the raptors rotors
 // stop working, presumably due to angle overflow. cute.
 void raptor_rotor_anglefix()
-{
+{SELFPARAM();
        self.gun1.angles_y = anglemods(self.gun1.angles_y);
        self.gun2.angles_y = anglemods(self.gun2.angles_y);
        self.nextthink = time + 15;
 }
 
 float raptor_impulse(float _imp)
-{
+{SELFPARAM();
        switch(_imp)
        {
                case 1:
@@ -790,13 +790,13 @@ float raptor_impulse(float _imp)
 }
 
 void spawnfunc_vehicle_raptor()
-{
+{SELFPARAM();
        if(!autocvar_g_vehicle_raptor) { remove(self); return; }
        if(!vehicle_initialize(VEH_RAPTOR, false)) { remove(self); return; }
 }
 
 float v_raptor(float req)
-{
+{SELFPARAM();
        switch(req)
        {
                case VR_IMPACT:
@@ -991,7 +991,7 @@ float v_raptor(float req)
 #ifdef CSQC
 
 void RaptorCBShellfragDraw()
-{
+{SELFPARAM();
        if(wasfreed(self))
                return;
 
@@ -1007,7 +1007,7 @@ void RaptorCBShellfragDraw()
 }
 
 void RaptorCBShellfragToss(vector _org, vector _vel, vector _ang)
-{
+{SELFPARAM();
        entity sfrag;
 
        sfrag = spawn();
index 973e1e5944741ee2353769495ad995ed0febd7d1..7060b781530f921da1fc60881a9a8e5bb2f61204 100644 (file)
@@ -86,13 +86,13 @@ float autocvar_g_vehicle_spiderbot_rocket_lifetime;
 vector autocvar_g_vehicle_spiderbot_bouncepain;
 
 void spiderbot_rocket_artillery()
-{
+{SELFPARAM();
        self.nextthink = time;
        UpdateCSQCProjectile(self);
 }
 
 void spiderbot_rocket_unguided()
-{
+{SELFPARAM();
        vector newdir, olddir;
 
        self.nextthink  = time;
@@ -108,7 +108,7 @@ void spiderbot_rocket_unguided()
 }
 
 void spiderbot_rocket_guided()
-{
+{SELFPARAM();
        vector newdir, olddir;
 
        self.nextthink  = time;
@@ -128,7 +128,7 @@ void spiderbot_rocket_guided()
 }
 
 void spiderbot_guide_release()
-{
+{SELFPARAM();
        entity rkt;
        rkt = findchainentity(realowner, self.owner);
        if(!rkt)
@@ -221,7 +221,7 @@ vector spiberbot_calcartillery(vector org, vector tgt, float ht)
 }
 
 void spiderbot_rocket_do()
-{
+{SELFPARAM();
        vector v;
        entity rocket = world;
 
@@ -333,7 +333,7 @@ void spiderbot_rocket_do()
 
 .float jump_delay;
 float spiderbot_frame()
-{
+{SELFPARAM();
        vector ad, vf;
        entity player, spider;
        float ftmp;
@@ -347,7 +347,7 @@ float spiderbot_frame()
 
        player = self;
        spider = self.vehicle;
-       self   = spider;
+       setself(spider);
 
        vehicles_painframe();
 
@@ -547,7 +547,7 @@ float spiderbot_frame()
                        vector v;
                        spider.misc_bulletcounter += 1;
 
-                       self = player;
+                       setself(player);
 
                        gun = (spider.misc_bulletcounter % 2) ? spider.gun1 : spider.gun2;
 
@@ -562,7 +562,7 @@ float spiderbot_frame()
                        //trailparticles(self, _particleeffectnum("spiderbot_minigun_trail"), v, trace_endpos);
                        pointparticles(particleeffectnum(EFFECT_SPIDERBOT_MINIGUN_MUZZLEFLASH), v, v_forward * 2500, 1);
 
-                       self = spider;
+                       setself(spider);
 
                        spider.vehicle_ammo1 -= autocvar_g_vehicle_spiderbot_minigun_ammo_cost;
                        spider.tur_head.attack_finished_single = time + autocvar_g_vehicle_spiderbot_minigun_refire;
@@ -607,12 +607,12 @@ float spiderbot_frame()
        if(self.vehicle_flags & VHF_HASSHIELD)
                VEHICLE_UPDATE_PLAYER(player, shield, spiderbot);
 
-       self = player;
+       setself(player);
        return 1;
 }
 
 void spiderbot_exit(float eject)
-{
+{SELFPARAM();
        entity e;
        vector spot;
 
@@ -669,7 +669,7 @@ void spiderbot_exit(float eject)
 }
 
 void spiderbot_headfade()
-{
+{SELFPARAM();
        self.think = spiderbot_headfade;
        self.nextthink = self.fade_time;
        self.alpha = 1 - (time - self.fade_time) * self.fade_rate;
@@ -686,7 +686,7 @@ void spiderbot_headfade()
 }
 
 void spiderbot_blowup()
-{
+{SELFPARAM();
        if(self.cnt > time)
        {
                if(random() < 0.1)
@@ -759,7 +759,7 @@ void spiderbot_blowup()
 }
 
 bool spiderbot_impulse(int _imp)
-{
+{SELFPARAM();
        switch(_imp)
        {
                case 1:
@@ -812,13 +812,13 @@ bool spiderbot_impulse(int _imp)
 }
 
 void spawnfunc_vehicle_spiderbot()
-{
+{SELFPARAM();
        if(!autocvar_g_vehicle_spiderbot) { remove(self); return; }
        if(!vehicle_initialize(VEH_SPIDERBOT, false)) { remove(self); return; }
 }
 
 float v_spiderbot(float req)
-{
+{SELFPARAM();
        switch(req)
        {
                case VR_IMPACT:
index 125e6f8e12f0cfa0d27ed2af62eabe33219ab890..ce89bde34e453d392be294d5cf7814db4e622cf4 100644 (file)
@@ -11,7 +11,7 @@
 
 // client movement
 void viewloc_PlayerPhysics()
-{
+{SELFPARAM();
        if(self.viewloc)
        {
                vector oldmovement = self.movement;
@@ -58,7 +58,7 @@ void viewloc_PlayerPhysics()
 #ifdef CSQC
 
 void viewloc_SetTags()
-{
+{SELFPARAM();
        if(self.viewloc && wasfreed(self.viewloc))
                self.viewloc = world;
 
index c101a8c8ab326f79fd8d0e72972d00d30b0fc2b5..fe8c20c7a240367ac85d9064b92b0ab0b380ab90 100644 (file)
@@ -129,7 +129,7 @@ vector Draw_ArcBeam_callback_last_bottom; // NOTE: in same coordinate system as
 void spawnfunc_weapon_arc(void) { weapon_defaultspawnfunc(WEP_ARC.m_id); }
 
 float W_Arc_Beam_Send(entity to, int sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_ARC_BEAM);
 
        // Truncate information when this beam is displayed to the owner client
@@ -213,7 +213,7 @@ void Arc_Player_SetHeat(entity player)
 }
 
 void W_Arc_Beam_Think(void)
-{
+{SELFPARAM();
        if(self != self.owner.arc_beam)
        {
                remove(self);
@@ -272,15 +272,14 @@ void W_Arc_Beam_Think(void)
                }
 
                if(self == self.owner.arc_beam) { self.owner.arc_beam = world; }
-               entity oldself = self;
-               self = self.owner;
+               setself(self.owner);
                if(!WEP_ACTION(WEP_ARC.m_id, WR_CHECKAMMO1) && !WEP_ACTION(WEP_ARC.m_id, WR_CHECKAMMO2))
                if(!(self.items & IT_UNLIMITED_WEAPON_AMMO))
                {
                        // note: this doesn't force the switch
                        W_SwitchToOtherWeapon(self);
                }
-               self = oldself;
+               setself(this);
                remove(self);
                return;
        }
@@ -576,7 +575,7 @@ void W_Arc_Beam_Think(void)
 }
 
 void W_Arc_Beam(float burst)
-{
+{SELFPARAM();
 
        // only play fire sound if 1 sec has passed since player let go the fire button
        if(time - self.beam_prev > 1)
@@ -593,14 +592,11 @@ void W_Arc_Beam(float burst)
        beam.beam_bursting = burst;
        Net_LinkEntity(beam, false, 0, W_Arc_Beam_Send);
 
-       entity oldself = self;
-       self = beam;
-       self.think();
-       self = oldself;
+       WITH(entity, self, beam, beam.think());
 }
 
 void Arc_Smoke()
-{
+{SELFPARAM();
        makevectors(self.v_angle);
        W_SetupShot_Range(self,true,0,"",0,0,0);
 
@@ -636,7 +632,7 @@ void Arc_Smoke()
 }
 
 bool W_Arc(int req)
-{
+{SELFPARAM();
        switch(req)
        {
                case WR_AIM:
@@ -870,7 +866,7 @@ void Reset_ArcBeam(void)
 }
 
 void Draw_ArcBeam(void)
-{
+{SELFPARAM();
        float dt = time - self.move_time;
        self.move_time = time;
        if(dt <= 0) { return; }
@@ -1163,13 +1159,13 @@ void Draw_ArcBeam(void)
 }
 
 void Remove_ArcBeam(void)
-{
+{SELFPARAM();
        remove(self.beam_muzzleentity);
        sound(self, CH_SHOTS_SINGLE, "misc/null.wav", VOL_BASE, ATTEN_NORM);
 }
 
 void Ent_ReadArcBeam(float isnew)
-{
+{SELFPARAM();
        int sf = ReadByte();
        entity flash;
 
@@ -1521,7 +1517,7 @@ void Ent_ReadArcBeam(float isnew)
 }
 
 bool W_Arc(int req)
-{
+{SELFPARAM();
        switch(req)
        {
                case WR_IMPACTEFFECT:
index 6234f4a3e1154b1233afa9ee52ad5fd1b0d7f06d..e3edb492eba64b9c5d0e5f057b7f96cccfd18824 100644 (file)
@@ -52,7 +52,7 @@ void spawnfunc_weapon_blaster(void) { weapon_defaultspawnfunc(WEP_BLASTER.m_id);
 void spawnfunc_weapon_laser(void) { spawnfunc_weapon_blaster(); }
 
 void W_Blaster_Touch(void)
-{
+{SELFPARAM();
        PROJECTILE_TOUCH;
 
        self.event_damage = func_null;
@@ -74,7 +74,7 @@ void W_Blaster_Touch(void)
 }
 
 void W_Blaster_Think(void)
-{
+{SELFPARAM();
        self.movetype = MOVETYPE_FLY;
        self.think = SUB_Remove;
        self.nextthink = time + self.blaster_lifetime;
@@ -92,7 +92,7 @@ void W_Blaster_Attack(
        float atk_spread,
        float atk_delay,
        float atk_lifetime)
-{
+{SELFPARAM();
        vector s_forward = v_forward * cos(atk_shotangle * DEG2RAD) + v_up * sin(atk_shotangle * DEG2RAD);
 
        W_SetupShot_Dir(self, s_forward, false, 3, W_Sound("lasergun_fire"), CH_WEAPON_B, atk_damage);
@@ -141,15 +141,11 @@ void W_Blaster_Attack(
 
        if(time >= missile.nextthink)
        {
-               entity oldself;
-               oldself = self;
-               self = missile;
-               self.think();
-               self = oldself;
+               WITH(entity, self, missile, missile.think());
        }
 }
 bool W_Blaster(int request)
-{
+{SELFPARAM();
        switch(request)
        {
                case WR_AIM:
@@ -268,7 +264,7 @@ bool W_Blaster(int request)
 #endif
 #ifdef CSQC
 bool W_Blaster(int request)
-{
+{SELFPARAM();
        switch(request)
        {
                case WR_IMPACTEFFECT:
index 08deaf78c4a81e5ade345c1e9fd8590e5fb194bf..ba63afbceaecb92bd3b4ac9733a43df3ec8a4ec8 100644 (file)
@@ -107,7 +107,7 @@ void W_Crylink_Dequeue(entity e)
 }
 
 void W_Crylink_Reset(void)
-{
+{SELFPARAM();
        W_Crylink_Dequeue(self);
        remove(self);
 }
@@ -224,7 +224,7 @@ vector W_Crylink_LinkJoin(entity e, float jspeed)
 }
 
 void W_Crylink_LinkJoinEffect_Think(void)
-{
+{SELFPARAM();
        // is there at least 2 projectiles very close?
        entity e, p;
        float n;
@@ -289,7 +289,7 @@ float W_Crylink_Touch_WouldHitFriendly(entity projectile, float rad)
 
 // NO bounce protection, as bounces are limited!
 void W_Crylink_Touch(void)
-{
+{SELFPARAM();
        float finalhit;
        float f;
        float isprimary = !(self.projectiledeathtype & HITTYPE_SECONDARY);
@@ -334,13 +334,13 @@ void W_Crylink_Touch(void)
 }
 
 void W_Crylink_Fadethink(void)
-{
+{SELFPARAM();
        W_Crylink_Dequeue(self);
        remove(self);
 }
 
 void W_Crylink_Attack(void)
-{
+{SELFPARAM();
        float counter, shots;
        entity proj, prevproj, firstproj;
        vector s;
@@ -449,7 +449,7 @@ void W_Crylink_Attack(void)
 }
 
 void W_Crylink_Attack2(void)
-{
+{SELFPARAM();
        float counter, shots;
        entity proj, prevproj, firstproj;
        vector s;
@@ -565,7 +565,7 @@ void W_Crylink_Attack2(void)
 }
 
 bool W_Crylink(int req)
-{
+{SELFPARAM();
        float ammo_amount;
        switch(req)
        {
@@ -691,7 +691,7 @@ bool W_Crylink(int req)
 #endif
 #ifdef CSQC
 bool W_Crylink(int req)
-{
+{SELFPARAM();
        switch(req)
        {
                case WR_IMPACTEFFECT:
index 9a235bf35d5206b4d5d8fe049aa355d85ad5a50c..bbce1a8ca4d4b3f6a361f4831253021e328ee8bb 100644 (file)
@@ -66,7 +66,7 @@ void spawnfunc_weapon_devastator(void) { weapon_defaultspawnfunc(WEP_DEVASTATOR.
 void spawnfunc_weapon_rocketlauncher(void) { spawnfunc_weapon_devastator(); }
 
 void W_Devastator_Unregister(void)
-{
+{SELFPARAM();
        if(self.realowner && self.realowner.lastrocket == self)
        {
                self.realowner.lastrocket = world;
@@ -75,7 +75,7 @@ void W_Devastator_Unregister(void)
 }
 
 void W_Devastator_Explode(void)
-{
+{SELFPARAM();
        W_Devastator_Unregister();
 
        if(other.takedamage == DAMAGE_AIM)
@@ -115,7 +115,7 @@ void W_Devastator_Explode(void)
 }
 
 void W_Devastator_DoRemoteExplode(void)
-{
+{SELFPARAM();
        W_Devastator_Unregister();
 
        self.event_damage = func_null;
@@ -194,7 +194,7 @@ void W_Devastator_DoRemoteExplode(void)
 }
 
 void W_Devastator_RemoteExplode(void)
-{
+{SELFPARAM();
        if(self.realowner.deadflag == DEAD_NO)
        if(self.realowner.lastrocket)
        {
@@ -242,7 +242,7 @@ vector W_Devastator_SteerTo(vector thisdir, vector goaldir, float maxturn_cos)
 //   normalize(0)
 
 void W_Devastator_Think(void)
-{
+{SELFPARAM();
        vector desireddir, olddir, newdir, desiredorigin, goal;
        float velspeed, f;
        self.nextthink = time;
@@ -309,7 +309,7 @@ void W_Devastator_Think(void)
 }
 
 void W_Devastator_Touch(void)
-{
+{SELFPARAM();
        if(WarpZone_Projectile_Touch())
        {
                if(wasfreed(self))
@@ -321,7 +321,7 @@ void W_Devastator_Touch(void)
 }
 
 void W_Devastator_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        if(self.health <= 0)
                return;
 
@@ -336,7 +336,7 @@ void W_Devastator_Damage(entity inflictor, entity attacker, float damage, int de
 }
 
 void W_Devastator_Attack(void)
-{
+{SELFPARAM();
        entity missile;
        entity flash;
 
@@ -393,7 +393,7 @@ void W_Devastator_Attack(void)
 }
 
 bool W_Devastator(int req)
-{
+{SELFPARAM();
        entity rock;
        float rockfound;
        float ammo_amount;
@@ -657,7 +657,7 @@ bool W_Devastator(int req)
 #endif
 #ifdef CSQC
 bool W_Devastator(int req)
-{
+{SELFPARAM();
        switch(req)
        {
                case WR_IMPACTEFFECT:
index 0f60fd29d3568b6b430ba864ed9c23882e60f9e1..b308d2e0fc6c87bb7e55a093eb418951d0348133 100644 (file)
@@ -117,7 +117,7 @@ void W_Electro_TriggerCombo(vector org, float rad, entity own)
 }
 
 void W_Electro_ExplodeCombo(void)
-{
+{SELFPARAM();
        W_Electro_TriggerCombo(self.origin, WEP_CVAR(electro, combo_comboradius), self.realowner);
 
        self.event_damage = func_null;
@@ -139,7 +139,7 @@ void W_Electro_ExplodeCombo(void)
 }
 
 void W_Electro_Explode(void)
-{
+{SELFPARAM();
        if(other.takedamage == DAMAGE_AIM)
                if(IS_PLAYER(other))
                        if(DIFF_TEAM(self.realowner, other))
@@ -192,7 +192,7 @@ void W_Electro_TouchExplode(void)
 }
 
 void W_Electro_Bolt_Think(void)
-{
+{SELFPARAM();
        if(time >= self.ltime)
        {
                self.use();
@@ -244,7 +244,7 @@ void W_Electro_Bolt_Think(void)
 }
 
 void W_Electro_Attack_Bolt(void)
-{
+{SELFPARAM();
        entity proj;
 
        W_DecreaseAmmo(WEP_CVAR_PRI(electro, ammo));
@@ -289,7 +289,7 @@ void W_Electro_Attack_Bolt(void)
 }
 
 void W_Electro_Orb_Touch(void)
-{
+{SELFPARAM();
        PROJECTILE_TOUCH;
        if(other.takedamage == DAMAGE_AIM)
                { if(WEP_CVAR_SEC(electro, touchexplode)) { W_Electro_Explode(); } }
@@ -302,7 +302,7 @@ void W_Electro_Orb_Touch(void)
 }
 
 void W_Electro_Orb_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        if(self.health <= 0)
                return;
 
@@ -344,7 +344,7 @@ void W_Electro_Orb_Damage(entity inflictor, entity attacker, float damage, int d
 }
 
 void W_Electro_Attack_Orb(void)
-{
+{SELFPARAM();
        W_DecreaseAmmo(WEP_CVAR_SEC(electro, ammo));
 
        W_SetupShot_ProjectileSize(
@@ -405,7 +405,7 @@ void W_Electro_Attack_Orb(void)
 }
 
 void W_Electro_CheckAttack(void)
-{
+{SELFPARAM();
        if(self.electro_count > 1)
        if(self.BUTTON_ATCK2)
        if(weapon_prepareattack(1, -1))
@@ -421,7 +421,7 @@ void W_Electro_CheckAttack(void)
 
 .float bot_secondary_electromooth;
 bool W_Electro(int req)
-{
+{SELFPARAM();
        float ammo_amount;
        switch(req)
        {
@@ -571,7 +571,7 @@ bool W_Electro(int req)
 #endif
 #ifdef CSQC
 bool W_Electro(int req)
-{
+{SELFPARAM();
        switch(req)
        {
                case WR_IMPACTEFFECT:
index 4f8f3787c3443335c0d91ca11aa72c5648d5b484..cb33a244c44b3d0f78234d7d973328928a169b20 100644 (file)
@@ -58,7 +58,7 @@ FIREBALL_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 void spawnfunc_weapon_fireball(void) { weapon_defaultspawnfunc(WEP_FIREBALL.m_id); }
 
 void W_Fireball_Explode(void)
-{
+{SELFPARAM();
        entity e;
        float dist;
        float points;
@@ -114,7 +114,7 @@ void W_Fireball_TouchExplode(void)
 }
 
 void W_Fireball_LaserPlay(float dt, float dist, float damage, float edgedamage, float burntime)
-{
+{SELFPARAM();
        entity e;
        float d;
        vector p;
@@ -148,7 +148,7 @@ void W_Fireball_LaserPlay(float dt, float dist, float damage, float edgedamage,
 }
 
 void W_Fireball_Think(void)
-{
+{SELFPARAM();
        if(time > self.pushltime)
        {
                self.cnt = 1;
@@ -163,7 +163,7 @@ void W_Fireball_Think(void)
 }
 
 void W_Fireball_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        if(self.health <= 0)
                return;
 
@@ -179,7 +179,7 @@ void W_Fireball_Damage(entity inflictor, entity attacker, float damage, int deat
 }
 
 void W_Fireball_Attack1(void)
-{
+{SELFPARAM();
        entity proj;
 
        W_SetupShot_ProjectileSize(self, '-16 -16 -16', '16 16 16', false, 2, W_Sound("fireball_fire2"), CH_WEAPON_A, WEP_CVAR_PRI(fireball, damage) + WEP_CVAR_PRI(fireball, bfgdamage));
@@ -218,7 +218,7 @@ void W_Fireball_Attack1(void)
 }
 
 void W_Fireball_AttackEffect(float i, vector f_diff)
-{
+{SELFPARAM();
        W_SetupShot_ProjectileSize(self, '-16 -16 -16', '16 16 16', false, 0, "", 0, 0);
        w_shotorg += f_diff.x * v_up + f_diff.y * v_right;
        Send_Effect(EFFECT_FIREBALL_PRE_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
@@ -249,14 +249,14 @@ void W_Fireball_Attack1_Frame1(void)
 }
 
 void W_Fireball_Attack1_Frame0(void)
-{
+{SELFPARAM();
        W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
        sound(self, CH_WEAPON_SINGLE, W_Sound("fireball_prefire2"), VOL_BASE, ATTEN_NORM);
        weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame1);
 }
 
 void W_Fireball_Firemine_Think(void)
-{
+{SELFPARAM();
        if(time > self.pushltime)
        {
                remove(self);
@@ -282,7 +282,7 @@ void W_Fireball_Firemine_Think(void)
 }
 
 void W_Fireball_Firemine_Touch(void)
-{
+{SELFPARAM();
        PROJECTILE_TOUCH;
        if(other.takedamage == DAMAGE_AIM)
        if(Fire_AddDamage(other, self.realowner, WEP_CVAR_SEC(fireball, damage), WEP_CVAR_SEC(fireball, damagetime), self.projectiledeathtype) >= 0)
@@ -294,7 +294,7 @@ void W_Fireball_Firemine_Touch(void)
 }
 
 void W_Fireball_Attack2(void)
-{
+{SELFPARAM();
        entity proj;
        vector f_diff;
        float c;
@@ -349,7 +349,7 @@ void W_Fireball_Attack2(void)
 }
 
 bool W_Fireball(int req)
-{
+{SELFPARAM();
        switch(req)
        {
                case WR_AIM:
@@ -449,7 +449,7 @@ bool W_Fireball(int req)
 #endif
 #ifdef CSQC
 bool W_Fireball(int req)
-{
+{SELFPARAM();
        switch(req)
        {
                case WR_IMPACTEFFECT:
index 4f1b9058474596b1f1fc148090ed02cfe5488166..cc01af7db194b9dd8b8e95241c58de2d7dfa097c 100644 (file)
@@ -61,7 +61,7 @@ void spawnfunc_weapon_hagar(void) { weapon_defaultspawnfunc(WEP_HAGAR.m_id); }
 // NO bounce protection, as bounces are limited!
 
 void W_Hagar_Explode(void)
-{
+{SELFPARAM();
        self.event_damage = func_null;
        RadiusDamage(self, self.realowner, WEP_CVAR_PRI(hagar, damage), WEP_CVAR_PRI(hagar, edgedamage), WEP_CVAR_PRI(hagar, radius), world, world, WEP_CVAR_PRI(hagar, force), self.projectiledeathtype, other);
 
@@ -69,7 +69,7 @@ void W_Hagar_Explode(void)
 }
 
 void W_Hagar_Explode2(void)
-{
+{SELFPARAM();
        self.event_damage = func_null;
        RadiusDamage(self, self.realowner, WEP_CVAR_SEC(hagar, damage), WEP_CVAR_SEC(hagar, edgedamage), WEP_CVAR_SEC(hagar, radius), world, world, WEP_CVAR_SEC(hagar, force), self.projectiledeathtype, other);
 
@@ -77,7 +77,7 @@ void W_Hagar_Explode2(void)
 }
 
 void W_Hagar_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        if(self.health <= 0)
                return;
 
@@ -101,13 +101,13 @@ void W_Hagar_Damage(entity inflictor, entity attacker, float damage, int deathty
 }
 
 void W_Hagar_Touch(void)
-{
+{SELFPARAM();
        PROJECTILE_TOUCH;
        self.use();
 }
 
 void W_Hagar_Touch2(void)
-{
+{SELFPARAM();
        PROJECTILE_TOUCH;
 
        if(self.cnt > 0 || other.takedamage == DAMAGE_AIM) {
@@ -122,7 +122,7 @@ void W_Hagar_Touch2(void)
 }
 
 void W_Hagar_Attack(void)
-{
+{SELFPARAM();
        entity missile;
 
        W_DecreaseAmmo(WEP_CVAR_PRI(hagar, ammo));
@@ -165,7 +165,7 @@ void W_Hagar_Attack(void)
 }
 
 void W_Hagar_Attack2(void)
-{
+{SELFPARAM();
        entity missile;
 
        W_DecreaseAmmo(WEP_CVAR_SEC(hagar, ammo));
@@ -210,7 +210,7 @@ void W_Hagar_Attack2(void)
 
 .float hagar_loadstep, hagar_loadblock, hagar_loadbeep, hagar_warning;
 void W_Hagar_Attack2_Load_Release(void)
-{
+{SELFPARAM();
        // time to release the rockets we've loaded
 
        entity missile;
@@ -290,7 +290,7 @@ void W_Hagar_Attack2_Load_Release(void)
 }
 
 void W_Hagar_Attack2_Load(void)
-{
+{SELFPARAM();
        // loadable hagar secondary attack, must always run each frame
 
        if(time < game_starttime)
@@ -398,7 +398,7 @@ void W_Hagar_Attack2_Load(void)
 }
 
 bool W_Hagar(int req)
-{
+{SELFPARAM();
        float ammo_amount;
        switch(req)
        {
@@ -526,7 +526,7 @@ bool W_Hagar(int req)
 #endif
 #ifdef CSQC
 bool W_Hagar(int req)
-{
+{SELFPARAM();
        switch(req)
        {
                case WR_IMPACTEFFECT:
index 49685296a86385f6ffad495fff76356406be238f..8e0ce6f11844f2faf1e7e0d78b6ece8172db7af9 100644 (file)
@@ -51,7 +51,7 @@ HLAC_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 void spawnfunc_weapon_hlac(void) { weapon_defaultspawnfunc(WEP_HLAC.m_id); }
 
 void W_HLAC_Touch(void)
-{
+{SELFPARAM();
        float isprimary;
 
        PROJECTILE_TOUCH;
@@ -66,7 +66,7 @@ void W_HLAC_Touch(void)
 }
 
 void W_HLAC_Attack(void)
-{
+{SELFPARAM();
        entity missile;
     float spread;
 
@@ -115,7 +115,7 @@ void W_HLAC_Attack(void)
 }
 
 void W_HLAC_Attack2(void)
-{
+{SELFPARAM();
        entity missile;
     float spread;
 
@@ -160,7 +160,7 @@ void W_HLAC_Attack2(void)
 
 // weapon frames
 void W_HLAC_Attack_Frame(void)
-{
+{SELFPARAM();
        if(self.weapon != self.switchweapon) // abort immediately if switching
        {
                w_ready();
@@ -189,7 +189,7 @@ void W_HLAC_Attack_Frame(void)
 }
 
 void W_HLAC_Attack2_Frame(void)
-{
+{SELFPARAM();
     float i;
 
        W_DecreaseAmmo(WEP_CVAR_SEC(hlac, ammo));
@@ -205,7 +205,7 @@ void W_HLAC_Attack2_Frame(void)
 }
 
 bool W_HLAC(int req)
-{
+{SELFPARAM();
        float ammo_amount;
        switch(req)
        {
@@ -284,7 +284,7 @@ bool W_HLAC(int req)
 #endif
 #ifdef CSQC
 bool W_HLAC(int req)
-{
+{SELFPARAM();
        switch(req)
        {
                case WR_IMPACTEFFECT:
index 52b60e83bbf2549b5771f482efe3d64baa25de9c..c9afd42ecd155ab75ddaf24e4f2f63af0ece841e 100644 (file)
@@ -44,7 +44,7 @@ HMG_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 void spawnfunc_weapon_hmg() { weapon_defaultspawnfunc(WEP_HMG.m_id); }
 
 void W_HeavyMachineGun_Attack_Auto()
-{
+{SELFPARAM();
        if (!self.BUTTON_ATCK)
        {
                w_ready();
@@ -87,7 +87,7 @@ void W_HeavyMachineGun_Attack_Auto()
 }
 
 bool W_HeavyMachineGun(int req)
-{
+{SELFPARAM();
        float ammo_amount;
        switch(req)
        {
@@ -171,7 +171,7 @@ bool W_HeavyMachineGun(int req)
 #endif
 #ifdef CSQC
 bool W_HeavyMachineGun(int req)
-{
+{SELFPARAM();
        switch(req)
        {
                case WR_IMPACTEFFECT:
index 6c5519e60b5c8e5eab3768ed900426440c5e5deb..c6b352212ee7a724edbfc3a93cbebfa5d18fd7fb 100644 (file)
@@ -60,7 +60,7 @@ HOOK_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 #ifdef SVQC
 
 void spawnfunc_weapon_hook(void)
-{
+{SELFPARAM();
        if(g_grappling_hook) // offhand hook
        {
                startitem_failed = true;
@@ -71,7 +71,7 @@ void spawnfunc_weapon_hook(void)
 }
 
 void W_Hook_ExplodeThink(void)
-{
+{SELFPARAM();
        float dt, dmg_remaining_next, f;
 
        dt = time - self.teleport_time;
@@ -91,7 +91,7 @@ void W_Hook_ExplodeThink(void)
 }
 
 void W_Hook_Explode2(void)
-{
+{SELFPARAM();
        self.event_damage = func_null;
        self.touch = func_null;
        self.effects |= EF_NODRAW;
@@ -110,7 +110,7 @@ void W_Hook_Explode2(void)
 }
 
 void W_Hook_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        if(self.health <= 0)
                return;
 
@@ -124,13 +124,13 @@ void W_Hook_Damage(entity inflictor, entity attacker, float damage, int deathtyp
 }
 
 void W_Hook_Touch2(void)
-{
+{SELFPARAM();
        PROJECTILE_TOUCH;
        self.use();
 }
 
 void W_Hook_Attack2(void)
-{
+{SELFPARAM();
        entity gren;
 
        //W_DecreaseAmmo(WEP_CVAR_SEC(hook, ammo)); // WEAPONTODO: Figure out how to handle ammo with hook secondary (gravitybomb)
@@ -175,7 +175,7 @@ void W_Hook_Attack2(void)
 }
 
 bool W_Hook(int req)
-{
+{SELFPARAM();
        float hooked_time_max, hooked_fuel;
 
        switch(req)
@@ -338,7 +338,7 @@ bool W_Hook(int req)
 #endif
 #ifdef CSQC
 bool W_Hook(int req)
-{
+{SELFPARAM();
        switch(req)
        {
                case WR_IMPACTEFFECT:
index da1eb33a6046cf30fdda57a2a1d7d1de698ba60a..a0bad57faa3abc7e5cf7a77a71b98be98c2f6ec3 100644 (file)
@@ -56,7 +56,7 @@ MACHINEGUN_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 #ifdef SVQC
 
 void spawnfunc_weapon_machinegun(void)
-{
+{SELFPARAM();
        if(autocvar_sv_q3acompat_machineshotgunswap)
        if(self.classname != "droppedweapon")
        {
@@ -68,7 +68,7 @@ void spawnfunc_weapon_machinegun(void)
 void spawnfunc_weapon_uzi(void) { spawnfunc_weapon_machinegun(); }
 
 void W_MachineGun_MuzzleFlash_Think(void)
-{
+{SELFPARAM();
        self.frame = self.frame + 2;
        self.scale = self.scale * 0.5;
        self.alpha = self.alpha - 0.25;
@@ -85,7 +85,7 @@ void W_MachineGun_MuzzleFlash_Think(void)
 }
 
 void W_MachineGun_MuzzleFlash(void)
-{
+{SELFPARAM();
        if(self.muzzle_flash == world)
                self.muzzle_flash = spawn();
 
@@ -103,7 +103,7 @@ void W_MachineGun_MuzzleFlash(void)
 }
 
 void W_MachineGun_Attack(int deathtype)
-{
+{SELFPARAM();
        W_SetupShot(self, true, 0, W_Sound("uzi_fire"), CH_WEAPON_A, ((self.misc_bulletcounter == 1) ? WEP_CVAR(machinegun, first_damage) : WEP_CVAR(machinegun, sustained_damage)));
        if(!autocvar_g_norecoil)
        {
@@ -136,7 +136,7 @@ void W_MachineGun_Attack(int deathtype)
 
 // weapon frames
 void W_MachineGun_Attack_Frame(void)
-{
+{SELFPARAM();
        if(self.weapon != self.switchweapon) // abort immediately if switching
        {
                w_ready();
@@ -161,7 +161,7 @@ void W_MachineGun_Attack_Frame(void)
 
 
 void W_MachineGun_Attack_Auto(void)
-{
+{SELFPARAM();
        float machinegun_spread;
 
        if(!self.BUTTON_ATCK)
@@ -205,7 +205,7 @@ void W_MachineGun_Attack_Auto(void)
 }
 
 void W_MachineGun_Attack_Burst(void)
-{
+{SELFPARAM();
        W_SetupShot(self, true, 0, W_Sound("uzi_fire"), CH_WEAPON_A, WEP_CVAR(machinegun, sustained_damage));
        if(!autocvar_g_norecoil)
        {
@@ -237,7 +237,7 @@ void W_MachineGun_Attack_Burst(void)
 }
 
 bool W_MachineGun(int req)
-{
+{SELFPARAM();
        float ammo_amount;
        switch(req)
        {
@@ -371,7 +371,7 @@ bool W_MachineGun(int req)
 #endif
 #ifdef CSQC
 bool W_MachineGun(int req)
-{
+{SELFPARAM();
        switch(req)
        {
                case WR_IMPACTEFFECT:
index 8048957bce8ab958dab25b557a0c55128b8daf86..7d655615c6da02afc1f8275299760d9bf3b29213 100644 (file)
@@ -60,7 +60,7 @@ void W_MineLayer_Think(void);
 void spawnfunc_weapon_minelayer(void) { weapon_defaultspawnfunc(WEP_MINE_LAYER.m_id); }
 
 void W_MineLayer_Stick(entity to)
-{
+{SELFPARAM();
        spamsound(self, CH_SHOTS, W_Sound("mine_stick"), VOL_BASE, ATTN_NORM);
 
        // in order for mines to face properly when sticking to the ground, they must be a server side entity rather than a csqc projectile
@@ -100,14 +100,14 @@ void W_MineLayer_Stick(entity to)
        newmine.flags = self.flags;
 
        remove(self);
-       self = newmine;
+       setself(newmine);
 
        if(to)
                SetMovetypeFollow(self, to);
 }
 
 void W_MineLayer_Explode(void)
-{
+{SELFPARAM();
        if(other.takedamage == DAMAGE_AIM)
                if(IS_PLAYER(other))
                        if(DIFF_TEAM(self.realowner, other))
@@ -122,23 +122,21 @@ void W_MineLayer_Explode(void)
 
        if(self.realowner.weapon == WEP_MINE_LAYER.m_id)
        {
-               entity oldself;
-               oldself = self;
-               self = self.realowner;
+               setself(self.realowner);
                if(!WEP_ACTION(WEP_MINE_LAYER.m_id, WR_CHECKAMMO1))
                {
                        self.cnt = WEP_MINE_LAYER.m_id;
                        ATTACK_FINISHED(self) = time;
                        self.switchweapon = w_getbestweapon(self);
                }
-               self = oldself;
+               setself(this);
        }
        self.realowner.minelayer_mines -= 1;
        remove(self);
 }
 
 void W_MineLayer_DoRemoteExplode(void)
-{
+{SELFPARAM();
        self.event_damage = func_null;
        self.takedamage = DAMAGE_NO;
 
@@ -149,23 +147,21 @@ void W_MineLayer_DoRemoteExplode(void)
 
        if(self.realowner.weapon == WEP_MINE_LAYER.m_id)
        {
-               entity oldself;
-               oldself = self;
-               self = self.realowner;
+               setself(self.realowner);
                if(!WEP_ACTION(WEP_MINE_LAYER.m_id, WR_CHECKAMMO1))
                {
                        self.cnt = WEP_MINE_LAYER.m_id;
                        ATTACK_FINISHED(self) = time;
                        self.switchweapon = w_getbestweapon(self);
                }
-               self = oldself;
+               setself(this);
        }
        self.realowner.minelayer_mines -= 1;
        remove(self);
 }
 
 void W_MineLayer_RemoteExplode(void)
-{
+{SELFPARAM();
        if(self.realowner.deadflag == DEAD_NO)
                if((self.spawnshieldtime >= 0)
                        ? (time >= self.spawnshieldtime) // timer
@@ -177,7 +173,7 @@ void W_MineLayer_RemoteExplode(void)
 }
 
 void W_MineLayer_ProximityExplode(void)
-{
+{SELFPARAM();
        // make sure no friend is in the mine's radius. If there is any, explosion is delayed until he's at a safe distance
        if(WEP_CVAR(minelayer, protection) && self.mine_explodeanyway == 0)
        {
@@ -206,7 +202,7 @@ int W_MineLayer_Count(entity e)
 }
 
 void W_MineLayer_Think(void)
-{
+{SELFPARAM();
        entity head;
 
        self.nextthink = time;
@@ -269,7 +265,7 @@ void W_MineLayer_Think(void)
 }
 
 void W_MineLayer_Touch(void)
-{
+{SELFPARAM();
        if(self.movetype == MOVETYPE_NONE || self.movetype == MOVETYPE_FOLLOW)
                return; // we're already a stuck mine, why do we get called? TODO does this even happen?
 
@@ -292,7 +288,7 @@ void W_MineLayer_Touch(void)
 }
 
 void W_MineLayer_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        if(self.health <= 0)
                return;
 
@@ -309,7 +305,7 @@ void W_MineLayer_Damage(entity inflictor, entity attacker, float damage, int dea
 }
 
 void W_MineLayer_Attack(void)
-{
+{SELFPARAM();
        entity mine;
        entity flash;
 
@@ -381,7 +377,7 @@ void W_MineLayer_Attack(void)
 }
 
 float W_MineLayer_PlacedMines(float detonate)
-{
+{SELFPARAM();
        entity mine;
        float minfound = 0;
 
@@ -402,7 +398,7 @@ float W_MineLayer_PlacedMines(float detonate)
 }
 
 bool W_MineLayer(int req)
-{
+{SELFPARAM();
        entity mine;
        float ammo_amount;
        switch(req)
@@ -593,7 +589,7 @@ bool W_MineLayer(int req)
 #endif
 #ifdef CSQC
 bool W_MineLayer(int req)
-{
+{SELFPARAM();
        switch(req)
        {
                case WR_IMPACTEFFECT:
index 850a6c342fb4e2a6d0a4d47d552ab611e473bc9b..1e8f4f91a1df4c470d1ee2a95cfbcb58a89c9653 100644 (file)
@@ -60,7 +60,7 @@ void spawnfunc_weapon_mortar(void) { weapon_defaultspawnfunc(WEP_MORTAR.m_id); }
 void spawnfunc_weapon_grenadelauncher(void) { spawnfunc_weapon_mortar(); }
 
 void W_Mortar_Grenade_Explode(void)
-{
+{SELFPARAM();
        if(other.takedamage == DAMAGE_AIM)
                if(IS_PLAYER(other))
                        if(DIFF_TEAM(self.realowner, other))
@@ -80,7 +80,7 @@ void W_Mortar_Grenade_Explode(void)
 }
 
 void W_Mortar_Grenade_Explode2(void)
-{
+{SELFPARAM();
        if(other.takedamage == DAMAGE_AIM)
                if(IS_PLAYER(other))
                        if(DIFF_TEAM(self.realowner, other))
@@ -101,7 +101,7 @@ void W_Mortar_Grenade_Explode2(void)
 
 
 void W_Mortar_Grenade_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        if(self.health <= 0)
                return;
 
@@ -115,7 +115,7 @@ void W_Mortar_Grenade_Damage(entity inflictor, entity attacker, float damage, in
 }
 
 void W_Mortar_Grenade_Think1(void)
-{
+{SELFPARAM();
        self.nextthink = time;
        if(time > self.cnt)
        {
@@ -129,7 +129,7 @@ void W_Mortar_Grenade_Think1(void)
 }
 
 void W_Mortar_Grenade_Touch1(void)
-{
+{SELFPARAM();
        PROJECTILE_TOUCH;
        if(other.takedamage == DAMAGE_AIM || WEP_CVAR_PRI(mortar, type) == 0) // always explode when hitting a player, or if normal mortar projectile
        {
@@ -174,7 +174,7 @@ void W_Mortar_Grenade_Touch1(void)
 }
 
 void W_Mortar_Grenade_Touch2(void)
-{
+{SELFPARAM();
        PROJECTILE_TOUCH;
        if(other.takedamage == DAMAGE_AIM || WEP_CVAR_SEC(mortar, type) == 0) // always explode when hitting a player, or if normal mortar projectile
        {
@@ -223,7 +223,7 @@ void W_Mortar_Grenade_Touch2(void)
 }
 
 void W_Mortar_Attack(void)
-{
+{SELFPARAM();
        entity gren;
 
        W_DecreaseAmmo(WEP_CVAR_PRI(mortar, ammo));
@@ -272,7 +272,7 @@ void W_Mortar_Attack(void)
 }
 
 void W_Mortar_Attack2(void)
-{
+{SELFPARAM();
        entity gren;
 
        W_DecreaseAmmo(WEP_CVAR_SEC(mortar, ammo));
@@ -321,7 +321,7 @@ void W_Mortar_Attack2(void)
 
 .float bot_secondary_grenademooth;
 bool W_Mortar(int req)
-{
+{SELFPARAM();
        entity nade;
        float nadefound;
        float ammo_amount;
@@ -461,7 +461,7 @@ bool W_Mortar(int req)
 #endif
 #ifdef CSQC
 bool W_Mortar(int req)
-{
+{SELFPARAM();
        switch(req)
        {
                case WR_IMPACTEFFECT:
index 2d08c0fcfd2e553de3db16996b6eb07feb353ded..03a77f0cb9c06302731352a9e4d0a3cc069297b0 100644 (file)
@@ -44,7 +44,7 @@ PORTO_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 void spawnfunc_weapon_porto(void) { weapon_defaultspawnfunc(WEP_PORTO.m_id); }
 
 void W_Porto_Success(void)
-{
+{SELFPARAM();
        if(self.realowner == world)
        {
                objerror("Cannot succeed successfully: no owner\n");
@@ -57,7 +57,7 @@ void W_Porto_Success(void)
 
 string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo);
 void W_Porto_Fail(float failhard)
-{
+{SELFPARAM();
        if(self.realowner == world)
        {
                objerror("Cannot fail successfully: no owner\n");
@@ -92,19 +92,15 @@ void W_Porto_Fail(float failhard)
 }
 
 void W_Porto_Remove(entity p)
-{
+{SELFPARAM();
        if(p.porto_current.realowner == p && p.porto_current.classname == "porto")
        {
-               entity oldself;
-               oldself = self;
-               self = p.porto_current;
-               W_Porto_Fail(1);
-               self = oldself;
+               WITH(entity, self, p.porto_current, W_Porto_Fail(1));
        }
 }
 
 void W_Porto_Think(void)
-{
+{SELFPARAM();
        trace_plane_normal = '0 0 0';
        if(self.realowner.playerid != self.playerid)
                remove(self);
@@ -113,7 +109,7 @@ void W_Porto_Think(void)
 }
 
 void W_Porto_Touch(void)
-{
+{SELFPARAM();
        vector norm;
 
        // do not use PROJECTILE_TOUCH here
@@ -235,7 +231,7 @@ void W_Porto_Touch(void)
 }
 
 void W_Porto_Attack(float type)
-{
+{SELFPARAM();
        entity gren;
 
        W_SetupShot(self, false, 4, "porto/fire.wav", CH_WEAPON_A, 0);
@@ -289,7 +285,7 @@ void W_Porto_Attack(float type)
 
 bool w_nexball_weapon(int req); // WEAPONTODO
 bool W_Porto(int req)
-{
+{SELFPARAM();
        //vector v_angle_save;
 
        if(g_nexball) { return w_nexball_weapon(req); }
@@ -406,7 +402,7 @@ bool W_Porto(int req)
 #endif
 #ifdef CSQC
 bool W_Porto(int req)
-{
+{SELFPARAM();
        switch(req)
        {
                case WR_IMPACTEFFECT:
index ef3babd8723c24128b30f9a6ff813fb676c0c1b9..37923e16c85ee249819ab451563da2205da27bb2 100644 (file)
@@ -52,7 +52,7 @@ void spawnfunc_weapon_campingrifle(void) { spawnfunc_weapon_rifle(); }
 void spawnfunc_weapon_sniperrifle(void) { spawnfunc_weapon_rifle(); }
 
 void W_Rifle_FireBullet(float pSpread, float pDamage, float pForce, float pSolidPenetration, float pAmmo, int deathtype, float pTracer, float pShots, string pSound)
-{
+{SELFPARAM();
        float i;
 
        W_DecreaseAmmo(pAmmo);
@@ -89,7 +89,7 @@ void W_Rifle_Attack2(void)
 .float rifle_bullethail_animtime;
 .float rifle_bullethail_refire;
 void W_Rifle_BulletHail_Continue(void)
-{
+{SELFPARAM();
        float r, sw, af;
 
        sw = self.switchweapon; // make it not detect weapon changes as reason to abort firing
@@ -114,7 +114,7 @@ void W_Rifle_BulletHail_Continue(void)
 }
 
 void W_Rifle_BulletHail(float mode, void(void) AttackFunc, float fr, float animtime, float refire)
-{
+{SELFPARAM();
        // if we get here, we have at least one bullet to fire
        AttackFunc();
        if(mode)
@@ -135,7 +135,7 @@ void W_Rifle_BulletHail(float mode, void(void) AttackFunc, float fr, float animt
 
 .float bot_secondary_riflemooth;
 bool W_Rifle(int req)
-{
+{SELFPARAM();
        float ammo_amount;
 
        switch(req)
@@ -266,7 +266,7 @@ bool W_Rifle(int req)
 #endif
 #ifdef CSQC
 bool W_Rifle(int req)
-{
+{SELFPARAM();
        switch(req)
        {
                case WR_IMPACTEFFECT:
index 8a34490e28c0760b91f07994c7dcde7907fb823a..1b336f4edfacb05546115c9385943d3373a504d5 100644 (file)
@@ -48,7 +48,7 @@ RPC_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 void spawnfunc_weapon_rpc() { weapon_defaultspawnfunc(WEP_RPC.m_id); }
 
 void W_RocketPropelledChainsaw_Explode()
-{
+{SELFPARAM();
        self.event_damage = func_null;
        self.takedamage = DAMAGE_NO;
 
@@ -58,7 +58,7 @@ void W_RocketPropelledChainsaw_Explode()
 }
 
 void W_RocketPropelledChainsaw_Touch (void)
-{
+{SELFPARAM();
        if(WarpZone_Projectile_Touch())
                if(wasfreed(self))
                        return;
@@ -67,7 +67,7 @@ void W_RocketPropelledChainsaw_Touch (void)
 }
 
 void W_RocketPropelledChainsaw_Damage (entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        if (self.health <= 0)
                return;
 
@@ -81,7 +81,7 @@ void W_RocketPropelledChainsaw_Damage (entity inflictor, entity attacker, float
 }
 
 void W_RocketPropelledChainsaw_Think()
-{
+{SELFPARAM();
        if(self.cnt <= time)
        {
                remove(self);
@@ -103,7 +103,7 @@ void W_RocketPropelledChainsaw_Think()
 }
 
 void W_RocketPropelledChainsaw_Attack (void)
-{
+{SELFPARAM();
        entity missile = spawn(); //WarpZone_RefSys_SpawnSameRefSys(self);
        entity flash = spawn ();
 
@@ -148,7 +148,7 @@ void W_RocketPropelledChainsaw_Attack (void)
 }
 
 bool W_RocketPropelledChainsaw(int req)
-{
+{SELFPARAM();
        float ammo_amount = false;
        switch(req)
        {
@@ -234,7 +234,7 @@ bool W_RocketPropelledChainsaw(int req)
 
 #ifdef CSQC
 bool W_RocketPropelledChainsaw(int req)
-{
+{SELFPARAM();
        switch(req)
        {
                case WR_IMPACTEFFECT:
index 69c4974de666df4ac72f24dd5a759c4be0457f5a..7350cb1bc0353a4f48aa11f43a97fdf15614a6ca 100644 (file)
@@ -90,7 +90,7 @@ void spawnfunc_weapon_seeker(void) { weapon_defaultspawnfunc(WEP_SEEKER.m_id); }
 // Begin: Missile functions, these are general functions to be manipulated by other code
 // ============================
 void W_Seeker_Missile_Explode(void)
-{
+{SELFPARAM();
        self.event_damage = func_null;
        RadiusDamage(self, self.realowner, WEP_CVAR(seeker, missile_damage), WEP_CVAR(seeker, missile_edgedamage), WEP_CVAR(seeker, missile_radius), world, world, WEP_CVAR(seeker, missile_force), self.projectiledeathtype, other);
 
@@ -105,7 +105,7 @@ void W_Seeker_Missile_Touch(void)
 }
 
 void W_Seeker_Missile_Think(void)
-{
+{SELFPARAM();
        entity e;
        vector desireddir, olddir, newdir, eorg;
        float turnrate;
@@ -202,7 +202,7 @@ void W_Seeker_Missile_Think(void)
 
 
 void W_Seeker_Missile_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        if(self.health <= 0)
                return;
 
@@ -244,7 +244,7 @@ void W_Seeker_Missile_Animate(void)
 */
 
 void W_Seeker_Fire_Missile(vector f_diff, entity m_target)
-{
+{SELFPARAM();
        entity missile;
 
        W_DecreaseAmmo(WEP_CVAR(seeker, missile_ammo));
@@ -301,7 +301,7 @@ void W_Seeker_Fire_Missile(vector f_diff, entity m_target)
 // Begin: FLAC, close range attack meant for defeating rockets which are coming at you.
 // ============================
 void W_Seeker_Flac_Explode(void)
-{
+{SELFPARAM();
        self.event_damage = func_null;
 
        RadiusDamage(self, self.realowner, WEP_CVAR(seeker, flac_damage), WEP_CVAR(seeker, flac_edgedamage), WEP_CVAR(seeker, flac_radius), world, world, WEP_CVAR(seeker, flac_force), self.projectiledeathtype, other);
@@ -317,7 +317,7 @@ void W_Seeker_Flac_Touch(void)
 }
 
 void W_Seeker_Fire_Flac(void)
-{
+{SELFPARAM();
        entity missile;
        vector f_diff;
        float c;
@@ -389,7 +389,7 @@ entity W_Seeker_Tagged_Info(entity isowner, entity istarget)
 }
 
 void W_Seeker_Attack(void)
-{
+{SELFPARAM();
        entity tracker, closest_target;
 
        closest_target = world;
@@ -412,9 +412,9 @@ void W_Seeker_Attack(void)
 }
 
 void W_Seeker_Vollycontroller_Think(void) // TODO: Merge this with W_Seeker_Attack
-{
+{SELFPARAM();
        float c;
-       entity oldself,oldenemy;
+       entity oldenemy;
        self.cnt = self.cnt - 1;
 
        if((!(self.realowner.items & IT_UNLIMITED_AMMO) && self.realowner.WEP_AMMO(SEEKER) < WEP_CVAR(seeker, missile_ammo)) || (self.cnt <= -1) || (self.realowner.deadflag != DEAD_NO) || (self.realowner.switchweapon != WEP_SEEKER.m_id))
@@ -425,11 +425,10 @@ void W_Seeker_Vollycontroller_Think(void) // TODO: Merge this with W_Seeker_Atta
 
        self.nextthink = time + WEP_CVAR(seeker, missile_delay) * W_WeaponRateFactor();
 
-       oldself = self;
-       self = self.realowner;
+       setself(self.realowner);
 
        oldenemy = self.enemy;
-       self.enemy = oldself.enemy;
+       self.enemy = this.enemy;
 
        c = self.cnt % 4;
        switch(c)
@@ -450,11 +449,11 @@ void W_Seeker_Vollycontroller_Think(void) // TODO: Merge this with W_Seeker_Atta
        }
 
        self.enemy = oldenemy;
-       self = oldself;
+       setself(this);
 }
 
 void W_Seeker_Tracker_Think(void)
-{
+{SELFPARAM();
        // commit suicide if: You die OR target dies OR you switch away from the seeker OR commit suicide if lifetime is up
        if((self.realowner.deadflag != DEAD_NO) || (self.tag_target.deadflag != DEAD_NO) || (self.realowner.switchweapon != WEP_SEEKER.m_id)
        || (time > self.tag_time + WEP_CVAR(seeker, tag_tracker_lifetime)))
@@ -475,7 +474,7 @@ void W_Seeker_Tracker_Think(void)
 // Begin: Tag projectile
 // ============================
 void W_Seeker_Tag_Explode(void)
-{
+{SELFPARAM();
        //if(other==self.realowner)
        //    return;
        Damage_DamageInfo(self.origin, 0, 0, 0, self.velocity, WEP_SEEKER.m_id | HITTYPE_BOUNCE, other.species, self);
@@ -484,7 +483,7 @@ void W_Seeker_Tag_Explode(void)
 }
 
 void W_Seeker_Tag_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        if(self.health <= 0)
                return;
        self.health = self.health - damage;
@@ -493,7 +492,7 @@ void W_Seeker_Tag_Damage(entity inflictor, entity attacker, float damage, int de
 }
 
 void W_Seeker_Tag_Touch(void)
-{
+{SELFPARAM();
        vector dir;
        vector org2;
        entity e;
@@ -556,7 +555,7 @@ void W_Seeker_Tag_Touch(void)
 }
 
 void W_Seeker_Fire_Tag(void)
-{
+{SELFPARAM();
        entity missile;
        W_DecreaseAmmo(WEP_CVAR(seeker, tag_ammo));
 
@@ -598,7 +597,7 @@ void W_Seeker_Fire_Tag(void)
 // ============================
 
 bool W_Seeker(int req)
-{
+{SELFPARAM();
        float ammo_amount;
 
        switch(req)
@@ -727,7 +726,7 @@ bool W_Seeker(int req)
 #endif
 #ifdef CSQC
 bool W_Seeker(int req)
-{
+{SELFPARAM();
        switch(req)
        {
                case WR_IMPACTEFFECT:
index 3287ea3cb366e88a61cf9cca8d1a96fc67b81971..41033708018216a1eea49b452bf6e0ddb7676cbe 100644 (file)
@@ -83,7 +83,7 @@ void Net_ReadShockwaveParticle(void);
 #ifdef IMPLEMENTATION
 #ifdef SVQC
 void spawnfunc_weapon_shockwave(void)
-{
+{SELFPARAM();
        //if(autocvar_sv_q3acompat_machineshockwaveswap) // WEAPONTODO
        if(autocvar_sv_q3acompat_machineshotgunswap)
        if(self.classname != "droppedweapon")
@@ -106,7 +106,7 @@ vector shockwave_hit_force[MAX_SHOCKWAVE_HITS];
 
 // MELEE ATTACK MODE
 void W_Shockwave_Melee_Think(void)
-{
+{SELFPARAM();
        // declarations
        float i, f, swing, swing_factor, swing_damage, meleetime, is_player;
        entity target_victim;
@@ -228,7 +228,7 @@ void W_Shockwave_Melee_Think(void)
 }
 
 void W_Shockwave_Melee(void)
-{
+{SELFPARAM();
        sound(self, CH_WEAPON_A, W_Sound("shotgun_melee"), VOL_BASE, ATTN_NORM);
        weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(shockwave, melee_animtime), w_ready);
 
@@ -274,7 +274,7 @@ float W_Shockwave_Attack_IsVisible(
        vector nearest_on_line,
        vector sw_shotorg,
        vector attack_endpos)
-{
+{SELFPARAM();
        vector nearest_to_attacker = head.WarpZone_findradius_nearest;
        vector center = (head.origin + (head.mins + head.maxs) * 0.5);
        vector corner;
@@ -334,7 +334,7 @@ float W_Shockwave_Attack_CheckHit(
 }
 
 void W_Shockwave_Send(void)
-{
+{SELFPARAM();
        WriteByte(MSG_BROADCAST, SVC_TEMPENTITY);
        WriteByte(MSG_BROADCAST, TE_CSQC_SHOCKWAVEPARTICLE);
        WriteCoord(MSG_BROADCAST, w_shotorg.x);
@@ -350,7 +350,7 @@ void W_Shockwave_Send(void)
 }
 
 void W_Shockwave_Attack(void)
-{
+{SELFPARAM();
        // declarations
        float multiplier, multiplier_from_accuracy, multiplier_from_distance;
        float final_damage;
@@ -667,7 +667,7 @@ void W_Shockwave_Attack(void)
 }
 
 bool W_Shockwave(int req)
-{
+{SELFPARAM();
        switch(req)
        {
                case WR_AIM:
@@ -750,7 +750,7 @@ const float SW_MAXALPHA = 0.5;
 const float SW_FADETIME = 0.4;
 const float SW_DISTTOMIN = 200;
 void Draw_Shockwave()
-{
+{SELFPARAM();
        // fading/removal control
        float a = bound(0, (SW_MAXALPHA - ((time - self.sw_time) / SW_FADETIME)), SW_MAXALPHA);
        if(a < ALPHA_MIN_VISIBLE) { remove(self); }
@@ -866,7 +866,7 @@ void Net_ReadShockwaveParticle(void)
 }
 
 bool W_Shockwave(int req)
-{
+{SELFPARAM();
        switch(req)
        {
                case WR_IMPACTEFFECT:
index 9024bbfa1f70e36b57db17674bf6498f7c5e6d0a..d61a2521dd2894f87e61c620e6d902cc650baa7b 100644 (file)
@@ -55,7 +55,7 @@ SHOTGUN_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 void spawnfunc_weapon_shotgun(void) { weapon_defaultspawnfunc(WEP_SHOTGUN.m_id); }
 
 void W_Shotgun_Attack(float isprimary)
-{
+{SELFPARAM();
        float   sc;
        entity flash;
 
@@ -84,7 +84,7 @@ void W_Shotgun_Attack(float isprimary)
 .float swing_prev;
 .entity swing_alreadyhit;
 void W_Shotgun_Melee_Think(void)
-{
+{SELFPARAM();
        // declarations
        float i, f, swing, swing_factor, swing_damage, meleetime, is_player;
        entity target_victim;
@@ -180,7 +180,7 @@ void W_Shotgun_Melee_Think(void)
 }
 
 void W_Shotgun_Attack2(void)
-{
+{SELFPARAM();
        sound(self, CH_WEAPON_A, W_Sound("shotgun_melee"), VOL_BASE, ATTEN_NORM);
        weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(shotgun, animtime), w_ready);
 
@@ -194,7 +194,7 @@ void W_Shotgun_Attack2(void)
 
 // alternate secondary weapon frames
 void W_Shotgun_Attack3_Frame2()
-{
+{SELFPARAM();
        if (!WEP_ACTION(self.weapon, WR_CHECKAMMO2))
        if (!(self.items & IT_UNLIMITED_WEAPON_AMMO))
        {
@@ -208,7 +208,7 @@ void W_Shotgun_Attack3_Frame2()
        weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), w_ready);
 }
 void W_Shotgun_Attack3_Frame1()
-{
+{SELFPARAM();
        if (!WEP_ACTION(self.weapon, WR_CHECKAMMO2))
        if (!(self.items & IT_UNLIMITED_WEAPON_AMMO))
        {
@@ -224,7 +224,7 @@ void W_Shotgun_Attack3_Frame1()
 .float shotgun_primarytime;
 
 float W_Shotgun(float req)
-{
+{SELFPARAM();
        float ammo_amount;
        switch(req)
        {
@@ -352,7 +352,7 @@ float W_Shotgun(float req)
 #ifdef CSQC
 .float prevric;
 float W_Shotgun(float req)
-{
+{SELFPARAM();
        switch(req)
        {
                case WR_IMPACTEFFECT:
index 686c89ec3a7f6f0dae6a0fe3ed8c0761735b6555..2987d0b81697c8496d064b9f77410559b7ec6def 100644 (file)
@@ -148,7 +148,7 @@ bool W_Tuba_HasPlayed(entity pl, string melody, int instrument, bool ignorepitch
 }
 
 void W_Tuba_NoteOff(void)
-{
+{SELFPARAM();
        // we have a note:
        //   on: self.spawnshieldtime
        //   off: time
@@ -252,7 +252,7 @@ int W_Tuba_GetNote(entity pl, int hittype)
 }
 
 bool W_Tuba_NoteSendEntity(entity to, int sf)
-{
+{SELFPARAM();
        int f;
 
        msg_entity = to;
@@ -280,7 +280,7 @@ bool W_Tuba_NoteSendEntity(entity to, int sf)
 }
 
 void W_Tuba_NoteThink(void)
-{
+{SELFPARAM();
        float dist_mult;
        float vol0, vol1;
        vector dir0, dir1;
@@ -318,7 +318,7 @@ void W_Tuba_NoteThink(void)
 }
 
 void W_Tuba_NoteOn(float hittype)
-{
+{SELFPARAM();
        vector o;
        float n;
 
@@ -336,10 +336,7 @@ void W_Tuba_NoteOn(float hittype)
        {
                if(self.tuba_note.cnt != n || self.tuba_note.tuba_instrument != self.tuba_instrument)
                {
-                       entity oldself = self;
-                       self = self.tuba_note;
-                       W_Tuba_NoteOff();
-                       self = oldself;
+                       WITH(entity, self, self.tuba_note, W_Tuba_NoteOff());
                }
        }
 
@@ -369,7 +366,7 @@ void W_Tuba_NoteOn(float hittype)
 }
 
 bool W_Tuba(int req)
-{
+{SELFPARAM();
        switch(req)
        {
                case WR_AIM:
@@ -406,10 +403,7 @@ bool W_Tuba(int req)
                        {
                                if(!self.BUTTON_ATCK && !self.BUTTON_ATCK2)
                                {
-                                       entity oldself = self;
-                                       self = self.tuba_note;
-                                       W_Tuba_NoteOff();
-                                       self = oldself;
+                                       WITH(entity, self, self.tuba_note, W_Tuba_NoteOff());
                                }
                        }
 
@@ -495,7 +489,7 @@ bool W_Tuba(int req)
 #endif
 #ifdef CSQC
 bool W_Tuba(int req)
-{
+{SELFPARAM();
        // nothing to do here; particles of tuba are handled differently
        // WEAPONTODO
 
index 256019d69de67b91a12084a981a4e96e9b5b8b8d..399ce4e584366b2dd0e54c1fa4f645eeafab0665 100644 (file)
@@ -59,7 +59,7 @@ void spawnfunc_weapon_vaporizer(void) { weapon_defaultspawnfunc(WEP_VAPORIZER.m_
 void spawnfunc_weapon_minstanex(void) { spawnfunc_weapon_vaporizer(); }
 
 void W_RocketMinsta_Explosion(vector loc)
-{
+{SELFPARAM();
        if(accuracy_canbegooddamage(self))
                accuracy_add(self, WEP_DEVASTATOR.m_id, autocvar_g_rm_damage, 0);
        entity dmgent = spawn();
@@ -70,7 +70,7 @@ void W_RocketMinsta_Explosion(vector loc)
 }
 
 void W_Vaporizer_Attack(void)
-{
+{SELFPARAM();
        bool flying = IsFlying(self); // do this BEFORE to make the trace values from FireRailgunBullet last
        float vaporizer_damage = ((WEP_CVAR_PRI(vaporizer, damage) > 0) ? WEP_CVAR_PRI(vaporizer, damage) : 10000);
 
@@ -140,7 +140,7 @@ void W_Vaporizer_Attack(void)
 }
 
 void W_RocketMinsta_Laser_Explode (void)
-{
+{SELFPARAM();
        if(other.takedamage == DAMAGE_AIM)
                if(IS_PLAYER(other))
                        if(DIFF_TEAM(self.realowner, other))
@@ -155,7 +155,7 @@ void W_RocketMinsta_Laser_Explode (void)
 }
 
 void W_RocketMinsta_Laser_Touch (void)
-{
+{SELFPARAM();
        PROJECTILE_TOUCH;
        //W_RocketMinsta_Laser_Explode ();
        RadiusDamage (self, self.realowner, self.rm_damage, self.rm_edmg, autocvar_g_rm_laser_radius, world, world, self.rm_force, self.projectiledeathtype, other);
@@ -163,7 +163,7 @@ void W_RocketMinsta_Laser_Touch (void)
 }
 
 void W_RocketMinsta_Attack2(void)
-{
+{SELFPARAM();
        makevectors(self.v_angle);
        
        entity proj;
@@ -218,7 +218,7 @@ void W_RocketMinsta_Attack2(void)
 }
 
 void W_RocketMinsta_Attack3 (void)
-{
+{SELFPARAM();
        makevectors(self.v_angle);
        
        entity proj;
@@ -269,7 +269,7 @@ void W_RocketMinsta_Attack3 (void)
 }
 
 float W_Vaporizer(float req)
-{
+{SELFPARAM();
        float ammo_amount;
        float vaporizer_ammo;
        float rapid = autocvar_g_rm_laser_rapid;
@@ -429,7 +429,7 @@ float W_Vaporizer(float req)
 #endif
 #ifdef CSQC
 float W_Vaporizer(float req)
-{
+{SELFPARAM();
        switch(req)
        {
                case WR_IMPACTEFFECT:
index 3aa17e526d566f02734a72dd2d9cb7cbb753a35a..03cd25066b3c96c0760dd2046b271f58c1c17d85 100644 (file)
@@ -77,7 +77,7 @@ void SendCSQCVortexBeamParticle(float charge) {
 }
 
 void W_Vortex_Attack(float issecondary)
-{
+{SELFPARAM();
        float mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, myammo, charge;
 
        mydmg = WEP_CVAR_BOTH(vortex, !issecondary, damage);
@@ -133,7 +133,7 @@ void spawnfunc_weapon_vortex(void); // defined in t_items.qc
 
 .float vortex_chargepool_pauseregen_finished;
 bool W_Vortex(int req)
-{
+{SELFPARAM();
        float dt;
        float ammo_amount;
        switch(req)
@@ -320,7 +320,7 @@ bool W_Vortex(int req)
 #ifdef CSQC
 float autocvar_g_balance_vortex_secondary = 0; // WEAPONTODO
 bool W_Vortex(int req)
-{
+{SELFPARAM();
        switch(req)
        {
                case WR_IMPACTEFFECT:
index 95489ad4326de10d9874c5fd29118e1cdd3ba8cc..ab93b0172370f1998d6fde329b8a5b65fad7ea43 100644 (file)
@@ -42,7 +42,7 @@ float autocvar_cl_nolerp = 0;
 .float csqcmodel_lerpfrac2time;
 
 void CSQCModel_InterpolateAnimation_2To4_PreNote(int sf)
-{
+{SELFPARAM();
        if(sf & CSQCMODEL_PROPERTY_FRAME)
        {
                self.frame3 = self.frame;
@@ -61,7 +61,7 @@ void CSQCModel_InterpolateAnimation_2To4_PreNote(int sf)
        }
 }
 void CSQCModel_InterpolateAnimation_1To2_PreNote(int sf)
-{
+{SELFPARAM();
        if(sf & CSQCMODEL_PROPERTY_FRAME)
        {
                self.frame2 = self.frame;
@@ -78,7 +78,7 @@ void CSQCModel_InterpolateAnimation_PreNote(int sf)
 }
 
 void CSQCModel_InterpolateAnimation_2To4_Note(int sf, float set_times)
-{
+{SELFPARAM();
        if(sf & CSQCMODEL_PROPERTY_FRAME)
        {
                if(set_times)
@@ -97,7 +97,7 @@ void CSQCModel_InterpolateAnimation_2To4_Note(int sf, float set_times)
        }
 }
 void CSQCModel_InterpolateAnimation_1To2_Note(int sf, float set_times)
-{
+{SELFPARAM();
        if(sf & CSQCMODEL_PROPERTY_FRAME)
        {
                if(set_times)
@@ -114,7 +114,7 @@ void CSQCModel_InterpolateAnimation_Note(int sf)
 }
 
 void CSQCModel_InterpolateAnimation_2To4_Do()
-{
+{SELFPARAM();
        if(autocvar_cl_nolerp || (autocvar_cl_lerpanim_maxdelta_framegroups == 0))
        {
                self.lerpfrac = self.csqcmodel_lerpfrac;
@@ -161,7 +161,7 @@ void CSQCModel_InterpolateAnimation_2To4_Do()
        }
 }
 void CSQCModel_InterpolateAnimation_1To2_Do()
-{
+{SELFPARAM();
        if(autocvar_cl_nolerp || (autocvar_cl_lerpanim_maxdelta_framegroups == 0))
        {
                self.lerpfrac = 0;
@@ -184,7 +184,7 @@ void CSQCModel_InterpolateAnimation_Do()
 }
 
 void CSQCModel_Draw()
-{
+{SELFPARAM();
        // some nice flags for CSQCMODEL_IF and the hooks
        bool isplayer = (self.entnum >= 1 && self.entnum <= maxclients);
        noref bool islocalplayer = (self.entnum == player_localnum + 1);
@@ -214,7 +214,7 @@ void CSQCModel_Draw()
 }
 
 void CSQCModel_Read(bool isnew)
-{
+{SELFPARAM();
        int sf = ReadInt24_t();
 
        // some nice flags for CSQCMODEL_IF and the hooks
index 3d5f9a00cbc0679eb0cdc0234a87a3c43189e6db..1a96e23dd6d6c0e1fbe77ff4744e541fa3b4ffbf 100644 (file)
@@ -100,7 +100,7 @@ void CSQCPlayer_SetPredictionError(vector o, vector v, float onground_diff)
 }
 
 void CSQCPlayer_Unpredict()
-{
+{SELFPARAM();
        if(csqcplayer_status == CSQCPLAYERSTATUS_UNPREDICTED)
                return;
        if(csqcplayer_status != CSQCPLAYERSTATUS_PREDICTED)
@@ -112,7 +112,7 @@ void CSQCPlayer_Unpredict()
 }
 
 void CSQCPlayer_SetMinsMaxs()
-{
+{SELFPARAM();
        if(self.flags & FL_DUCKED)
        {
                self.mins = PL_CROUCH_MIN;
@@ -128,7 +128,7 @@ void CSQCPlayer_SetMinsMaxs()
 }
 
 void CSQCPlayer_SavePrediction()
-{
+{SELFPARAM();
        player_pmflags = self.flags;
        csqcplayer_origin = self.origin;
        csqcplayer_velocity = self.velocity;
@@ -139,7 +139,7 @@ void CSQCPlayer_SavePrediction()
 void CSQC_ClientMovement_PlayerMove_Frame();
 
 void PM_Movement_Move()
-{
+{SELFPARAM();
        runstandardplayerphysics(self);
 #ifdef CSQC
        self.flags =
@@ -159,7 +159,7 @@ void CSQCPlayer_Physics(void)
 }
 
 void CSQCPlayer_PredictTo(float endframe, float apply_error)
-{
+{SELFPARAM();
        CSQCPlayer_Unpredict();
        if(apply_error)
        {
@@ -204,7 +204,7 @@ void CSQCPlayer_PredictTo(float endframe, float apply_error)
 }
 
 bool CSQCPlayer_IsLocalPlayer()
-{
+{SELFPARAM();
        return (self == csqcplayer);
 }
 
@@ -214,15 +214,13 @@ void CSQCPlayer_SetViewLocation()
 }
 
 void CSQCPlayer_SetCamera()
-{
+{SELFPARAM();
        vector v0;
        v0 = pmove_vel; // TRICK: pmove_vel is set by the engine when we get here. No need to network velocity
 
        if(csqcplayer)
        {
-               entity oldself;
-               oldself = self;
-               self = csqcplayer;
+               setself(csqcplayer);
 
                if(servercommandframe == 0 || clientcommandframe == 0)
                {
@@ -299,19 +297,15 @@ void CSQCPlayer_SetCamera()
                // relink
                setorigin(self, self.origin);
 
-               self = oldself;
+               setself(this);
        }
 
-       entity view;
-       view = CSQCModel_server2csqc(player_localentnum);
+       entity view = CSQCModel_server2csqc(player_localentnum);
 
        if(view && view != csqcplayer)
        {
-               entity oldself = self;
-               self = view;
-               InterpolateOrigin_Do();
-               self.view_ofs = '0 0 1' * getstati(STAT_VIEWHEIGHT);
-               self = oldself;
+               WITH(entity, self, view, InterpolateOrigin_Do());
+               view.view_ofs = '0 0 1' * getstati(STAT_VIEWHEIGHT);
        }
 
        if(view)
@@ -353,7 +347,7 @@ void CSQCPlayer_Remove()
 }
 
 float CSQCPlayer_PreUpdate()
-{
+{SELFPARAM();
        if(self != csqcplayer)
                return 0;
        if(csqcplayer_status != CSQCPLAYERSTATUS_FROMSERVER)
@@ -362,7 +356,7 @@ float CSQCPlayer_PreUpdate()
 }
 
 float CSQCPlayer_PostUpdate()
-{
+{SELFPARAM();
        if(self.entnum != player_localnum + 1)
                return 0;
        csqcplayer = self;
index 5c8e1e31e62ce7d3af314b5116ce4f02eea24cbf..78fb051f793765d0c9f5d884dead2ef9a5bb8bb1 100644 (file)
 .vector ivup1, ivup2;
 .float itime1, itime2;
 void InterpolateOrigin_Reset()
-{
+{SELFPARAM();
        self.iflags &= ~IFLAG_INTERNALMASK;
        self.itime1 = self.itime2 = 0;
 }
 void InterpolateOrigin_Note()
-{
+{SELFPARAM();
        float dt;
        int f0;
 
@@ -138,7 +138,7 @@ void InterpolateOrigin_Note()
        }
 }
 void InterpolateOrigin_Do()
-{
+{SELFPARAM();
        vector forward, up;
        if(self.itime1 && self.itime2 && self.itime1 != self.itime2)
        {
@@ -165,7 +165,7 @@ void InterpolateOrigin_Do()
        }
 }
 void InterpolateOrigin_Undo()
-{
+{SELFPARAM();
        if(self.iflags & IFLAG_ORIGIN)
                setorigin(self, self.iorigin2);
        if(self.iflags & IFLAG_ANGLES)
index 32c8b870755997168cc9c7a708bcf9ac15f75923..bbd9071f9a39e9e7f1b66f68e18e4747845159ca 100644 (file)
@@ -37,7 +37,7 @@
 // generic CSQC model code
 
 bool CSQCModel_Send(entity to, int sf)
-{
+{SELFPARAM();
        // some nice flags for CSQCMODEL_IF
        float isplayer = (IS_CLIENT(self));
        float islocalplayer = (self == to);
@@ -70,10 +70,10 @@ bool CSQCModel_Send(entity to, int sf)
 #ifdef CSQCPLAYER_FORCE_UPDATES
 .float csqcmodel_nextforcedupdate;
 #endif
-void CSQCModel_CheckUpdate()
+void CSQCModel_CheckUpdate(entity e)
 {
        // some nice flags for CSQCMODEL_IF
-       float isplayer = (IS_CLIENT(self));
+       float isplayer = (IS_CLIENT(e));
        float islocalplayer = isplayer; // we set BOTH to 1 here as we need the sendflags
        float isnolocalplayer = isplayer; // we set BOTH to 1 here as we need the sendflags
 
@@ -82,43 +82,43 @@ void CSQCModel_CheckUpdate()
        unused_float = isnolocalplayer;
 
 #ifdef CSQCPLAYER_FORCE_UPDATES
-       if(isplayer && time > self.csqcmodel_nextforcedupdate)
+       if(isplayer && time > e.csqcmodel_nextforcedupdate)
        {
-               self.SendFlags |= CSQCMODEL_PROPERTY_ORIGIN;
-               self.csqcmodel_nextforcedupdate = time + CSQCPLAYER_FORCE_UPDATES * (0.5 + random()); // ensure about 4 origin sends per sec
+               e.SendFlags |= CSQCMODEL_PROPERTY_ORIGIN;
+               e.csqcmodel_nextforcedupdate = time + CSQCPLAYER_FORCE_UPDATES * (0.5 + random()); // ensure about 4 origin sends per sec
        }
 #endif
 
-       if(self.effects & EF_RESTARTANIM_BIT)
+       if(e.effects & EF_RESTARTANIM_BIT)
        {
-               self.SendFlags |= CSQCMODEL_PROPERTY_FRAME | CSQCMODEL_PROPERTY_FRAME2; // full anim resend please
-               self.effects &= ~EF_RESTARTANIM_BIT;
+               e.SendFlags |= CSQCMODEL_PROPERTY_FRAME | CSQCMODEL_PROPERTY_FRAME2; // full anim resend please
+               e.effects &= ~EF_RESTARTANIM_BIT;
        }
 
-       if(self.effects & EF_TELEPORT_BIT)
+       if(e.effects & EF_TELEPORT_BIT)
        {
-               self.SendFlags |= CSQCMODEL_PROPERTY_TELEPORTED; // no interpolation please
-               self.effects &= ~EF_TELEPORT_BIT;
+               e.SendFlags |= CSQCMODEL_PROPERTY_TELEPORTED; // no interpolation please
+               e.effects &= ~EF_TELEPORT_BIT;
        }
 
 #define CSQCMODEL_IF(cond) if(cond) {
 #define CSQCMODEL_ENDIF }
 #define CSQCMODEL_PROPERTY(flag,t,r,w,f) \
        { \
-               t tmp = self.f; \
-               if(tmp != self.csqcmodel_##f) \
+               t tmp = e.f; \
+               if(tmp != e.csqcmodel_##f) \
                { \
-                       self.csqcmodel_##f = tmp; \
-                       self.SendFlags |= flag; \
+                       e.csqcmodel_##f = tmp; \
+                       e.SendFlags |= flag; \
                } \
        }
 #define CSQCMODEL_PROPERTY_SCALED(flag,t,r,w,f,s,mi,ma) \
        { \
-               t tmp = rint(bound(mi, s * self.f, ma) - mi); \
-               if(tmp != self.csqcmodel_##f) \
+               t tmp = rint(bound(mi, s * e.f, ma) - mi); \
+               if(tmp != e.csqcmodel_##f) \
                { \
-                       self.csqcmodel_##f = tmp; \
-                       self.SendFlags |= flag; \
+                       e.csqcmodel_##f = tmp; \
+                       e.SendFlags |= flag; \
                } \
        }
        ALLPROPERTIES
@@ -128,14 +128,14 @@ void CSQCModel_CheckUpdate()
 #undef CSQCMODEL_IF
 }
 
-void CSQCModel_LinkEntity()
+void CSQCModel_LinkEntity(entity e)
 {
-       self.SendEntity = CSQCModel_Send;
-       self.SendFlags = 0xFFFFFF;
-       CSQCModel_CheckUpdate();
+       e.SendEntity = CSQCModel_Send;
+       e.SendFlags = 0xFFFFFF;
+       CSQCModel_CheckUpdate(e);
 }
 
 void CSQCModel_UnlinkEntity()
-{
+{SELFPARAM();
        self.SendEntity = func_null;
 }
index 73e03e86207e4bdeaf2321a6ef1d31273b64170a..6694ded1a633a8dcfa10fc2fdd4e543f5be3d515 100644 (file)
@@ -26,8 +26,8 @@
 
 // generic CSQC model code
 
-void CSQCModel_CheckUpdate();
-void CSQCModel_LinkEntity();
+void CSQCModel_CheckUpdate(entity e);
+void CSQCModel_LinkEntity(entity e);
 void CSQCModel_UnlinkEntity();
 
 #define CSQCMODEL_IF(cond)
index fd2619d6fb0be4b93ac667d490551bd483297fd2..ca626dd7bd0654c738551b197657223b5493cf91 100644 (file)
@@ -16,20 +16,15 @@ Remove self
 ==================
 */
 void SUB_Remove()
-{
+{SELFPARAM();
        remove (self);
 }
 
 void defer_think()
-{
-    entity oself;
-
-    oself           = self;
-    self            = self.owner;
-    oself.think     = SUB_Remove;
-    oself.nextthink = time;
-
-    oself.use();
+{SELFPARAM();
+    self.think     = SUB_Remove;
+    self.nextthink = time;
+    WITH(entity, self, self.owner, self.use());
 }
 
 /*
@@ -37,7 +32,7 @@ void defer_think()
     self when func is executed = self when defer is called
 */
 void defer(float fdelay, void() func)
-{
+{SELFPARAM();
     entity e;
 
     e           = spawn();
index cd99ebf973e4b31684313f49f80853fe7a9e2bb9..f74dd4aa2ed49a252583d4a9a4fc42c5471819ac 100644 (file)
@@ -7,6 +7,8 @@
 #define dprintf(...)        dprint(sprintf(__VA_ARGS__))
 #define _dprintf2(...)      do { if (autocvar_developer > 1) dprintf(__VA_ARGS__); } while (0)
 
+#define assert(expr, ...)   do { if (!(expr)) LOG_WARNINGF(__VA_ARGS__); } while (0)
+
 #define _LOG(f, level, s)   f("[::"level"] ["__FILE__":%s:%.0f] %s", __FUNC__, __LINE__, s)
 
 #define  LOG_FATAL(...)     _LOG_FATAL(strcat("", __VA_ARGS__))
index 6647633ff9c9eec920d6f24d8ea73e9f55ca2e80..32742d82d9555e41330fa559acbee64314a1b7f3 100644 (file)
@@ -63,7 +63,7 @@ float movement_oddity(vector m0, vector m1)
 }
 
 void anticheat_physics()
-{
+{SELFPARAM();
        float f;
 
        // div0_evade -> SPECTATORS
@@ -150,13 +150,13 @@ void anticheat_physics()
 }
 
 void anticheat_spectatecopy(entity spectatee)
-{
+{SELFPARAM();
        // div0_evade -> SPECTATORS
        self.angles = spectatee.anticheat_div0_evade_v_angle;
 }
 
 void anticheat_prethink()
-{
+{SELFPARAM();
        // div0_evade -> SPECTATORS
        self.anticheat_div0_evade_offset = 0;
 }
@@ -173,7 +173,7 @@ string anticheat_display(float f, float tmin, float mi, float ma)
 }
 
 void anticheat_report()
-{
+{SELFPARAM();
        if(!autocvar_sv_eventlog)
                return;
        // TODO(divVerent): Use xonstat to acquire good thresholds.
@@ -198,7 +198,7 @@ void anticheat_report()
 }
 
 float anticheat_getvalue(string id)
-{
+{SELFPARAM();
        switch(id) {
                case "_time": return servertime - self.anticheat_jointime;
                case "speedhack": return MEAN_EVALUATE(anticheat_speedhack);
@@ -228,22 +228,22 @@ void anticheat_startframe()
 }
 
 void anticheat_fixangle()
-{
+{SELFPARAM();
        self.anticheat_fixangle_endtime = servertime + ANTILAG_LATENCY(self) + 0.2;
 }
 
 void anticheat_endframe()
-{
-       entity oldself = self;
-       FOR_EACH_CLIENT(self)
-               if (self.fixangle)
-                       anticheat_fixangle();
-       self = oldself;
+{SELFPARAM();
+       entity e;
+       FOR_EACH_CLIENT(e)
+               if (e.fixangle) {
+                       WITH(entity, self, e, anticheat_fixangle());
+               }
        anticheat_div0_evade_evasion_delta += frametime * (0.5 + random());
 }
 
 void anticheat_init()
-{
+{SELFPARAM();
        self.anticheat_speedhack_offset = 0;
        self.anticheat_jointime = servertime;
 }
index 58ddfc0364f784e7ef60dd76055dd286ed9c6d15..a30f3993832877cbc5410248a6b9b3ac14bc1149 100644 (file)
@@ -86,7 +86,7 @@ float findtrajectorywithleading(vector org, vector m1, vector m2, entity targ, f
 }
 
 void lag_update()
-{
+{SELFPARAM();
        if (self.lag1_time) if (time > self.lag1_time) {self.lag_func(self.lag1_time, self.lag1_float1, self.lag1_float2, self.lag1_entity1, self.lag1_vec1, self.lag1_vec2, self.lag1_vec3, self.lag1_vec4);self.lag1_time = 0;}
        if (self.lag2_time) if (time > self.lag2_time) {self.lag_func(self.lag2_time, self.lag2_float1, self.lag2_float2, self.lag2_entity1, self.lag2_vec1, self.lag2_vec2, self.lag2_vec3, self.lag2_vec4);self.lag2_time = 0;}
        if (self.lag3_time) if (time > self.lag3_time) {self.lag_func(self.lag3_time, self.lag3_float1, self.lag3_float2, self.lag3_entity1, self.lag3_vec1, self.lag3_vec2, self.lag3_vec3, self.lag3_vec4);self.lag3_time = 0;}
@@ -95,7 +95,7 @@ void lag_update()
 }
 
 float lag_additem(float t, float f1, float f2, entity e1, vector v1, vector v2, vector v3, vector v4)
-{
+{SELFPARAM();
        if (self.lag1_time == 0) {self.lag1_time = t;self.lag1_float1 = f1;self.lag1_float2 = f2;self.lag1_entity1 = e1;self.lag1_vec1 = v1;self.lag1_vec2 = v2;self.lag1_vec3 = v3;self.lag1_vec4 = v4;return true;}
        if (self.lag2_time == 0) {self.lag2_time = t;self.lag2_float1 = f1;self.lag2_float2 = f2;self.lag2_entity1 = e1;self.lag2_vec1 = v1;self.lag2_vec2 = v2;self.lag2_vec3 = v3;self.lag2_vec4 = v4;return true;}
        if (self.lag3_time == 0) {self.lag3_time = t;self.lag3_float1 = f1;self.lag3_float2 = f2;self.lag3_entity1 = e1;self.lag3_vec1 = v1;self.lag3_vec2 = v2;self.lag3_vec3 = v3;self.lag3_vec4 = v4;return true;}
@@ -106,7 +106,7 @@ float lag_additem(float t, float f1, float f2, entity e1, vector v1, vector v2,
 }
 
 float bot_shouldattack(entity e)
-{
+{SELFPARAM();
        if (e.team == self.team)
        {
                if (e == self)
@@ -144,7 +144,7 @@ float bot_shouldattack(entity e)
 }
 
 void bot_lagfunc(float t, float f1, float f2, entity e1, vector v1, vector v2, vector v3, vector v4)
-{
+{SELFPARAM();
        if(self.flags & FL_INWATER)
        {
                self.bot_aimtarg = world;
@@ -167,7 +167,7 @@ void bot_lagfunc(float t, float f1, float f2, entity e1, vector v1, vector v2, v
 }
 
 float bot_aimdir(vector v, float maxfiredeviation)
-{
+{SELFPARAM();
        float dist, delta_t, blend;
        vector desiredang, diffang;
 
@@ -318,7 +318,7 @@ vector bot_shotlead(vector targorigin, vector targvelocity, float shotspeed, flo
 }
 
 float bot_aim(float shotspeed, float shotspeedupward, float maxshottime, float applygravity)
-{
+{SELFPARAM();
        float f, r, hf, distanceratio;
        vector v;
        /*
index 64f5eb7d4ce3a026c7175631066dac3ae202419b..a6762c76d0996c7e5db33ec098dcc77eada42e19 100644 (file)
 #include "../../warpzonelib/util_server.qh"
 
 entity bot_spawn()
-{
-       entity oldself, bot;
-       bot = spawnclient();
+{SELFPARAM();
+       entity bot = spawnclient();
        if (bot)
        {
                currentbots = currentbots + 1;
-               oldself = self;
-               self = bot;
+               setself(bot);
                bot_setnameandstuff();
                ClientConnect();
                PutClientInServer();
-               self = oldself;
+               setself(this);
        }
        return bot;
 }
 
 void bot_think()
-{
+{SELFPARAM();
        if (self.bot_nextthink > time)
                return;
 
@@ -133,7 +131,7 @@ void bot_think()
 }
 
 void bot_setnameandstuff()
-{
+{SELFPARAM();
        string readfile, s;
        float file, tokens, prio;
        entity p;
@@ -389,7 +387,7 @@ void bot_relinkplayerlist()
 }
 
 void bot_clientdisconnect()
-{
+{SELFPARAM();
        if (!IS_BOT_CLIENT(self))
                return;
        bot_clearqueue(self);
@@ -412,7 +410,7 @@ void bot_clientdisconnect()
 }
 
 void bot_clientconnect()
-{
+{SELFPARAM();
        if (!IS_BOT_CLIENT(self))
                return;
        self.bot_preferredcolors = self.clientcolors;
index 5796fe60163346a5023ede6a39b4b560dc6bfa88..7a3ac0561af3c6ec66917479cad1b6a2ab1756de 100644 (file)
@@ -14,7 +14,7 @@
 #include "../../../warpzonelib/common.qh"
 
 void havocbot_ai()
-{
+{SELFPARAM();
        if(self.draggedby)
                return;
 
@@ -179,7 +179,7 @@ void havocbot_ai()
 }
 
 void havocbot_keyboard_movement(vector destorg)
-{
+{SELFPARAM();
        vector keyboard;
        float blend, maxspeed;
        float sk;
@@ -254,7 +254,7 @@ void havocbot_keyboard_movement(vector destorg)
 }
 
 void havocbot_bunnyhop(vector dir)
-{
+{SELFPARAM();
        float bunnyhopdistance;
        vector deviation;
        float maxspeed;
@@ -397,7 +397,7 @@ void havocbot_bunnyhop(vector dir)
 }
 
 void havocbot_movetogoal()
-{
+{SELFPARAM();
        vector destorg;
        vector diff;
        vector dir;
@@ -854,7 +854,7 @@ void havocbot_movetogoal()
 }
 
 void havocbot_chooseenemy()
-{
+{SELFPARAM();
        entity head, best, head2;
        float rating, bestrating, i, hf;
        vector eye, v;
@@ -949,7 +949,7 @@ void havocbot_chooseenemy()
 }
 
 float havocbot_chooseweapon_checkreload(int new_weapon)
-{
+{SELFPARAM();
        // bots under this skill cannot find unloaded weapons to reload idly when not in combat,
        // so skip this for them, or they'll never get to reload their weapons at all.
        // this also allows bots under this skill to be more stupid, and reload more often during combat :)
@@ -974,7 +974,7 @@ float havocbot_chooseweapon_checkreload(int new_weapon)
 }
 
 void havocbot_chooseweapon()
-{
+{SELFPARAM();
        int i;
 
        // ;)
@@ -1076,7 +1076,7 @@ void havocbot_chooseweapon()
 }
 
 void havocbot_aim()
-{
+{SELFPARAM();
        vector selfvel, enemyvel;
 //     if(self.flags & FL_INWATER)
 //             return;
@@ -1098,7 +1098,7 @@ void havocbot_aim()
 }
 
 float havocbot_moveto_refresh_route()
-{
+{SELFPARAM();
        // Refresh path to goal if necessary
        entity wp;
        wp = self.havocbot_personal_waypoint;
@@ -1109,7 +1109,7 @@ float havocbot_moveto_refresh_route()
 }
 
 float havocbot_moveto(vector pos)
-{
+{SELFPARAM();
        entity wp;
 
        if(self.aistatus & AI_STATUS_WAYPOINT_PERSONAL_GOING)
@@ -1231,7 +1231,7 @@ float havocbot_resetgoal()
 }
 
 void havocbot_setupbot()
-{
+{SELFPARAM();
        self.bot_ai = havocbot_ai;
        self.cmd_moveto = havocbot_moveto;
        self.cmd_resetgoal = havocbot_resetgoal;
@@ -1240,7 +1240,7 @@ void havocbot_setupbot()
 }
 
 vector havocbot_dodge()
-{
+{SELFPARAM();
        // LordHavoc: disabled because this is too expensive
        return '0 0 0';
 #if 0
index 63888e45fc5f8d81af0ccf7734f91f02ce620b04..b1603c792ac033806577bcd189016cac89040674 100644 (file)
@@ -15,7 +15,7 @@ void() havocbot_role_kh_freelancer;
 
 
 void havocbot_goalrating_kh(float ratingscale_team, float ratingscale_dropped, float ratingscale_enemy)
-{
+{SELFPARAM();
        entity head;
        for (head = kh_worldkeylist; head; head = head.kh_worldkeynext)
        {
@@ -44,7 +44,7 @@ void havocbot_goalrating_kh(float ratingscale_team, float ratingscale_dropped, f
 }
 
 void havocbot_role_kh_carrier()
-{
+{SELFPARAM();
        if(self.deadflag != DEAD_NO)
                return;
 
@@ -71,7 +71,7 @@ void havocbot_role_kh_carrier()
 }
 
 void havocbot_role_kh_defense()
-{
+{SELFPARAM();
        if(self.deadflag != DEAD_NO)
                return;
 
@@ -112,7 +112,7 @@ void havocbot_role_kh_defense()
 }
 
 void havocbot_role_kh_offense()
-{
+{SELFPARAM();
        if(self.deadflag != DEAD_NO)
                return;
 
@@ -154,7 +154,7 @@ void havocbot_role_kh_offense()
 }
 
 void havocbot_role_kh_freelancer()
-{
+{SELFPARAM();
        if(self.deadflag != DEAD_NO)
                return;
 
@@ -204,7 +204,7 @@ void havocbot_role_kh_freelancer()
 }
 
 void havocbot_chooserole_kh()
-{
+{SELFPARAM();
        float r;
 
        if(self.deadflag != DEAD_NO)
index c56f70598e60b696e4f18c7a70d6f20cce995633..037968f1367b30205fbeccad9ce569e401dcbb7d 100644 (file)
@@ -13,7 +13,7 @@
 .void() havocbot_role;
 
 void havocbot_goalrating_items(float ratingscale, vector org, float sradius)
-{
+{SELFPARAM();
        entity head;
        entity player;
        float rating, d, discard, distance, friend_distance, enemy_distance;
@@ -138,7 +138,7 @@ void havocbot_goalrating_items(float ratingscale, vector org, float sradius)
 }
 
 void havocbot_goalrating_controlpoints(float ratingscale, vector org, float sradius)
-{
+{SELFPARAM();
        entity head;
        head = findchain(classname, "dom_controlpoint");
        while (head)
@@ -157,7 +157,7 @@ void havocbot_goalrating_controlpoints(float ratingscale, vector org, float srad
 }
 
 void havocbot_goalrating_enemyplayers(float ratingscale, vector org, float sradius)
-{
+{SELFPARAM();
        entity head;
        int t;
        float distance;
@@ -214,7 +214,7 @@ void havocbot_goalrating_enemyplayers(float ratingscale, vector org, float sradi
 // legacy bot role for standard gamemodes
 // go to best items
 void havocbot_role_generic()
-{
+{SELFPARAM();
        if(self.deadflag != DEAD_NO)
                return;
 
@@ -230,12 +230,12 @@ void havocbot_role_generic()
 }
 
 void havocbot_chooserole_generic()
-{
+{SELFPARAM();
        self.havocbot_role = havocbot_role_generic;
 }
 
 void havocbot_chooserole()
-{
+{SELFPARAM();
        LOG_TRACE("choosing a role...\n");
        self.bot_strategytime = 0;
        if (MUTATOR_CALLHOOK(HavocBot_ChooseRole, self))
index 72729ec8671bdbcf8a264295188ba89531f00b7d..99e3901b2b3cb095b771a89286c9b5ac1bcae721 100644 (file)
@@ -22,7 +22,7 @@ void bot_debug(string input)
 // can be traveled, used for waypoint linking and havocbot
 
 float tracewalk(entity e, vector start, vector m1, vector m2, vector end, float movemode)
-{
+{SELFPARAM();
        vector org;
        vector move;
        vector dir;
@@ -232,7 +232,7 @@ float tracewalk(entity e, vector start, vector m1, vector m2, vector end, float
 
 // completely empty the goal stack, used when deciding where to go
 void navigation_clearroute()
-{
+{SELFPARAM();
        //print("bot ", etos(self), " clear\n");
        self.navigation_hasgoals = false;
        self.goalcurrent = world;
@@ -276,7 +276,7 @@ void navigation_clearroute()
 // That means, if the stack overflows, the bot will know how to do the FIRST 32
 // steps to the goal, and then recalculate the path.
 void navigation_pushroute(entity e)
-{
+{SELFPARAM();
        //print("bot ", etos(self), " push ", etos(e), "\n");
        self.goalstack31 = self.goalstack30;
        self.goalstack30 = self.goalstack29;
@@ -316,7 +316,7 @@ void navigation_pushroute(entity e)
 // (in other words: remove a prerequisite for reaching the later goals)
 // (used when a spawnfunc_waypoint is reached)
 void navigation_poproute()
-{
+{SELFPARAM();
        //print("bot ", etos(self), " pop\n");
        self.goalcurrent = self.goalstack01;
        self.goalstack01 = self.goalstack02;
@@ -449,7 +449,7 @@ entity navigation_findnearestwaypoint(entity ent, float walkfromwp)
 
 // finds the waypoints near the bot initiating a navigation query
 float navigation_markroutes_nearestwaypoints(entity waylist, float maxdist)
-{
+{SELFPARAM();
        entity head;
        vector v, m1, m2, diff;
        float c;
@@ -520,7 +520,7 @@ void navigation_markroutes_checkwaypoint(entity w, entity wp, float cost2, vecto
 
 // queries the entire spawnfunc_waypoint network for pathes leading away from the bot
 void navigation_markroutes(entity fixed_source_waypoint)
-{
+{SELFPARAM();
        entity w, wp, waylist;
        float searching, cost, cost2;
        vector p;
@@ -679,7 +679,7 @@ void navigation_markroutes_inverted(entity fixed_source_waypoint)
 
 // updates the best goal according to a weighted calculation of travel cost and item value of a new proposed item
 void navigation_routerating(entity e, float f, float rangebias)
-{
+{SELFPARAM();
        entity nwp;
        vector o;
        if (!e)
@@ -861,7 +861,7 @@ void navigation_routerating(entity e, float f, float rangebias)
 
 // adds an item to the the goal stack with the path to a given item
 float navigation_routetogoal(entity e, vector startposition)
-{
+{SELFPARAM();
        self.goalentity = e;
 
        // if there is no goal, just exit
@@ -907,7 +907,7 @@ float navigation_routetogoal(entity e, vector startposition)
 // removes any currently touching waypoints from the goal stack
 // (this is how bots detect if they reached a goal)
 void navigation_poptouchedgoals()
-{
+{SELFPARAM();
        vector org, m1, m2;
        org = self.origin;
        m1 = org + self.mins;
@@ -993,7 +993,7 @@ void navigation_poptouchedgoals()
 
 // begin a goal selection session (queries spawnfunc_waypoint network)
 void navigation_goalrating_start()
-{
+{SELFPARAM();
        if(self.aistatus & AI_STATUS_STUCK)
                return;
 
@@ -1007,7 +1007,7 @@ void navigation_goalrating_start()
 
 // ends a goal selection session (updates goal stack to the best goal)
 void navigation_goalrating_end()
-{
+{SELFPARAM();
        if(self.aistatus & AI_STATUS_STUCK)
                return;
 
@@ -1067,7 +1067,7 @@ void botframe_updatedangerousobjects(float maxupdate)
 }
 
 void navigation_unstuck()
-{
+{SELFPARAM();
        float search_radius = 1000;
 
        if (!autocvar_bot_wander_enable)
@@ -1164,7 +1164,7 @@ void debugresetnodes()
 }
 
 void debugnode(vector node)
-{
+{SELFPARAM();
        if (!IS_PLAYER(self))
                return;
 
@@ -1207,7 +1207,7 @@ void debugnodestatus(vector position, float status)
 
 // Debug the goal stack visually
 void debuggoalstack()
-{
+{SELFPARAM();
        entity goal;
        vector org, go;
 
index a8dc92171746325702c23c1676d26bfd78c53fab..46193160da9e1203c42e755814a4a64ce6534d41 100644 (file)
@@ -101,7 +101,7 @@ const int MAX_BOT_PLACES = 4;
 .entity bot_places[MAX_BOT_PLACES];
 .string bot_placenames[MAX_BOT_PLACES];
 entity bot_getplace(string placename)
-{
+{SELFPARAM();
        entity e;
        if(substring(placename, 0, 1) == "@")
        {
@@ -480,20 +480,20 @@ float bot_cmd_cc()
 }
 
 float bot_cmd_impulse()
-{
+{SELFPARAM();
        self.impulse = bot_cmd.bot_cmd_parm_float;
        return CMD_STATUS_FINISHED;
 }
 
 float bot_cmd_continue()
-{
+{SELFPARAM();
        self.bot_exec_status &= ~BOT_EXEC_STATUS_PAUSED;
        return CMD_STATUS_FINISHED;
 }
 
 .float bot_cmd_wait_time;
 float bot_cmd_wait()
-{
+{SELFPARAM();
        if(self.bot_exec_status & BOT_EXEC_STATUS_WAITING)
        {
                if(time>=self.bot_cmd_wait_time)
@@ -511,7 +511,7 @@ float bot_cmd_wait()
 }
 
 float bot_cmd_wait_until()
-{
+{SELFPARAM();
        if(time < bot_cmd.bot_cmd_parm_float + bot_barriertime)
        {
                self.bot_exec_status |= BOT_EXEC_STATUS_WAITING;
@@ -522,7 +522,7 @@ float bot_cmd_wait_until()
 }
 
 float bot_cmd_barrier()
-{
+{SELFPARAM();
        entity cl;
 
        // 0 = no barrier, 1 = waiting, 2 = waiting finished
@@ -561,14 +561,14 @@ float bot_cmd_barrier()
 }
 
 float bot_cmd_turn()
-{
+{SELFPARAM();
        self.v_angle_y = self.v_angle.y + bot_cmd.bot_cmd_parm_float;
        self.v_angle_y = self.v_angle.y - floor(self.v_angle.y / 360) * 360;
        return CMD_STATUS_FINISHED;
 }
 
 float bot_cmd_select_weapon()
-{
+{SELFPARAM();
        float id;
 
        id = bot_cmd.bot_cmd_parm_float;
@@ -593,7 +593,7 @@ const int CMD_CONDITION_true_BLOCK = 4;
 const int CMD_CONDITION_false_BLOCK = 8;
 
 float bot_cmd_eval(string expr)
-{
+{SELFPARAM();
        // Search for numbers
        if(strstrofs("0123456789", substring(expr, 0, 1), 0) >= 0)
        {
@@ -622,7 +622,7 @@ float bot_cmd_eval(string expr)
 }
 
 float bot_cmd_if()
-{
+{SELFPARAM();
        string expr, val_a, val_b;
        float cmpofs;
 
@@ -693,20 +693,20 @@ float bot_cmd_if()
 }
 
 float bot_cmd_else()
-{
+{SELFPARAM();
        self.bot_cmd_condition_status &= ~CMD_CONDITION_true_BLOCK;
        self.bot_cmd_condition_status |= CMD_CONDITION_false_BLOCK;
        return CMD_STATUS_FINISHED;
 }
 
 float bot_cmd_fi()
-{
+{SELFPARAM();
        self.bot_cmd_condition_status = CMD_CONDITION_NONE;
        return CMD_STATUS_FINISHED;
 }
 
 float bot_cmd_resetaim()
-{
+{SELFPARAM();
        self.v_angle = '0 0 0';
        return CMD_STATUS_FINISHED;
 }
@@ -717,7 +717,7 @@ float bot_cmd_resetaim()
 .vector bot_cmd_aim_end;
 
 float bot_cmd_aim()
-{
+{SELFPARAM();
        // Current direction
        if(self.bot_cmd_aim_endtime)
        {
@@ -768,7 +768,7 @@ float bot_cmd_aim()
 }
 
 float bot_cmd_aimtarget()
-{
+{SELFPARAM();
        if(self.bot_cmd_aim_endtime)
        {
                return bot_cmd_aim();
@@ -827,7 +827,7 @@ const int BOT_CMD_KEY_CROUCH        = 512;
 const int BOT_CMD_KEY_CHAT             = 1024;
 
 float bot_presskeys()
-{
+{SELFPARAM();
        self.movement = '0 0 0';
        self.BUTTON_JUMP = false;
        self.BUTTON_CROUCH = false;
@@ -876,7 +876,7 @@ float bot_presskeys()
 
 
 float bot_cmd_keypress_handler(string key, float enabled)
-{
+{SELFPARAM();
        switch(key)
        {
                case "all":
@@ -990,7 +990,7 @@ float bot_cmd_releasekey()
 }
 
 float bot_cmd_pause()
-{
+{SELFPARAM();
        self.button1        = 0;
        self.button8        = 0;
        self.BUTTON_USE     = 0;
@@ -1009,12 +1009,12 @@ float bot_cmd_pause()
 }
 
 float bot_cmd_moveto()
-{
+{SELFPARAM();
        return self.cmd_moveto(bot_cmd.bot_cmd_parm_vector);
 }
 
 float bot_cmd_movetotarget()
-{
+{SELFPARAM();
        entity e;
        e = bot_getplace(bot_cmd.bot_cmd_parm_string);
        if(!e)
@@ -1023,13 +1023,13 @@ float bot_cmd_movetotarget()
 }
 
 float bot_cmd_resetgoal()
-{
+{SELFPARAM();
        return self.cmd_resetgoal();
 }
 
 
 float bot_cmd_sound()
-{
+{SELFPARAM();
        string f;
        f = bot_cmd.bot_cmd_parm_string;
 
@@ -1057,7 +1057,7 @@ float bot_cmd_sound()
 
 .entity tuba_note;
 float bot_cmd_debug_assert_canfire()
-{
+{SELFPARAM();
        float f;
        f = bot_cmd.bot_cmd_parm_float;
 
@@ -1100,7 +1100,7 @@ float bot_cmd_debug_assert_canfire()
 //
 
 void bot_command_executed(float rm)
-{
+{SELFPARAM();
        entity cmd;
 
        cmd = bot_cmd;
@@ -1112,7 +1112,7 @@ void bot_command_executed(float rm)
 }
 
 void bot_setcurrentcommand()
-{
+{SELFPARAM();
        bot_cmd = world;
 
        if(!self.bot_cmd_current)
@@ -1171,7 +1171,7 @@ void bot_resetqueues()
 // Here we map commands to functions and deal with complex interactions between commands and execution states
 // NOTE: Of course you need to include your commands here too :)
 float bot_execute_commands_once()
-{
+{SELFPARAM();
        float status, ispressingkey;
 
        // Find command
index ca209f9ca7ab4877c3ef0036c2d3756cf076a06f..957f2478d2e44a6f20ac2f0badf84d2460b69884 100644 (file)
@@ -162,7 +162,7 @@ void waypoint_addlink(entity from, entity to)
 // (precompile a list of all reachable waypoints from this spawnfunc_waypoint)
 // (SLOW!)
 void waypoint_think()
-{
+{SELFPARAM();
        entity e;
        vector sv, sm1, sm2, ev, em1, em2, dv;
 
@@ -294,7 +294,7 @@ void waypoint_schedulerelink(entity wp)
 
 // spawnfunc_waypoint map entity
 void spawnfunc_waypoint()
-{
+{SELFPARAM();
        setorigin(self, self.origin);
        // schedule a relink after other waypoints have had a chance to spawn
        waypoint_clearlinks(self);
@@ -808,7 +808,7 @@ void waypoint_spawnforteleporter(entity e, vector destination, float timetaken)
 }
 
 entity waypoint_spawnpersonal(vector position)
-{
+{SELFPARAM();
        entity w;
 
        // drop the waypoint to a proper location:
index 82bc9036158a3f343cf41c35108c2028d6c5c25a..2b72368fa56f3a4fcfca3f02fb9f821a81cd2bfd 100644 (file)
@@ -65,7 +65,7 @@ void CheatShutdownClient()
 }
 
 float CheatsAllowed(float i, float argc, float fr) // the cheat gets passed as argument for possible future ACL checking
-{
+{SELFPARAM();
        // dead people cannot cheat
        if(self.deadflag != DEAD_NO)
                return 0;
@@ -115,7 +115,7 @@ float CheatsAllowed(float i, float argc, float fr) // the cheat gets passed as a
 
 float num_autoscreenshot;
 void info_autoscreenshot_findtarget()
-{
+{SELFPARAM();
        entity e;
        e = find(world, targetname, self.target);
        if(!e)
@@ -130,7 +130,7 @@ void info_autoscreenshot_findtarget()
        // we leave Rick Roll alone
 }
 void spawnfunc_info_autoscreenshot()
-{
+{SELFPARAM();
        if(++num_autoscreenshot > autocvar_g_max_info_autoscreenshot)
        {
                objerror("Too many info_autoscreenshot entitites. FAIL!");
@@ -142,7 +142,7 @@ void spawnfunc_info_autoscreenshot()
 }
 
 float CheatImpulse(float i)
-{
+{SELFPARAM();
        BEGIN_CHEAT_FUNCTION();
        switch(i)
        {
@@ -301,13 +301,12 @@ float CheatImpulse(float i)
 void DragBox_Think();
 float drag_lastcnt;
 float CheatCommand(float argc)
-{
+{SELFPARAM();
        BEGIN_CHEAT_FUNCTION();
        string cmd;
        cmd = argv(0);
        switch(cmd)
        {
-               entity e;
                float effectnum, f;
                vector start, end;
                entity oldself;
@@ -362,7 +361,7 @@ float CheatCommand(float argc)
                                }
                                else
                                {
-                                       e = spawn();
+                                       entity e = spawn();
                                        e.model = strzone(argv(1));
                                        e.mdl = "rocket_explode";
                                        e.health = 1000;
@@ -373,10 +372,7 @@ float CheatCommand(float argc)
                                                e.angles = fixedvectoangles2(trace_plane_normal, v_forward);
                                                e.angles = AnglesTransform_ApplyToAngles(e.angles, '-90 0 0'); // so unrotated models work
                                        }
-                                       oldself = self;
-                                       self = e;
-                                       spawnfunc_func_breakable();
-                                       self = oldself;
+                                       WITH(entity, self, e, spawnfunc_func_breakable());
                                        // now, is it valid?
                                        if(f == 0)
                                        {
@@ -406,9 +402,9 @@ float CheatCommand(float argc)
                        }
                        sprint(self, "Usage: sv_cheats 1; restart; cmd penalty 5.0 AHAHAHAHAHAHAH))\n");
                        break;
-               case "dragbox_spawn":
+               case "dragbox_spawn": {
                        IS_CHEAT(0, argc, 0);
-                       e = spawn();
+                       entity e = spawn();
                        e.classname = "dragbox_box";
                        e.think = DragBox_Think;
                        e.nextthink = time;
@@ -460,9 +456,10 @@ float CheatCommand(float argc)
                        setorigin(e.killindicator.killindicator, '0 0 8');
                        DID_CHEAT();
                        break;
-               case "dragpoint_spawn":
+               }
+               case "dragpoint_spawn": {
                        IS_CHEAT(0, argc, 0);
-                       e = spawn();
+                       entity e = spawn();
                        e.classname = "dragpoint";
                        e.think = DragBox_Think;
                        e.nextthink = time;
@@ -495,13 +492,14 @@ float CheatCommand(float argc)
                        setorigin(e.killindicator.killindicator, '0 0 56');
                        DID_CHEAT();
                        break;
+               }
                case "drag_remove":
                        IS_CHEAT(0, argc, 0);
                        RandomSelection_Init();
                        crosshair_trace(self);
-                       for(e = world; (e = find(e, classname, "dragbox_box")); )
+                       for(entity e = world; (e = find(e, classname, "dragbox_box")); )
                                RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - trace_endpos));
-                       for(e = world; (e = find(e, classname, "dragpoint")); )
+                       for(entity e = world; (e = find(e, classname, "dragpoint")); )
                                RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - trace_endpos));
                        if(RandomSelection_chosen_ent)
                        {
@@ -521,9 +519,9 @@ float CheatCommand(float argc)
                        {
                                RandomSelection_Init();
                                crosshair_trace(self);
-                               for(e = world; (e = find(e, classname, "dragbox_box")); )
+                               for(entity e = world; (e = find(e, classname, "dragbox_box")); )
                                        RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - trace_endpos));
-                               for(e = world; (e = find(e, classname, "dragpoint")); )
+                               for(entity e = world; (e = find(e, classname, "dragpoint")); )
                                        RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - trace_endpos));
                                if(RandomSelection_chosen_ent)
                                {
@@ -543,11 +541,11 @@ float CheatCommand(float argc)
                        {
                                f = fopen(argv(1), FILE_WRITE);
                                fputs(f, "cmd drag_clear\n");
-                               for(e = world; (e = find(e, classname, "dragbox_box")); )
+                               for(entity e = world; (e = find(e, classname, "dragbox_box")); )
                                {
                                        fputs(f, strcat("cmd dragbox_spawn ", ftos(e.cnt), " \"", vtos(e.aiment.origin), "\" \"", vtos(e.enemy.origin), "\"\n"));
                                }
-                               for(e = world; (e = find(e, classname, "dragpoint")); )
+                               for(entity e = world; (e = find(e, classname, "dragpoint")); )
                                {
                                        fputs(f, strcat("cmd dragpoint_spawn ", ftos(e.cnt), " \"", vtos(e.origin), "\"\n"));
                                }
@@ -562,7 +560,7 @@ float CheatCommand(float argc)
                        if(argc == 2)
                        {
                                f = fopen(argv(1), FILE_WRITE);
-                               for(e = world; (e = find(e, classname, "dragbox_box")); )
+                               for(entity e = world; (e = find(e, classname, "dragbox_box")); )
                                {
                                        fputs(f, "{\n");
                                        fputs(f, "\"classname\" \"trigger_race_checkpoint\"\n");
@@ -572,7 +570,7 @@ float CheatCommand(float argc)
                                        fputs(f, strcat("\"targetname\" \"checkpoint", ftos(e.cnt), "\"\n"));
                                        fputs(f, "}\n");
                                }
-                               for(e = world; (e = find(e, classname, "dragpoint")); )
+                               for(entity e = world; (e = find(e, classname, "dragpoint")); )
                                {
                                        start = '0 0 0';
                                        effectnum = 0;
@@ -628,15 +626,15 @@ float CheatCommand(float argc)
                        break;
                case "drag_clear":
                        IS_CHEAT(0, argc, 0);
-                       for(e = world; (e = find(e, classname, "dragbox_box")); )
+                       for(entity e = world; (e = find(e, classname, "dragbox_box")); )
                                remove(e);
-                       for(e = world; (e = find(e, classname, "dragbox_corner_1")); )
+                       for(entity e = world; (e = find(e, classname, "dragbox_corner_1")); )
                                remove(e);
-                       for(e = world; (e = find(e, classname, "dragbox_corner_2")); )
+                       for(entity e = world; (e = find(e, classname, "dragbox_corner_2")); )
                                remove(e);
-                       for(e = world; (e = find(e, classname, "dragpoint")); )
+                       for(entity e = world; (e = find(e, classname, "dragpoint")); )
                                remove(e);
-                       for(e = world; (e = find(e, classname, "drag_digit")); )
+                       for(entity e = world; (e = find(e, classname, "drag_digit")); )
                                remove(e);
                        DID_CHEAT();
                        break;
@@ -697,43 +695,38 @@ float CheatCommand(float argc)
                        break;
                case "usetarget":
                        IS_CHEAT(0, argc, 0);
-                       e = self;
-                       self = spawn();
+                       setself(spawn());
                        self.target = argv(1);
-                       activator = e;
+                       activator = this;
                        SUB_UseTargets();
                        remove(self);
-                       self = e;
+                       setself(this);
                        DID_CHEAT();
                        break;
                case "killtarget":
                        IS_CHEAT(0, argc, 0);
-                       e = self;
-                       self = spawn();
+                       setself(spawn());
                        self.killtarget = argv(1);
-                       activator = e;
+                       activator = this;
                        SUB_UseTargets();
                        remove(self);
-                       self = e;
+                       setself(this);
                        DID_CHEAT();
                        break;
                case "teleporttotarget":
                        IS_CHEAT(0, argc, 0);
-                       e = self;
-                       self = spawn();
+                       setself(spawn());
                        setorigin(self, self.origin);
                        self.classname = "cheattriggerteleport";
                        self.target = argv(1);
                        teleport_findtarget();
                        if(!wasfreed(self))
                        {
-                               Simple_TeleportPlayer(self, e);
+                               Simple_TeleportPlayer(self, this);
                                remove(self);
-                               self = e;
                                DID_CHEAT();
                        }
-                       else
-                               self = e;
+                       setself(this);
                        break;
        }
 
@@ -755,7 +748,7 @@ void Drag_MoveDrag(entity from, entity to);
 .entity dragentity;
 
 float CheatFrame()
-{
+{SELFPARAM();
        BEGIN_CHEAT_FUNCTION();
 
        // Dragging can be used as either a cheat, or a function for some objects. If sv_cheats is active,
@@ -799,7 +792,7 @@ float CheatFrame()
 .float dragmovetype;
 
 float Drag(float force_allow_pick, float ischeat)
-{
+{SELFPARAM();
        BEGIN_CHEAT_FUNCTION();
 
        // returns true when an entity has been picked up
@@ -1075,7 +1068,7 @@ void Drag_MoveDrag(entity from, entity to)
 }
 
 void DragBox_Think()
-{
+{SELFPARAM();
        if(self.aiment && self.enemy)
        {
                self.origin_x = (self.aiment.origin.x + self.enemy.origin.x) * 0.5;
index 4d7b9fa0bf25a20d901ad6e231e525c070e74fbb..036d417d54d1aed75ae01d45444d1767e24adad1 100644 (file)
@@ -54,7 +54,7 @@ void send_CSQC_teamnagger() {
 }
 
 float ClientData_Send(entity to, int sf)
-{
+{SELFPARAM();
        if(to != self.owner)
        {
                error("wtf");
@@ -94,14 +94,14 @@ float ClientData_Send(entity to, int sf)
 }
 
 void ClientData_Attach()
-{
+{SELFPARAM();
        Net_LinkEntity(self.clientdata = spawn(), false, 0, ClientData_Send);
        self.clientdata.drawonlytoclient = self;
        self.clientdata.owner = self;
 }
 
 void ClientData_Detach()
-{
+{SELFPARAM();
        remove(self.clientdata);
        self.clientdata = world;
 }
@@ -186,7 +186,7 @@ putting a client as observer in the server
 */
 void FixPlayermodel();
 void PutObserverInServer (void)
-{
+{SELFPARAM();
        entity  spot;
     self.hud = HUD_NORMAL;
 
@@ -316,7 +316,7 @@ void PutObserverInServer (void)
 
 .float model_randomizer;
 void FixPlayermodel()
-{
+{SELFPARAM();
        string defaultmodel;
        float defaultskin, chmdl, oldskin, n, i;
        vector m1, m2;
@@ -406,15 +406,11 @@ void FixPlayermodel()
                                setcolor(self, stof(autocvar_sv_defaultplayercolors));
 }
 
-/*
-=============
-PutClientInServer
 
-Called when a client spawns in the server
-=============
-*/
-void PutClientInServer (void)
+/** Called when a client spawns in the server */
+void PutClientInServer()
 {
+       SELFPARAM();
        if(IS_BOT_CLIENT(self))
                self.classname = "player";
        else if(IS_REAL_CLIENT(self))
@@ -436,7 +432,7 @@ void PutClientInServer (void)
 
        if(IS_PLAYER(self))
        {
-               entity spot, oldself;
+               entity spot;
 
                accuracy_resend(self);
 
@@ -609,7 +605,7 @@ void PutClientInServer (void)
                        self.killcount = 0;
                }
 
-               CL_SpawnWeaponentity();
+               CL_SpawnWeaponentity(self);
                self.alpha = default_player_alpha;
                self.colormod = '1 1 1' * autocvar_g_player_brightness;
                self.exteriorweaponentity.alpha = default_weapon_alpha;
@@ -632,16 +628,12 @@ void PutClientInServer (void)
                                self.(weapon_load[j]) = e.reloading_ammo;
                }
 
-               oldself = self;
-               self = spot;
-                       activator = oldself;
-                               string s;
-                               s = self.target;
-                               self.target = string_null;
-                               SUB_UseTargets();
-                               self.target = s;
-                       activator = world;
-               self = oldself;
+               string s = spot.target;
+               spot.target = string_null;
+               activator = self;
+               WITH(entity, self, spot, SUB_UseTargets());
+               activator = world;
+               spot.target = s;
 
                Unfreeze(self);
 
@@ -675,7 +667,7 @@ void PutClientInServer (void)
 // TODO do we need all these fields, or should we stop autodetecting runtime
 // changes and just have a console command to update this?
 float ClientInit_SendEntity(entity to, int sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_INIT);
        WriteByte(MSG_ENTITY, g_nexball_meter_period * 32);
        WriteInt24_t(MSG_ENTITY, compressShotOrigin(hook_shotorigin[0]));
@@ -707,7 +699,7 @@ float ClientInit_SendEntity(entity to, int sf)
 }
 
 void ClientInit_CheckUpdate()
-{
+{SELFPARAM();
        self.nextthink = time;
        if(self.count != autocvar_g_balance_armor_blockpercent)
        {
@@ -737,18 +729,13 @@ void ClientInit_CheckUpdate()
 }
 
 void ClientInit_Spawn()
-{
-       entity o;
-       entity e;
-       e = spawn();
+{SELFPARAM();
+       entity e = spawn();
        e.classname = "clientinit";
        e.think = ClientInit_CheckUpdate;
        Net_LinkEntity(e, false, 0, ClientInit_SendEntity);
 
-       o = self;
-       self = e;
-       ClientInit_CheckUpdate();
-       self = o;
+       WITH(entity, self, e, ClientInit_CheckUpdate());
 }
 
 /*
@@ -768,7 +755,7 @@ SetChangeParms
 =============
 */
 void SetChangeParms (void)
-{
+{SELFPARAM();
        // save parms for level change
        parm1 = self.parm_idlesince - time;
 }
@@ -779,7 +766,7 @@ DecodeLevelParms
 =============
 */
 void DecodeLevelParms (void)
-{
+{SELFPARAM();
        // load parms
        self.parm_idlesince = parm1;
        if(self.parm_idlesince == -(86400 * 366))
@@ -799,7 +786,7 @@ Called when a client types 'kill' in the console
 
 .float clientkill_nexttime;
 void ClientKill_Now_TeamChange()
-{
+{SELFPARAM();
        if(self.killindicator_teamchange == -1)
        {
                JoinBestTeam( self, false, true );
@@ -816,7 +803,7 @@ void ClientKill_Now_TeamChange()
 }
 
 void ClientKill_Now()
-{
+{SELFPARAM();
        if(self.vehicle)
        {
            vehicles_exit(VHEF_RELEASE);
@@ -841,7 +828,7 @@ void ClientKill_Now()
        // now I am sure the player IS dead
 }
 void KillIndicator_Think()
-{
+{SELFPARAM();
        if (gameover)
        {
                self.owner.killindicator = world;
@@ -858,8 +845,7 @@ void KillIndicator_Think()
 
        if(self.cnt <= 0)
        {
-               self = self.owner;
-               ClientKill_Now(); // no oldself needed
+               WITH(entity, self, self.owner, ClientKill_Now());
                return;
        }
     else if(g_cts && self.health == 1) // health == 1 means that it's silent
@@ -883,7 +869,7 @@ void KillIndicator_Think()
 
 float clientkilltime;
 void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto, -2 = spec
-{
+{SELFPARAM();
        float killtime;
        float starttime;
        entity e;
@@ -987,7 +973,7 @@ void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto, -2
 }
 
 void ClientKill (void)
-{
+{SELFPARAM();
        if(gameover) return;
        if(self.player_blocked) return;
        if(self.frozen) return;
@@ -1048,7 +1034,7 @@ Called once (not at each match start) when a client begins a connection to the s
 =============
 */
 void ClientPreConnect (void)
-{
+{SELFPARAM();
        if(autocvar_sv_eventlog)
        {
                GameLogEcho(sprintf(":connect:%d:%d:%s",
@@ -1069,7 +1055,7 @@ Called when a client connects to the server
 */
 void DecodeLevelParms (void);
 void ClientConnect (void)
-{
+{SELFPARAM();
        float t;
 
        if(IS_CLIENT(self))
@@ -1264,7 +1250,7 @@ void ClientConnect (void)
 
        CheatInitClient();
 
-       CSQCMODEL_AUTOINIT();
+       CSQCMODEL_AUTOINIT(self);
 
        self.model_randomizer = random();
 
@@ -1272,10 +1258,7 @@ void ClientConnect (void)
                sv_notice_join();
 
        for (entity e = world; (e = findfloat(e, init_for_player_needed, 1)); ) {
-               entity oldself = self;
-               self = e;
-               e.init_for_player(oldself);
-               self = oldself;
+               WITH(entity, self, e, e.init_for_player(this));
        }
 
        MUTATOR_CALLHOOK(ClientConnect, self);
@@ -1290,7 +1273,7 @@ Called when a client disconnects from the server
 .entity chatbubbleentity;
 void ReadyCount();
 void ClientDisconnect (void)
-{
+{SELFPARAM();
        if(self.vehicle)
            vehicles_exit(VHEF_RELEASE);
 
@@ -1374,7 +1357,7 @@ void ClientDisconnect (void)
 
 .float BUTTON_CHAT;
 void ChatBubbleThink()
-{
+{SELFPARAM();
        self.nextthink = time;
        if ((self.owner.alpha < 0) || self.owner.chatbubbleentity != self)
        {
@@ -1400,7 +1383,7 @@ void ChatBubbleThink()
 }
 
 void UpdateChatBubble()
-{
+{SELFPARAM();
        if (self.alpha < 0)
                return;
        // spawn a chatbubble entity if needed
@@ -1439,7 +1422,7 @@ void UpdateChatBubble()
 }*/
 
 void respawn(void)
-{
+{SELFPARAM();
        if(self.alpha >= 0 && autocvar_g_respawn_ghosts)
        {
                self.solid = SOLID_NOT;
@@ -1460,7 +1443,7 @@ void respawn(void)
 }
 
 void play_countdown(float finished, string samp)
-{
+{SELFPARAM();
        if(IS_REAL_CLIENT(self))
                if(floor(finished - time - frametime) != floor(finished - time))
                        if(finished - time < 6)
@@ -1468,7 +1451,7 @@ void play_countdown(float finished, string samp)
 }
 
 void player_powerups (void)
-{
+{SELFPARAM();
        // add a way to see what the items were BEFORE all of these checks for the mutator hook
        int items_prev = self.items;
 
@@ -1631,7 +1614,7 @@ float CalcRotRegen(float current, float regenstable, float regenfactor, float re
 }
 
 void player_regen (void)
-{
+{SELFPARAM();
        float max_mod, regen_mod, rot_mod, limit_mod;
        max_mod = regen_mod = rot_mod = limit_mod = 1;
        regen_mod_max = max_mod;
@@ -1691,7 +1674,7 @@ void player_regen (void)
 
 float zoomstate_set;
 void SetZoomState(float z)
-{
+{SELFPARAM();
        if(z != self.zoomstate)
        {
                self.zoomstate = z;
@@ -1700,7 +1683,8 @@ void SetZoomState(float z)
        zoomstate_set = 1;
 }
 
-void GetPressedKeys(void) {
+void GetPressedKeys()
+{SELFPARAM();
        MUTATOR_CALLHOOK(GetPressedKeys);
        #define X(var,bit,flag) (flag ? var |= bit : var &= ~bit)
        X(self.pressedkeys, KEY_FORWARD,        self.movement_x > 0);
@@ -1721,7 +1705,8 @@ spectate mode routines
 ======================
 */
 
-void SpectateCopy(entity spectatee) {
+void SpectateCopy(entity spectatee)
+{SELFPARAM();
        MUTATOR_CALLHOOK(SpectateCopy, spectatee, self);
        self.armortype = spectatee.armortype;
        self.armorvalue = spectatee.armorvalue;
@@ -1797,7 +1782,7 @@ void SpectateCopy(entity spectatee) {
 }
 
 bool SpectateUpdate()
-{
+{SELFPARAM();
        if(!self.enemy)
            return false;
 
@@ -1813,7 +1798,7 @@ bool SpectateUpdate()
 }
 
 bool SpectateSet()
-{
+{SELFPARAM();
        if(!IS_PLAYER(self.enemy))
                return false;
 
@@ -1842,7 +1827,7 @@ void SetSpectator(entity player, entity spectatee)
 }
 
 bool Spectate(entity pl)
-{
+{SELFPARAM();
        if(g_ca && !autocvar_g_ca_spectate_enemies && self.caplayer)
        if(DIFF_TEAM(pl, self))
                return false;
@@ -1853,7 +1838,7 @@ bool Spectate(entity pl)
 
 // Returns next available player to spectate if g_ca_spectate_enemies == 0
 entity CA_SpectateNext(entity start)
-{
+{SELFPARAM();
        if(SAME_TEAM(start, self))
                return start;
 
@@ -1874,7 +1859,7 @@ entity CA_SpectateNext(entity start)
 }
 
 bool SpectateNext()
-{
+{SELFPARAM();
        other = find(self.enemy, classname, "player");
 
        if (g_ca && !autocvar_g_ca_spectate_enemies && self.caplayer)
@@ -1893,7 +1878,7 @@ bool SpectateNext()
 }
 
 bool SpectatePrev()
-{
+{SELFPARAM();
        // NOTE: chain order is from the highest to the lower entnum (unlike find)
        other = findchain(classname, "player");
        if (!other) // no player
@@ -1938,7 +1923,7 @@ Update a respawn countdown display.
 =============
 */
 void ShowRespawnCountdown()
-{
+{SELFPARAM();
        float number;
        if(self.deadflag == DEAD_NO) // just respawned?
                return;
@@ -1957,7 +1942,7 @@ void ShowRespawnCountdown()
 }
 
 void LeaveSpectatorMode()
-{
+{SELFPARAM();
        if(self.caplayer)
                return;
        if(nJoinAllowed(self))
@@ -1995,7 +1980,8 @@ void LeaveSpectatorMode()
  * it checks whether the number of currently playing players exceeds g_maxplayers.
  * @return int number of free slots for players, 0 if none
  */
-float nJoinAllowed(entity ignore) {
+float nJoinAllowed(entity ignore)
+{SELFPARAM();
        if(!ignore)
        // this is called that way when checking if anyone may be able to join (to build qcstatus)
        // so report 0 free slots if restricted
@@ -2034,7 +2020,8 @@ float nJoinAllowed(entity ignore) {
  * Checks whether the client is an observer or spectator, if so, he will get kicked after
  * g_maxplayers_spectator_blocktime seconds
  */
-void checkSpectatorBlock() {
+void checkSpectatorBlock()
+{SELFPARAM();
        if(IS_SPEC(self) || IS_OBSERVER(self))
        if(!self.caplayer)
        if(IS_REAL_CLIENT(self))
@@ -2047,7 +2034,7 @@ void checkSpectatorBlock() {
 }
 
 void PrintWelcomeMessage()
-{
+{SELFPARAM();
        if(self.motd_actived_time == 0)
        {
                if (autocvar_g_campaign) {
@@ -2094,7 +2081,7 @@ void PrintWelcomeMessage()
 }
 
 void ObserverThink()
-{
+{SELFPARAM();
        if ( self.impulse )
        {
                MinigameImpulse(self.impulse);
@@ -2129,7 +2116,7 @@ void ObserverThink()
 }
 
 void SpectatorThink()
-{
+{SELFPARAM();
        if ( self.impulse )
        {
                if(MinigameImpulse(self.impulse))
@@ -2184,7 +2171,7 @@ void SpectatorThink()
 
 void vehicles_enter (entity pl, entity veh);
 void PlayerUseKey()
-{
+{SELFPARAM();
        if (!IS_PLAYER(self))
                return;
 
@@ -2270,7 +2257,7 @@ void() nexball_setstatus;
 .float last_vehiclecheck;
 .int items_added;
 void PlayerPreThink (void)
-{
+{SELFPARAM();
        WarpZone_PlayerPhysics_FixVAngle();
 
        self.stat_game_starttime = game_starttime;
@@ -2626,15 +2613,14 @@ void PlayerPreThink (void)
        {
                self.teamkill_soundtime = 0;
 
-               entity oldpusher, oldself;
-
-               oldself = self; self = self.teamkill_soundsource;
-               oldpusher = self.pusher; self.pusher = oldself;
+               setself(self.teamkill_soundsource);
+               entity oldpusher = self.pusher;
+               self.pusher = this;
 
                PlayerSound(playersound_teamshoot, CH_VOICE, VOICETYPE_LASTATTACKER_ONLY);
 
                self.pusher = oldpusher;
-               self = oldself;
+               setself(this);
        }
 
        if(self.taunt_soundtime)
@@ -2661,7 +2647,7 @@ Called every frame for each client after the physics are run
 */
 .float idlekick_lasttimeleft;
 void PlayerPostThink (void)
-{
+{SELFPARAM();
        if(sv_maxidle > 0 && frametime) // WORKAROUND: only use dropclient in server frames (frametime set). Never use it in cl_movement frames (frametime zero).
        if(IS_REAL_CLIENT(self))
        if(IS_PLAYER(self) || sv_maxidle_spectatorsareidle)
@@ -2733,5 +2719,5 @@ void PlayerPostThink (void)
 
        playerdemo_write();
 
-       CSQCMODEL_AUTOUPDATE();
+       CSQCMODEL_AUTOUPDATE(self);
 }
index dd010214e589a57cbbfc70033bf22e87f67e25bc..0271f085bd0a68b96304ee1571893959465fcec3 100644 (file)
@@ -51,7 +51,7 @@
  */
 
 void ImpulseCommands (void)
-{
+{SELFPARAM();
        int imp;
        vector org;
        float i;
index 6310d7ff3ef3cb6daeefb423615dc0f8187161a7..8e84f4863a9e3b2b7373a05f0d680831e4d1d86f 100644 (file)
@@ -25,7 +25,7 @@
 #include "../common/animdecide.qh"
 
 void CopyBody_Think(void)
-{
+{SELFPARAM();
        if(self.CopyBody_nextthink && time > self.CopyBody_nextthink)
        {
                self.CopyBody_think();
@@ -35,90 +35,88 @@ void CopyBody_Think(void)
                self.CopyBody_think = self.think;
                self.think = CopyBody_Think;
        }
-       CSQCMODEL_AUTOUPDATE();
+       CSQCMODEL_AUTOUPDATE(self);
        self.nextthink = time;
 }
 void CopyBody(float keepvelocity)
-{
-       entity oldself;
+{SELFPARAM();
        if (self.effects & EF_NODRAW)
                return;
-       oldself = self;
-       self = spawn();
-       self.enemy = oldself;
-       self.lip = oldself.lip;
-       self.colormap = oldself.colormap;
-       self.iscreature = oldself.iscreature;
-       self.teleportable = oldself.teleportable;
-       self.damagedbycontents = oldself.damagedbycontents;
-       self.angles = oldself.angles;
-       self.v_angle = oldself.v_angle;
-       self.avelocity = oldself.avelocity;
+       setself(spawn());
+       self.enemy = this;
+       self.lip = this.lip;
+       self.colormap = this.colormap;
+       self.iscreature = this.iscreature;
+       self.teleportable = this.teleportable;
+       self.damagedbycontents = this.damagedbycontents;
+       self.angles = this.angles;
+       self.v_angle = this.v_angle;
+       self.avelocity = this.avelocity;
        self.classname = "body";
-       self.damageforcescale = oldself.damageforcescale;
-       self.effects = oldself.effects;
-       self.glowmod = oldself.glowmod;
-       self.event_damage = oldself.event_damage;
-       self.anim_state = oldself.anim_state;
-       self.anim_time = oldself.anim_time;
-       self.anim_lower_action = oldself.anim_lower_action;
-       self.anim_lower_time = oldself.anim_lower_time;
-       self.anim_upper_action = oldself.anim_upper_action;
-       self.anim_upper_time = oldself.anim_upper_time;
-       self.anim_implicit_state = oldself.anim_implicit_state;
-       self.anim_implicit_time = oldself.anim_implicit_time;
-       self.anim_lower_implicit_action = oldself.anim_lower_implicit_action;
-       self.anim_lower_implicit_time = oldself.anim_lower_implicit_time;
-       self.anim_upper_implicit_action = oldself.anim_upper_implicit_action;
-       self.anim_upper_implicit_time = oldself.anim_upper_implicit_time;
-       self.dphitcontentsmask = oldself.dphitcontentsmask;
-       self.death_time = oldself.death_time;
-       self.pain_finished = oldself.pain_finished;
-       self.health = oldself.health;
-       self.armorvalue = oldself.armorvalue;
-       self.armortype = oldself.armortype;
-       self.model = oldself.model;
-       self.modelindex = oldself.modelindex;
-       self.skin = oldself.skin;
-       self.species = oldself.species;
-       self.movetype = oldself.movetype;
-       self.solid = oldself.solid;
-       self.ballistics_density = oldself.ballistics_density;
-       self.takedamage = oldself.takedamage;
-       self.customizeentityforclient = oldself.customizeentityforclient;
-       self.uncustomizeentityforclient = oldself.uncustomizeentityforclient;
-       self.uncustomizeentityforclient_set = oldself.uncustomizeentityforclient_set;
+       self.damageforcescale = this.damageforcescale;
+       self.effects = this.effects;
+       self.glowmod = this.glowmod;
+       self.event_damage = this.event_damage;
+       self.anim_state = this.anim_state;
+       self.anim_time = this.anim_time;
+       self.anim_lower_action = this.anim_lower_action;
+       self.anim_lower_time = this.anim_lower_time;
+       self.anim_upper_action = this.anim_upper_action;
+       self.anim_upper_time = this.anim_upper_time;
+       self.anim_implicit_state = this.anim_implicit_state;
+       self.anim_implicit_time = this.anim_implicit_time;
+       self.anim_lower_implicit_action = this.anim_lower_implicit_action;
+       self.anim_lower_implicit_time = this.anim_lower_implicit_time;
+       self.anim_upper_implicit_action = this.anim_upper_implicit_action;
+       self.anim_upper_implicit_time = this.anim_upper_implicit_time;
+       self.dphitcontentsmask = this.dphitcontentsmask;
+       self.death_time = this.death_time;
+       self.pain_finished = this.pain_finished;
+       self.health = this.health;
+       self.armorvalue = this.armorvalue;
+       self.armortype = this.armortype;
+       self.model = this.model;
+       self.modelindex = this.modelindex;
+       self.skin = this.skin;
+       self.species = this.species;
+       self.movetype = this.movetype;
+       self.solid = this.solid;
+       self.ballistics_density = this.ballistics_density;
+       self.takedamage = this.takedamage;
+       self.customizeentityforclient = this.customizeentityforclient;
+       self.uncustomizeentityforclient = this.uncustomizeentityforclient;
+       self.uncustomizeentityforclient_set = this.uncustomizeentityforclient_set;
        if (keepvelocity == 1)
-               self.velocity = oldself.velocity;
+               self.velocity = this.velocity;
        self.oldvelocity = self.velocity;
-       self.alpha = oldself.alpha;
-       self.fade_time = oldself.fade_time;
-       self.fade_rate = oldself.fade_rate;
-       //self.weapon = oldself.weapon;
-       setorigin(self, oldself.origin);
-       setsize(self, oldself.mins, oldself.maxs);
-       self.prevorigin = oldself.origin;
+       self.alpha = this.alpha;
+       self.fade_time = this.fade_time;
+       self.fade_rate = this.fade_rate;
+       //self.weapon = this.weapon;
+       setorigin(self, this.origin);
+       setsize(self, this.mins, this.maxs);
+       self.prevorigin = this.origin;
        self.reset = SUB_Remove;
 
-       Drag_MoveDrag(oldself, self);
+       Drag_MoveDrag(this, self);
 
        if(self.colormap <= maxclients && self.colormap > 0)
-               self.colormap = 1024 + oldself.clientcolors;
+               self.colormap = 1024 + this.clientcolors;
 
-       CSQCMODEL_AUTOINIT();
-       self.CopyBody_nextthink = oldself.nextthink;
-       self.CopyBody_think = oldself.think;
+       CSQCMODEL_AUTOINIT(self);
+       self.CopyBody_nextthink = this.nextthink;
+       self.CopyBody_think = this.think;
        self.nextthink = time;
        self.think = CopyBody_Think;
        // "bake" the current animation frame for clones (they don't get clientside animation)
        animdecide_load_if_needed(self);
        animdecide_setframes(self, false, frame, frame1time, frame2, frame2time);
 
-       self = oldself;
+       setself(this);
 }
 
 float player_getspecies()
-{
+{SELFPARAM();
        float s;
        get_model_parameters(self.model, self.skin);
        s = get_model_parameters_species;
@@ -129,14 +127,14 @@ float player_getspecies()
 }
 
 void player_setupanimsformodel()
-{
+{SELFPARAM();
        // load animation info
        animdecide_load_if_needed(self);
        animdecide_setstate(self, 0, false);
 }
 
 void player_anim (void)
-{
+{SELFPARAM();
        int deadbits = (self.anim_state & (ANIMSTATE_DEAD1 | ANIMSTATE_DEAD2));
        if(self.deadflag) {
                if (!deadbits) {
@@ -169,7 +167,7 @@ void player_anim (void)
 }
 
 void PlayerCorpseDamage (entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        float take, save;
        vector v;
        Violence_GibSplash_At(hitloc, force, 2, bound(0, damage, 200) / 16, self, attacker);
@@ -221,7 +219,7 @@ void PlayerCorpseDamage (entity inflictor, entity attacker, float damage, int de
 }
 
 void calculate_player_respawn_time()
-{
+{SELFPARAM();
        if(g_ca)
                return;
 
@@ -308,7 +306,7 @@ void calculate_player_respawn_time()
 }
 
 void PlayerDamage (entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        float take, save, dh, da;
        int j;
        vector v;
@@ -1014,7 +1012,7 @@ void PrecachePlayerSounds(string f)
 }
 
 void ClearPlayerSounds()
-{
+{SELFPARAM();
 #define _VOICEMSG(m) if(self.playersound_##m) { strunzone(self.playersound_##m); self.playersound_##m = string_null; }
        ALLPLAYERSOUNDS
        ALLVOICEMSGS
@@ -1022,7 +1020,7 @@ void ClearPlayerSounds()
 }
 
 float LoadPlayerSounds(string f, float first)
-{
+{SELFPARAM();
        float fh;
        string s;
        var .string field;
@@ -1050,7 +1048,7 @@ float LoadPlayerSounds(string f, float first)
 }
 
 void UpdatePlayerSounds()
-{
+{SELFPARAM();
        if(self.modelindex == self.modelindex_for_playersound)
        if(self.skin == self.skin_for_playersound)
                return;
@@ -1064,7 +1062,7 @@ void UpdatePlayerSounds()
 }
 
 void FakeGlobalSound(string sample, float chan, float voicetype)
-{
+{SELFPARAM();
        float n;
        float tauntrand;
 
@@ -1139,7 +1137,7 @@ void FakeGlobalSound(string sample, float chan, float voicetype)
 }
 
 void GlobalSound(string sample, float chan, float voicetype)
-{
+{SELFPARAM();
        float n;
        float tauntrand;
 
@@ -1237,12 +1235,12 @@ void GlobalSound(string sample, float chan, float voicetype)
 }
 
 void PlayerSound(.string samplefield, float chan, float voicetype)
-{
+{SELFPARAM();
        GlobalSound(self.(samplefield), chan, voicetype);
 }
 
 void VoiceMessage(string type, string msg)
-{
+{SELFPARAM();
        var .string sample;
        float voicetype, ownteam;
        float flood;
index a34752c9c76587b079be74788917a245343ebcdf..f849deb6a878119056aca16a3cfe81fd1995c89e 100644 (file)
@@ -40,7 +40,7 @@ void ClientKill_TeamChange (float targetteam); // 0 = don't change, -1 = auto, -
 // =========================================================
 
 float SV_ParseClientCommand_floodcheck()
-{
+{SELFPARAM();
        if (!timeout_status) // not while paused
        {
                if(time <= (self.cmd_floodtime + autocvar_sv_clientcommand_antispam_time))
@@ -63,7 +63,7 @@ float SV_ParseClientCommand_floodcheck()
 // =======================
 
 void ClientCommand_autoswitch(float request, float argc)
-{
+{SELFPARAM();
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
@@ -88,7 +88,7 @@ void ClientCommand_autoswitch(float request, float argc)
 }
 
 void ClientCommand_clientversion(float request, float argc) // internal command, used only by code
-{
+{SELFPARAM();
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
@@ -131,7 +131,7 @@ void ClientCommand_clientversion(float request, float argc) // internal command,
 }
 
 void ClientCommand_mv_getpicture(float request, float argc) // internal command, used only by code
-{
+{SELFPARAM();
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
@@ -157,7 +157,7 @@ void ClientCommand_mv_getpicture(float request, float argc) // internal command,
 }
 
 void ClientCommand_join(float request)
-{
+{SELFPARAM();
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
@@ -199,7 +199,7 @@ void ClientCommand_join(float request)
 }
 
 void ClientCommand_physics(float request, float argc)
-{
+{SELFPARAM();
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
@@ -239,7 +239,7 @@ void ClientCommand_physics(float request, float argc)
 }
 
 void ClientCommand_ready(float request) // todo: anti-spam for toggling readyness
-{
+{SELFPARAM();
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
@@ -285,7 +285,7 @@ void ClientCommand_ready(float request) // todo: anti-spam for toggling readynes
 }
 
 void ClientCommand_say(float request, float argc, string command)
-{
+{SELFPARAM();
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
@@ -305,7 +305,7 @@ void ClientCommand_say(float request, float argc, string command)
 }
 
 void ClientCommand_say_team(float request, float argc, string command)
-{
+{SELFPARAM();
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
@@ -325,7 +325,7 @@ void ClientCommand_say_team(float request, float argc, string command)
 }
 
 void ClientCommand_selectteam(float request, float argc)
-{
+{SELFPARAM();
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
@@ -397,7 +397,7 @@ void ClientCommand_selectteam(float request, float argc)
 }
 
 void ClientCommand_selfstuff(float request, string command)
-{
+{SELFPARAM();
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
@@ -421,7 +421,7 @@ void ClientCommand_selfstuff(float request, string command)
 }
 
 void ClientCommand_sentcvar(float request, float argc, string command)
-{
+{SELFPARAM();
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
@@ -455,7 +455,7 @@ void ClientCommand_sentcvar(float request, float argc, string command)
 }
 
 void ClientCommand_spectate(float request)
-{
+{SELFPARAM();
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
@@ -500,7 +500,7 @@ void ClientCommand_spectate(float request)
 }
 
 void ClientCommand_suggestmap(float request, float argc)
-{
+{SELFPARAM();
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
@@ -524,7 +524,7 @@ void ClientCommand_suggestmap(float request, float argc)
 }
 
 void ClientCommand_tell(float request, float argc, string command)
-{
+{SELFPARAM();
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
@@ -575,7 +575,7 @@ void ClientCommand_tell(float request, float argc, string command)
 }
 
 void ClientCommand_voice(float request, float argc, string command)
-{
+{SELFPARAM();
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
@@ -652,7 +652,7 @@ void ClientCommand_(float request)
        /* nothing */
 
 void ClientCommand_macro_help()
-{
+{SELFPARAM();
        #define CLIENT_COMMAND(name,function,description) \
                { sprint(self, "  ^2", name, "^7: ", description, "\n"); }
 
@@ -701,7 +701,7 @@ void ClientCommand_macro_write_aliases(float fh)
 // If this function exists, server game code parses clientcommand before the engine code gets it.
 
 void SV_ParseClientCommand(string command)
-{
+{SELFPARAM();
        // If invalid UTF-8, don't even parse it
        string command2 = "";
        float len = strlen(command);
index ee832bcc8529d3ec9ef3e104a96209c39fc588c4..5ddea150a974103a04946359bcc5dcf6b22638e1 100644 (file)
@@ -178,7 +178,7 @@ void print_to(entity to, string input)
 
 // used by CommonCommand_timeout() and CommonCommand_timein() to handle game pausing and messaging and such.
 void timeout_handler_reset()
-{
+{SELFPARAM();
        timeout_caller = world;
        timeout_time = 0;
        timeout_leadtime = 0;
@@ -187,7 +187,7 @@ void timeout_handler_reset()
 }
 
 void timeout_handler_think()
-{
+{SELFPARAM();
        entity tmp_player;
 
        switch(timeout_status)
@@ -312,7 +312,7 @@ void CommonCommand_cvar_purechanges(float request, entity caller)
 }
 
 void CommonCommand_editmob(int request, entity caller, int argc)
-{
+{SELFPARAM();
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
index 396337a1871572ba9a9797652389943010aed35b..8c15819e05ad174a0ea24f09e573b92061554048 100644 (file)
@@ -227,7 +227,7 @@ void RadarMap_Next()
        radarmapper = world;
 }
 void RadarMap_Think()
-{
+{SELFPARAM();
        // rough map entity
        //   cnt: current line
        //   size: pixel width/height
index fdf82e368fffaa4826a95a0c772707754a8dbabb..8287643b9959a7ad59d131bf786d6ce0c5a4042f 100644 (file)
@@ -41,7 +41,7 @@ void PutObserverInServer (void);
 
 //  used by GameCommand_make_mapinfo()
 void make_mapinfo_Think()
-{
+{SELFPARAM();
        if(MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, 0, 1))
        {
                LOG_INFO("Done rebuiling mapinfos.\n");
@@ -196,7 +196,7 @@ void GameCommand_allready(float request)
 }
 
 void GameCommand_allspec(float request, float argc)
-{
+{SELFPARAM();
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
@@ -207,10 +207,9 @@ void GameCommand_allspec(float request, float argc)
 
                        FOR_EACH_REALPLAYER(client)
                        {
-                               self = client;
-                               if(self.caplayer)
-                                       self.caplayer = 0;
-                               PutObserverInServer();
+                               if (client.caplayer)
+                                       client.caplayer = 0;
+                               WITH(entity, self, client, PutObserverInServer());
                                ++i;
                        }
                        if(i) { bprint(strcat("Successfully forced all (", ftos(i), ") players to spectate", (reason ? strcat(" for reason: '", reason, "'") : ""), ".\n")); }
@@ -230,7 +229,7 @@ void GameCommand_allspec(float request, float argc)
 }
 
 void GameCommand_anticheat(float request, float argc)
-{
+{SELFPARAM();
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
@@ -240,8 +239,7 @@ void GameCommand_anticheat(float request, float argc)
 
                        if(accepted > 0)
                        {
-                               self = client;
-                               anticheat_report();
+                               WITH(entity, self, client, anticheat_report());
                                return;
                        }
                        else
@@ -1002,7 +1000,7 @@ void GameCommand_make_mapinfo(float request)
 }
 
 void GameCommand_moveplayer(float request, float argc)
-{
+{SELFPARAM();
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
@@ -1039,10 +1037,9 @@ void GameCommand_moveplayer(float request, float argc)
                                        {
                                                if(!IS_SPEC(client) && !IS_OBSERVER(client))
                                                {
-                                                       self = client;
-                                                       if(self.caplayer)
-                                                               self.caplayer = 0;
-                                                       PutObserverInServer();
+                                                       if (client.caplayer)
+                                                               client.caplayer = 0;
+                                                       WITH(entity, self, client, PutObserverInServer());
 
                                                        successful = strcat(successful, (successful ? ", " : ""), client.netname);
                                                }
@@ -1171,7 +1168,7 @@ void GameCommand_nospectators(float request)
 }
 
 void GameCommand_playerdemo(float request, float argc)
-{
+{SELFPARAM();
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
@@ -1194,8 +1191,7 @@ void GameCommand_playerdemo(float request, float argc)
                                                        return;
                                                }
 
-                                               self = client;
-                                               playerdemo_open_read(argv(next_token));
+                                               WITH(entity, self, client, playerdemo_open_read(argv(next_token)));
                                                return;
                                        }
 
@@ -1210,8 +1206,7 @@ void GameCommand_playerdemo(float request, float argc)
                                                        return;
                                                }
 
-                                               self = client;
-                                               playerdemo_open_write(argv(next_token));
+                                               WITH(entity, self, client, playerdemo_open_write(argv(next_token)));
                                                return;
                                        }
 
@@ -1344,7 +1339,7 @@ void GameCommand_setbots(float request, float argc)
 }
 
 void GameCommand_shuffleteams(float request)
-{
+{SELFPARAM();
        switch(request)
        {
                case CMD_REQUEST_COMMAND:
@@ -1409,7 +1404,7 @@ void GameCommand_shuffleteams(float request)
                                                                continue; // not a player, move on to next random slot
 
                                                        if(VerifyClientNumber(shuffleteams_players[z]))
-                                                               self = edict_num(shuffleteams_players[z]);
+                                                               setself(edict_num(shuffleteams_players[z]));
 
                                                        if(self.team != team_color)
                                                                MoveToTeam(self, team_color, 6);
index 4be48e124e82b98d38fb26c41c5df7dfe18efc29..3e9f129622c61ac64dcccc4d2f96a1cdc16547dd 100644 (file)
@@ -348,52 +348,60 @@ void VoteThink()
 
 // Resets the state of all clients, items, weapons, waypoints, ... of the map.
 void reset_map(float dorespawn)
-{
-       entity oldself;
-       oldself = self;
+{SELFPARAM();
 
        if(time <= game_starttime && round_handler_IsActive())
                round_handler_Reset(game_starttime);
 
        MUTATOR_CALLHOOK(reset_map_global);
 
-       for(self = world; (self = nextent(self)); )
-       if(IS_NOT_A_CLIENT(self))
+       for(entity e = world; (e = nextent(e)); )
        {
-               if(self.reset)
+               setself(e);
+               if(IS_NOT_A_CLIENT(self))
                {
-                       self.reset();
-                       continue;
-               }
+                       if(self.reset)
+                       {
+                               self.reset();
+                               continue;
+                       }
 
-               if(self.team_saved)
-                       self.team = self.team_saved;
+                       if(self.team_saved)
+                               self.team = self.team_saved;
 
-               if(self.flags & FL_PROJECTILE) // remove any projectiles left
-                       remove(self);
+                       if(self.flags & FL_PROJECTILE) // remove any projectiles left
+                               remove(self);
+               }
        }
 
        // Waypoints and assault start come LAST
-       for(self = world; (self = nextent(self)); )
-       if(IS_NOT_A_CLIENT(self))
+       for(entity e = world; (e = nextent(e)); )
        {
-               if(self.reset2)
+               setself(e);
+               if(IS_NOT_A_CLIENT(self))
                {
-                       self.reset2();
-                       continue;
+                       if(self.reset2)
+                       {
+                               self.reset2();
+                               continue;
+                       }
                }
        }
 
-       FOR_EACH_PLAYER(self)
-       if(self.frozen)
-               Unfreeze(self);
+       entity e;
+       FOR_EACH_PLAYER(e)
+       if(e.frozen)
+       {
+               WITH(entity, self, e, Unfreeze(self));
+       }
 
        // Moving the player reset code here since the player-reset depends
        // on spawnpoint entities which have to be reset first --blub
        if(dorespawn)
        if(!MUTATOR_CALLHOOK(reset_map_players))
-       FOR_EACH_CLIENT(self) // reset all players
+       FOR_EACH_CLIENT(e) // reset all players
        {
+               setself(e);
                /*
                only reset players if a restart countdown is active
                this can either be due to cvar sv_ready_restart_after_countdown having set
@@ -418,12 +426,12 @@ void reset_map(float dorespawn)
        if(g_keyhunt)
                kh_Controller_SetThink(autocvar_g_balance_keyhunt_delay_round + (game_starttime - time), kh_StartRound);
 
-       self = oldself;
+       setself(this);
 }
 
 // Restarts the map after the countdown is over (and cvar sv_ready_restart_after_countdown is set)
 void ReadyRestart_think()
-{
+{SELFPARAM();
        restart_mapalreadyrestarted = 1;
        reset_map(true);
        Score_ClearAll();
index 7cf81d762ee0e73b8b6f018ba16825c7d51fff99..fac8bca4dd4d5f84bf92fcec714e960ffd540a25 100644 (file)
@@ -1,7 +1,7 @@
 #include "controlpoint.qh"
 
 bool cpicon_send(entity to, int sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_CONTROLPOINT_ICON);
        WriteByte(MSG_ENTITY, sf);
        if(sf & CPSF_SETUP)
index 40dbf1aefa9f99822433ffbdae96ddd2fbf3cd6e..a3be17bf2bb5c99d5652a099c342c5bf07b3cb4e 100644 (file)
@@ -26,7 +26,7 @@ void entcs_init()
 }
 
 float entcs_customize()
-{
+{SELFPARAM();
        entity o;
        o = self.owner;
        if(o.deadflag != DEAD_NO)
@@ -43,7 +43,7 @@ float entcs_customize()
 }
 
 float entcs_send(entity to, int sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_ENTCS);
        WriteByte(MSG_ENTITY, sf);
        if(sf & 1)
@@ -64,7 +64,7 @@ float entcs_send(entity to, int sf)
 }
 
 void entcs_think()
-{
+{SELFPARAM();
        self.nextthink = time + 0.033333333333; // increase this to like 0.15 once the client can do smoothing
 
        entity o;
@@ -93,7 +93,7 @@ void entcs_think()
 }
 
 entity attach_entcs()
-{
+{SELFPARAM();
        entity ent;
 
        ent = spawn();
@@ -111,7 +111,7 @@ entity attach_entcs()
 }
 
 void detach_entcs()
-{
+{SELFPARAM();
        remove(self.entcs);
        self.entcs = world;
 }
index 0807c924c2d1f584afb153c5039e06f282306944..5e10f41a041e97633aa490e49de3c4094e84acd7 100644 (file)
@@ -23,7 +23,7 @@
 #include "../warpzonelib/common.qh"
 
 float Damage_DamageInfo_SendEntity(entity to, int sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_DAMAGEINFO);
        WriteShort(MSG_ENTITY, self.projectiledeathtype);
        WriteCoord(MSG_ENTITY, floor(self.origin.x));
@@ -67,7 +67,7 @@ void UpdateFrags(entity player, float f)
 }
 
 void GiveFrags (entity attacker, entity targ, float f, int deathtype)
-{
+{SELFPARAM();
        // TODO route through PlayerScores instead
        if(gameover) return;
 
@@ -142,17 +142,9 @@ void GiveFrags (entity attacker, entity targ, float f, int deathtype)
        }
 
        // FIXME fix the mess this is (we have REAL points now!)
-       entity oldself;
-       oldself = self;
-       self = attacker;
-       if(MUTATOR_CALLHOOK(GiveFragsForKill, attacker, targ, f))
+       if(MUTATOR_CALLHOOK(GiveFragsForKill, self, attacker, targ, f))
        {
                f = frag_score;
-               self = oldself;
-       }
-       else
-       {
-               self = oldself;
        }
 
        attacker.totalfrags += f;
@@ -544,7 +536,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype)
 }
 
 void Ice_Think()
-{
+{SELFPARAM();
        if(!self.owner.frozen || self.owner.iceblock != self)
        {
                remove(self);
@@ -555,7 +547,7 @@ void Ice_Think()
 }
 
 void Freeze (entity targ, float freeze_time, float frozen_type, float show_waypoint)
-{
+{SELFPARAM();
        if(!IS_PLAYER(targ) && !IS_MONSTER(targ)) // only specified entities can be freezed
                return;
 
@@ -584,11 +576,7 @@ void Freeze (entity targ, float freeze_time, float frozen_type, float show_waypo
        targ.iceblock = ice;
        targ.revival_time = 0;
 
-       entity oldself;
-       oldself = self;
-       self = ice;
-       Ice_Think();
-       self = oldself;
+       WITH(entity, self, ice, Ice_Think());
 
        RemoveGrapplingHook(targ);
 
@@ -624,7 +612,7 @@ void Unfreeze (entity targ)
 }
 
 void Damage (entity targ, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        float mirrordamage;
        float mirrorforce;
        float complainteamdamage = 0;
@@ -635,9 +623,7 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d
        if (gameover || targ.killcount == -666)
                return;
 
-       entity oldself;
-       oldself = self;
-       self = targ;
+       setself(targ);
         damage_targ = targ;
         damage_inflictor = inflictor;
         damage_attacker = attacker;
@@ -655,7 +641,7 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d
                if(IS_PLAYER(targ))
                        if(SAME_TEAM(targ, attacker))
                        {
-                               self = oldself;
+                               setself(this);
                                return;
                        }
        }
@@ -775,8 +761,7 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d
                {
                        Send_Effect(EFFECT_TELEPORT, targ.origin, '0 0 0', 1);
 
-                       entity oldself = self;
-                       self = targ;
+                       setself(targ);
                        entity spot = SelectSpawnPoint (false);
 
                        if(spot)
@@ -806,7 +791,7 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d
                                Send_Effect(EFFECT_TELEPORT, self.origin, '0 0 0', 1);
                        }
 
-                       self = oldself;
+                       setself(this);
                }
 
                if(!g_instagib)
@@ -923,7 +908,7 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d
        if (damage != 0 || (self.damageforcescale && vlen(force)))
        if (self.event_damage)
                self.event_damage (inflictor, attacker, damage, deathtype, hitloc, force);
-       self = oldself;
+       setself(this);
 
        // apply mirror damage if any
        if(mirrordamage > 0 || mirrorforce > 0)
@@ -1313,7 +1298,7 @@ void Fire_ApplyEffect(entity e)
 }
 
 void fireburner_think()
-{
+{SELFPARAM();
        // for players, this is done in the regular loop
        if(wasfreed(self.owner))
        {
index d63a2ade0d8453e809204465d9f9acdd35c3369d..543432e4053f90037efa9ec6dcd035fc836b32ad 100644 (file)
@@ -80,7 +80,7 @@ void RemoveGrapplingHook(entity pl)
 }
 
 void GrapplingHookReset(void)
-{
+{SELFPARAM();
        if(self.realowner.hook == self)
                RemoveGrapplingHook(self.owner);
        else // in any case:
@@ -89,7 +89,7 @@ void GrapplingHookReset(void)
 
 void GrapplingHookThink();
 void GrapplingHook_Stop()
-{
+{SELFPARAM();
        Send_Effect(EFFECT_HOOK_IMPACT, self.origin, '0 0 0', 1);
        sound (self, CH_SHOTS, W_Sound("hook_impact"), VOL_BASE, ATTEN_NORM);
 
@@ -104,7 +104,7 @@ void GrapplingHook_Stop()
 
 .vector hook_start, hook_end;
 float GrapplingHookSend(entity to, int sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_HOOK);
        sf = sf & 0x7F;
        if(sound_allowed(MSG_BROADCAST, self.realowner))
@@ -130,7 +130,7 @@ float GrapplingHookSend(entity to, int sf)
 }
 
 void GrapplingHookThink()
-{
+{SELFPARAM();
        float spd, dist, minlength, pullspeed, ropestretch, ropeairfriction, rubberforce, newlength, rubberforce_overstretch;
        vector dir, org, end, v0, dv, v, myorg, vs;
        if(self.realowner.hook != self) // how did that happen?
@@ -300,7 +300,7 @@ void GrapplingHookThink()
 }
 
 void GrapplingHookTouch (void)
-{
+{SELFPARAM();
        if(other.movetype == MOVETYPE_FOLLOW)
                return;
        PROJECTILE_TOUCH;
@@ -318,7 +318,7 @@ void GrapplingHookTouch (void)
 }
 
 void GrapplingHook_Damage (entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        if(self.health <= 0)
                return;
 
@@ -340,7 +340,7 @@ void GrapplingHook_Damage (entity inflictor, entity attacker, float damage, int
 }
 
 void FireGrapplingHook (void)
-{
+{SELFPARAM();
        entity missile;
        vector org;
        vector vs;
@@ -423,7 +423,7 @@ void FireGrapplingHook (void)
 //         if((self.hook == world || !self.hook.state) && self.movetype == MOVETYPE_FLY)
 
 void GrapplingHookFrame()
-{
+{SELFPARAM();
        if(g_grappling_hook && timeout_status != TIMEOUT_ACTIVE && self.weapon != WEP_HOOK.m_id && !self.vehicle)
        {
                // offhand hook controls
@@ -531,7 +531,7 @@ void GrappleHookInit()
 }
 
 void SetGrappleHookBindings()
-{
+{SELFPARAM();
        // this function has been modified for Xonotic
        // don't remove these lines! old server or demos coud overwrite the new aliases
        stuffcmd(self, "alias +hook +button6\n");
index 62b2cfb51dd5d3a5c9a52a38b78d9654c0e97e58..8bb2b1b6afd5d4688a4d781d90aa89c9d02303e6 100644 (file)
@@ -10,7 +10,7 @@
 .float modelscale;
 
 void g_model_setcolormaptoactivator (void)
-{
+{SELFPARAM();
        if(teamplay)
        {
                if(activator.team)
@@ -24,13 +24,13 @@ void g_model_setcolormaptoactivator (void)
 }
 
 void g_clientmodel_setcolormaptoactivator (void)
-{
+{SELFPARAM();
        g_model_setcolormaptoactivator();
        self.SendFlags |= (8 | 1);
 }
 
 void g_clientmodel_use(void)
-{
+{SELFPARAM();
        if (self.antiwall_flag == 1)
        {
                self.inactive = 1;
@@ -45,7 +45,7 @@ void g_clientmodel_use(void)
 }
 
 void g_model_dropbyspawnflags()
-{
+{SELFPARAM();
        if((self.spawnflags & 3) == 1) // ALIGN_ORIGIN
        {
                traceline(self.origin, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
@@ -64,7 +64,7 @@ void g_model_dropbyspawnflags()
 }
 
 void g_clientmodel_dropbyspawnflags()
-{
+{SELFPARAM();
        vector o0;
        o0 = self.origin;
        g_model_dropbyspawnflags();
@@ -73,7 +73,7 @@ void g_clientmodel_dropbyspawnflags()
 }
 
 float g_clientmodel_genericsendentity (entity to, int sf)
-{
+{SELFPARAM();
        sf = sf & 0x0F;
        if(self.angles != '0 0 0')
                sf |= 0x10;
@@ -177,15 +177,15 @@ float g_clientmodel_genericsendentity (entity to, int sf)
        self.default_solid = sol;
 
 // non-solid model entities:
-void spawnfunc_misc_gamemodel()         { self.angles_x = -self.angles.x; G_MODEL_INIT      (SOLID_NOT) } // model entity
-void spawnfunc_misc_clientmodel()       { self.angles_x = -self.angles.x; G_CLIENTMODEL_INIT(SOLID_NOT) } // model entity
-void spawnfunc_misc_models()            { self.angles_x = -self.angles.x; G_MODEL_INIT      (SOLID_NOT) } // DEPRECATED old compat entity with confusing name, do not use
+void spawnfunc_misc_gamemodel()         { SELFPARAM(); self.angles_x = -self.angles.x; G_MODEL_INIT      (SOLID_NOT) } // model entity
+void spawnfunc_misc_clientmodel()       { SELFPARAM(); self.angles_x = -self.angles.x; G_CLIENTMODEL_INIT(SOLID_NOT) } // model entity
+void spawnfunc_misc_models()            { SELFPARAM(); self.angles_x = -self.angles.x; G_MODEL_INIT      (SOLID_NOT) } // DEPRECATED old compat entity with confusing name, do not use
 
 // non-solid brush entities:
-void spawnfunc_func_illusionary()       { G_MODEL_INIT      (SOLID_NOT) } // Q1 name (WARNING: MISPREDICTED)
-void spawnfunc_func_clientillusionary() { G_CLIENTMODEL_INIT(SOLID_NOT) } // brush entity
-void spawnfunc_func_static()            { G_MODEL_INIT      (SOLID_NOT) } // DEPRECATED old alias name from some other game
+void spawnfunc_func_illusionary()       { SELFPARAM(); G_MODEL_INIT      (SOLID_NOT) } // Q1 name (WARNING: MISPREDICTED)
+void spawnfunc_func_clientillusionary() { SELFPARAM(); G_CLIENTMODEL_INIT(SOLID_NOT) } // brush entity
+void spawnfunc_func_static()            { SELFPARAM(); G_MODEL_INIT      (SOLID_NOT) } // DEPRECATED old alias name from some other game
 
 // solid brush entities
-void spawnfunc_func_wall()              { G_MODEL_INIT      (SOLID_BSP) } // Q1 name
-void spawnfunc_func_clientwall()        { G_CLIENTMODEL_INIT(SOLID_BSP) } // brush entity (WARNING: MISPREDICTED)
+void spawnfunc_func_wall()              { SELFPARAM(); G_MODEL_INIT      (SOLID_BSP) } // Q1 name
+void spawnfunc_func_clientwall()        { SELFPARAM(); G_CLIENTMODEL_INIT(SOLID_BSP) } // brush entity (WARNING: MISPREDICTED)
index 3a242dcf32a81f157220ee8f95446589193aeaec..fc70c758a4ffcb389f348878a783e0cdda42d448 100644 (file)
@@ -6,7 +6,7 @@
 #include "../warpzonelib/common.qh"
 
 void spawnfunc_info_null (void)
-{
+{SELFPARAM();
        remove(self);
        // if anything breaks, tell the mapper to fix his map! info_null is meant to remove itself immediately.
 }
@@ -281,7 +281,7 @@ vector findbetterlocation (vector org, float mindist)
 }
 
 float LOD_customize()
-{
+{SELFPARAM();
        float d;
 
        if(autocvar_loddebug)
@@ -309,12 +309,12 @@ float LOD_customize()
 }
 
 void LOD_uncustomize()
-{
+{SELFPARAM();
        self.modelindex = self.lodmodelindex0;
 }
 
 void LODmodel_attach()
-{
+{SELFPARAM();
        entity e;
 
        if(!self.loddistance1)
@@ -374,7 +374,7 @@ void LODmodel_attach()
 }
 
 void ApplyMinMaxScaleAngles(entity e)
-{
+{SELFPARAM();
        if(e.angles.x != 0 || e.angles.z != 0 || self.avelocity.x != 0 || self.avelocity.z != 0) // "weird" rotation
        {
                e.maxs = '1 1 1' * vlen(
@@ -401,7 +401,7 @@ void ApplyMinMaxScaleAngles(entity e)
 }
 
 void SetBrushEntityModel()
-{
+{SELFPARAM();
        if(self.model != "")
        {
                precache_model(self.model);
@@ -421,7 +421,7 @@ void SetBrushEntityModel()
 }
 
 void SetBrushEntityModelNoLOD()
-{
+{SELFPARAM();
        if(self.model != "")
        {
                precache_model(self.model);
@@ -446,7 +446,7 @@ InitTrigger
 */
 
 void SetMovedir()
-{
+{SELFPARAM();
        if (self.movedir != '0 0 0')
                self.movedir = normalize(self.movedir);
        else
@@ -459,7 +459,7 @@ void SetMovedir()
 }
 
 void InitTrigger()
-{
+{SELFPARAM();
 // trigger angles are used for one-way touches.  An angle of 0 is assumed
 // to mean no restrictions, so use a yaw of 360 instead.
        SetMovedir ();
@@ -471,7 +471,7 @@ void InitTrigger()
 }
 
 void InitSolidBSPTrigger()
-{
+{SELFPARAM();
 // trigger angles are used for one-way touches.  An angle of 0 is assumed
 // to mean no restrictions, so use a yaw of 360 instead.
        SetMovedir ();
@@ -483,7 +483,7 @@ void InitSolidBSPTrigger()
 }
 
 float InitMovingBrushTrigger()
-{
+{SELFPARAM();
 // trigger angles are used for one-way touches.  An angle of 0 is assumed
 // to mean no restrictions, so use a yaw of 360 instead.
        self.solid = SOLID_BSP;
index 5bc8aafd377202719e58dd38569a70afedb452c5..a9111a03bc7f3ef231b3e4445df5d32f4a9e0abc 100644 (file)
@@ -2,7 +2,7 @@
 #include "_all.qh"
 
 float Violence_GibSplash_SendEntity(entity to, int sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_GIBSPLASH);
        WriteByte(MSG_ENTITY, self.state); // actually type
        WriteByte(MSG_ENTITY, bound(1, self.cnt * 16, 255)); // gibbage amount multiplier
@@ -15,7 +15,7 @@ float Violence_GibSplash_SendEntity(entity to, int sf)
 
 // TODO maybe convert this to a TE?
 void Violence_GibSplash_At(vector org, vector dir, float type, float amount, entity gibowner, entity attacker)
-{
+{SELFPARAM();
        if(g_cts) // no gibs in CTS
                return;
 
index 15c1ae68deebc79c6ede8126f218c3f4febb7c59..b15e847c59be00694a36cc89acc2d8406f7566b8 100644 (file)
@@ -41,7 +41,7 @@ const float LATENCY_THINKRATE = 10;
 .float latency_time;
 entity pingplreport;
 void PingPLReport_Think()
-{
+{SELFPARAM();
        float delta;
        entity e;
 
@@ -117,7 +117,7 @@ void SetDefaultAlpha()
 }
 
 void GotoFirstMap()
-{
+{SELFPARAM();
        float n;
        if(autocvar__sv_init)
        {
@@ -513,33 +513,29 @@ void detect_maptype()
 
 entity randomseed;
 float RandomSeed_Send(entity to, int sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_RANDOMSEED);
        WriteShort(MSG_ENTITY, self.cnt);
        return true;
 }
 void RandomSeed_Think()
-{
+{SELFPARAM();
        self.cnt = bound(0, floor(random() * 65536), 65535);
        self.nextthink = time + 5;
 
        self.SendFlags |= 1;
 }
 void RandomSeed_Spawn()
-{
+{SELFPARAM();
        randomseed = spawn();
        randomseed.think = RandomSeed_Think;
        Net_LinkEntity(randomseed, false, 0, RandomSeed_Send);
 
-       entity oldself;
-       oldself = self;
-       self = randomseed;
-       self.think(); // sets random seed and nextthink
-       self = oldself;
+       WITH(entity, self, randomseed, randomseed.think()); // sets random seed and nextthink
 }
 
 void spawnfunc___init_dedicated_server(void)
-{
+{SELFPARAM();
        // handler for _init/_init map (only for dedicated server initialization)
 
        world_initialized = -1; // don't complain
@@ -577,7 +573,7 @@ void WeaponStats_Init();
 void WeaponStats_Shutdown();
 void Physics_AddStats();
 void spawnfunc_worldspawn (void)
-{
+{SELFPARAM();
        float fd, l, j, n;
        string s;
 
@@ -926,7 +922,7 @@ void spawnfunc_worldspawn (void)
 }
 
 void spawnfunc_light (void)
-{
+{SELFPARAM();
        //makestatic (self); // Who the f___ did that?
        remove(self);
 }
@@ -1318,7 +1314,7 @@ When the player presses attack or jump, change to the next level
 */
 .float autoscreenshot;
 void IntermissionThink()
-{
+{SELFPARAM();
        FixIntermissionClient(self);
 
        float server_screenshot = (autocvar_sv_autoscreenshot && self.cvar_cl_autoscreenshot);
@@ -1595,7 +1591,7 @@ Exit deathmatch games upon conditions
 ============
 */
 void CheckRules_Player()
-{
+{SELFPARAM();
        if (gameover)   // someone else quit the game already
                return;
 
@@ -1694,7 +1690,7 @@ void ClearWinners(void)
 // they win. Otherwise the defending team wins once the timelimit passes.
 void assault_new_round();
 float WinningCondition_Assault()
-{
+{SELFPARAM();
        float status;
 
        WinningConditionHelper(); // set worldstatus
@@ -1727,11 +1723,7 @@ float WinningCondition_Assault()
                        }
                        else
                        {
-                               entity oldself;
-                               oldself = self;
-                               self = ent;
-                               assault_new_round();
-                               self = oldself;
+                               WITH(entity, self, ent, assault_new_round());
                        }
                }
        }
@@ -2202,19 +2194,20 @@ string GotoMap(string m)
 
 
 void EndFrame()
-{
+{SELFPARAM();
        anticheat_endframe();
 
        float altime;
-       FOR_EACH_REALCLIENT(self)
+       entity e_;
+       FOR_EACH_REALCLIENT(e_)
        {
-               entity e = IS_SPEC(self) ? self.enemy : self;
+               entity e = IS_SPEC(e_) ? e_.enemy : e_;
                if(e.typehitsound)
-                       self.typehit_time = time;
+                       e_.typehit_time = time;
                else if(e.damage_dealt)
                {
-                       self.hit_time = time;
-                       self.damage_dealt_total += ceil(e.damage_dealt);
+                       e_.hit_time = time;
+                       e_.damage_dealt_total += ceil(e.damage_dealt);
                }
        }
        altime = time + frametime * (1 + autocvar_g_antilag_nudge);
@@ -2223,14 +2216,18 @@ void EndFrame()
        // add another frametime because client shows everything with
        // 1 frame of lag (cl_nolerp 0). The last +1 however should not be
        // needed!
-       FOR_EACH_CLIENT(self)
+       FOR_EACH_CLIENT(e_)
        {
-               self.typehitsound = false;
-               self.damage_dealt = 0;
-               antilag_record(self, altime);
+               e_.typehitsound = false;
+               e_.damage_dealt = 0;
+               setself(e_);
+               antilag_record(e_, altime);
+       }
+       FOR_EACH_MONSTER(e_)
+       {
+               setself(e_);
+               antilag_record(e_, altime);
        }
-       FOR_EACH_MONSTER(self)
-               antilag_record(self, altime);
 }
 
 
@@ -2241,7 +2238,7 @@ void EndFrame()
 float redirection_timeout;
 float redirection_nextthink;
 float RedirectionThink()
-{
+{SELFPARAM();
        float clients_found;
 
        if(redirection_target == "")
@@ -2263,8 +2260,10 @@ float RedirectionThink()
        redirection_nextthink = time + 1;
 
        clients_found = 0;
-       FOR_EACH_REALCLIENT(self)
+       entity e;
+       FOR_EACH_REALCLIENT(e)
        {
+               setself(e);
                // TODO add timer
                LOG_INFO("Redirecting: sending connect command to ", self.netname, "\n");
                if(redirection_target == "self")
index 3e0b5171f249350679e64ec0cf9896ed4933227d..ec38521c6650670e43ddf00217db62a76131b756 100644 (file)
@@ -1,7 +1,7 @@
 #include "generator.qh"
 
 bool generator_send(entity to, int sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_GENERATOR);
        WriteByte(MSG_ENTITY, sf);
        if(sf & GSF_SETUP)
@@ -30,7 +30,7 @@ bool generator_send(entity to, int sf)
 }
 
 void generator_link(void() spawnproc)
-{
+{SELFPARAM();
        Net_LinkEntity(self, true, 0, generator_send);
        self.think              = spawnproc;
        self.nextthink  = time;
index 671137a645f37ae20583d838732205f1304f29e4..5bf648a0b5995b7269e7e10ceb09af334088ba44 100644 (file)
@@ -200,7 +200,7 @@ void OnlineBanList_URI_Get_Callback(float id, float status, string data)
 }
 
 void OnlineBanList_Think()
-{
+{SELFPARAM();
        float argc;
        string uri;
        float i, n;
index 1518151f2c85b457fff515b37634030b68f838b0..eccfbd91c79b40b094290b40307754f95873589f 100644 (file)
@@ -69,7 +69,8 @@ item_key
 /**
  * Key touch handler.
  */
-void item_key_touch(void) {
+void item_key_touch()
+{SELFPARAM();
        if (!IS_PLAYER(other))
                return;
 
@@ -86,7 +87,8 @@ void item_key_touch(void) {
 /**
  * Spawn a key with given model, key code and color.
  */
-void spawn_item_key() {
+void spawn_item_key()
+{SELFPARAM();
        precache_model(self.model);
 
        if (self.spawnflags & 1) // FLOATING
@@ -146,7 +148,8 @@ This is the only correct way to put keys on the map!
 
 itemkeys MUST always have exactly one bit set.
 */
-void spawnfunc_item_key() {
+void spawnfunc_item_key()
+{SELFPARAM();
        string _netname;
        vector _colormod;
 
@@ -252,7 +255,8 @@ FLOATING: the item will float in air, instead of aligning to the floor by fallin
 ---------NOTES----------
 Don't use this entity on new maps! Use item_key instead.
 */
-void spawnfunc_item_key1(void) {
+void spawnfunc_item_key1(void)
+{SELFPARAM();
        self.classname = "item_key";
        self.itemkeys = ITEM_KEY_BIT(1);
        spawnfunc_item_key();
@@ -270,7 +274,8 @@ FLOATING: the item will float in air, instead of aligning to the floor by fallin
 ---------NOTES----------
 Don't use this entity on new maps! Use item_key instead.
 */
-void spawnfunc_item_key2(void) {
+void spawnfunc_item_key2(void)
+{SELFPARAM();
        self.classname = "item_key";
        self.itemkeys = ITEM_KEY_BIT(0);
        spawnfunc_item_key();
index d453606d3946419c660cd4693d98730010b3f874..8e7deae8fe94c09023baa3181c93ac96ff540c15 100644 (file)
@@ -123,7 +123,7 @@ void MapVote_UnzoneStrings()
 }
 
 string MapVote_Suggest(string m)
-{
+{SELFPARAM();
        float i;
        if(m == "")
                return "That's not how to use this command.";
@@ -263,7 +263,7 @@ void MapVote_Init()
 }
 
 void MapVote_SendPicture(float id)
-{
+{SELFPARAM();
        msg_entity = self;
        WriteByte(MSG_ONE, SVC_TEMPENTITY);
        WriteByte(MSG_ONE, TE_CSQC_PICTURE);
index 55b8c2ea275665975078982819647dd378889b7e..e76545c73e769073c9e5f7593a58237c1b42871d 100644 (file)
@@ -241,7 +241,7 @@ string NearestLocation(vector p)
 }
 
 string formatmessage(string msg)
-{
+{SELFPARAM();
        float p, p1, p2;
        float n;
        vector cursor;
@@ -323,7 +323,7 @@ Called with:
   >0: receives a cvar from name=argv(f) value=argv(f+1)
 */
 void GetCvars_handleString(string thisname, float f, .string field, string name)
-{
+{SELFPARAM();
        if (f < 0)
        {
                if (self.(field))
@@ -343,7 +343,7 @@ void GetCvars_handleString(string thisname, float f, .string field, string name)
                stuffcmd(self, strcat("cl_cmd sendcvar ", name, "\n"));
 }
 void GetCvars_handleString_Fixup(string thisname, float f, .string field, string name, string(string) func)
-{
+{SELFPARAM();
        GetCvars_handleString(thisname, f, field, name);
        if (f >= 0) // also initialize to the fitting value for "" when sending cvars out
                if (thisname == name)
@@ -357,7 +357,7 @@ void GetCvars_handleString_Fixup(string thisname, float f, .string field, string
                }
 }
 void GetCvars_handleFloat(string thisname, float f, .float field, string name)
-{
+{SELFPARAM();
        if (f < 0)
        {
        }
@@ -370,7 +370,7 @@ void GetCvars_handleFloat(string thisname, float f, .float field, string name)
                stuffcmd(self, strcat("cl_cmd sendcvar ", name, "\n"));
 }
 void GetCvars_handleFloatOnce(string thisname, float f, .float field, string name)
-{
+{SELFPARAM();
        if (f < 0)
        {
        }
@@ -393,7 +393,7 @@ void GetCvars_handleFloatOnce(string thisname, float f, .float field, string nam
        }
 }
 string W_FixWeaponOrder_ForceComplete_AndBuildImpulseList(string wo)
-{
+{SELFPARAM();
        string o;
        o = W_FixWeaponOrder_ForceComplete(wo);
        if(self.weaponorder_byimpulse)
@@ -405,7 +405,7 @@ string W_FixWeaponOrder_ForceComplete_AndBuildImpulseList(string wo)
        return o;
 }
 void GetCvars(float f)
-{
+{SELFPARAM();
        string s = string_null;
 
        if (f > 0)
@@ -970,7 +970,7 @@ void precache_all_playermodels(string pattern)
 }
 
 void precache()
-{
+{SELFPARAM();
     // gamemode related things
     precache_model ("models/misc/chatbubble.spr");
        precache_model("models/ice/ice.md3");
@@ -1111,7 +1111,7 @@ void make_safe_for_remove(entity e)
 }
 
 void objerror(string s)
-{
+{SELFPARAM();
     make_safe_for_remove(self);
     builtin_objerror(s);
 }
@@ -1144,10 +1144,8 @@ void InitializeEntity(entity e, void(void) func, float order)
     if (!e || e.initialize_entity)
     {
         // make a proxy initializer entity
-        entity e_old;
-        e_old = e;
-        e = spawn();
-        e.classname = "initialize_entity";
+        entity e_old = e;
+        e = new(initialize_entity);
         e.enemy = e_old;
     }
 
@@ -1173,52 +1171,49 @@ void InitializeEntity(entity e, void(void) func, float order)
     }
 }
 void InitializeEntitiesRun()
-{
-    entity startoflist;
-    startoflist = initialize_entity_first;
-    initialize_entity_first = world;
+{SELFPARAM();
+    entity startoflist = initialize_entity_first;
+    initialize_entity_first = NULL;
     remove = remove_except_protected;
-    for (self = startoflist; self; self = self.initialize_entity_next)
+    for (entity e = startoflist; e; e = e.initialize_entity_next)
     {
-       self.remove_except_protected_forbidden = 1;
+               e.remove_except_protected_forbidden = 1;
     }
-    for (self = startoflist; self; )
+    for (entity e = startoflist; e; )
     {
-        entity e;
-        var void(void) func;
-        e = self.initialize_entity_next;
-        func = self.initialize_entity;
-        self.initialize_entity_order = 0;
-        self.initialize_entity = func_null;
-        self.initialize_entity_next = world;
-       self.remove_except_protected_forbidden = 0;
-        if (self.classname == "initialize_entity")
+               e.remove_except_protected_forbidden = 0;
+        e.initialize_entity_order = 0;
+       entity next = e.initialize_entity_next;
+        e.initialize_entity_next = NULL;
+        var void() func = e.initialize_entity;
+        e.initialize_entity = func_null;
+        if (e.classname == "initialize_entity")
         {
-            entity e_old;
-            e_old = self.enemy;
-            builtin_remove(self);
-            self = e_old;
+            entity wrappee = e.enemy;
+            builtin_remove(e);
+            e = wrappee;
+        }
+        //dprint("Delayed initialization: ", e.classname, "\n");
+        if (func)
+        {
+               WITH(entity, self, e, func());
         }
-        //dprint("Delayed initialization: ", self.classname, "\n");
-        if(func)
-            func();
         else
         {
-            eprint(self);
-            backtrace(strcat("Null function in: ", self.classname, "\n"));
+            eprint(e);
+            backtrace(strcat("Null function in: ", e.classname, "\n"));
         }
-        self = e;
+        e = next;
     }
     remove = remove_unsafely;
 }
 
 void UncustomizeEntitiesRun()
-{
-    entity oldself;
-    oldself = self;
-    for (self = world; (self = findfloat(self, uncustomizeentityforclient_set, 1)); )
-        self.uncustomizeentityforclient();
-    self = oldself;
+{SELFPARAM();
+    for (entity e = NULL; (e = findfloat(e, uncustomizeentityforclient_set, 1)); )
+    {
+        WITH(entity, self, e, e.uncustomizeentityforclient());
+    }
 }
 void SetCustomizer(entity e, float(void) customizer, void(void) uncustomizer)
 {
@@ -1228,7 +1223,7 @@ void SetCustomizer(entity e, float(void) customizer, void(void) uncustomizer)
 }
 
 void Net_LinkEntity(entity e, bool docull, float dt, bool(entity, int) sendfunc)
-{
+{SELFPARAM();
     vector mi, ma;
 
     if (e.classname == "")
@@ -1293,7 +1288,7 @@ void EliminatedPlayers_Init(float(entity) isEliminated_func)
 
 
 void adaptor_think2touch()
-{
+{SELFPARAM();
     entity o;
     o = other;
     other = world;
@@ -1302,7 +1297,7 @@ void adaptor_think2touch()
 }
 
 void adaptor_think2use()
-{
+{SELFPARAM();
     entity o, a;
     o = other;
     a = activator;
@@ -1314,7 +1309,7 @@ void adaptor_think2use()
 }
 
 void adaptor_think2use_hittype_splash() // for timed projectile detonation
-{
+{SELFPARAM();
        if(!(self.flags & FL_ONGROUND)) // if onground, we ARE touching something, but HITTYPE_SPLASH is to be networked if the damage causing projectile is not touching ANYTHING
                self.projectiledeathtype |= HITTYPE_SPLASH;
        adaptor_think2use();
@@ -1322,13 +1317,13 @@ void adaptor_think2use_hittype_splash() // for timed projectile detonation
 
 // deferred dropping
 void DropToFloor_Handler()
-{
+{SELFPARAM();
     builtin_droptofloor();
     self.dropped_origin = self.origin;
 }
 
 void droptofloor()
-{
+{SELFPARAM();
     InitializeEntity(self, DropToFloor_Handler, INITPRIO_DROPTOFLOOR);
 }
 
@@ -1384,7 +1379,7 @@ float tracebox_hits_box(vector start, vector mi, vector ma, vector end, vector t
 }
 
 float SUB_NoImpactCheck()
-{
+{SELFPARAM();
        // zero hitcontents = this is not the real impact, but either the
        // mirror-impact of something hitting the projectile instead of the
        // projectile hitting the something, or a touchareagrid one. Neither of
@@ -1421,7 +1416,7 @@ float SUB_NoImpactCheck()
 
 void W_Crylink_Dequeue(entity e);
 float WarpZone_Projectile_Touch_ImpactFilter_Callback()
-{
+{SELFPARAM();
        if(SUB_OwnerCheck())
                return true;
        if(SUB_NoImpactCheck())
@@ -1697,7 +1692,7 @@ vector shotorg_adjust_values(vector vecs, float y_is_right, float visual, float
 }
 
 vector shotorg_adjust(vector vecs, float y_is_right, float visual)
-{
+{SELFPARAM();
        return shotorg_adjust_values(vecs, y_is_right, visual, self.owner.cvar_cl_gunalign);
 }
 
@@ -1787,7 +1782,7 @@ vector gettaginfo_relative(entity e, float tag)
 .float scale2;
 
 float modeleffect_SendEntity(entity to, int sf)
-{
+{SELFPARAM();
        float f;
        WriteByte(MSG_ENTITY, ENT_CLIENT_MODELEFFECT);
 
index 994849f5572cfa712148705297c363cf48cbf079..acacba093a80dc2547da6206b6735dae9fa9ddab 100644 (file)
@@ -8,7 +8,7 @@
     self.velocity = movelib_dragvec(self.velocity,0.02,0.5);
 **/
 vector movelib_dragvec(float drag, float exp_)
-{
+{SELFPARAM();
     float lspeed,ldrag;
 
     lspeed = vlen(self.velocity);
@@ -40,7 +40,7 @@ float movelib_dragflt(float fspeed,float drag,float exp_)
     self.velocity = movelib_inertmove_byspeed(self.velocity,newvel,1000,0.1,0.9);
 **/
 vector movelib_inertmove_byspeed(vector vel_new, float vel_max,float newmin,float oldmax)
-{
+{SELFPARAM();
     float influense;
 
     influense = vlen(self.velocity) * (1 / vel_max);
@@ -51,12 +51,12 @@ vector movelib_inertmove_byspeed(vector vel_new, float vel_max,float newmin,floa
 }
 
 vector movelib_inertmove(vector new_vel,float new_bias)
-{
+{SELFPARAM();
     return new_vel * new_bias + self.velocity * (1-new_bias);
 }
 
 void movelib_move(vector force,float max_velocity,float drag,float theMass,float breakforce)
-{
+{SELFPARAM();
     float deltatime;
     float acceleration;
     float mspeed;
@@ -164,7 +164,7 @@ void movelib_update(vector dir,float force)
 */
 
 void movelib_beak_simple(float force)
-{
+{SELFPARAM();
     float mspeed;
     vector mdir;
     float vz;
@@ -183,7 +183,7 @@ Yed need to set v_up and v_forward (generally by calling makevectors) before cal
 #endif
 
 void movelib_groundalign4point(float spring_length, float spring_up, float blendrate, float _max)
-{
+{SELFPARAM();
     vector a, b, c, d, e, r, push_angle, ahead, side;
 
     push_angle.y = 0;
index e867e049a398cb1b253638644c6836573094a6d4..881938f06809030eb83eb4c28aa10241de785165 100644 (file)
@@ -12,7 +12,7 @@ MUTATOR_HOOKABLE(MakePlayerObserver, EV_MakePlayerObserver)
 
 /** */
 #define EV_PutClientInServer(i, o) \
-    /** client wanting to spawn */ i(entity, self) \
+    /** client wanting to spawn */ i(entity, __self) \
     /**/
 MUTATOR_HOOKABLE(PutClientInServer, EV_PutClientInServer);
 
@@ -106,6 +106,7 @@ MUTATOR_HOOKABLE(PlayerJump, EV_PlayerJump);
 
 /** called when someone was fragged by "self", and is expected to change frag_score to adjust scoring for the kill */
 #define EV_GiveFragsForKill(i, o) \
+    /**/ i(entity, __self) \
     /** same as self */ i(entity, frag_attacker) \
     /**/ i(entity, frag_target) \
     /**/ i(float, frag_score) \
@@ -128,7 +129,7 @@ MUTATOR_HOOKABLE(GetTeamCount, EV_GetTeamCount);
 /** copies variables for spectating "other" to "self" */
 #define EV_SpectateCopy(i, o) \
     /**/ i(entity, other) \
-    /**/ i(entity, self) \
+    /**/ i(entity, __self) \
     /**/
 MUTATOR_HOOKABLE(SpectateCopy, EV_SpectateCopy);
 
@@ -167,7 +168,7 @@ MUTATOR_HOOKABLE(SetStartItems, EV_NO_ARGS);
 
 /** called every frame. customizes the waypoint for spectators */
 #define EV_CustomizeWaypoint(i, o) \
-    /** waypoint */ i(entity, self) \
+    /** waypoint */ i(entity, __self) \
     /** player; other.enemy = spectator */ i(entity, other) \
     /**/
 MUTATOR_HOOKABLE(CustomizeWaypoint, EV_CustomizeWaypoint);
@@ -180,13 +181,13 @@ MUTATOR_HOOKABLE(FilterItem, EV_NO_ARGS);
 
 /** return error to request removal */
 #define EV_TurretSpawn(i, o) \
-    /** turret */ i(entity, self) \
+    /** turret */ i(entity, __self) \
     /**/
 MUTATOR_HOOKABLE(TurretSpawn, EV_TurretSpawn);
 
 /** return error to not attack */
 #define EV_TurretFire(i, o) \
-    /** turret */ i(entity, self) \
+    /** turret */ i(entity, __self) \
     /**/
 MUTATOR_HOOKABLE(TurretFire, EV_TurretFire);
 
@@ -224,7 +225,7 @@ MUTATOR_HOOKABLE(GetCvars, EV_NO_ARGS); // NOTE: Can't use EV_GetCvars because o
 
 /** can edit any "just fired" projectile */
 #define EV_EditProjectile(i, o) \
-    /**/ i(entity, self) \
+    /**/ i(entity, __self) \
     /**/ i(entity, other) \
     /**/
 MUTATOR_HOOKABLE(EditProjectile, EV_EditProjectile);
@@ -338,7 +339,7 @@ MUTATOR_HOOKABLE(PlayerDamaged, EV_PlayerDamaged);
 
 /** called at the end of player_powerups() in cl_client.qc, used for manipulating the values which are set by powerup items. */
 #define EV_PlayerPowerups(i, o) \
-    /**/ i(entity, self) \
+    /**/ i(entity, __self) \
     /**/ i(int, olditems) \
     /**/
 int olditems;
@@ -416,7 +417,7 @@ MUTATOR_HOOKABLE(SV_ParseServerCommand, EV_SV_ParseServerCommand);
  * return 1 to make the spawnpoint unusable
  */
 #define EV_Spawn_Score(i, o) \
-    /** player wanting to spawn */ i(entity, self) \
+    /** player wanting to spawn */ i(entity, __self) \
     /** spot to be evaluated */ i(entity, spawn_spot) \
     /** _x is priority, _y is "distance" */ i(vector, spawn_score) \
     /**/ o(vector, spawn_score) \
@@ -438,12 +439,12 @@ MUTATOR_HOOKABLE(SetModname, EV_SetModname);
  * return 1 to remove an item
  */
 #define EV_Item_Spawn(i, o) \
-    /** the item */ i(entity, self) \
+    /** the item */ i(entity, __self) \
     /**/
 MUTATOR_HOOKABLE(Item_Spawn, EV_Item_Spawn);
 
 #define EV_SetWeaponreplace(i, o) \
-    /** map entity */ i(entity, self) \
+    /** map entity */ i(entity, __self) \
     /** weapon info */ i(entity, other) \
     /**/ i(string, ret_string) \
     /**/ o(string, ret_string) \
@@ -473,7 +474,7 @@ MUTATOR_HOOKABLE(BotShouldAttack, EV_BotShouldAttack);
  * allows you to strip a player of an item if they go through the teleporter to help prevent cheating
  */
 #define EV_PortalTeleport(i, o) \
-    /**/ i(entity, self) \
+    /**/ i(entity, __self) \
     /**/
 MUTATOR_HOOKABLE(PortalTeleport, EV_PortalTeleport);
 
@@ -484,7 +485,7 @@ MUTATOR_HOOKABLE(PortalTeleport, EV_PortalTeleport);
  * in a special manner using this hook
  */
 #define EV_HelpMePing(i, o) \
-    /** the player who pressed impulse 33 */ i(entity, self) \
+    /** the player who pressed impulse 33 */ i(entity, __self) \
     /**/
 MUTATOR_HOOKABLE(HelpMePing, EV_HelpMePing);
 
@@ -511,7 +512,7 @@ MUTATOR_HOOKABLE(VehicleEnter, EV_VehicleEnter);
  * return true to stop player from entering the vehicle
  */
 #define EV_VehicleTouch(i, o) \
-    /** vehicle */ i(entity, self) \
+    /** vehicle */ i(entity, __self) \
     /** player */ i(entity, other) \
     /**/
 MUTATOR_HOOKABLE(VehicleTouch, EV_VehicleTouch);
@@ -528,13 +529,13 @@ MUTATOR_HOOKABLE(VehicleExit, EV_VehicleExit);
 
 /** called when a speedrun is aborted and the player is teleported back to start position */
 #define EV_AbortSpeedrun(i, o) \
-    /** player */ i(entity, self) \
+    /** player */ i(entity, __self) \
     /**/
 MUTATOR_HOOKABLE(AbortSpeedrun, EV_AbortSpeedrun);
 
 /** called at when a item is touched. Called early, can edit item properties. */
 #define EV_ItemTouch(i, o) \
-    /** item */ i(entity, self) \
+    /** item */ i(entity, __self) \
     /** player */ i(entity, other) \
     /**/
 MUTATOR_HOOKABLE(ItemTouch, EV_ItemTouch);
@@ -547,12 +548,12 @@ enum {
 
 /** called at when a player connect */
 #define EV_ClientConnect(i, o) \
-    /** player */ i(entity, self) \
+    /** player */ i(entity, __self) \
     /**/
 MUTATOR_HOOKABLE(ClientConnect, EV_ClientConnect);
 
 #define EV_HavocBot_ChooseRole(i, o) \
-    /**/ i(entity, self) \
+    /**/ i(entity, __self) \
     /**/
 MUTATOR_HOOKABLE(HavocBot_ChooseRole, EV_HavocBot_ChooseRole);
 
@@ -581,7 +582,7 @@ MUTATOR_HOOKABLE(GetModelParams, EV_GetModelParams);
 
 /** called when a bullet has hit a target */
 #define EV_FireBullet_Hit(i, o) \
-    /**/ i(entity, self) \
+    /**/ i(entity, __self) \
     /**/ i(entity, bullet_hit) \
     /**/ i(vector, bullet_startpos) \
     /**/ i(vector, bullet_endpos) \
@@ -608,7 +609,7 @@ MUTATOR_HOOKABLE(FixPlayermodel, EV_FixPlayermodel);
 MUTATOR_HOOKABLE(Scores_CountFragsRemaining, EV_NO_ARGS);
 
 #define EV_GrappleHookThink(i, o) \
-    /**/ i(entity, self) \
+    /**/ i(entity, __self) \
     /**/ i(int, hook_tarzan) \
     /**/ o(int, hook_tarzan) \
     /**/ i(entity, hook_pullentity) \
@@ -622,7 +623,7 @@ float hook_velmultiplier;
 MUTATOR_HOOKABLE(GrappleHookThink, EV_GrappleHookThink);
 
 #define EV_BuffModel_Customize(i, o) \
-    /**/ i(entity, self) \
+    /**/ i(entity, __self) \
     /**/ i(entity, buff_player) \
     /**/
 entity buff_player;
@@ -630,7 +631,7 @@ MUTATOR_HOOKABLE(BuffModel_Customize, EV_BuffModel_Customize);
 
 /** called at when a buff is touched. Called early, can edit buff properties. */
 #define EV_BuffTouch(i, o) \
-    /** item */ i(entity, self) \
+    /** item */ i(entity, __self) \
     /** player */ i(entity, other) \
     /**/
 MUTATOR_HOOKABLE(BuffTouch, EV_BuffTouch);
index 7e13b334d38d5e56a9547d89ddaaaa86e766e966..239c3d3b4bf262da7ab8ba7d1cc2120930505f1c 100644 (file)
@@ -7,26 +7,25 @@
 
 // random functions
 void assault_objective_use()
-{
+{SELFPARAM();
        // activate objective
        self.health = 100;
        //print("^2Activated objective ", self.targetname, "=", etos(self), "\n");
        //print("Activator is ", activator.classname, "\n");
 
-       entity oldself;
-       oldself = self;
-
-       for(self = world; (self = find(self, target, oldself.targetname)); )
+       for (entity e = world; (e = find(e, target, this.targetname)); )
        {
-               if(self.classname == "target_objective_decrease")
-                       target_objective_decrease_activate();
+               if (e.classname == "target_objective_decrease")
+               {
+                       WITH(entity, self, e, target_objective_decrease_activate());
+               }
        }
 
-       self = oldself;
+       setself(this);
 }
 
 vector target_objective_spawn_evalfunc(entity player, entity spot, vector current)
-{
+{SELFPARAM();
        if(self.health < 0 || self.health >= ASSAULT_VALUE_INACTIVE)
                return '-1 0 0';
        return current;
@@ -35,13 +34,13 @@ vector target_objective_spawn_evalfunc(entity player, entity spot, vector curren
 // reset this objective. Used when spawning an objective
 // and when a new round starts
 void assault_objective_reset()
-{
+{SELFPARAM();
        self.health = ASSAULT_VALUE_INACTIVE;
 }
 
 // decrease the health of targeted objectives
 void assault_objective_decrease_use()
-{
+{SELFPARAM();
        if(activator.team != assault_attacker_team)
        {
                // wrong team triggered decrease
@@ -70,25 +69,24 @@ void assault_objective_decrease_use()
                        PlayerTeamScore_Add(activator, SP_ASSAULT_OBJECTIVES, ST_ASSAULT_OBJECTIVES, 1);
                        self.enemy.health = -1;
 
-                       entity oldself, oldactivator, head;
+                       entity oldactivator, head;
 
-                       oldself = self;
-                       self = oldself.enemy;
+                       setself(this.enemy);
                        if(self.message)
                        FOR_EACH_PLAYER(head)
                                centerprint(head, self.message);
 
                        oldactivator = activator;
-                       activator = oldself;
+                       activator = this;
                        SUB_UseTargets();
                        activator = oldactivator;
-                       self = oldself;
+                       setself(this);
                }
        }
 }
 
 void assault_setenemytoobjective()
-{
+{SELFPARAM();
        entity objective;
        for(objective = world; (objective = find(objective, targetname, self.target)); )
        {
@@ -107,7 +105,7 @@ void assault_setenemytoobjective()
 }
 
 float assault_decreaser_sprite_visible(entity e)
-{
+{SELFPARAM();
        entity decreaser;
 
        decreaser = self.assault_decreaser;
@@ -119,7 +117,7 @@ float assault_decreaser_sprite_visible(entity e)
 }
 
 void target_objective_decrease_activate()
-{
+{SELFPARAM();
        entity ent, spr;
        self.owner = world;
        for(ent = world; (ent = find(ent, target, self.targetname)); )
@@ -154,46 +152,37 @@ void target_objective_decrease_findtarget()
 }
 
 void target_assault_roundend_reset()
-{
+{SELFPARAM();
        //print("round end reset\n");
        self.cnt = self.cnt + 1; // up round counter
        self.winning = 0; // up round
 }
 
 void target_assault_roundend_use()
-{
+{SELFPARAM();
        self.winning = 1; // round has been won by attackers
 }
 
 void assault_roundstart_use()
-{
+{SELFPARAM();
        activator = self;
        SUB_UseTargets();
 
-       entity ent, oldself;
-
        //(Re)spawn all turrets
-       oldself = self;
-       ent = find(world, classname, "turret_main");
-       while(ent) {
+       for(entity ent = NULL; (ent = find(ent, classname, "turret_main")); ) {
                // Swap turret teams
                if(ent.team == NUM_TEAM_1)
                        ent.team = NUM_TEAM_2;
                else
                        ent.team = NUM_TEAM_1;
 
-               self = ent;
-
                // Dubbles as teamchange
-               turret_respawn();
-
-               ent = find(ent, classname, "turret_main");
+               WITH(entity, self, ent, turret_respawn());
        }
-       self = oldself;
 }
 
 void assault_wall_think()
-{
+{SELFPARAM();
        if(self.enemy.health < 0)
        {
                self.model = "";
@@ -213,27 +202,27 @@ void assault_wall_think()
 void vehicles_clearreturn(entity veh);
 void vehicles_spawn();
 void assault_new_round()
-{
-    entity oldself;
+{SELFPARAM();
        //bprint("ASSAULT: new round\n");
 
-       oldself = self;
        // Eject players from vehicles
-    FOR_EACH_PLAYER(self)
+       entity e;
+    FOR_EACH_PLAYER(e)
     {
-        if(self.vehicle)
-            vehicles_exit(VHEF_RELEASE);
+        if(e.vehicle)
+        {
+               WITH(entity, self, e, vehicles_exit(VHEF_RELEASE));
+        }
     }
 
-    self = findchainflags(vehicle_flags, VHF_ISVEHICLE);
-    while(self)
+    for (entity e_ = findchainflags(vehicle_flags, VHF_ISVEHICLE); e_; e_ = e_.chain)
     {
+       setself(e_);
         vehicles_clearreturn(self);
         vehicles_spawn();
-        self = self.chain;
     }
 
-    self = oldself;
+    setself(this);
 
        // up round counter
        self.winning = self.winning + 1;
@@ -263,7 +252,7 @@ void assault_new_round()
 
 // spawnfuncs
 void spawnfunc_info_player_attacker()
-{
+{SELFPARAM();
        if (!g_assault) { remove(self); return; }
 
        self.team = NUM_TEAM_1; // red, gets swapped every round
@@ -271,7 +260,7 @@ void spawnfunc_info_player_attacker()
 }
 
 void spawnfunc_info_player_defender()
-{
+{SELFPARAM();
        if (!g_assault) { remove(self); return; }
 
        self.team = NUM_TEAM_2; // blue, gets swapped every round
@@ -279,7 +268,7 @@ void spawnfunc_info_player_defender()
 }
 
 void spawnfunc_target_objective()
-{
+{SELFPARAM();
        if (!g_assault) { remove(self); return; }
 
        self.classname = "target_objective";
@@ -290,7 +279,7 @@ void spawnfunc_target_objective()
 }
 
 void spawnfunc_target_objective_decrease()
-{
+{SELFPARAM();
        if (!g_assault) { remove(self); return; }
 
        self.classname = "target_objective_decrease";
@@ -308,7 +297,7 @@ void spawnfunc_target_objective_decrease()
 
 // destructible walls that can be used to trigger target_objective_decrease
 void spawnfunc_func_assault_destructible()
-{
+{SELFPARAM();
        if (!g_assault) { remove(self); return; }
 
        self.spawnflags = 3;
@@ -323,7 +312,7 @@ void spawnfunc_func_assault_destructible()
 }
 
 void spawnfunc_func_assault_wall()
-{
+{SELFPARAM();
        if (!g_assault) { remove(self); return; }
 
        self.classname = "func_assault_wall";
@@ -336,7 +325,7 @@ void spawnfunc_func_assault_wall()
 }
 
 void spawnfunc_target_assault_roundend()
-{
+{SELFPARAM();
        if (!g_assault) { remove(self); return; }
 
        self.winning = 0; // round not yet won by attackers
@@ -347,7 +336,7 @@ void spawnfunc_target_assault_roundend()
 }
 
 void spawnfunc_target_assault_roundstart()
-{
+{SELFPARAM();
        if (!g_assault) { remove(self); return; }
 
        assault_attacker_team = NUM_TEAM_1;
@@ -359,7 +348,7 @@ void spawnfunc_target_assault_roundstart()
 
 // legacy bot code
 void havocbot_goalrating_ast_targets(float ratingscale)
-{
+{SELFPARAM();
        entity ad, best, wp, tod;
        float radius, found, bestvalue;
        vector p;
@@ -445,7 +434,7 @@ void havocbot_goalrating_ast_targets(float ratingscale)
 }
 
 void havocbot_role_ast_offense()
-{
+{SELFPARAM();
        if(self.deadflag != DEAD_NO)
        {
                self.havocbot_attack_time = 0;
@@ -479,7 +468,7 @@ void havocbot_role_ast_offense()
 }
 
 void havocbot_role_ast_defense()
-{
+{SELFPARAM();
        if(self.deadflag != DEAD_NO)
        {
                self.havocbot_attack_time = 0;
@@ -530,7 +519,7 @@ void havocbot_role_ast_setrole(entity bot, float role)
 }
 
 void havocbot_ast_reset_role(entity bot)
-{
+{SELFPARAM();
        if(self.deadflag != DEAD_NO)
                return;
 
@@ -542,7 +531,7 @@ void havocbot_ast_reset_role(entity bot)
 
 // mutator hooks
 MUTATOR_HOOKFUNCTION(assault_PlayerSpawn)
-{
+{SELFPARAM();
        if(self.team == assault_attacker_team)
                Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_ASSAULT_ATTACKING);
        else
@@ -552,7 +541,7 @@ MUTATOR_HOOKFUNCTION(assault_PlayerSpawn)
 }
 
 MUTATOR_HOOKFUNCTION(assault_TurretSpawn)
-{
+{SELFPARAM();
        if(!self.team || self.team == MAX_SHOT_DISTANCE)
                self.team = 5; // this gets reversed when match starts?
 
@@ -560,14 +549,14 @@ MUTATOR_HOOKFUNCTION(assault_TurretSpawn)
 }
 
 MUTATOR_HOOKFUNCTION(assault_VehicleSpawn)
-{
+{SELFPARAM();
        self.nextthink = time + 0.5;
 
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(assault_BotRoles)
-{
+{SELFPARAM();
        havocbot_ast_reset_role(self);
        return true;
 }
index f4c4f6826d34be248dc7e9b49df280161d6e7980..570fc38016ca43cca22568cab450e85e969dc583 100644 (file)
@@ -163,7 +163,7 @@ float ca_isEliminated(entity e)
 }
 
 MUTATOR_HOOKFUNCTION(ca_PlayerSpawn)
-{
+{SELFPARAM();
        self.caplayer = 1;
        if(!warmup_stage)
                eliminatedPlayers.SendFlags |= 1;
@@ -171,7 +171,7 @@ MUTATOR_HOOKFUNCTION(ca_PlayerSpawn)
 }
 
 MUTATOR_HOOKFUNCTION(ca_PutClientInServer)
-{
+{SELFPARAM();
        if(!allowed_to_spawn)
        if(IS_PLAYER(self)) // this is true even when player is trying to join
        {
@@ -188,9 +188,11 @@ MUTATOR_HOOKFUNCTION(ca_PutClientInServer)
 }
 
 MUTATOR_HOOKFUNCTION(ca_reset_map_players)
-{
-       FOR_EACH_CLIENT(self)
+{SELFPARAM();
+       entity e;
+       FOR_EACH_CLIENT(e)
        {
+               setself(e);
                self.killcount = 0;
                if(!self.caplayer && IS_BOT_CLIENT(self))
                {
@@ -208,7 +210,7 @@ MUTATOR_HOOKFUNCTION(ca_reset_map_players)
 }
 
 MUTATOR_HOOKFUNCTION(ca_ClientConnect)
-{
+{SELFPARAM();
        self.classname = "observer";
        return 1;
 }
@@ -226,7 +228,7 @@ MUTATOR_HOOKFUNCTION(ca_GetTeamCount)
 }
 
 entity ca_LastPlayerForTeam()
-{
+{SELFPARAM();
        entity pl, last_pl = world;
        FOR_EACH_PLAYER(pl)
        {
@@ -253,7 +255,7 @@ void ca_LastPlayerForTeam_Notify()
 }
 
 MUTATOR_HOOKFUNCTION(ca_PlayerDies)
-{
+{SELFPARAM();
        ca_LastPlayerForTeam_Notify();
        if(!allowed_to_spawn)
                self.respawn_flags =  RESPAWN_SILENT;
@@ -263,7 +265,7 @@ MUTATOR_HOOKFUNCTION(ca_PlayerDies)
 }
 
 MUTATOR_HOOKFUNCTION(ca_ClientDisconnect)
-{
+{SELFPARAM();
        if(self.caplayer == 1)
                ca_LastPlayerForTeam_Notify();
        return 1;
@@ -275,7 +277,7 @@ MUTATOR_HOOKFUNCTION(ca_ForbidPlayerScore_Clear)
 }
 
 MUTATOR_HOOKFUNCTION(ca_MakePlayerObserver)
-{
+{SELFPARAM();
        if(self.caplayer == 1)
                ca_LastPlayerForTeam_Notify();
        if(self.killindicator_teamchange == -2)
@@ -326,7 +328,7 @@ MUTATOR_HOOKFUNCTION(ca_PlayerDamage)
 }
 
 MUTATOR_HOOKFUNCTION(ca_FilterItem)
-{
+{SELFPARAM();
        if(autocvar_g_powerups <= 0)
        if(self.flags & FL_POWERUP)
                return true;
index 0df123e3a44655d7bc1f602ea7f97504068e1e9f..6cf7c1a6546b4044f0a2a2bf8f69e763bfdcf6b1 100644 (file)
@@ -179,7 +179,7 @@ void ctf_CaptureShield_Update(entity player, bool wanted_status)
 }
 
 bool ctf_CaptureShield_Customize()
-{
+{SELFPARAM();
        if(!other.ctf_captureshielded) { return false; }
        if(CTF_SAMETEAM(self, other)) { return false; }
 
@@ -187,7 +187,7 @@ bool ctf_CaptureShield_Customize()
 }
 
 void ctf_CaptureShield_Touch()
-{
+{SELFPARAM();
        if(!other.ctf_captureshielded) { return; }
        if(CTF_SAMETEAM(self, other)) { return; }
 
@@ -199,7 +199,7 @@ void ctf_CaptureShield_Touch()
 }
 
 void ctf_CaptureShield_Spawn(entity flag)
-{
+{SELFPARAM();
        entity shield = spawn();
 
        shield.enemy = self;
@@ -649,7 +649,7 @@ void ctf_CheckFlagReturn(entity flag, int returntype)
 }
 
 bool ctf_Stalemate_Customize()
-{
+{SELFPARAM();
        // make spectators see what the player would see
        entity e, wp_owner;
        e = WaypointSprite_getviewentity(other);
@@ -730,7 +730,7 @@ void ctf_CheckStalemate(void)
 }
 
 void ctf_FlagDamage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        if(ITEM_DAMAGE_NEEDKILL(deathtype))
        {
                if(autocvar_g_ctf_flag_return_damage_delay)
@@ -754,7 +754,7 @@ void ctf_FlagDamage(entity inflictor, entity attacker, float damage, int deathty
 }
 
 void ctf_FlagThink()
-{
+{SELFPARAM();
        // declarations
        entity tmp_entity;
 
@@ -846,11 +846,10 @@ void ctf_FlagThink()
                                self.health = 0;
                                ctf_CheckFlagReturn(self, RETURN_SPEEDRUN);
 
-                               tmp_entity = self;
-                               self = self.owner;
+                               setself(self.owner);
                                self.impulse = CHIMPULSE_SPEEDRUN; // move the player back to the waypoint they set
                                ImpulseCommands();
-                               self = tmp_entity;
+                               setself(this);
                        }
                        if(autocvar_g_ctf_stalemate)
                        {
@@ -903,7 +902,7 @@ void ctf_FlagThink()
 }
 
 void ctf_FlagTouch()
-{
+{SELFPARAM();
        if(gameover) { return; }
        if(trace_dphitcontents & (DPCONTENTS_PLAYERCLIP | DPCONTENTS_MONSTERCLIP)) { return; }
 
@@ -1049,7 +1048,7 @@ void ctf_RespawnFlag(entity flag)
 }
 
 void ctf_Reset()
-{
+{SELFPARAM();
        if(self.owner)
                if(IS_PLAYER(self.owner))
                        ctf_Handle_Throw(self.owner, world, DROP_RESET);
@@ -1058,7 +1057,7 @@ void ctf_Reset()
 }
 
 void ctf_DelayedFlagSetup(void) // called after a flag is placed on a map by ctf_FlagSetup()
-{
+{SELFPARAM();
        // bot waypoints
        waypoint_spawnforitem_force(self, self.origin);
        self.nearestwaypointtimeout = 0; // activate waypointing again
@@ -1090,10 +1089,10 @@ void set_flag_string(entity flag, .string field, string value, string teamname)
 }
 
 void ctf_FlagSetup(int teamnumber, entity flag) // called when spawning a flag entity on the map as a spawnfunc
-{
+{SELFPARAM();
        // declarations
        string teamname = Static_Team_ColorName_Lower(teamnumber);
-       self = flag; // for later usage with droptofloor()
+       setself(flag); // for later usage with droptofloor()
 
        // main setup
        flag.ctf_worldflagnext = ctf_worldflaglist; // link flag into ctf_worldflaglist
@@ -1197,7 +1196,7 @@ void ctf_FlagSetup(int teamnumber, entity flag) // called when spawning a flag e
        else // drop to floor, automatically find a platform and set that as spawn origin
        {
                flag.noalign = false;
-               self = flag;
+               setself(flag);
                droptofloor();
                flag.movetype = MOVETYPE_TOSS;
        }
@@ -1293,7 +1292,7 @@ int havocbot_ctf_teamcount(entity bot, vector org, float tc_radius)
 }
 
 void havocbot_goalrating_ctf_ourflag(float ratingscale)
-{
+{SELFPARAM();
        entity head;
        head = ctf_worldflaglist;
        while (head)
@@ -1307,7 +1306,7 @@ void havocbot_goalrating_ctf_ourflag(float ratingscale)
 }
 
 void havocbot_goalrating_ctf_ourbase(float ratingscale)
-{
+{SELFPARAM();
        entity head;
        head = ctf_worldflaglist;
        while (head)
@@ -1323,7 +1322,7 @@ void havocbot_goalrating_ctf_ourbase(float ratingscale)
 }
 
 void havocbot_goalrating_ctf_enemyflag(float ratingscale)
-{
+{SELFPARAM();
        entity head;
        head = ctf_worldflaglist;
        while (head)
@@ -1350,7 +1349,7 @@ void havocbot_goalrating_ctf_enemyflag(float ratingscale)
 }
 
 void havocbot_goalrating_ctf_enemybase(float ratingscale)
-{
+{SELFPARAM();
        if (!bot_waypoints_for_items)
        {
                havocbot_goalrating_ctf_enemyflag(ratingscale);
@@ -1368,7 +1367,7 @@ void havocbot_goalrating_ctf_enemybase(float ratingscale)
 }
 
 void havocbot_goalrating_ctf_ourstolenflag(float ratingscale)
-{
+{SELFPARAM();
        entity mf;
 
        mf = havocbot_ctf_find_flag(self);
@@ -1404,7 +1403,7 @@ void havocbot_goalrating_ctf_droppedflags(float ratingscale, vector org, float d
 }
 
 void havocbot_goalrating_ctf_carrieritems(float ratingscale, vector org, float sradius)
-{
+{SELFPARAM();
        entity head;
        float t;
        head = findchainfloat(bot_pickup, true);
@@ -1491,7 +1490,7 @@ void havocbot_ctf_reset_role(entity bot)
 }
 
 void havocbot_role_ctf_carrier()
-{
+{SELFPARAM();
        if(self.deadflag != DEAD_NO)
        {
                havocbot_ctf_reset_role(self);
@@ -1532,7 +1531,7 @@ void havocbot_role_ctf_carrier()
 }
 
 void havocbot_role_ctf_escort()
-{
+{SELFPARAM();
        entity mf, ef;
 
        if(self.deadflag != DEAD_NO)
@@ -1592,7 +1591,7 @@ void havocbot_role_ctf_escort()
 }
 
 void havocbot_role_ctf_offense()
-{
+{SELFPARAM();
        entity mf, ef;
        vector pos;
 
@@ -1674,7 +1673,7 @@ void havocbot_role_ctf_offense()
 
 // Retriever (temporary role):
 void havocbot_role_ctf_retriever()
-{
+{SELFPARAM();
        entity mf;
 
        if(self.deadflag != DEAD_NO)
@@ -1722,7 +1721,7 @@ void havocbot_role_ctf_retriever()
 }
 
 void havocbot_role_ctf_middle()
-{
+{SELFPARAM();
        entity mf;
 
        if(self.deadflag != DEAD_NO)
@@ -1773,7 +1772,7 @@ void havocbot_role_ctf_middle()
 }
 
 void havocbot_role_ctf_defense()
-{
+{SELFPARAM();
        entity mf;
 
        if(self.deadflag != DEAD_NO)
@@ -1897,7 +1896,7 @@ void havocbot_role_ctf_setrole(entity bot, int role)
 // ==============
 
 MUTATOR_HOOKFUNCTION(ctf_PlayerPreThink)
-{
+{SELFPARAM();
        entity flag;
        int t = 0, t2 = 0, t3 = 0;
 
@@ -2001,7 +2000,7 @@ MUTATOR_HOOKFUNCTION(ctf_GiveFragsForKill)
 }
 
 MUTATOR_HOOKFUNCTION(ctf_RemovePlayer)
-{
+{SELFPARAM();
        entity flag; // temporary entity for the search method
 
        if(self.flagcarried)
@@ -2018,7 +2017,7 @@ MUTATOR_HOOKFUNCTION(ctf_RemovePlayer)
 }
 
 MUTATOR_HOOKFUNCTION(ctf_PortalTeleport)
-{
+{SELFPARAM();
        if(self.flagcarried)
        if(!autocvar_g_ctf_portalteleport)
                { ctf_Handle_Throw(self, world, DROP_NORMAL); }
@@ -2027,7 +2026,7 @@ MUTATOR_HOOKFUNCTION(ctf_PortalTeleport)
 }
 
 MUTATOR_HOOKFUNCTION(ctf_PlayerUseKey)
-{
+{SELFPARAM();
        if(MUTATOR_RETURNVALUE || gameover) { return false; }
 
        entity player = self;
@@ -2120,7 +2119,7 @@ MUTATOR_HOOKFUNCTION(ctf_PlayerUseKey)
 }
 
 MUTATOR_HOOKFUNCTION(ctf_HelpMePing)
-{
+{SELFPARAM();
        if(self.wps_flagcarrier) // update the flagcarrier waypointsprite with "NEEDING HELP" notification
        {
                self.wps_helpme_time = time;
@@ -2174,7 +2173,7 @@ MUTATOR_HOOKFUNCTION(ctf_VehicleExit)
 }
 
 MUTATOR_HOOKFUNCTION(ctf_AbortSpeedrun)
-{
+{SELFPARAM();
        if(self.flagcarried)
        {
                Send_Notification(NOTIF_ALL, world, MSG_INFO, ((self.flagcarried.team) ? APP_TEAM_ENT_4(self.flagcarried, INFO_CTF_FLAGRETURN_ABORTRUN_) : INFO_CTF_FLAGRETURN_ABORTRUN_NEUTRAL));
@@ -2220,7 +2219,7 @@ MUTATOR_HOOKFUNCTION(ctf_MatchEnd)
 }
 
 MUTATOR_HOOKFUNCTION(ctf_BotRoles)
-{
+{SELFPARAM();
        havocbot_ctf_reset_role(self);
        return true;
 }
@@ -2233,7 +2232,7 @@ MUTATOR_HOOKFUNCTION(ctf_GetTeamCount)
 }
 
 MUTATOR_HOOKFUNCTION(ctf_SpectateCopy)
-{
+{SELFPARAM();
        self.ctf_flagstatus = other.ctf_flagstatus;
        return false;
 }
@@ -2255,7 +2254,7 @@ Keys:
 "noise4" sound played when flag is dropped by a player...
 "noise5" sound played when flag touches the ground... */
 void spawnfunc_item_flag_team1()
-{
+{SELFPARAM();
        if(!g_ctf) { remove(self); return; }
 
        ctf_FlagSetup(NUM_TEAM_1, self);
@@ -2273,7 +2272,7 @@ Keys:
 "noise4" sound played when flag is dropped by a player...
 "noise5" sound played when flag touches the ground... */
 void spawnfunc_item_flag_team2()
-{
+{SELFPARAM();
        if(!g_ctf) { remove(self); return; }
 
        ctf_FlagSetup(NUM_TEAM_2, self);
@@ -2291,7 +2290,7 @@ Keys:
 "noise4" sound played when flag is dropped by a player...
 "noise5" sound played when flag touches the ground... */
 void spawnfunc_item_flag_team3()
-{
+{SELFPARAM();
        if(!g_ctf) { remove(self); return; }
 
        ctf_FlagSetup(NUM_TEAM_3, self);
@@ -2309,7 +2308,7 @@ Keys:
 "noise4" sound played when flag is dropped by a player...
 "noise5" sound played when flag touches the ground... */
 void spawnfunc_item_flag_team4()
-{
+{SELFPARAM();
        if(!g_ctf) { remove(self); return; }
 
        ctf_FlagSetup(NUM_TEAM_4, self);
@@ -2327,7 +2326,7 @@ Keys:
 "noise4" sound played when flag is dropped by a player...
 "noise5" sound played when flag touches the ground... */
 void spawnfunc_item_flag_neutral()
-{
+{SELFPARAM();
        if(!g_ctf) { remove(self); return; }
        if(!cvar("g_ctf_oneflag")) { remove(self); return; }
 
@@ -2341,7 +2340,7 @@ Keys:
 "netname" Name of the team (for example Red, Blue, Green, Yellow, Life, Death, Offense, Defense, etc)...
 "cnt" Scoreboard color of the team (for example 4 is red and 13 is blue)... */
 void spawnfunc_ctf_team()
-{
+{SELFPARAM();
        if(!g_ctf) { remove(self); return; }
 
        self.classname = "ctf_team";
@@ -2381,17 +2380,15 @@ void ctf_ScoreRules(int teams)
 
 // code from here on is just to support maps that don't have flag and team entities
 void ctf_SpawnTeam (string teamname, int teamcolor)
-{
-       entity oldself;
-       oldself = self;
-       self = spawn();
+{SELFPARAM();
+       setself(spawn());
        self.classname = "ctf_team";
        self.netname = teamname;
        self.cnt = teamcolor;
 
        spawnfunc_ctf_team();
 
-       self = oldself;
+       setself(this);
 }
 
 void ctf_DelayedInit() // Do this check with a delay so we can wait for teams to be set up.
index 04c589ce181a3d920bd0bd744ff923eb08f7e4e3..f9b478232aee988a6cd636fd2f652bdc62794c1a 100644 (file)
@@ -8,7 +8,7 @@
 // legacy bot roles
 .float race_checkpoint;
 void havocbot_role_cts()
-{
+{SELFPARAM();
        if(self.deadflag != DEAD_NO)
                return;
 
@@ -57,7 +57,7 @@ void cts_EventLog(string mode, entity actor) // use an alias for easy changing a
 }
 
 MUTATOR_HOOKFUNCTION(cts_PlayerPhysics)
-{
+{SELFPARAM();
        // force kbd movement for fairness
        float wishspeed;
        vector wishvel;
@@ -142,7 +142,7 @@ MUTATOR_HOOKFUNCTION(cts_ResetMap)
 }
 
 MUTATOR_HOOKFUNCTION(cts_PlayerPreThink)
-{
+{SELFPARAM();
        if(IS_SPEC(self) || IS_OBSERVER(self))
        if(g_race_qualifying)
        if(msg_entity.enemy.race_laptime)
@@ -152,7 +152,7 @@ MUTATOR_HOOKFUNCTION(cts_PlayerPreThink)
 }
 
 MUTATOR_HOOKFUNCTION(cts_ClientConnect)
-{
+{SELFPARAM();
        race_PreparePlayer();
        self.race_checkpoint = -1;
 
@@ -179,7 +179,7 @@ MUTATOR_HOOKFUNCTION(cts_ClientConnect)
 }
 
 MUTATOR_HOOKFUNCTION(cts_MakePlayerObserver)
-{
+{SELFPARAM();
        if(PlayerScore_Add(self, SP_RACE_FASTEST, 0))
                self.frags = FRAGS_LMS_LOSER;
        else
@@ -192,7 +192,7 @@ MUTATOR_HOOKFUNCTION(cts_MakePlayerObserver)
 }
 
 MUTATOR_HOOKFUNCTION(cts_PlayerSpawn)
-{
+{SELFPARAM();
        if(spawn_spot.target == "")
                // Emergency: this wasn't a real spawnpoint. Can this ever happen?
                race_PreparePlayer();
@@ -207,7 +207,7 @@ MUTATOR_HOOKFUNCTION(cts_PlayerSpawn)
 }
 
 MUTATOR_HOOKFUNCTION(cts_PutClientInServer)
-{
+{SELFPARAM();
        if(IS_PLAYER(self))
        if(!gameover)
        {
@@ -222,20 +222,20 @@ MUTATOR_HOOKFUNCTION(cts_PutClientInServer)
 }
 
 MUTATOR_HOOKFUNCTION(cts_PlayerDies)
-{
+{SELFPARAM();
        self.respawn_flags |= RESPAWN_FORCE;
        race_AbandonRaceCheck(self);
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(cts_BotRoles)
-{
+{SELFPARAM();
        self.havocbot_role = havocbot_role_cts;
        return true;
 }
 
 MUTATOR_HOOKFUNCTION(cts_PlayerPostThink)
-{
+{SELFPARAM();
        if(self.cvar_cl_allow_uidtracking == 1 && self.cvar_cl_allow_uid2name == 1)
        {
                if (!self.stored_netname)
@@ -258,7 +258,7 @@ MUTATOR_HOOKFUNCTION(cts_ForbidThrowing)
 }
 
 MUTATOR_HOOKFUNCTION(cts_FilterItem)
-{
+{SELFPARAM();
        if(self.classname == "droppedweapon")
                return true;
 
index 7b392a0663af09b0b65be533388aee3cb211b083..322c7e0dd68235447dd533632e3e851f05ed7339 100644 (file)
@@ -21,7 +21,7 @@ void set_dom_state(entity e)
 }
 
 void dompoint_captured ()
-{
+{SELFPARAM();
        entity head;
        float old_delay, old_team, real_team;
 
@@ -129,7 +129,7 @@ void dompoint_captured ()
 }
 
 void AnimateDomPoint()
-{
+{SELFPARAM();
        if(self.pain_finished > time)
                return;
        self.pain_finished = time + self.t_width;
@@ -142,7 +142,7 @@ void AnimateDomPoint()
 }
 
 void dompointthink()
-{
+{SELFPARAM();
        float fragamt;
 
        self.nextthink = time + 0.1;
@@ -186,7 +186,7 @@ void dompointthink()
 }
 
 void dompointtouch()
-{
+{SELFPARAM();
        entity head;
        if (!IS_PLAYER(other))
                return;
@@ -241,7 +241,7 @@ void dompointtouch()
 }
 
 void dom_controlpoint_setup()
-{
+{SELFPARAM();
        entity head;
        // find the spawnfunc_dom_team representing unclaimed points
        head = find(world, classname, "dom_team");
@@ -385,7 +385,7 @@ void Domination_RoundStart()
 
 //go to best items, or control points you don't own
 void havocbot_role_dom()
-{
+{SELFPARAM();
        if(self.deadflag != DEAD_NO)
                return;
 
@@ -408,10 +408,12 @@ MUTATOR_HOOKFUNCTION(dom_GetTeamCount)
 }
 
 MUTATOR_HOOKFUNCTION(dom_ResetMap)
-{
+{SELFPARAM();
        total_pps = 0, pps_red = 0, pps_blue = 0, pps_yellow = 0, pps_pink = 0;
-       FOR_EACH_PLAYER(self)
+       entity e;
+       FOR_EACH_PLAYER(e)
        {
+               setself(e);
                PutClientInServer();
                self.player_blocked = 1;
                if(IS_REAL_CLIENT(self))
@@ -421,7 +423,7 @@ MUTATOR_HOOKFUNCTION(dom_ResetMap)
 }
 
 MUTATOR_HOOKFUNCTION(dom_PlayerSpawn)
-{
+{SELFPARAM();
        if(domination_roundbased)
        if(!round_handler_IsRoundStarted())
                self.player_blocked = 1;
@@ -431,13 +433,13 @@ MUTATOR_HOOKFUNCTION(dom_PlayerSpawn)
 }
 
 MUTATOR_HOOKFUNCTION(dom_ClientConnect)
-{
+{SELFPARAM();
        set_dom_state(self);
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(dom_BotRoles)
-{
+{SELFPARAM();
        self.havocbot_role = havocbot_role_dom;
        return true;
 }
@@ -446,7 +448,7 @@ MUTATOR_HOOKFUNCTION(dom_BotRoles)
 Control point for Domination gameplay.
 */
 void spawnfunc_dom_controlpoint()
-{
+{SELFPARAM();
        if(!g_domination)
        {
                remove(self);
@@ -491,7 +493,7 @@ Keys:
 */
 
 void spawnfunc_dom_team()
-{
+{SELFPARAM();
        if(!g_domination || autocvar_g_domination_teams_override >= 2)
        {
                remove(self);
@@ -541,10 +543,8 @@ void ScoreRules_dom(float teams)
 
 // code from here on is just to support maps that don't have control point and team entities
 void dom_spawnteam (string teamname, float teamcolor, string pointmodel, float pointskin, string capsound, string capnarration, string capmessage)
-{
-       entity oldself;
-       oldself = self;
-       self = spawn();
+{SELFPARAM();
+       setself(spawn());
        self.classname = "dom_team";
        self.netname = teamname;
        self.cnt = teamcolor;
@@ -564,20 +564,18 @@ void dom_spawnteam (string teamname, float teamcolor, string pointmodel, float p
        self.team = self.cnt + 1;
 
        //eprint(self);
-       self = oldself;
+       setself(this);
 }
 
 void dom_spawnpoint(vector org)
-{
-       entity oldself;
-       oldself = self;
-       self = spawn();
+{SELFPARAM();
+       setself(spawn());
        self.classname = "dom_controlpoint";
        self.think = spawnfunc_dom_controlpoint;
        self.nextthink = time;
        setorigin(self, org);
        spawnfunc_dom_controlpoint();
-       self = oldself;
+       setself(this);
 }
 
 // spawn some default teams if the map is not set up for domination
index 1fa168d63fbe84a9aa957afdb0760161d25a49d2..e7790c974d435776dee2da7ddd8344bf7e453d6e 100644 (file)
@@ -134,7 +134,7 @@ float freezetag_CheckWinner()
 }
 
 entity freezetag_LastPlayerForTeam()
-{
+{SELFPARAM();
        entity pl, last_pl = world;
        FOR_EACH_PLAYER(pl)
        {
@@ -162,7 +162,7 @@ void freezetag_LastPlayerForTeam_Notify()
 }
 
 void freezetag_Add_Score(entity attacker)
-{
+{SELFPARAM();
        if(attacker == self)
        {
                // you froze your own dumb self
@@ -180,7 +180,7 @@ void freezetag_Add_Score(entity attacker)
 }
 
 void freezetag_Freeze(entity attacker)
-{
+{SELFPARAM();
        if(self.frozen)
                return;
 
@@ -195,7 +195,7 @@ void freezetag_Freeze(entity attacker)
 }
 
 void freezetag_Unfreeze(entity attacker)
-{
+{SELFPARAM();
        self.freezetag_frozen_time = 0;
        self.freezetag_frozen_timeout = 0;
 
@@ -218,7 +218,7 @@ void() havocbot_role_ft_freeing;
 void() havocbot_role_ft_offense;
 
 void havocbot_goalrating_freeplayers(float ratingscale, vector org, float sradius)
-{
+{SELFPARAM();
        entity head;
        float distance;
 
@@ -244,7 +244,7 @@ void havocbot_goalrating_freeplayers(float ratingscale, vector org, float sradiu
 }
 
 void havocbot_role_ft_offense()
-{
+{SELFPARAM();
        entity head;
        float unfrozen;
 
@@ -285,7 +285,7 @@ void havocbot_role_ft_offense()
 }
 
 void havocbot_role_ft_freeing()
-{
+{SELFPARAM();
        if(self.deadflag != DEAD_NO)
                return;
 
@@ -319,7 +319,7 @@ void havocbot_role_ft_freeing()
 // ==============
 
 MUTATOR_HOOKFUNCTION(freezetag_RemovePlayer)
-{
+{SELFPARAM();
        self.health = 0; // neccessary to update correctly alive stats
        if(!self.frozen)
                freezetag_LastPlayerForTeam_Notify();
@@ -329,7 +329,7 @@ MUTATOR_HOOKFUNCTION(freezetag_RemovePlayer)
 }
 
 MUTATOR_HOOKFUNCTION(freezetag_PlayerDies)
-{
+{SELFPARAM();
        if(round_handler_IsActive())
        if(round_handler_CountdownRunning())
        {
@@ -383,7 +383,7 @@ MUTATOR_HOOKFUNCTION(freezetag_PlayerDies)
 }
 
 MUTATOR_HOOKFUNCTION(freezetag_PlayerSpawn)
-{
+{SELFPARAM();
        if(self.freezetag_frozen_timeout == -1) // if PlayerSpawn is called by reset_map_players
                return 1; // do nothing, round is starting right now
 
@@ -406,13 +406,15 @@ MUTATOR_HOOKFUNCTION(freezetag_PlayerSpawn)
 }
 
 MUTATOR_HOOKFUNCTION(freezetag_reset_map_players)
-{
-       FOR_EACH_PLAYER(self)
+{SELFPARAM();
+       entity e;
+       FOR_EACH_PLAYER(e)
        {
-               self.killcount = 0;
-               self.freezetag_frozen_timeout = -1;
+               e.killcount = 0;
+               e.freezetag_frozen_timeout = -1;
+               setself(e);
                PutClientInServer();
-               self.freezetag_frozen_timeout = 0;
+               e.freezetag_frozen_timeout = 0;
        }
        freezetag_count_alive_players();
        return 1;
@@ -425,7 +427,7 @@ MUTATOR_HOOKFUNCTION(freezetag_GiveFragsForKill)
 }
 
 MUTATOR_HOOKFUNCTION(freezetag_PlayerPreThink)
-{
+{SELFPARAM();
        float n;
 
        if(gameover)
@@ -540,7 +542,7 @@ MUTATOR_HOOKFUNCTION(freezetag_SetStartItems)
 }
 
 MUTATOR_HOOKFUNCTION(freezetag_BotRoles)
-{
+{SELFPARAM();
        if (!self.deadflag)
        {
                if (random() < 0.5)
index c4750d98228fc6279e3bfa2bbe5f2ba9c83ca0bf..412e7bd5405caa28832a5edc54ad8dcd4f01c652 100644 (file)
@@ -7,7 +7,7 @@
 #include "../../common/monsters/sv_monsters.qh"
 
 void spawnfunc_invasion_spawnpoint()
-{
+{SELFPARAM();
        if(!g_invasion) { remove(self); return; }
 
        self.classname = "invasion_spawnpoint";
@@ -261,7 +261,7 @@ void Invasion_RoundStart()
 }
 
 MUTATOR_HOOKFUNCTION(invasion_MonsterDies)
-{
+{SELFPARAM();
        if(!(self.spawnflags & MONSTERFLAG_RESPAWNED))
        {
                inv_numkilled += 1;
@@ -283,7 +283,7 @@ MUTATOR_HOOKFUNCTION(invasion_MonsterDies)
 }
 
 MUTATOR_HOOKFUNCTION(invasion_MonsterSpawn)
-{
+{SELFPARAM();
        if(!(self.spawnflags & MONSTERFLAG_SPAWNED))
                return true;
 
@@ -304,7 +304,7 @@ MUTATOR_HOOKFUNCTION(invasion_MonsterSpawn)
 }
 
 MUTATOR_HOOKFUNCTION(invasion_OnEntityPreSpawn)
-{
+{SELFPARAM();
        if(startsWith(self.classname, "monster_"))
        if(!(self.spawnflags & MONSTERFLAG_SPAWNED))
                return true;
@@ -327,7 +327,7 @@ MUTATOR_HOOKFUNCTION(invasion_PlayerRegen)
 }
 
 MUTATOR_HOOKFUNCTION(invasion_PlayerSpawn)
-{
+{SELFPARAM();
        self.bot_attack = false;
        return false;
 }
@@ -344,7 +344,7 @@ MUTATOR_HOOKFUNCTION(invasion_PlayerDamage)
 }
 
 MUTATOR_HOOKFUNCTION(invasion_PlayerCommand)
-{
+{SELFPARAM();
        if(MUTATOR_RETURNVALUE) // command was already handled?
                return false;
 
index 96765796a1de7967bd938b17e00facdf70f3a8a5..3ab6342b3becd1e936ad92c80334304051f93536 100644 (file)
@@ -27,7 +27,7 @@ void ka_EventLog(string mode, entity actor) // use an alias for easy changing an
 
 void ka_TouchEvent();
 void ka_RespawnBall() // runs whenever the ball needs to be relocated
-{
+{SELFPARAM();
        if(gameover) { return; }
        vector oldballorigin = self.origin;
 
@@ -57,7 +57,7 @@ void ka_RespawnBall() // runs whenever the ball needs to be relocated
 }
 
 void ka_TimeScoring()
-{
+{SELFPARAM();
        if(self.owner.ballcarried)
        { // add points for holding the ball after a certain amount of time
                if(autocvar_g_keepaway_score_timepoints)
@@ -69,7 +69,7 @@ void ka_TimeScoring()
 }
 
 void ka_TouchEvent() // runs any time that the ball comes in contact with something
-{
+{SELFPARAM();
        if(gameover) { return; }
        if(!self) { return; }
        if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
@@ -167,7 +167,7 @@ void ka_DropEvent(entity plyr) // runs any time that a player is supposed to los
 }
 
 void ka_Reset() // used to clear the ballcarrier whenever the match switches from warmup to normal
-{
+{SELFPARAM();
        if((self.owner) && (IS_PLAYER(self.owner)))
                ka_DropEvent(self.owner);
 
@@ -187,7 +187,7 @@ void ka_Reset() // used to clear the ballcarrier whenever the match switches fro
 // ================
 
 void havocbot_goalrating_ball(float ratingscale, vector org)
-{
+{SELFPARAM();
        float t;
        entity ball_owner;
        ball_owner = ka_ball.owner;
@@ -206,7 +206,7 @@ void havocbot_goalrating_ball(float ratingscale, vector org)
 }
 
 void havocbot_role_ka_carrier()
-{
+{SELFPARAM();
        if (self.deadflag != DEAD_NO)
                return;
 
@@ -229,7 +229,7 @@ void havocbot_role_ka_carrier()
 }
 
 void havocbot_role_ka_collector()
-{
+{SELFPARAM();
        if (self.deadflag != DEAD_NO)
                return;
 
@@ -257,7 +257,7 @@ void havocbot_role_ka_collector()
 // ==============
 
 MUTATOR_HOOKFUNCTION(ka_Scoring)
-{
+{SELFPARAM();
        if((frag_attacker != frag_target) && (IS_PLAYER(frag_attacker)))
        {
                if(frag_target.ballcarried) { // add to amount of times killing carrier
@@ -284,7 +284,7 @@ MUTATOR_HOOKFUNCTION(ka_GiveFragsForKill)
 }
 
 MUTATOR_HOOKFUNCTION(ka_PlayerPreThink)
-{
+{SELFPARAM();
        // clear the item used for the ball in keepaway
        self.items &= ~IT_KEY1;
 
@@ -296,7 +296,7 @@ MUTATOR_HOOKFUNCTION(ka_PlayerPreThink)
 }
 
 MUTATOR_HOOKFUNCTION(ka_PlayerUseKey)
-{
+{SELFPARAM();
        if(MUTATOR_RETURNVALUE == 0)
        if(self.ballcarried)
        {
@@ -338,13 +338,13 @@ MUTATOR_HOOKFUNCTION(ka_PlayerDamage) // for changing damage and force values th
 }
 
 MUTATOR_HOOKFUNCTION(ka_RemovePlayer)
-{
+{SELFPARAM();
        if(self.ballcarried) { ka_DropEvent(self); } // a player with the ball has left the match, drop it
        return 0;
 }
 
 MUTATOR_HOOKFUNCTION(ka_PlayerPowerups)
-{
+{SELFPARAM();
        // In the future this hook is supposed to allow me to do some extra stuff with waypointsprites and invisibility powerup
        // So bare with me until I can fix a certain bug with ka_ballcarrier_waypointsprite_visible_for_player()
 
@@ -357,7 +357,7 @@ MUTATOR_HOOKFUNCTION(ka_PlayerPowerups)
 }
 
 MUTATOR_HOOKFUNCTION(ka_PlayerPhysics)
-{
+{SELFPARAM();
        if(self.ballcarried)
        {
                self.stat_sv_airspeedlimit_nonqw *= autocvar_g_keepaway_ballcarrier_highspeed;
@@ -367,7 +367,7 @@ MUTATOR_HOOKFUNCTION(ka_PlayerPhysics)
 }
 
 MUTATOR_HOOKFUNCTION(ka_BotShouldAttack)
-{
+{SELFPARAM();
        // if neither player has ball then don't attack unless the ball is on the ground
        if(!checkentity.ballcarried && !self.ballcarried && ka_ball.owner)
                return true;
@@ -375,7 +375,7 @@ MUTATOR_HOOKFUNCTION(ka_BotShouldAttack)
 }
 
 MUTATOR_HOOKFUNCTION(ka_BotRoles)
-{
+{SELFPARAM();
        if (self.ballcarried)
                self.havocbot_role = havocbot_role_ka_carrier;
        else
index fe53c1fcc4dbaf39c7b11da153a19e154f7d159a..92125926f78daaa1c7d13ea6c8f785dc02da83e9 100644 (file)
@@ -92,7 +92,7 @@ void kh_ScoreRules(float teams)
 }
 
 float kh_KeyCarrier_waypointsprite_visible_for_player(entity e)  // runs all the time
-{
+{SELFPARAM();
        if(!IS_PLAYER(e) || self.team != e.team)
                if(!kh_tracking_enabled)
                        return false;
@@ -101,7 +101,7 @@ float kh_KeyCarrier_waypointsprite_visible_for_player(entity e)  // runs all the
 }
 
 float kh_Key_waypointsprite_visible_for_player(entity e) // ??
-{
+{SELFPARAM();
        if(!kh_tracking_enabled)
                return false;
        if(!self.owner)
@@ -154,7 +154,7 @@ void kh_Controller_SetThink(float t, kh_Think_t func)  // runs occasionaly
 }
 void kh_WaitForPlayers();
 void kh_Controller_Think()  // called a lot
-{
+{SELFPARAM();
        if(intermission_running)
                return;
        if(self.cnt > 0)
@@ -411,7 +411,7 @@ void kh_Key_AssignTo(entity key, entity player)  // runs every time a key is pic
 }
 
 void kh_Key_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        if(self.owner)
                return;
        if(ITEM_DAMAGE_NEEDKILL(deathtype))
@@ -444,7 +444,7 @@ void kh_Key_Collect(entity key, entity player)  //a player picks up a dropped ke
 }
 
 void kh_Key_Touch()  // runs many, many times when a key has been dropped and can be picked up
-{
+{SELFPARAM();
        if(intermission_running)
                return;
 
@@ -671,7 +671,7 @@ void kh_LoserTeam(float teem, entity lostkey)  // runs when a player pushes a fl
 }
 
 void kh_Key_Think()  // runs all the time
-{
+{SELFPARAM();
        entity head;
        //entity player;  // needed by FOR_EACH_PLAYER
 
@@ -729,7 +729,7 @@ void kh_Key_Think()  // runs all the time
 }
 
 void key_reset()
-{
+{SELFPARAM();
        kh_Key_AssignTo(self, world);
        kh_Key_Remove(self);
 }
@@ -1058,13 +1058,13 @@ void kh_finalize()
 // register this as a mutator
 
 MUTATOR_HOOKFUNCTION(kh_Key_DropAll)
-{
+{SELFPARAM();
        kh_Key_DropAll(self, true);
        return 0;
 }
 
 MUTATOR_HOOKFUNCTION(kh_PlayerDies)
-{
+{SELFPARAM();
        if(self == other)
                kh_Key_DropAll(self, true);
        else if(IS_PLAYER(other))
@@ -1093,13 +1093,13 @@ MUTATOR_HOOKFUNCTION(kh_GetTeamCount)
 }
 
 MUTATOR_HOOKFUNCTION(kh_SpectateCopy)
-{
+{SELFPARAM();
        self.kh_state = other.kh_state;
        return 0;
 }
 
 MUTATOR_HOOKFUNCTION(kh_PlayerUseKey)
-{
+{SELFPARAM();
        if(MUTATOR_RETURNVALUE == 0)
        {
                entity k;
index 85f2e1ed237e2af51209b1bcf8235ffc0a711955..b9395b913a2ad018feeca4540da7dc7adebb513d 100644 (file)
@@ -35,17 +35,20 @@ MUTATOR_HOOKFUNCTION(lms_ResetMap)
 }
 
 MUTATOR_HOOKFUNCTION(lms_ResetPlayers)
-{
+{SELFPARAM();
+       entity e;
        if(restart_mapalreadyrestarted || (time < game_starttime))
-       FOR_EACH_CLIENT(self)
-       if(IS_PLAYER(self))
-               PlayerScore_Add(self, SP_LMS_LIVES, LMS_NewPlayerLives());
+       FOR_EACH_CLIENT(e)
+       if(IS_PLAYER(e))
+       {
+               WITH(entity, self, e, PlayerScore_Add(e, SP_LMS_LIVES, LMS_NewPlayerLives()));
+       }
 
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(lms_PlayerPreSpawn)
-{
+{SELFPARAM();
        // player is dead and becomes observer
        // FIXME fix LMS scoring for new system
        if(PlayerScore_Add(self, SP_LMS_RANK, 0) > 0)
@@ -58,14 +61,14 @@ MUTATOR_HOOKFUNCTION(lms_PlayerPreSpawn)
 }
 
 MUTATOR_HOOKFUNCTION(lms_PlayerDies)
-{
+{SELFPARAM();
        self.respawn_flags |= RESPAWN_FORCE;
 
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(lms_RemovePlayer)
-{
+{SELFPARAM();
        // Only if the player cannot play at all
        if(PlayerScore_Add(self, SP_LMS_RANK, 0) == 666)
                self.frags = FRAGS_SPECTATOR;
@@ -82,7 +85,7 @@ MUTATOR_HOOKFUNCTION(lms_RemovePlayer)
 }
 
 MUTATOR_HOOKFUNCTION(lms_ClientConnect)
-{
+{SELFPARAM();
        self.classname = "player";
        campaign_bots_may_start = 1;
 
@@ -96,7 +99,7 @@ MUTATOR_HOOKFUNCTION(lms_ClientConnect)
 }
 
 MUTATOR_HOOKFUNCTION(lms_PlayerThink)
-{
+{SELFPARAM();
        if(self.deadflag == DEAD_DYING)
                self.deadflag = DEAD_RESPAWNING;
 
@@ -159,7 +162,7 @@ MUTATOR_HOOKFUNCTION(lms_KeepScore)
 }
 
 MUTATOR_HOOKFUNCTION(lms_FilterItem)
-{
+{SELFPARAM();
        if(autocvar_g_lms_extra_lives)
        if(self.itemdef == ITEM_HealthMega)
        {
@@ -171,7 +174,7 @@ MUTATOR_HOOKFUNCTION(lms_FilterItem)
 }
 
 MUTATOR_HOOKFUNCTION(lms_ItemTouch)
-{
+{SELFPARAM();
        // give extra lives for mega health
        if (self.items & ITEM_HealthMega.m_itemid)
        {
index 6b8d5a07d7ee9c9f44a27927092254d46ceae2ae..fad911386c1bed56b6cf86a5f8fd90e74d77c42f 100644 (file)
@@ -51,26 +51,24 @@ void LogNB(string mode, entity actor)
 }
 
 void ball_restart(void)
-{
+{SELFPARAM();
        if(self.owner)
                DropBall(self, self.owner.origin, '0 0 0');
        ResetBall();
 }
 
 void nexball_setstatus(void)
-{
-       entity oldself;
+{SELFPARAM();
        self.items &= ~IT_KEY1;
        if(self.ballcarried)
        {
                if(self.ballcarried.teamtime && (self.ballcarried.teamtime < time))
                {
                        bprint("The ", Team_ColoredFullName(self.team), " held the ball for too long.\n");
-                       oldself = self;
-                       self = self.ballcarried;
+                       setself(self.ballcarried);
                        DropBall(self, self.owner.origin, '0 0 0');
                        ResetBall();
-                       self = oldself;
+                       setself(this);
                }
                else
                        self.items |= IT_KEY1;
@@ -78,7 +76,7 @@ void nexball_setstatus(void)
 }
 
 void relocate_nexball(void)
-{
+{SELFPARAM();
        tracebox(self.origin, BALL_MINS, BALL_MAXS, self.origin, true, self);
        if(trace_startsolid)
        {
@@ -95,7 +93,7 @@ void relocate_nexball(void)
 }
 
 void DropOwner(void)
-{
+{SELFPARAM();
        entity ownr;
        ownr = self.owner;
        DropBall(self, ownr.origin, ownr.velocity);
@@ -105,7 +103,7 @@ void DropOwner(void)
 }
 
 void GiveBall(entity plyr, entity ball)
-{
+{SELFPARAM();
        entity ownr;
 
        if((ownr = ball.owner))
@@ -153,15 +151,14 @@ void GiveBall(entity plyr, entity ball)
                ball.nextthink = time + autocvar_g_nexball_basketball_delay_hold;
        }
 
-       ownr = self;
-       self = plyr;
-       self.weaponentity.weapons = self.weapons;
-       self.weaponentity.switchweapon = self.weapon;
-       self.weapons = WEPSET_PORTO;
+       plyr.weaponentity.weapons = plyr.weapons;
+       plyr.weaponentity.switchweapon = plyr.weapon;
+       plyr.weapons = WEPSET_PORTO;
+       setself(plyr);
        WEP_ACTION(WEP_PORTO.m_id, WR_RESETPLAYER);
-       self.switchweapon = WEP_PORTO.m_id;
+       plyr.switchweapon = WEP_PORTO.m_id;
        W_SwitchWeapon(WEP_PORTO.m_id);
-       self = ownr;
+       setself(this);
 }
 
 void DropBall(entity ball, vector org, vector vel)
@@ -196,7 +193,7 @@ void DropBall(entity ball, vector org, vector vel)
 }
 
 void InitBall(void)
-{
+{SELFPARAM();
        if(gameover) return;
        self.flags &= ~FL_ONGROUND;
        self.movetype = MOVETYPE_BOUNCE;
@@ -216,7 +213,7 @@ void InitBall(void)
 }
 
 void ResetBall(void)
-{
+{SELFPARAM();
        if(self.cnt < 2)        // step 1
        {
                if(time == self.teamtime)
@@ -252,7 +249,7 @@ void ResetBall(void)
 }
 
 void football_touch(void)
-{
+{SELFPARAM();
        if(other.solid == SOLID_BSP)
        {
                if(time > self.lastground + 0.1)
@@ -298,7 +295,7 @@ void football_touch(void)
 }
 
 void basketball_touch(void)
-{
+{SELFPARAM();
        if(other.ballcarried)
        {
                football_touch();
@@ -320,7 +317,7 @@ void basketball_touch(void)
 }
 
 void GoalTouch(void)
-{
+{SELFPARAM();
        entity ball;
        float isclient, pscore, otherteam;
        string pname;
@@ -412,7 +409,7 @@ void GoalTouch(void)
 //        team ents       //
 //=======================//
 void spawnfunc_nexball_team(void)
-{
+{SELFPARAM();
        if(!g_nexball)
        {
                remove(self);
@@ -486,7 +483,7 @@ void nb_delayedinit(void)
 //=======================//
 
 void SpawnBall(void)
-{
+{SELFPARAM();
        if(!g_nexball) { remove(self); return; }
 
 //     balls += 4; // using the remaining bits to count balls will leave more than the max edict count, so it's fine
@@ -538,7 +535,7 @@ void SpawnBall(void)
 }
 
 void spawnfunc_nexball_basketball(void)
-{
+{SELFPARAM();
        nexball_mode |= NBM_BASKETBALL;
        self.classname = "nexball_basketball";
        if (!(balls & BALL_BASKET))
@@ -561,7 +558,7 @@ void spawnfunc_nexball_basketball(void)
 }
 
 void spawnfunc_nexball_football(void)
-{
+{SELFPARAM();
        nexball_mode |= NBM_FOOTBALL;
        self.classname = "nexball_football";
        self.solid = SOLID_TRIGGER;
@@ -572,7 +569,7 @@ void spawnfunc_nexball_football(void)
 }
 
 float nb_Goal_Customize()
-{
+{SELFPARAM();
        entity e, wp_owner;
        e = WaypointSprite_getviewentity(other);
        wp_owner = self.owner;
@@ -582,7 +579,7 @@ float nb_Goal_Customize()
 }
 
 void SpawnGoal(void)
-{
+{SELFPARAM();
        if(!g_nexball) { remove(self); return; }
 
        EXACTTRIGGER_INIT;
@@ -602,28 +599,28 @@ void SpawnGoal(void)
 }
 
 void spawnfunc_nexball_redgoal(void)
-{
+{SELFPARAM();
        self.team = NUM_TEAM_1;
        SpawnGoal();
 }
 void spawnfunc_nexball_bluegoal(void)
-{
+{SELFPARAM();
        self.team = NUM_TEAM_2;
        SpawnGoal();
 }
 void spawnfunc_nexball_yellowgoal(void)
-{
+{SELFPARAM();
        self.team = NUM_TEAM_3;
        SpawnGoal();
 }
 void spawnfunc_nexball_pinkgoal(void)
-{
+{SELFPARAM();
        self.team = NUM_TEAM_4;
        SpawnGoal();
 }
 
 void spawnfunc_nexball_fault(void)
-{
+{SELFPARAM();
        self.team = GOAL_FAULT;
        if(self.noise == "")
                self.noise = "misc/typehit.wav";
@@ -631,7 +628,7 @@ void spawnfunc_nexball_fault(void)
 }
 
 void spawnfunc_nexball_out(void)
-{
+{SELFPARAM();
        self.team = GOAL_OUT;
        if(self.noise == "")
                self.noise = "misc/typehit.wav";
@@ -678,7 +675,7 @@ void spawnfunc_ball_bound(void)
 
 
 void W_Nexball_Think()
-{
+{SELFPARAM();
        //dprint("W_Nexball_Think\n");
        //vector new_dir = steerlib_arrive(self.enemy.origin, 2500);
        vector new_dir = normalize(self.enemy.origin + '0 0 50' - self.origin);
@@ -693,7 +690,7 @@ void W_Nexball_Think()
 }
 
 void W_Nexball_Touch(void)
-{
+{SELFPARAM();
        entity ball, attacker;
        attacker = self.owner;
        //self.think = func_null;
@@ -724,7 +721,7 @@ void W_Nexball_Touch(void)
 }
 
 void W_Nexball_Attack(float t)
-{
+{SELFPARAM();
        entity ball;
        float mul, mi, ma;
        if(!(ball = self.ballcarried))
@@ -760,7 +757,7 @@ void W_Nexball_Attack(float t)
 }
 
 void W_Nexball_Attack2(void)
-{
+{SELFPARAM();
        if(self.ballcarried.enemy)
        {
                entity _ball = self.ballcarried;
@@ -803,7 +800,7 @@ void W_Nexball_Attack2(void)
 }
 
 float ball_customize()
-{
+{SELFPARAM();
        if(!self.owner)
        {
                self.effects &= ~EF_FLAME;
@@ -830,7 +827,7 @@ float ball_customize()
 }
 
 float w_nexball_weapon(float req)
-{
+{SELFPARAM();
        if(req == WR_THINK)
        {
                if(self.BUTTON_ATCK)
@@ -880,7 +877,7 @@ float w_nexball_weapon(float req)
 }
 
 MUTATOR_HOOKFUNCTION(nexball_BallDrop)
-{
+{SELFPARAM();
        if(self.ballcarried && g_nexball)
                DropBall(self.ballcarried, self.origin, self.velocity);
 
@@ -888,7 +885,7 @@ MUTATOR_HOOKFUNCTION(nexball_BallDrop)
 }
 
 MUTATOR_HOOKFUNCTION(nexball_PlayerPreThink)
-{
+{SELFPARAM();
        makevectors(self.v_angle);
        if(nexball_mode & NBM_BASKETBALL)
        {
@@ -952,7 +949,7 @@ MUTATOR_HOOKFUNCTION(nexball_PlayerPreThink)
 }
 
 MUTATOR_HOOKFUNCTION(nexball_PlayerSpawn)
-{
+{SELFPARAM();
        self.weaponentity.weapons = '0 0 0';
 
        if(nexball_mode & NBM_BASKETBALL)
@@ -964,7 +961,7 @@ MUTATOR_HOOKFUNCTION(nexball_PlayerSpawn)
 }
 
 MUTATOR_HOOKFUNCTION(nexball_PlayerPhysics)
-{
+{SELFPARAM();
        if(self.ballcarried)
        {
                self.stat_sv_airspeedlimit_nonqw *= autocvar_g_nexball_basketball_carrier_highspeed;
@@ -981,7 +978,7 @@ MUTATOR_HOOKFUNCTION(nexball_SetStartItems)
 }
 
 MUTATOR_HOOKFUNCTION(nexball_ForbidThrowing)
-{
+{SELFPARAM();
        if(self.weapon == WEP_MORTAR.m_id)
                return true;
 
@@ -989,7 +986,7 @@ MUTATOR_HOOKFUNCTION(nexball_ForbidThrowing)
 }
 
 MUTATOR_HOOKFUNCTION(nexball_FilterItem)
-{
+{SELFPARAM();
        if(self.classname == "droppedweapon")
        if(self.weapon == WEP_MORTAR.m_id)
                return true;
index 33bebd04ccd44821dfd8106b18e012e50384acc8..76a7a65d57b7f97954a20e92280d96254b90f87c 100644 (file)
@@ -9,7 +9,7 @@
 // =======================
 
 bool ons_CaptureShield_Customize()
-{
+{SELFPARAM();
        entity e = WaypointSprite_getviewentity(other);
 
        if(!self.enemy.isshielded && (ons_ControlPoint_Attackable(self.enemy, e.team) > 0 || self.enemy.classname != "onslaught_controlpoint")) { return false; }
@@ -19,7 +19,7 @@ bool ons_CaptureShield_Customize()
 }
 
 void ons_CaptureShield_Touch()
-{
+{SELFPARAM();
        if(!self.enemy.isshielded && (ons_ControlPoint_Attackable(self.enemy, other.team) > 0 || self.enemy.classname != "onslaught_controlpoint")) { return; }
        if(!IS_PLAYER(other)) { return; }
        if(SAME_TEAM(other, self)) { return; }
@@ -41,7 +41,7 @@ void ons_CaptureShield_Touch()
 }
 
 void ons_CaptureShield_Reset()
-{
+{SELFPARAM();
        self.colormap = self.enemy.colormap;
        self.team = self.enemy.team;
 }
@@ -229,7 +229,7 @@ void onslaught_updatelinks()
 // ===================
 
 bool ons_Link_Send(entity to, int sendflags)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_RADARLINK);
        WriteByte(MSG_ENTITY, sendflags);
        if(sendflags & 1)
@@ -252,7 +252,7 @@ bool ons_Link_Send(entity to, int sendflags)
 }
 
 void ons_Link_CheckUpdate()
-{
+{SELFPARAM();
        // TODO check if the two sides have moved (currently they won't move anyway)
        float cc = 0, cc1 = 0, cc2 = 0;
 
@@ -271,7 +271,7 @@ void ons_Link_CheckUpdate()
 }
 
 void ons_DelayedLinkSetup()
-{
+{SELFPARAM();
        self.goalentity = find(world, targetname, self.target);
        self.enemy = find(world, targetname, self.target2);
        if(!self.goalentity) { objerror("can not find target\n"); }
@@ -344,9 +344,7 @@ int ons_ControlPoint_Attackable(entity cp, int teamnumber)
 }
 
 void ons_ControlPoint_Icon_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
-       entity oself;
-
+{SELFPARAM();
        if(damage <= 0) { return; }
 
        if (self.owner.isshielded)
@@ -404,11 +402,10 @@ void ons_ControlPoint_Icon_Damage(entity inflictor, entity attacker, float damag
                onslaught_updatelinks();
 
                // Use targets now (somebody make sure this is in the right place..)
-               oself = self;
-               self = self.owner;
+               setself(self.owner);
                activator = self;
                SUB_UseTargets ();
-               self = oself;
+               setself(this);
 
                self.owner.waslinked = self.owner.islinked;
                if(self.owner.model != "models/onslaught/controlpoint_pad.md3")
@@ -422,8 +419,7 @@ void ons_ControlPoint_Icon_Damage(entity inflictor, entity attacker, float damag
 }
 
 void ons_ControlPoint_Icon_Think()
-{
-       entity oself;
+{SELFPARAM();
        self.nextthink = time + ONS_CP_THINKRATE;
 
        if(autocvar_g_onslaught_cp_proxydecap)
@@ -478,11 +474,10 @@ void ons_ControlPoint_Icon_Think()
                if(!self.owner.islinked)
                        self.owner.team = 0;
 
-               oself = self;
-               self = self.owner;
+               setself(self.owner);
                activator = self;
                SUB_UseTargets ();
-               self = oself;
+               setself(this);
 
                self.owner.team = t;
 
@@ -502,8 +497,7 @@ void ons_ControlPoint_Icon_Think()
 }
 
 void ons_ControlPoint_Icon_BuildThink()
-{
-       entity oself;
+{SELFPARAM();
        int a;
 
        self.nextthink = time + ONS_CP_THINKRATE;
@@ -545,11 +539,10 @@ void ons_ControlPoint_Icon_BuildThink()
                onslaught_updatelinks();
 
                // Use targets now (somebody make sure this is in the right place..)
-               oself = self;
-               self = self.owner;
+               setself(self.owner);
                activator = self;
                SUB_UseTargets ();
-               self = oself;
+               setself(this);
 
                self.SendFlags |= CPSF_SETUP;
        }
@@ -655,7 +648,7 @@ void ons_ControlPoint_UpdateSprite(entity e)
 }
 
 void ons_ControlPoint_Touch()
-{
+{SELFPARAM();
        entity toucher = other;
        int attackable;
 
@@ -692,13 +685,13 @@ void ons_ControlPoint_Touch()
 }
 
 void ons_ControlPoint_Think()
-{
+{SELFPARAM();
        self.nextthink = time + ONS_CP_THINKRATE;
-       CSQCMODEL_AUTOUPDATE();
+       CSQCMODEL_AUTOUPDATE(self);
 }
 
 void ons_ControlPoint_Reset()
-{
+{SELFPARAM();
        if(self.goalentity)
                remove(self.goalentity);
 
@@ -721,23 +714,23 @@ void ons_ControlPoint_Reset()
        activator = self;
        SUB_UseTargets(); // to reset the structures, playerspawns etc.
 
-       CSQCMODEL_AUTOUPDATE();
+       CSQCMODEL_AUTOUPDATE(self);
 }
 
 void ons_DelayedControlPoint_Setup(void)
-{
+{SELFPARAM();
        onslaught_updatelinks();
 
        // captureshield setup
        ons_CaptureShield_Spawn(self, false);
 
-       CSQCMODEL_AUTOINIT();
+       CSQCMODEL_AUTOINIT(self);
 }
 
 void ons_ControlPoint_Setup(entity cp)
-{
+{SELFPARAM();
        // declarations
-       self = cp; // for later usage with droptofloor()
+       setself(cp); // for later usage with droptofloor()
 
        // main setup
        cp.ons_worldcpnext = ons_worldcplist; // link control point into ons_worldcplist
@@ -790,7 +783,7 @@ void ons_ControlPoint_Setup(entity cp)
        {
                setorigin(cp, cp.origin + '0 0 20');
                cp.noalign = false;
-               self = cp;
+               setself(cp);
                droptofloor();
                cp.movetype = MOVETYPE_TOSS;
        }
@@ -842,7 +835,7 @@ void ons_Generator_UpdateSprite(entity e)
 }
 
 void ons_GeneratorDamage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        if(damage <= 0) { return; }
        if(warmup_stage || gameover) { return; }
        if(!round_handler_IsRoundStarted()) { return; }
@@ -925,7 +918,7 @@ void ons_GeneratorDamage(entity inflictor, entity attacker, float damage, int de
 }
 
 void ons_GeneratorThink()
-{
+{SELFPARAM();
        entity e;
        self.nextthink = time + GEN_THINKRATE;
        if (!gameover)
@@ -948,7 +941,7 @@ void ons_GeneratorThink()
 }
 
 void ons_GeneratorReset()
-{
+{SELFPARAM();
        self.team = self.team_saved;
        self.lasthealth = self.max_health = self.health = autocvar_g_onslaught_gen_health;
        self.takedamage = DAMAGE_AIM;
@@ -973,7 +966,7 @@ void ons_GeneratorReset()
 }
 
 void ons_DelayedGeneratorSetup()
-{
+{SELFPARAM();
        // bot waypoints
        waypoint_spawnforitem_force(self, self.origin);
        self.nearestwaypointtimeout = 0; // activate waypointing again
@@ -989,7 +982,7 @@ void ons_DelayedGeneratorSetup()
 
 
 void onslaught_generator_touch()
-{
+{SELFPARAM();
        if ( IS_PLAYER(other) )
        if ( SAME_TEAM(self,other) )
        if ( self.iscaptured )
@@ -999,10 +992,10 @@ 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;
-       self = gen; // for later usage with droptofloor()
+       setself(gen); // for later usage with droptofloor()
 
        // main setup
        gen.ons_worldgeneratornext = ons_worldgeneratorlist; // link generator into ons_worldgeneratorlist
@@ -1046,7 +1039,7 @@ void ons_GeneratorSetup(entity gen) // called when spawning a generator entity o
        gen.colormap = 1024 + (teamnumber - 1) * 17;
 
        // generator placement
-       self = gen;
+       setself(gen);
        droptofloor();
 
        // waypointsprites
@@ -1210,7 +1203,7 @@ void Onslaught_RoundStart()
 // NOTE: LEGACY CODE, needs to be re-written!
 
 void havocbot_goalrating_ons_offenseitems(float ratingscale, vector org, float sradius)
-{
+{SELFPARAM();
        entity head;
        float t, c;
        int i;
@@ -1284,7 +1277,7 @@ void havocbot_role_ons_setrole(entity bot, int role)
 }
 
 int havocbot_ons_teamcount(entity bot, int role)
-{
+{SELFPARAM();
        int c = 0;
        entity head;
 
@@ -1297,7 +1290,7 @@ int havocbot_ons_teamcount(entity bot, int role)
 }
 
 void havocbot_goalrating_ons_controlpoints_attack(float ratingscale)
-{
+{SELFPARAM();
        entity cp, cp1, cp2, best, pl, wp;
        float radius, bestvalue;
        int c;
@@ -1415,7 +1408,7 @@ void havocbot_goalrating_ons_controlpoints_attack(float ratingscale)
 }
 
 bool havocbot_goalrating_ons_generator_attack(float ratingscale)
-{
+{SELFPARAM();
        entity g, wp, bestwp;
        bool found;
        int best;
@@ -1471,7 +1464,7 @@ bool havocbot_goalrating_ons_generator_attack(float ratingscale)
 }
 
 void havocbot_role_ons_offense()
-{
+{SELFPARAM();
        if(self.deadflag != DEAD_NO)
        {
                self.havocbot_attack_time = 0;
@@ -1506,17 +1499,17 @@ void havocbot_role_ons_offense()
 }
 
 void havocbot_role_ons_assistant()
-{
+{SELFPARAM();
        havocbot_ons_reset_role(self);
 }
 
 void havocbot_role_ons_defense()
-{
+{SELFPARAM();
        havocbot_ons_reset_role(self);
 }
 
 void havocbot_ons_reset_role(entity bot)
-{
+{SELFPARAM();
        entity head;
        int c = 0;
 
@@ -1548,7 +1541,7 @@ void havocbot_ons_reset_role(entity bot)
  * if max_dist is positive, only control points within this range will be considered
  */
 entity ons_Nearest_ControlPoint(vector pos, float max_dist)
-{
+{SELFPARAM();
        entity tmp_entity, closest_target = world;
        tmp_entity = findchain(classname, "onslaught_controlpoint");
        while(tmp_entity)
@@ -1579,7 +1572,7 @@ entity ons_Nearest_ControlPoint(vector pos, float max_dist)
  * This function only check distances on the XY plane, disregarding Z
  */
 entity ons_Nearest_ControlPoint_2D(vector pos, float max_dist)
-{
+{SELFPARAM();
        entity tmp_entity, closest_target = world;
        vector delta;
        float smallest_distance = 0, distance;
@@ -1626,7 +1619,7 @@ entity ons_Nearest_ControlPoint_2D(vector pos, float max_dist)
  * find the number of control points and generators in the same team as self
  */
 int ons_Count_SelfControlPoints()
-{
+{SELFPARAM();
        entity tmp_entity;
        tmp_entity = findchain(classname, "onslaught_controlpoint");
        int n = 0;
@@ -1702,24 +1695,25 @@ bool ons_Teleport(entity player, entity tele_target, float range, bool tele_effe
 // ==============
 
 MUTATOR_HOOKFUNCTION(ons_ResetMap)
-{
-       FOR_EACH_PLAYER(self)
+{SELFPARAM();
+       entity e;
+       FOR_EACH_PLAYER(e)
        {
-               self.ons_roundlost = false;
-               self.ons_deathloc = '0 0 0';
-               PutClientInServer();
+               e.ons_roundlost = false;
+               e.ons_deathloc = '0 0 0';
+               WITH(entity, self, e, PutClientInServer());
        }
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(ons_RemovePlayer)
-{
+{SELFPARAM();
        self.ons_deathloc = '0 0 0';
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(ons_PlayerSpawn)
-{
+{SELFPARAM();
        if(!round_handler_IsRoundStarted())
        {
                self.player_blocked = true;
@@ -1845,7 +1839,7 @@ MUTATOR_HOOKFUNCTION(ons_PlayerSpawn)
 }
 
 MUTATOR_HOOKFUNCTION(ons_PlayerDies)
-{
+{SELFPARAM();
        frag_target.ons_deathloc = frag_target.origin;
        entity l;
        for(l = ons_worldgeneratorlist; l; l = l.ons_worldgeneratornext)
@@ -1865,7 +1859,7 @@ MUTATOR_HOOKFUNCTION(ons_PlayerDies)
 }
 
 MUTATOR_HOOKFUNCTION(ons_MonsterThink)
-{
+{SELFPARAM();
        entity e = find(world, targetname, self.target);
        if (e != world)
                self.team = e.team;
@@ -1874,7 +1868,7 @@ MUTATOR_HOOKFUNCTION(ons_MonsterThink)
 }
 
 void ons_MonsterSpawn_Delayed()
-{
+{SELFPARAM();
        entity e, own = self.owner;
 
        if(!own) { remove(self); return; }
@@ -1895,7 +1889,7 @@ void ons_MonsterSpawn_Delayed()
 }
 
 MUTATOR_HOOKFUNCTION(ons_MonsterSpawn)
-{
+{SELFPARAM();
        entity e = spawn();
        e.owner = self;
        InitializeEntity(e, ons_MonsterSpawn_Delayed, INITPRIO_FINDTARGET);
@@ -1904,7 +1898,7 @@ MUTATOR_HOOKFUNCTION(ons_MonsterSpawn)
 }
 
 void ons_TurretSpawn_Delayed()
-{
+{SELFPARAM();
        entity e, own = self.owner;
 
        if(!own) { remove(self); return; }
@@ -1926,7 +1920,7 @@ void ons_TurretSpawn_Delayed()
 }
 
 MUTATOR_HOOKFUNCTION(ons_TurretSpawn)
-{
+{SELFPARAM();
        entity e = spawn();
        e.owner = self;
        InitializeEntity(e, ons_TurretSpawn_Delayed, INITPRIO_FINDTARGET);
@@ -1935,7 +1929,7 @@ MUTATOR_HOOKFUNCTION(ons_TurretSpawn)
 }
 
 MUTATOR_HOOKFUNCTION(ons_BotRoles)
-{
+{SELFPARAM();
        havocbot_ons_reset_role(self);
        return true;
 }
@@ -1959,13 +1953,13 @@ MUTATOR_HOOKFUNCTION(ons_GetTeamCount)
 }
 
 MUTATOR_HOOKFUNCTION(ons_SpectateCopy)
-{
+{SELFPARAM();
        self.ons_roundlost = other.ons_roundlost; // make spectators see it too
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(ons_SV_ParseClientCommand)
-{
+{SELFPARAM();
        if(MUTATOR_RETURNVALUE) // command was already handled?
                return false;
 
@@ -2029,7 +2023,7 @@ MUTATOR_HOOKFUNCTION(ons_SV_ParseClientCommand)
 }
 
 MUTATOR_HOOKFUNCTION(ons_PlayerUseKey)
-{
+{SELFPARAM();
        if(MUTATOR_RETURNVALUE || gameover) { return false; }
 
        if((time > self.teleport_antispam) && (self.deadflag == DEAD_NO) && !self.vehicle)
@@ -2065,7 +2059,7 @@ keys:
 "target2" - second control point.
  */
 void spawnfunc_onslaught_link()
-{
+{SELFPARAM();
        if(!g_onslaught) { remove(self); return; }
 
        if (self.target == "" || self.target2 == "")
@@ -2090,7 +2084,7 @@ keys:
  */
 
 void spawnfunc_onslaught_controlpoint()
-{
+{SELFPARAM();
        if(!g_onslaught) { remove(self); return; }
 
        ons_ControlPoint_Setup(self);
@@ -2106,7 +2100,7 @@ keys:
 "targetname" - name that spawnfunc_onslaught_link entities will use to target this.
  */
 void spawnfunc_onslaught_generator()
-{
+{SELFPARAM();
        if(!g_onslaught) { remove(self); return; }
        if(!self.team) { objerror("team must be set"); }
 
index a7a832281a870ec8d3a32fb56e51f0f1c218181c..d51b33ec2f3eb048de0bafd1a809398e664d26e0 100644 (file)
@@ -8,7 +8,7 @@
 // legacy bot roles
 .float race_checkpoint;
 void havocbot_role_race()
-{
+{SELFPARAM();
        if(self.deadflag != DEAD_NO)
                return;
 
@@ -64,7 +64,7 @@ void race_EventLog(string mode, entity actor) // use an alias for easy changing
 }
 
 MUTATOR_HOOKFUNCTION(race_PlayerPhysics)
-{
+{SELFPARAM();
        // force kbd movement for fairness
        float wishspeed;
        vector wishvel;
@@ -149,7 +149,7 @@ MUTATOR_HOOKFUNCTION(race_ResetMap)
 }
 
 MUTATOR_HOOKFUNCTION(race_PlayerPreThink)
-{
+{SELFPARAM();
        if(IS_SPEC(self) || IS_OBSERVER(self))
        if(g_race_qualifying)
        if(msg_entity.enemy.race_laptime)
@@ -159,7 +159,7 @@ MUTATOR_HOOKFUNCTION(race_PlayerPreThink)
 }
 
 MUTATOR_HOOKFUNCTION(race_ClientConnect)
-{
+{SELFPARAM();
        race_PreparePlayer();
        self.race_checkpoint = -1;
 
@@ -186,7 +186,7 @@ MUTATOR_HOOKFUNCTION(race_ClientConnect)
 }
 
 MUTATOR_HOOKFUNCTION(race_MakePlayerObserver)
-{
+{SELFPARAM();
        if(g_race_qualifying)
        if(PlayerScore_Add(self, SP_RACE_FASTEST, 0))
                self.frags = FRAGS_LMS_LOSER;
@@ -200,7 +200,7 @@ MUTATOR_HOOKFUNCTION(race_MakePlayerObserver)
 }
 
 MUTATOR_HOOKFUNCTION(race_PlayerSpawn)
-{
+{SELFPARAM();
        if(spawn_spot.target == "")
                // Emergency: this wasn't a real spawnpoint. Can this ever happen?
                race_PreparePlayer();
@@ -215,7 +215,7 @@ MUTATOR_HOOKFUNCTION(race_PlayerSpawn)
 }
 
 MUTATOR_HOOKFUNCTION(race_PutClientInServer)
-{
+{SELFPARAM();
        if(IS_PLAYER(self))
        if(!gameover)
        {
@@ -230,20 +230,20 @@ MUTATOR_HOOKFUNCTION(race_PutClientInServer)
 }
 
 MUTATOR_HOOKFUNCTION(race_PlayerDies)
-{
+{SELFPARAM();
        self.respawn_flags |= RESPAWN_FORCE;
        race_AbandonRaceCheck(self);
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(race_BotRoles)
-{
+{SELFPARAM();
        self.havocbot_role = havocbot_role_race;
        return true;
 }
 
 MUTATOR_HOOKFUNCTION(race_PlayerPostThink)
-{
+{SELFPARAM();
        if(self.cvar_cl_allow_uidtracking == 1 && self.cvar_cl_allow_uid2name == 1)
        {
                if (!self.stored_netname)
index fda2161a6b99f48cefaf9e5d6de25af927a6ecdd..27cc19b0ab8d029f17092ac75a8ad1e903263a84 100644 (file)
@@ -9,7 +9,7 @@ Keys:
 "netname" Name of the team (for example Red, Blue, Green, Yellow, Life, Death, Offense, Defense, etc)...
 "cnt" Scoreboard color of the team (for example 4 is red and 13 is blue)... */
 void spawnfunc_tdm_team()
-{
+{SELFPARAM();
        if(!g_tdm || !self.cnt) { remove(self); return; }
 
        self.classname = "tdm_team";
@@ -18,17 +18,15 @@ void spawnfunc_tdm_team()
 
 // code from here on is just to support maps that don't have team entities
 void tdm_SpawnTeam (string teamname, float teamcolor)
-{
-       entity oldself;
-       oldself = self;
-       self = spawn();
+{SELFPARAM();
+       setself(spawn());
        self.classname = "tdm_team";
        self.netname = teamname;
        self.cnt = teamcolor;
 
        spawnfunc_tdm_team();
 
-       self = oldself;
+       setself(this);
 }
 
 void tdm_DelayedInit()
index d68ff388f8583ae472366f513232a097e4bbb37e..da9a608f0156a6bc047aebf8bf98886921673830 100644 (file)
@@ -5,7 +5,7 @@
 .float bloodloss_timer;
 
 MUTATOR_HOOKFUNCTION(bloodloss_PlayerThink)
-{
+{SELFPARAM();
        if(IS_PLAYER(self))
        if(self.health <= autocvar_g_bloodloss && self.deadflag == DEAD_NO)
        {
@@ -25,7 +25,7 @@ MUTATOR_HOOKFUNCTION(bloodloss_PlayerThink)
 }
 
 MUTATOR_HOOKFUNCTION(bloodloss_PlayerJump)
-{
+{SELFPARAM();
        if(self.health <= autocvar_g_bloodloss)
                return true;
 
index 4433055b61b27f570298759fdff64f1fd78f251a..62e4d9f53d3a79303716a9e34064a5cb0d10e5ae 100644 (file)
@@ -16,7 +16,7 @@ entity buff_FirstFromFlags(int _buffs)
 }
 
 bool buffs_BuffModel_Customize()
-{
+{SELFPARAM();
        entity player, myowner;
        bool same_team;
 
@@ -65,7 +65,7 @@ vector buff_GlowColor(entity buff)
 }
 
 void buff_Effect(entity player, string eff)
-{
+{SELFPARAM();
        if(!autocvar_g_buffs_effects) { return; }
 
        if(time >= self.buff_effect_delay)
@@ -77,7 +77,7 @@ void buff_Effect(entity player, string eff)
 
 // buff item
 float buff_Waypoint_visible_for_player(entity plr)
-{
+{SELFPARAM();
        if(!self.owner.buff_active && !self.owner.buff_activetime)
                return false;
 
@@ -99,7 +99,7 @@ void buff_Waypoint_Spawn(entity e)
 }
 
 void buff_SetCooldown(float cd)
-{
+{SELFPARAM();
        cd = max(0, cd);
 
        if(!self.buff_waypoint)
@@ -111,7 +111,7 @@ void buff_SetCooldown(float cd)
 }
 
 void buff_Respawn(entity ent)
-{
+{SELFPARAM();
        if(gameover) { return; }
 
        vector oldbufforigin = ent.origin;
@@ -144,7 +144,7 @@ void buff_Respawn(entity ent)
 }
 
 void buff_Touch()
-{
+{SELFPARAM();
        if(gameover) { return; }
 
        if(ITEM_TOUCH_NEEDKILL())
@@ -220,7 +220,7 @@ void buff_NewType(entity ent, float cb)
 }
 
 void buff_Think()
-{
+{SELFPARAM();
        if(self.buffs != self.oldbuffs)
        {
                entity buff = buff_FirstFromFlags(self.buffs);
@@ -291,14 +291,14 @@ void buff_Think()
 }
 
 void buff_Waypoint_Reset()
-{
+{SELFPARAM();
        WaypointSprite_Kill(self.buff_waypoint);
 
        if(self.buff_activetime) { buff_Waypoint_Spawn(self); }
 }
 
 void buff_Reset()
-{
+{SELFPARAM();
        if(autocvar_g_buffs_randomize)
                buff_NewType(self, self.buffs);
        self.owner = world;
@@ -311,7 +311,7 @@ void buff_Reset()
 }
 
 float buff_Customize()
-{
+{SELFPARAM();
        entity player = WaypointSprite_getviewentity(other);
        if(!self.buff_active || (self.team && DIFF_TEAM(player, self)))
        {
@@ -330,15 +330,14 @@ float buff_Customize()
 }
 
 void buff_Init(entity ent)
-{
+{SELFPARAM();
        if(!cvar("g_buffs")) { remove(ent); return; }
 
        if(!teamplay && ent.team) { ent.team = 0; }
 
        entity buff = buff_FirstFromFlags(self.buffs);
 
-       entity oldself = self;
-       self = ent;
+       setself(ent);
        if(!self.buffs || buff_Available(buff))
                buff_NewType(self, 0);
 
@@ -375,7 +374,7 @@ void buff_Init(entity ent)
        if(cvar("g_buffs_random_location") || (self.spawnflags & 64))
                buff_Respawn(self);
 
-       self = oldself;
+       setself(this);
 }
 
 void buff_Init_Compat(entity ent, entity replacement)
@@ -400,7 +399,7 @@ void buff_SpawnReplacement(entity ent, entity old)
 }
 
 void buff_Vengeance_DelayedDamage()
-{
+{SELFPARAM();
        if(self.enemy)
                Damage(self.enemy, self.owner, self.owner, self.dmg, DEATH_BUFF, self.enemy.origin, '0 0 0');
 
@@ -520,7 +519,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerDamage_Calculate)
 }
 
 MUTATOR_HOOKFUNCTION(buffs_PlayerSpawn)
-{
+{SELFPARAM();
        self.buffs = 0;
        // reset timers here to prevent them continuing after re-spawn
        self.buff_disability_time = 0;
@@ -529,7 +528,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerSpawn)
 }
 
 MUTATOR_HOOKFUNCTION(buffs_PlayerPhysics)
-{
+{SELFPARAM();
        if(self.buffs & BUFF_SPEED.m_itemid)
        {
                self.stat_sv_maxspeed *= autocvar_g_buffs_speed_speed;
@@ -552,7 +551,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerPhysics)
 }
 
 MUTATOR_HOOKFUNCTION(buffs_PlayerJump)
-{
+{SELFPARAM();
        if(self.buffs & BUFF_JUMP.m_itemid)
                player_jumpheight = autocvar_g_buffs_jump_height;
 
@@ -560,7 +559,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerJump)
 }
 
 MUTATOR_HOOKFUNCTION(buffs_MonsterMove)
-{
+{SELFPARAM();
        if(time < self.buff_disability_time)
        {
                monster_speed_walk *= autocvar_g_buffs_disability_speed;
@@ -571,7 +570,7 @@ MUTATOR_HOOKFUNCTION(buffs_MonsterMove)
 }
 
 MUTATOR_HOOKFUNCTION(buffs_PlayerDies)
-{
+{SELFPARAM();
        if(self.buffs)
        {
                int buffid = buff_FirstFromFlags(self.buffs).m_id;
@@ -588,7 +587,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerDies)
 }
 
 MUTATOR_HOOKFUNCTION(buffs_PlayerUseKey)
-{
+{SELFPARAM();
        if(MUTATOR_RETURNVALUE || gameover) { return false; }
        if(self.buffs)
        {
@@ -604,7 +603,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerUseKey)
 }
 
 MUTATOR_HOOKFUNCTION(buffs_PlayerThrowKey)
-{
+{SELFPARAM();
        if(MUTATOR_RETURNVALUE || gameover) { return false; }
 
        if(self.buffs & BUFF_SWAPPER.m_itemid)
@@ -674,7 +673,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerThrowKey)
 }
 
 MUTATOR_HOOKFUNCTION(buffs_RemovePlayer)
-{
+{SELFPARAM();
        if(self.buff_model)
        {
                remove(self.buff_model);
@@ -689,7 +688,7 @@ MUTATOR_HOOKFUNCTION(buffs_RemovePlayer)
 }
 
 MUTATOR_HOOKFUNCTION(buffs_CustomizeWaypoint)
-{
+{SELFPARAM();
        entity e = WaypointSprite_getviewentity(other);
 
        // if you have the invisibility powerup, sprites ALWAYS are restricted to your team
@@ -702,7 +701,7 @@ MUTATOR_HOOKFUNCTION(buffs_CustomizeWaypoint)
 }
 
 MUTATOR_HOOKFUNCTION(buffs_OnEntityPreSpawn)
-{
+{SELFPARAM();
        if(autocvar_g_buffs_replace_powerups)
        switch(self.classname)
        {
@@ -718,7 +717,7 @@ MUTATOR_HOOKFUNCTION(buffs_OnEntityPreSpawn)
 }
 
 MUTATOR_HOOKFUNCTION(buffs_WeaponRate)
-{
+{SELFPARAM();
        if(self.buffs & BUFF_SPEED.m_itemid)
                weapon_rate *= autocvar_g_buffs_speed_rate;
 
@@ -729,7 +728,7 @@ MUTATOR_HOOKFUNCTION(buffs_WeaponRate)
 }
 
 MUTATOR_HOOKFUNCTION(buffs_WeaponSpeed)
-{
+{SELFPARAM();
        if(self.buffs & BUFF_SPEED.m_itemid)
                ret_float *= autocvar_g_buffs_speed_weaponspeed;
 
@@ -742,7 +741,7 @@ MUTATOR_HOOKFUNCTION(buffs_WeaponSpeed)
 .float buff_time;
 
 MUTATOR_HOOKFUNCTION(buffs_PlayerThink)
-{
+{SELFPARAM();
        if(gameover || self.deadflag != DEAD_NO) { return false; }
 
        if(time < self.buff_disability_time)
@@ -784,13 +783,12 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerThink)
                for(other = world; (other = findflags(other, flags, FL_ITEM)); )
                if(boxesoverlap(self.absmin - pickup_size, self.absmax + pickup_size, other.absmin, other.absmax))
                {
-                       entity oldself = self;
-                       self = other;
-                       other = oldself;
+                       setself(other);
+                       other = this;
                        if(self.touch)
                                self.touch();
                        other = self;
-                       self = oldself;
+                       setself(this);
                }
        }
 
@@ -889,7 +887,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerThink)
 }
 
 MUTATOR_HOOKFUNCTION(buffs_SpectateCopy)
-{
+{SELFPARAM();
        self.buffs = other.buffs;
        return false;
 }
@@ -909,7 +907,7 @@ MUTATOR_HOOKFUNCTION(buffs_VehicleExit)
 }
 
 MUTATOR_HOOKFUNCTION(buffs_PlayerRegen)
-{
+{SELFPARAM();
        if(self.buffs & BUFF_MEDIC.m_itemid)
        {
                regen_mod_rot = autocvar_g_buffs_medic_rot;
index 2839ae09b6e546ee01faa1adf04be0ed0fc39e90..e4ad5ba19854f13851fb987bca87c111f189e1cf 100644 (file)
@@ -8,7 +8,7 @@
 .float campcheck_traveled_distance;
 
 MUTATOR_HOOKFUNCTION(campcheck_PlayerDies)
-{
+{SELFPARAM();
        Kill_Notification(NOTIF_ONE, self, MSG_CENTER_CPID, CPID_CAMPCHECK);
 
        return false;
@@ -28,7 +28,7 @@ MUTATOR_HOOKFUNCTION(campcheck_PlayerDamage)
 }
 
 MUTATOR_HOOKFUNCTION(campcheck_PlayerThink)
-{
+{SELFPARAM();
        if(!gameover)
        if(!warmup_stage) // don't consider it camping during warmup?
        if(time >= game_starttime)
@@ -74,7 +74,7 @@ MUTATOR_HOOKFUNCTION(campcheck_PlayerThink)
 }
 
 MUTATOR_HOOKFUNCTION(campcheck_PlayerSpawn)
-{
+{SELFPARAM();
        self.campcheck_nextcheck = time + autocvar_g_campcheck_interval * 2;
        self.campcheck_traveled_distance = 0;
 
index ab70fb217da5829ae99d1df98c8dd7c9e5dfb007..b5dc32fdfe0d924a233b099ab47f802eaceba6e3 100644 (file)
@@ -83,7 +83,7 @@
 #elif defined(SVQC)
 
 void dodging_UpdateStats()
-{
+{SELFPARAM();
        self.stat_dodging = PHYS_DODGING;
        self.stat_dodging_delay = PHYS_DODGING_DELAY;
        self.stat_dodging_horiz_speed_frozen = PHYS_DODGING_HORIZ_SPEED_FROZEN;
@@ -116,7 +116,7 @@ void dodging_Initialize()
 
 // returns 1 if the player is close to a wall
 bool check_close_to_wall(float threshold)
-{
+{SELFPARAM();
        if (PHYS_DODGING_WALL == 0) { return false; }
 
        #define X(OFFSET)                                                                                                                               \
@@ -133,12 +133,12 @@ bool check_close_to_wall(float threshold)
 }
 
 bool check_close_to_ground(float threshold)
-{
+{SELFPARAM();
        return IS_ONGROUND(self) ? true : false;
 }
 
 float PM_dodging_checkpressedkeys()
-{
+{SELFPARAM();
        if(!PHYS_DODGING)
                return false;
 
@@ -199,7 +199,7 @@ float PM_dodging_checkpressedkeys()
 }
 
 void PM_dodging()
-{
+{SELFPARAM();
        if (!PHYS_DODGING)
                return;
 
index 3055dbf539b931e6137fdbc0c4cad513d26118c2..9aecd0e4e7e9917cbbd12bf1a04b359c8f9ad85e 100644 (file)
@@ -8,7 +8,7 @@
 #include "../../common/items/all.qc"
 
 void spawnfunc_item_minst_cells()
-{
+{SELFPARAM();
        if (!g_instagib) { remove(self); return; }
        if (!self.ammo_cells) self.ammo_cells = autocvar_g_instagib_ammo_drop;
        StartItemA(ITEM_VaporizerCells);
@@ -21,7 +21,7 @@ void instagib_invisibility()
 }
 
 void instagib_extralife()
-{
+{SELFPARAM();
        self.max_health = 1;
        StartItemA(ITEM_ExtraLife);
 }
@@ -42,7 +42,7 @@ void instagib_stop_countdown(entity e)
        e.instagib_needammo = false;
 }
 void instagib_ammocheck()
-{
+{SELFPARAM();
        if(time < self.instagib_nextthink)
                return;
        if(!IS_PLAYER(self))
@@ -140,7 +140,7 @@ MUTATOR_HOOKFUNCTION(instagib_MonsterLoot)
 }
 
 MUTATOR_HOOKFUNCTION(instagib_MonsterSpawn)
-{
+{SELFPARAM();
        // always refill ammo
        if(self.monsterid == MON_MAGE.monsterid)
                self.skin = 1;
@@ -157,13 +157,13 @@ MUTATOR_HOOKFUNCTION(instagib_BotShouldAttack)
 }
 
 MUTATOR_HOOKFUNCTION(instagib_MakePlayerObserver)
-{
+{SELFPARAM();
        instagib_stop_countdown(self);
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(instagib_PlayerSpawn)
-{
+{SELFPARAM();
        self.effects |= EF_FULLBRIGHT;
        return false;
 }
@@ -181,7 +181,7 @@ MUTATOR_HOOKFUNCTION(instagib_PlayerRegen)
 }
 
 MUTATOR_HOOKFUNCTION(instagib_PlayerPowerups)
-{
+{SELFPARAM();
        if (!(self.effects & EF_FULLBRIGHT))
                self.effects |= EF_FULLBRIGHT;
 
@@ -230,7 +230,7 @@ MUTATOR_HOOKFUNCTION(instagib_PlayerPowerups)
 }
 
 MUTATOR_HOOKFUNCTION(instagib_PlayerPhysics)
-{
+{SELFPARAM();
        if(self.items & ITEM_Speed.m_itemid)
                self.stat_sv_maxspeed = self.stat_sv_maxspeed * autocvar_g_instagib_speed_highspeed;
 
@@ -340,7 +340,7 @@ MUTATOR_HOOKFUNCTION(instagib_SetStartItems)
 }
 
 MUTATOR_HOOKFUNCTION(instagib_FilterItem)
-{
+{SELFPARAM();
        if(self.classname == "item_cells")
                return true; // no normal cells?
 
@@ -352,15 +352,12 @@ MUTATOR_HOOKFUNCTION(instagib_FilterItem)
 
        if(self.weapon == WEP_DEVASTATOR.m_id || self.weapon == WEP_VORTEX.m_id)
        {
-               entity e = spawn(), oldself;
+               entity e = spawn();
                setorigin(e, self.origin);
-               oldself = self;
-               self = e;
-               self.noalign = oldself.noalign;
-               self.cnt = oldself.cnt;
-               self.team = oldself.team;
-               spawnfunc_item_minst_cells();
-               self = oldself;
+               e.noalign = self.noalign;
+        e.cnt = self.cnt;
+        e.team = self.team;
+               WITH(entity, self, e, spawnfunc_item_minst_cells());
                return true;
        }
 
@@ -377,7 +374,7 @@ MUTATOR_HOOKFUNCTION(instagib_FilterItem)
 }
 
 MUTATOR_HOOKFUNCTION(instagib_CustomizeWaypoint)
-{
+{SELFPARAM();
        entity e = WaypointSprite_getviewentity(other);
 
        // if you have the invisibility powerup, sprites ALWAYS are restricted to your team
@@ -398,7 +395,7 @@ MUTATOR_HOOKFUNCTION(instagib_PlayerDies)
 }
 
 MUTATOR_HOOKFUNCTION(instagib_ItemTouch)
-{
+{SELFPARAM();
        if(self.ammo_cells)
        {
                // play some cool sounds ;)
@@ -427,7 +424,7 @@ MUTATOR_HOOKFUNCTION(instagib_ItemTouch)
 }
 
 MUTATOR_HOOKFUNCTION(instagib_OnEntityPreSpawn)
-{
+{SELFPARAM();
        if (!autocvar_g_powerups) { return false; }
        // Can't use .itemdef here
        if (!(self.classname == "item_strength" || self.classname == "item_invincible" || self.classname == "item_health_mega"))
index c77bba51630a59378bbfe02a0714d7ce32413391..dee8dd6bc92c20d702da0587dcc0181392cc4b30 100644 (file)
@@ -16,7 +16,7 @@ MUTATOR_HOOKFUNCTION(melee_ForbidThrowing)
 }
 
 MUTATOR_HOOKFUNCTION(melee_FilterItem)
-{
+{SELFPARAM();
        switch (self.items)
        {
                case ITEM_HealthSmall.m_itemid:
index 686df9a567ad123316f2200c08e1e9d0c1efc4a9..3ac73031713d92d47be9d605f5472cf1bbd3ea3b 100644 (file)
@@ -5,7 +5,7 @@
 .float midair_shieldtime;
 
 MUTATOR_HOOKFUNCTION(midair_PlayerDamage)
-{
+{SELFPARAM();
        if(IS_PLAYER(frag_attacker))
        if(IS_PLAYER(frag_target))
        if(time < self.midair_shieldtime)
@@ -15,7 +15,7 @@ MUTATOR_HOOKFUNCTION(midair_PlayerDamage)
 }
 
 MUTATOR_HOOKFUNCTION(midair_PlayerPowerups)
-{
+{SELFPARAM();
        if(time >= game_starttime)
        if(self.flags & FL_ONGROUND)
        {
@@ -27,7 +27,7 @@ MUTATOR_HOOKFUNCTION(midair_PlayerPowerups)
 }
 
 MUTATOR_HOOKFUNCTION(midair_PlayerSpawn)
-{
+{SELFPARAM();
        if(IS_BOT_CLIENT(self))
                self.bot_moveskill = 0; // disable bunnyhopping
 
index a5bb70b8e2ed44b988fcf2d586841a3553db8dce..04e60bb83ec490cc6ebad1483a0642dfefff4fef 100644 (file)
@@ -32,7 +32,7 @@
 .float stat_multijump_dodging;
 
 void multijump_UpdateStats()
-{
+{SELFPARAM();
        self.stat_multijump = PHYS_MULTIJUMP;
        self.stat_multijump_speed = PHYS_MULTIJUMP_SPEED;
        self.stat_multijump_add = PHYS_MULTIJUMP_ADD;
@@ -52,7 +52,7 @@ void multijump_AddStats()
 #endif
 
 void PM_multijump()
-{
+{SELFPARAM();
        if(!PHYS_MULTIJUMP) { return; }
 
        if(IS_ONGROUND(self))
@@ -62,7 +62,7 @@ void PM_multijump()
 }
 
 bool PM_multijump_checkjump()
-{
+{SELFPARAM();
        if(!PHYS_MULTIJUMP) { return false; }
 
 #ifdef SVQC
index 0adff6068c77770b6b754c1aa053ae194b51b2b3..8e49e2aa63404fe6c9505f84026935dd38e830af 100644 (file)
@@ -14,7 +14,7 @@
 .entity nade_spawnloc;
 
 void nade_timer_think()
-{
+{SELFPARAM();
        self.skin = 8 - (self.owner.wait - time) / (autocvar_g_nades_nade_lifetime / 10);
        self.nextthink = time;
        if(!self.owner || wasfreed(self.owner))
@@ -46,7 +46,7 @@ void nade_spawn(entity _nade)
 }
 
 void napalm_damage(float dist, float damage, float edgedamage, float burntime)
-{
+{SELFPARAM();
        entity e;
        float d;
        vector p;
@@ -84,7 +84,7 @@ void napalm_damage(float dist, float damage, float edgedamage, float burntime)
 
 
 void napalm_ball_think()
-{
+{SELFPARAM();
        if(round_handler_IsActive())
        if(!round_handler_IsRoundStarted())
        {
@@ -117,7 +117,7 @@ void napalm_ball_think()
 
 
 void nade_napalm_ball()
-{
+{SELFPARAM();
        entity proj;
        vector kick;
 
@@ -158,7 +158,7 @@ void nade_napalm_ball()
 
 
 void napalm_fountain_think()
-{
+{SELFPARAM();
 
        if(round_handler_IsActive())
        if(!round_handler_IsRoundStarted())
@@ -196,7 +196,7 @@ void napalm_fountain_think()
 }
 
 void nade_napalm_boom()
-{
+{SELFPARAM();
        entity fountain;
        int c;
        for (c = 0; c < autocvar_g_nades_napalm_ball_count; c++)
@@ -237,7 +237,7 @@ void nade_ice_freeze(entity freezefield, entity frost_target, float freeze_time)
 }
 
 void nade_ice_think()
-{
+{SELFPARAM();
 
        if(round_handler_IsActive())
        if(!round_handler_IsRoundStarted())
@@ -310,7 +310,7 @@ void nade_ice_think()
 }
 
 void nade_ice_boom()
-{
+{SELFPARAM();
        entity fountain;
        fountain = spawn();
        fountain.owner = self.owner;
@@ -349,7 +349,7 @@ void nade_ice_boom()
 }
 
 void nade_translocate_boom()
-{
+{SELFPARAM();
        if(self.realowner.vehicle)
                return;
 
@@ -365,7 +365,7 @@ void nade_translocate_boom()
 }
 
 void nade_spawn_boom()
-{
+{SELFPARAM();
        entity spawnloc = spawn();
        setorigin(spawnloc, self.origin);
        setsize(spawnloc, self.realowner.mins, self.realowner.maxs);
@@ -385,7 +385,7 @@ void nade_spawn_boom()
 }
 
 void nade_heal_think()
-{
+{SELFPARAM();
        if(time >= self.ltime)
        {
                remove(self);
@@ -404,7 +404,7 @@ void nade_heal_think()
 }
 
 void nade_heal_touch()
-{
+{SELFPARAM();
        float maxhealth;
        float health_factor;
        if(IS_PLAYER(other) || IS_MONSTER(other))
@@ -446,7 +446,7 @@ void nade_heal_touch()
 }
 
 void nade_heal_boom()
-{
+{SELFPARAM();
        entity healer;
        healer = spawn();
        healer.owner = self.owner;
@@ -472,7 +472,7 @@ void nade_heal_boom()
 }
 
 void nade_monster_boom()
-{
+{SELFPARAM();
        entity e = spawnmonster(self.pokenade_type, 0, self.realowner, self.realowner, self.origin, false, false, 1);
 
        if(autocvar_g_nades_pokenade_monster_lifetime > 0)
@@ -481,7 +481,7 @@ void nade_monster_boom()
 }
 
 void nade_boom()
-{
+{SELFPARAM();
        entity expef = NULL;
        bool nade_blast = true;
 
@@ -562,7 +562,7 @@ void nade_boom()
 }
 
 void nade_touch()
-{
+{SELFPARAM();
        /*float is_weapclip = 0;
        if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NODRAW)
        if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NONSOLID))
@@ -593,14 +593,14 @@ void nade_touch()
 }
 
 void nade_beep()
-{
+{SELFPARAM();
        sound(self, CH_SHOTS_SINGLE, "overkill/grenadebip.ogg", VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
        self.think = nade_boom;
        self.nextthink = max(self.wait, time);
 }
 
 void nade_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        if(ITEM_DAMAGE_NEEDKILL(deathtype))
        {
                self.takedamage = DAMAGE_NO;
@@ -666,7 +666,7 @@ void nade_damage(entity inflictor, entity attacker, float damage, int deathtype,
 }
 
 void toss_nade(entity e, vector _velocity, float _time)
-{
+{SELFPARAM();
        if(e.nade == world)
                return;
 
@@ -772,7 +772,7 @@ void nades_RemoveBonus(entity player)
 }
 
 float nade_customize()
-{
+{SELFPARAM();
        //if(IS_SPEC(other)) { return false; }
        if(other == self.realowner || (IS_SPEC(other) && other.enemy == self.realowner))
        {
@@ -794,7 +794,7 @@ float nade_customize()
 }
 
 void nade_prime()
-{
+{SELFPARAM();
        if(autocvar_g_nades_bonus_only)
        if(!self.bonus_nades)
                return; // only allow bonus nades
@@ -855,7 +855,7 @@ void nade_prime()
 }
 
 float CanThrowNade()
-{
+{SELFPARAM();
        if(self.vehicle)
                return false;
 
@@ -878,7 +878,7 @@ float CanThrowNade()
 }
 
 void nades_CheckThrow()
-{
+{SELFPARAM();
        if(!CanThrowNade())
                return;
 
@@ -930,7 +930,7 @@ MUTATOR_HOOKFUNCTION(nades_VehicleEnter)
 }
 
 MUTATOR_HOOKFUNCTION(nades_PlayerPreThink)
-{
+{SELFPARAM();
        if(!IS_PLAYER(self)) { return false; }
 
        float key_pressed = self.BUTTON_HOOK;
@@ -1061,7 +1061,7 @@ MUTATOR_HOOKFUNCTION(nades_PlayerPreThink)
 }
 
 MUTATOR_HOOKFUNCTION(nades_PlayerSpawn)
-{
+{SELFPARAM();
        if(autocvar_g_nades_spawn)
                self.nade_refire = time + autocvar_g_spawnshieldtime;
        else
@@ -1142,7 +1142,7 @@ MUTATOR_HOOKFUNCTION(nades_PlayerDamage)
 }
 
 MUTATOR_HOOKFUNCTION(nades_MonsterDies)
-{
+{SELFPARAM();
        if(IS_PLAYER(frag_attacker))
        if(DIFF_TEAM(frag_attacker, self))
        if(!(self.spawnflags & MONSTERFLAG_SPAWNED))
@@ -1152,14 +1152,14 @@ MUTATOR_HOOKFUNCTION(nades_MonsterDies)
 }
 
 MUTATOR_HOOKFUNCTION(nades_RemovePlayer)
-{
+{SELFPARAM();
        nades_Clear(self);
        nades_RemoveBonus(self);
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(nades_SpectateCopy)
-{
+{SELFPARAM();
        self.nade_timer = other.nade_timer;
        self.nade_type = other.nade_type;
        self.pokenade_type = other.pokenade_type;
index 1d4beda65d4dfa27efd1bed57031c84d7d0efa4c..172ee4d651430b2d8a6e08458f54cfb71a4f17f9 100644 (file)
@@ -169,7 +169,7 @@ MUTATOR_HOOKFUNCTION(nt_SetStartItems)
 }
 
 MUTATOR_HOOKFUNCTION(nt_SetWeaponreplace)
-{
+{SELFPARAM();
        // otherwise, we do replace
        if(self.new_toys)
        {
@@ -189,7 +189,7 @@ MUTATOR_HOOKFUNCTION(nt_SetWeaponreplace)
 }
 
 MUTATOR_HOOKFUNCTION(nt_FilterItem)
-{
+{SELFPARAM();
        if(nt_IsNewToy(self.weapon) && autocvar_g_new_toys_use_pickupsound)
                self.item_pickupsound = W_Sound("weaponpickup_new_toys");
        return 0;
index f239dbbf635d17623c2e2d20fcdb164a932a3914..8cf0118d4e428465befc4f810012246f5b700b15 100644 (file)
@@ -44,7 +44,7 @@ void NIX_ChooseNextWeapon()
 }
 
 void NIX_GiveCurrentWeapon()
-{
+{SELFPARAM();
        float dt;
 
        if(!nix_nextweapon)
@@ -177,7 +177,7 @@ MUTATOR_HOOKFUNCTION(nix_BuildMutatorsPrettyString)
 }
 
 MUTATOR_HOOKFUNCTION(nix_FilterItem)
-{
+{SELFPARAM();
        switch (self.items)
        {
                case ITEM_HealthSmall.m_itemid:
@@ -202,14 +202,14 @@ MUTATOR_HOOKFUNCTION(nix_FilterItem)
 }
 
 MUTATOR_HOOKFUNCTION(nix_OnEntityPreSpawn)
-{
+{SELFPARAM();
        if(self.classname == "target_items") // items triggers cannot work in nix (as they change weapons/ammo)
                return 1;
        return 0;
 }
 
 MUTATOR_HOOKFUNCTION(nix_PlayerPreThink)
-{
+{SELFPARAM();
        if(!intermission_running)
        if(self.deadflag == DEAD_NO)
        if(IS_PLAYER(self))
@@ -218,7 +218,7 @@ MUTATOR_HOOKFUNCTION(nix_PlayerPreThink)
 }
 
 MUTATOR_HOOKFUNCTION(nix_PlayerSpawn)
-{
+{SELFPARAM();
        self.nix_lastchange_id = -1;
        NIX_GiveCurrentWeapon(); // overrides the weapons you got when spawning
        self.items |= IT_UNLIMITED_SUPERWEAPONS;
@@ -232,7 +232,7 @@ MUTATOR_HOOKFUNCTION(nix_SetModname)
 }
 
 MUTATOR_DEFINITION(mutator_nix)
-{
+{SELFPARAM();
        entity e;
 
        MUTATOR_HOOK(ForbidThrowCurrentWeapon, nix_ForbidThrowCurrentWeapon, CBC_ORDER_ANY);
index 9247dffacaf1317ab1fbccb4157fdaa9de7fbf89..d7739d8eec46604b660077479e7ce81ba6a9148b 100644 (file)
@@ -64,15 +64,14 @@ MUTATOR_HOOKFUNCTION(ok_PlayerDamage_Calculate)
 }
 
 MUTATOR_HOOKFUNCTION(ok_PlayerDamage_SplitHealthArmor)
-{
+{SELFPARAM();
        if(damage_take)
                self.ok_pauseregen_finished = max(self.ok_pauseregen_finished, time + 2);
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(ok_PlayerDies)
-{
-       entity oldself = self;
+{SELFPARAM();
        entity targ = ((frag_attacker) ? frag_attacker : frag_target);
 
        if(IS_MONSTER(self))
@@ -81,7 +80,7 @@ MUTATOR_HOOKFUNCTION(ok_PlayerDies)
                other = world;
        }
 
-       self = spawn();
+       setself(spawn());
        self.ok_item = true;
        self.noalign = true;
        self.pickup_anyway = true;
@@ -93,7 +92,7 @@ MUTATOR_HOOKFUNCTION(ok_PlayerDies)
        self.velocity = '0 0 200' + normalize(targ.origin - self.origin) * 500;
        self.classname = "droppedweapon"; // hax
        SUB_SetFade(self, time + 5, 1);
-       self = oldself;
+       setself(this);
 
        self.ok_lastwep = self.switchweapon;
 
@@ -101,7 +100,7 @@ MUTATOR_HOOKFUNCTION(ok_PlayerDies)
 }
 
 MUTATOR_HOOKFUNCTION(ok_PlayerRegen)
-{
+{SELFPARAM();
        // overkill's values are different, so use custom regen
        if(!self.frozen)
        {
@@ -125,7 +124,7 @@ MUTATOR_HOOKFUNCTION(ok_ForbidThrowCurrentWeapon)
 }
 
 MUTATOR_HOOKFUNCTION(ok_PlayerPreThink)
-{
+{SELFPARAM();
        if(intermission_running || gameover)
                return false;
 
@@ -189,7 +188,7 @@ MUTATOR_HOOKFUNCTION(ok_PlayerPreThink)
 }
 
 MUTATOR_HOOKFUNCTION(ok_PlayerSpawn)
-{
+{SELFPARAM();
        if(autocvar_g_overkill_ammo_charge)
        {
                for(int i = WEP_FIRST; i <= WEP_LAST; ++i)
@@ -207,7 +206,7 @@ MUTATOR_HOOKFUNCTION(ok_PlayerSpawn)
 }
 
 MUTATOR_HOOKFUNCTION(ok_OnEntityPreSpawn)
-{
+{SELFPARAM();
        if(autocvar_g_powerups)
        if(autocvar_g_overkill_powerups_replace)
        {
@@ -250,7 +249,7 @@ MUTATOR_HOOKFUNCTION(ok_OnEntityPreSpawn)
 }
 
 MUTATOR_HOOKFUNCTION(ok_ItemRemove)
-{
+{SELFPARAM();
        if(self.ok_item)
                return false;
 
@@ -264,7 +263,7 @@ MUTATOR_HOOKFUNCTION(ok_ItemRemove)
 }
 
 MUTATOR_HOOKFUNCTION(ok_SpectateCopy)
-{
+{SELFPARAM();
        self.ammo_charge[self.weapon] = other.ammo_charge[other.weapon];
        self.ok_use_ammocharge = other.ok_use_ammocharge;
 
index 0ee697d261f2d4425cdd4eb37b68a634cc7da734..d02158ffc1496a22305c9ab02e79e0eeae1819b3 100644 (file)
@@ -5,7 +5,7 @@
 .vector spawn_origin, spawn_angles;
 
 void physical_item_think()
-{
+{SELFPARAM();
        self.nextthink = time;
 
        self.alpha = self.owner.alpha; // apply fading and ghosting
@@ -42,7 +42,7 @@ void physical_item_think()
 }
 
 void physical_item_touch()
-{
+{SELFPARAM();
        if(!self.cnt) // not for dropped items
        if (ITEM_TOUCH_NEEDKILL())
        {
@@ -52,7 +52,7 @@ void physical_item_touch()
 }
 
 void physical_item_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        if(!self.cnt) // not for dropped items
        if(ITEM_DAMAGE_NEEDKILL(deathtype))
        {
@@ -62,7 +62,7 @@ void physical_item_damage(entity inflictor, entity attacker, float damage, int d
 }
 
 MUTATOR_HOOKFUNCTION(item_spawning)
-{
+{SELFPARAM();
        if(self.owner == world && autocvar_g_physical_items <= 1)
                return false;
        if (self.spawnflags & 1) // floating item
index 5dd6aa92e46e90b02aae2e1277f70460b9243db7..71262b923df8ca18e4ff4a6b36ab7d18cb46f30f 100644 (file)
@@ -3,7 +3,7 @@
 #include "mutator.qh"
 
 MUTATOR_HOOKFUNCTION(pinata_PlayerDies)
-{
+{SELFPARAM();
        float j;
        for(j = WEP_FIRST; j <= WEP_LAST; ++j)
        if(self.weapons & WepSet_FromWeapon(j))
index 1464870916ebaa23b06be4fe3992fb60a9b58ed0..e3178b338874f9892eb174afdffa6800e2c3c8a7 100644 (file)
@@ -10,7 +10,7 @@
 .float cvar_cl_spawn_near_teammate;
 
 MUTATOR_HOOKFUNCTION(msnt_Spawn_Score)
-{
+{SELFPARAM();
        if(autocvar_g_spawn_near_teammate_ignore_spawnpoint == 1 || (autocvar_g_spawn_near_teammate_ignore_spawnpoint == 2 && self.cvar_cl_spawn_near_teammate))
                return 0;
 
@@ -46,7 +46,7 @@ MUTATOR_HOOKFUNCTION(msnt_Spawn_Score)
 }
 
 MUTATOR_HOOKFUNCTION(msnt_PlayerSpawn)
-{
+{SELFPARAM();
        // Note: when entering this, fixangle is already set.
        if(autocvar_g_spawn_near_teammate_ignore_spawnpoint == 1 || (autocvar_g_spawn_near_teammate_ignore_spawnpoint == 2 && self.cvar_cl_spawn_near_teammate))
        {
@@ -155,7 +155,7 @@ MUTATOR_HOOKFUNCTION(msnt_PlayerSpawn)
 }
 
 MUTATOR_HOOKFUNCTION(msnt_PlayerDies)
-{
+{SELFPARAM();
        self.msnt_deathloc = self.origin;
        return 0;
 }
index b75e5d424c8638c4038aad900e500314d952ed13..32e81319dfe87dda5d6eeaa680aed00836bd77ae 100644 (file)
@@ -25,7 +25,7 @@ const float SSF_ITEMMSG = 4;
 .string superspec_itemfilter; //"classname1 classname2 ..."
 
 float _spectate(entity _player)
-{
+{SELFPARAM();
        if(Spectate(_player) == 1)
                self.classname = "spectator";
 
@@ -33,7 +33,7 @@ float _spectate(entity _player)
 }
 
 void superspec_save_client_conf()
-{
+{SELFPARAM();
        string fn = "superspec-local.options";
        float fh;
 
@@ -99,12 +99,13 @@ float superspec_filteritem(entity _for, entity _item)
 }
 
 MUTATOR_HOOKFUNCTION(superspec_ItemTouch)
-{
-       entity _oldself = self;
+{SELFPARAM();
        entity _item = self;
 
-       FOR_EACH_SPEC(self)
+       entity e;
+       FOR_EACH_SPEC(e)
        {
+               setself(e);
                if(self.superspec_flags & SSF_ITEMMSG)
                        if(superspec_filteritem(self, _item))
                        {
@@ -116,7 +117,7 @@ MUTATOR_HOOKFUNCTION(superspec_ItemTouch)
                                {
                                        _spectate(other);
 
-                                       self = _oldself;
+                                       setself(this);
                                        return MUT_ITEMTOUCH_CONTINUE;
                                }
                        }
@@ -146,13 +147,13 @@ MUTATOR_HOOKFUNCTION(superspec_ItemTouch)
                }
        }
 
-       self = _oldself;
+       setself(this);
 
        return MUT_ITEMTOUCH_CONTINUE;
 }
 
 MUTATOR_HOOKFUNCTION(superspec_SV_ParseClientCommand)
-{
+{SELFPARAM();
 #define OPTIONINFO(flag,var,test,text,long,short) \
     var = strcat(var, ((flag & test) ? "^2[ON]  ^7" : "^1[OFF] ^7")); \
     var = strcat(var, text," ^7(^3 ", long, "^7 | ^3", short, " ^7)\n")
@@ -434,7 +435,7 @@ MUTATOR_HOOKFUNCTION(superspec_BuildMutatorsPrettyString)
 }
 
 void superspec_hello()
-{
+{SELFPARAM();
        if(self.enemy.crypto_idfp == "")
                Send_Notification(NOTIF_ONE_ONLY, self.enemy, MSG_INFO, INFO_SUPERSPEC_MISSING_UID);
 
@@ -442,7 +443,7 @@ void superspec_hello()
 }
 
 MUTATOR_HOOKFUNCTION(superspec_ClientConnect)
-{
+{SELFPARAM();
        if(!IS_REAL_CLIENT(self))
                return false;
 
@@ -490,12 +491,12 @@ MUTATOR_HOOKFUNCTION(superspec_ClientConnect)
 }
 
 MUTATOR_HOOKFUNCTION(superspec_PlayerDies)
-{
-       entity _old_self = self;
-
-       FOR_EACH_SPEC(self)
+{SELFPARAM();
+       entity e;
+       FOR_EACH_SPEC(e)
        {
-               if(self.autospec_flags & ASF_FOLLOWKILLER && IS_PLAYER(frag_attacker) && self.enemy == _old_self)
+               setself(e);
+               if(self.autospec_flags & ASF_FOLLOWKILLER && IS_PLAYER(frag_attacker) && self.enemy == this)
                {
                        if(self.autospec_flags & ASF_SHOWWHAT)
                                superspec_msg("", "", self, sprintf("^7Following %s^7 due to followkiller\n", frag_attacker.netname), 2);
@@ -504,7 +505,7 @@ MUTATOR_HOOKFUNCTION(superspec_PlayerDies)
                }
        }
 
-       self = _old_self;
+       setself(this);
        return false;
 }
 
index 3c0e2706f8d8f52c16406de17ff03e86b16604ee..4f49d550d9704aa1d44a4959288db4dae0168770 100644 (file)
@@ -5,7 +5,7 @@
 .float touchexplode_time;
 
 void PlayerTouchExplode(entity p1, entity p2)
-{
+{SELFPARAM();
        vector org;
        org = (p1.origin + p2.origin) * 0.5;
        org.z += (p1.mins.z + p2.mins.z) * 0.5;
@@ -21,7 +21,7 @@ void PlayerTouchExplode(entity p1, entity p2)
 }
 
 MUTATOR_HOOKFUNCTION(touchexplode_PlayerThink)
-{
+{SELFPARAM();
        if(time > self.touchexplode_time)
        if(!gameover)
        if(!self.frozen)
index 85ff7b0586ef328978631a8bb3f2ce986bc05e21..3d88a901571a13ca8c77beaa274b41dc7be40c9f 100644 (file)
@@ -8,7 +8,7 @@ float autocvar_g_vampirehook_health_steal;
 .float last_dmg;
 
 MUTATOR_HOOKFUNCTION(vh, GrappleHookThink)
-{      
+{SELFPARAM();
        entity dmgent = ((SAME_TEAM(self.owner, self.aiment) && autocvar_g_vampirehook_teamheal) ? self.owner : self.aiment);
 
        if(IS_PLAYER(self.aiment))
index 273e25e3f959df6da6bb578f1c921035aef79a5b..da4f68d58eea020a6468cebc589a88d126a76ad3 100644 (file)
@@ -10,7 +10,7 @@ float object_count;
 
 .float touch_timer;
 void sandbox_ObjectFunction_Touch()
-{
+{SELFPARAM();
        // apply material impact effects
 
        if(!self.material)
@@ -35,7 +35,7 @@ void sandbox_ObjectFunction_Touch()
 }
 
 void sandbox_ObjectFunction_Think()
-{
+{SELFPARAM();
        entity e;
 
        // decide if and how this object can be grabbed
@@ -61,12 +61,12 @@ void sandbox_ObjectFunction_Think()
 
        self.nextthink = time;
 
-       CSQCMODEL_AUTOUPDATE();
+       CSQCMODEL_AUTOUPDATE(self);
 }
 
 .float old_solid, old_movetype;
 entity sandbox_ObjectEdit_Get(float permissions)
-{
+{SELFPARAM();
        // Returns the traced entity if the player can edit it, and world if not.
        // If permissions if false, the object is returned regardless of editing rights.
        // Attached objects are SOLID_NOT and do not get traced.
@@ -140,11 +140,10 @@ void sandbox_ObjectAttach_Remove(entity e)
 }
 
 entity sandbox_ObjectSpawn(float database)
-{
+{SELFPARAM();
        // spawn a new object with default properties
 
-       entity e, oldself;
-       e = spawn();
+       entity e = spawn();
        e.classname = "object";
        e.takedamage = DAMAGE_AIM;
        e.damageforcescale = 1;
@@ -179,10 +178,7 @@ entity sandbox_ObjectSpawn(float database)
                e.angles_y = self.v_angle.y;
        }
 
-       oldself = self;
-       self = e;
-       CSQCMODEL_AUTOINIT();
-       self = oldself;
+       WITH(entity, self, e, CSQCMODEL_AUTOINIT(e));
 
        object_count += 1;
        return e;
@@ -424,7 +420,7 @@ void sandbox_Database_Load()
 }
 
 MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
-{
+{SELFPARAM();
        if(MUTATOR_RETURNVALUE) // command was already handled?
                return false;
        if(cmd_name == "g_sandbox")
index 5c97cf7ac41575adba77f604d88399f000597d95..1da4fc0493a1ff4238fce60eafc50ffb5e651af1 100644 (file)
@@ -18,13 +18,13 @@ void pathlib_showpath(entity start)
 }
 
 void path_dbg_think()
-{
+{SELFPARAM();
     pathlib_showpath(self);
     self.nextthink = time + 1;
 }
 
 void __showpath2_think()
-{
+{SELFPARAM();
     #ifdef TURRET_DEBUG
        mark_info(self.origin,1);
        #endif
index 39847f635d220661cf60c9caa56f57f87b06169f..f097e8a0fec8199dabff0c0501307ab768bfe703 100644 (file)
@@ -370,7 +370,7 @@ entity path_build(entity next, vector where, entity prev, entity start)
 }
 
 entity pathlib_astar(vector from,vector to)
-{
+{SELFPARAM();
     entity path, start, end, open, n, ln;
     float ptime, ftime, ctime;
 
index 8720eca8b7fdf4198ffededf425784cce73de41e..6645d712661d9a08e5c95be125f41073d526f783 100644 (file)
@@ -4,7 +4,7 @@
 #include "utility.qh"
 
 vector pathlib_wateroutnode(vector start,vector end, float doedge)
-{
+{SELFPARAM();
     vector surface;
 
     pathlib_movenode_goodnode = 0;
@@ -38,7 +38,7 @@ vector pathlib_wateroutnode(vector start,vector end, float doedge)
 }
 
 vector pathlib_swimnode(vector start,vector end, float doedge)
-{
+{SELFPARAM();
     pathlib_movenode_goodnode = 0;
 
     if(pointcontents(start) != CONTENT_WATER)
@@ -58,7 +58,7 @@ vector pathlib_swimnode(vector start,vector end, float doedge)
 }
 
 vector pathlib_flynode(vector start,vector end, float doedge)
-{
+{SELFPARAM();
     pathlib_movenode_goodnode = 0;
 
     end.x = fsnap(end.x, pathlib_gridsize);
@@ -72,7 +72,7 @@ vector pathlib_flynode(vector start,vector end, float doedge)
 }
 
 void a_think()
-{
+{SELFPARAM();
     te_lightning1(self,self.origin, self.pos1);
     if(self.cnt < time)
         remove(self);
@@ -81,7 +81,7 @@ void a_think()
 }
 
 vector pathlib_walknode(vector start,vector end,float doedge)
-{
+{SELFPARAM();
     vector direction,point,last_point,s,e;
     float steps, distance, i;
 
index 7dee3e80f6154d6980061635f280b50b34c2dcf4..4c3a7a1aadb70153b8918a330851467e74d19b1c 100644 (file)
@@ -234,7 +234,7 @@ entity pathlib_waypointpath_step()
     return world;
 }
 void plas_think()
-{
+{SELFPARAM();
     pathlib_waypointpath_step();
     if(pathlib_foundgoal)
         return;
index ce12c1c631fed9bf994d4ace53a176cf776d540a..9028f85e4f8be3ab4d65a21656634151522ecb4f 100644 (file)
@@ -72,7 +72,7 @@ entity pathlib_nodeatpoint(vector where)
 }
 
 float tile_check_cross(vector where)
-{
+{SELFPARAM();
     vector p,f,r;
 
     f = PLIB_FORWARD * tile_check_size;
@@ -107,7 +107,7 @@ float tile_check_cross(vector where)
 }
 
 float tile_check_plus(vector where)
-{
+{SELFPARAM();
     vector p,f,r;
 
     f = PLIB_FORWARD * tile_check_size;
@@ -142,7 +142,7 @@ float tile_check_plus(vector where)
 }
 
 float tile_check_plus2(vector where)
-{
+{SELFPARAM();
     vector p,f,r;
     float i = 0, e = 0;
 
index 2450d5865108112767fc15caebd10e8dd9102c0a..4a750be3e6ea7789a58dae346e045f268f8c0b6f 100644 (file)
@@ -15,11 +15,11 @@ const float PLAYERDEMO_MODE_OFF = 0;
 const float PLAYERDEMO_MODE_READING = 1;
 const float PLAYERDEMO_MODE_WRITING = 2;
 void playerdemo_init()
-{
+{SELFPARAM();
        self.playerdemo_mode = PLAYERDEMO_MODE_OFF;
 }
 void playerdemo_shutdown()
-{
+{SELFPARAM();
        if(self.playerdemo_mode != PLAYERDEMO_MODE_OFF)
        {
                LOG_INFO("playerdemo: ", self.netname, " closed\n");
@@ -28,7 +28,7 @@ void playerdemo_shutdown()
        self.playerdemo_mode = 0;
 }
 void playerdemo_open_read(string f)
-{
+{SELFPARAM();
        playerdemo_shutdown();
        self.playerdemo_mode = PLAYERDEMO_MODE_READING;
        self.playerdemo_fh = fopen(f, FILE_READ);
@@ -39,7 +39,7 @@ void playerdemo_open_read(string f)
        LOG_INFO("playerdemo: ", self.netname, " reading from ", f, "\n");
 }
 void playerdemo_open_write(string f)
-{
+{SELFPARAM();
        playerdemo_shutdown();
        self.playerdemo_mode = PLAYERDEMO_MODE_WRITING;
        self.playerdemo_fh = fopen(f, FILE_WRITE);
@@ -70,51 +70,51 @@ void playerdemo_open_write(string f)
        // end of list
 
 void playerdemo_write_originvector(.vector f, string name)
-{
+{SELFPARAM();
        fputs(self.playerdemo_fh, strcat(vtos(self.(f)), "\n"));
 }
 void playerdemo_write_sizevector(.vector f, string name)
-{
+{SELFPARAM();
        fputs(self.playerdemo_fh, strcat(vtos(self.(f)), "\n"));
 }
 void playerdemo_write_vector(.vector f, string name)
-{
+{SELFPARAM();
        fputs(self.playerdemo_fh, strcat(vtos(self.(f)), "\n"));
 }
 void playerdemo_write_string(.string f, string name)
-{
+{SELFPARAM();
        fputs(self.playerdemo_fh, strcat(self.(f), "\n"));
 }
 void playerdemo_write_modelstring(.string f, string name)
-{
+{SELFPARAM();
        fputs(self.playerdemo_fh, strcat(self.(f), "\n"));
 }
 void playerdemo_write_float(.float f, string name)
-{
+{SELFPARAM();
        fputs(self.playerdemo_fh, strcat(ftos(self.(f)), "\n"));
 }
 void playerdemo_write()
-{
+{SELFPARAM();
        if(self.playerdemo_mode != PLAYERDEMO_MODE_WRITING)
                return;
        fputs(self.playerdemo_fh, strcat(ftos(time - self.playerdemo_starttime), "\n"));
        PLAYERDEMO_FIELDS(playerdemo_write_)
 }
 void playerdemo_read_originvector(.vector f, string name)
-{
+{SELFPARAM();
        setorigin(self, stov(fgets(self.playerdemo_fh)));
 }
 void playerdemo_read_sizevector(.vector f, string name)
-{
+{SELFPARAM();
        self.(f) = stov(fgets(self.playerdemo_fh));
        setsize(self, self.mins, self.maxs);
 }
 void playerdemo_read_vector(.vector f, string name)
-{
+{SELFPARAM();
        self.(f) = stov(fgets(self.playerdemo_fh));
 }
 void playerdemo_read_string(.string f, string name)
-{
+{SELFPARAM();
        string s = fgets(self.playerdemo_fh);
        if (s != self.(f))
        {
@@ -126,17 +126,17 @@ void playerdemo_read_string(.string f, string name)
        }
 }
 void playerdemo_read_modelstring(.string f, string name)
-{
+{SELFPARAM();
        string s = fgets(self.playerdemo_fh);
        if (s != self.(f))
                setmodel(self, s);
 }
 void playerdemo_read_float(.float f, string name)
-{
+{SELFPARAM();
        self.(f) = stof(fgets(self.playerdemo_fh));
 }
 float playerdemo_read()
-{
+{SELFPARAM();
        if(self.playerdemo_mode != PLAYERDEMO_MODE_READING)
                return 0;
        if(self.playerdemo_time < 0)
index 09cd6e9d20810481f2adb9dceb18d16271ee5927..e02c04d6b25e5bcffc0139424d51a2c0fadfad0b 100644 (file)
@@ -248,7 +248,7 @@ float Portal_WillHitPlane(vector eorg, vector emins, vector emaxs, vector evel,
 }
 
 void Portal_Touch()
-{
+{SELFPARAM();
        vector g;
 
 #ifdef PORTALS_ARE_NOT_SOLID
@@ -427,7 +427,7 @@ void Portal_Remove(entity portal, float killed)
 }
 
 void Portal_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{
+{SELFPARAM();
        if(deathtype == DEATH_TELEFRAG)
                return;
        if(attacker != self.aiment)
@@ -439,7 +439,7 @@ void Portal_Damage(entity inflictor, entity attacker, float damage, int deathtyp
 }
 
 void Portal_Think_TryTeleportPlayer(entity e, vector g)
-{
+{SELFPARAM();
        if(!Portal_WillHitPlane(e.origin, e.mins, e.maxs, e.velocity + g, self.origin, v_forward, self.maxs.x))
                return;
 
@@ -451,7 +451,7 @@ void Portal_Think_TryTeleportPlayer(entity e, vector g)
 }
 
 void Portal_Think()
-{
+{SELFPARAM();
        entity e, o;
        vector g;
 
@@ -494,7 +494,7 @@ void Portal_Think()
 }
 
 float Portal_Customize()
-{
+{SELFPARAM();
        if(IS_SPEC(other))
                other = other.enemy;
        if(other == self.aiment)
@@ -574,7 +574,7 @@ void Portal_ClearAll(entity own)
        W_Porto_Remove(own);
 }
 void Portal_RemoveLater_Think()
-{
+{SELFPARAM();
        Portal_Remove(self, self.cnt);
 }
 void Portal_RemoveLater(entity portal, float kill)
index bffb221a24287bd4671ca615b7a12d2cd69b68e8..1638dc9855d6bc012cc48490a5cbbb0afbc684d3 100644 (file)
@@ -569,7 +569,7 @@ void dumpsurface(entity e)
 }
 
 void checkpoint_passed()
-{
+{SELFPARAM();
        string oldmsg;
        entity cp;
 
@@ -577,7 +577,7 @@ void checkpoint_passed()
        {
                // do not allow portalling through checkpoints
                trace_plane_normal = normalize(-1 * other.velocity);
-               self = other;
+               setself(other);
                W_Porto_Fail(0);
                return;
        }
@@ -724,7 +724,7 @@ void checkpoint_use()
 }
 
 float race_waypointsprite_visible_for_player(entity e)
-{
+{SELFPARAM();
        if(e.race_checkpoint == -1 || self.owner.race_checkpoint == -2)
                return true;
        else if(e.race_checkpoint == self.owner.race_checkpoint)
@@ -735,8 +735,8 @@ float race_waypointsprite_visible_for_player(entity e)
 
 float have_verified;
 void trigger_race_checkpoint_verify()
-{
-       entity oldself, cp;
+{SELFPARAM();
+       entity cp;
        float i, p;
        float qual;
 
@@ -746,8 +746,7 @@ void trigger_race_checkpoint_verify()
 
        qual = g_race_qualifying;
 
-       oldself = self;
-       self = spawn();
+       setself(spawn());
        self.classname = "player";
 
        if(g_race)
@@ -895,11 +894,11 @@ void trigger_race_checkpoint_verify()
                                }
        }
        remove(self);
-       self = oldself;
+       setself(this);
 }
 
 vector trigger_race_checkpoint_spawn_evalfunc(entity player, entity spot, vector current)
-{
+{SELFPARAM();
        if(g_race_qualifying)
        {
                // spawn at first
@@ -931,7 +930,7 @@ vector trigger_race_checkpoint_spawn_evalfunc(entity player, entity spot, vector
 }
 
 void spawnfunc_trigger_race_checkpoint()
-{
+{SELFPARAM();
        vector o;
        if(!g_race && !g_cts) { remove(self); return; }
 
@@ -979,7 +978,7 @@ void spawnfunc_trigger_race_checkpoint()
 }
 
 void spawnfunc_target_checkpoint() // defrag entity
-{
+{SELFPARAM();
        vector o;
        if(!g_race && !g_cts) { remove(self); return; }
        defrag_ents = 1;
@@ -1043,7 +1042,7 @@ void race_StartCompleting()
 }
 
 void race_PreparePlayer()
-{
+{SELFPARAM();
        race_ClearTime(self);
        self.race_place = 0;
        self.race_started = 0;
@@ -1052,7 +1051,7 @@ void race_PreparePlayer()
 }
 
 void race_RetractPlayer()
-{
+{SELFPARAM();
        if(!g_race && !g_cts)
                return;
        if(self.race_respawn_checkpoint == 0 || self.race_respawn_checkpoint == race_timed_checkpoint)
@@ -1061,7 +1060,7 @@ void race_RetractPlayer()
 }
 
 void spawnfunc_info_player_race (void)
-{
+{SELFPARAM();
        if(!g_race && !g_cts) { remove(self); return; }
        ++race_spawns;
        spawnfunc_info_player_deathmatch();
@@ -1073,9 +1072,8 @@ void spawnfunc_info_player_race (void)
 }
 
 void race_ClearRecords()
-{
+{SELFPARAM();
        float i;
-       entity e;
 
        for(i = 0; i < MAX_CHECKPOINTS; ++i)
        {
@@ -1085,15 +1083,13 @@ void race_ClearRecords()
                race_checkpoint_recordholders[i] = string_null;
        }
 
-       e = self;
-       FOR_EACH_CLIENT(self)
+       entity e;
+       FOR_EACH_CLIENT(e)
        {
-               float p;
-               p = self.race_place;
-               race_PreparePlayer();
-               self.race_place = p;
+               float p = e.race_place;
+               WITH(entity, self, e, race_PreparePlayer());
+               e.race_place = p;
        }
-       self = e;
 }
 
 void race_ImposePenaltyTime(entity pl, float penalty, string reason)
@@ -1131,7 +1127,7 @@ void race_ImposePenaltyTime(entity pl, float penalty, string reason)
 }
 
 void penalty_touch()
-{
+{SELFPARAM();
        EXACTTRIGGER_TOUCH;
        if(other.race_lastpenalty != self)
        {
@@ -1141,12 +1137,12 @@ void penalty_touch()
 }
 
 void penalty_use()
-{
+{SELFPARAM();
        race_ImposePenaltyTime(activator, self.race_penalty, self.race_penalty_reason);
 }
 
 void spawnfunc_trigger_race_penalty()
-{
+{SELFPARAM();
        EXACTTRIGGER_INIT;
 
        self.use = penalty_use;
index d5b0281338ac22f1999db48338432feb482f0af2..0d608f9af76268de54d415746ca813e2b965453c 100644 (file)
@@ -5,7 +5,7 @@
 #include "../common/util.qh"
 
 void round_handler_Think()
-{
+{SELFPARAM();
        float f;
 
        if(time < game_starttime)
index 57f5e95f8fd6878951ac9d42e5ce79c7ba1dcbd2..ad00c5437d4765da3a3bc56e22e4cadd4f2558c5 100644 (file)
@@ -56,7 +56,7 @@ vector ScoreField_Compare(entity t1, entity t2, .float field, float fieldflags,
  */
 
 float TeamScore_SendEntity(entity to, float sendflags)
-{
+{SELFPARAM();
        float i, p, longflags;
 
        WriteByte(MSG_ENTITY, ENT_CLIENT_TEAMSCORES);
@@ -231,7 +231,7 @@ void ScoreInfo_Init(float teams)
  */
 
 float PlayerScore_SendEntity(entity to, float sendflags)
-{
+{SELFPARAM();
        float i, p, longflags;
 
        WriteByte(MSG_ENTITY, ENT_CLIENT_SCORES);
index b8045b4691a5398222a050a5ed31e2517f7932f6..3a574b28b2bfead37bf5a6eb73380f6f5af382ca 100644 (file)
@@ -10,7 +10,7 @@
 #include "../warpzonelib/util_server.qh"
 
 float SpawnPoint_Send(entity to, int sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_SPAWNPOINT);
 
        WriteByte(MSG_ENTITY, self.team);
@@ -22,7 +22,7 @@ float SpawnPoint_Send(entity to, int sf)
 }
 
 float SpawnEvent_Send(entity to, int sf)
-{
+{SELFPARAM();
        float send;
 
        WriteByte(MSG_ENTITY, ENT_CLIENT_SPAWNEVENT);
@@ -46,7 +46,7 @@ float SpawnEvent_Send(entity to, int sf)
 }
 
 void spawnpoint_use()
-{
+{SELFPARAM();
        if(teamplay)
        if(have_team_spawns > 0)
        {
@@ -57,7 +57,7 @@ void spawnpoint_use()
 }
 
 void relocate_spawnpoint()
-{
+{SELFPARAM();
     // nudge off the floor
     setorigin(self, self.origin + '0 0 1');
 
@@ -152,7 +152,7 @@ void spawnfunc_info_player_start (void)
 }
 
 void spawnfunc_info_player_deathmatch (void)
-{
+{SELFPARAM();
        self.classname = "info_player_deathmatch";
        relocate_spawnpoint();
 }
@@ -161,7 +161,7 @@ void spawnfunc_info_player_deathmatch (void)
 Starting point for a player in team one (Red).
 Keys: "angle" viewing angle when spawning. */
 void spawnfunc_info_player_team1()
-{
+{SELFPARAM();
        if(g_assault) { remove(self); return; }
 
        self.team = NUM_TEAM_1; // red
@@ -173,7 +173,7 @@ void spawnfunc_info_player_team1()
 Starting point for a player in team two (Blue).
 Keys: "angle" viewing angle when spawning. */
 void spawnfunc_info_player_team2()
-{
+{SELFPARAM();
        if(g_assault) { remove(self); return; }
 
        self.team = NUM_TEAM_2; // blue
@@ -184,7 +184,7 @@ void spawnfunc_info_player_team2()
 Starting point for a player in team three (Yellow).
 Keys: "angle" viewing angle when spawning. */
 void spawnfunc_info_player_team3()
-{
+{SELFPARAM();
        if(g_assault) { remove(self); return; }
 
        self.team = NUM_TEAM_3; // yellow
@@ -196,7 +196,7 @@ void spawnfunc_info_player_team3()
 Starting point for a player in team four (Purple).
 Keys: "angle" viewing angle when spawning. */
 void spawnfunc_info_player_team4()
-{
+{SELFPARAM();
        if(g_assault) { remove(self); return; }
 
        self.team = NUM_TEAM_4; // purple
@@ -207,7 +207,7 @@ void spawnfunc_info_player_team4()
 //   _x: prio (-1 if unusable)
 //   _y: weight
 vector Spawn_Score(entity spot, float mindist, float teamcheck)
-{
+{SELFPARAM();
        float shortest, thisdist;
        float prio;
        entity player;
@@ -258,10 +258,9 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck)
                        ++found;
                        if(ent.spawn_evalfunc)
                        {
-                               entity oldself = self;
-                               self = ent;
-                               spawn_score = ent.spawn_evalfunc(oldself, spot, spawn_score);
-                               self = oldself;
+                               WITH(entity, self, ent, {
+                                       spawn_score = ent.spawn_evalfunc(this, spot, spawn_score);
+                               });
                                if(spawn_score.x < 0)
                                        return spawn_score;
                        }
@@ -332,7 +331,7 @@ Finds a point to respawn
 =============
 */
 entity SelectSpawnPoint (float anypoint)
-{
+{SELFPARAM();
        float teamcheck;
        entity spot, firstspot;
 
index e57d56dd169be0022cd881bc00d32e581f8e5842..fcdbda97768906734e5b468a007357b87061d825 100644 (file)
@@ -9,7 +9,7 @@
     Uniform pull towards a point
 **/
 vector steerlib_pull(vector point)
-{
+{SELFPARAM();
     return normalize(point - self.origin);
 }
 
@@ -27,7 +27,7 @@ vector steerlib_push(vector point)
     Pull toward a point, The further away, the stronger the pull.
 **/
 vector steerlib_arrive(vector point,float maximal_distance)
-{
+{SELFPARAM();
     float distance;
     vector direction;
 
@@ -40,7 +40,7 @@ vector steerlib_arrive(vector point,float maximal_distance)
     Pull toward a point increasing the pull the closer we get
 **/
 vector steerlib_attract(vector point, float maximal_distance)
-{
+{SELFPARAM();
     float distance;
     vector direction;
 
@@ -51,7 +51,7 @@ vector steerlib_attract(vector point, float maximal_distance)
 }
 
 vector steerlib_attract2(vector point, float min_influense,float max_distance,float max_influense)
-{
+{SELFPARAM();
     float distance;
     vector direction;
     float influense;
@@ -99,7 +99,7 @@ vector steerlib_attract2(vector point, float maximal_distance,float min_influens
     Move away from a point.
 **/
 vector steerlib_repell(vector point,float maximal_distance)
-{
+{SELFPARAM();
     float distance;
     vector direction;
 
@@ -113,7 +113,7 @@ vector steerlib_repell(vector point,float maximal_distance)
     Try to keep at ideal_distance away from point
 **/
 vector steerlib_standoff(vector point,float ideal_distance)
-{
+{SELFPARAM();
     float distance;
     vector direction;
 
@@ -140,7 +140,7 @@ vector steerlib_standoff(vector point,float ideal_distance)
     where range is the cicrle radius and tresh is how close we need to be to pick a new heading.
 **/
 vector steerlib_wander(float range,float tresh,vector oldpoint)
-{
+{SELFPARAM();
     vector wander_point;
     wander_point = v_forward - oldpoint;
 
@@ -159,7 +159,7 @@ vector steerlib_wander(float range,float tresh,vector oldpoint)
     Dodge a point. dont work to well.
 **/
 vector steerlib_dodge(vector point,vector dodge_dir,float min_distance)
-{
+{SELFPARAM();
     float distance;
 
     distance = max(vlen(self.origin - point),min_distance);
@@ -175,7 +175,7 @@ vector steerlib_dodge(vector point,vector dodge_dir,float min_distance)
 **/
 .float flock_id;
 vector steerlib_flock(float _radius, float standoff,float separation_force,float flock_force)
-{
+{SELFPARAM();
     entity flock_member;
     vector push = '0 0 0', pull = '0 0 0';
     float ccount = 0;
@@ -201,7 +201,7 @@ vector steerlib_flock(float _radius, float standoff,float separation_force,float
     xy only version (for ground movers).
 **/
 vector steerlib_flock2d(float _radius, float standoff,float separation_force,float flock_force)
-{
+{SELFPARAM();
     entity flock_member;
     vector push = '0 0 0', pull = '0 0 0';
     float ccount = 0;
@@ -232,7 +232,7 @@ vector steerlib_flock2d(float _radius, float standoff,float separation_force,flo
     This results in a aligned movement (?!) much like flocking.
 **/
 vector steerlib_swarm(float _radius, float standoff,float separation_force,float swarm_force)
-{
+{SELFPARAM();
     entity swarm_member;
     vector force = '0 0 0', center = '0 0 0';
     float ccount = 0;
@@ -262,7 +262,7 @@ vector steerlib_swarm(float _radius, float standoff,float separation_force,float
     You need to call makevectors() (or equivalent) before this function to set v_forward and v_right
 **/
 vector steerlib_traceavoid(float pitch,float length)
-{
+{SELFPARAM();
     vector vup_left,vup_right,vdown_left,vdown_right;
     float fup_left,fup_right,fdown_left,fdown_right;
     vector upwish,downwish,leftwish,rightwish;
@@ -309,7 +309,7 @@ vector steerlib_traceavoid(float pitch,float length)
     Run tracelines in a forward trident, bias each direction negative if something is found there.
 **/
 vector steerlib_traceavoid_flat(float pitch, float length, vector vofs)
-{
+{SELFPARAM();
     vector vt_left, vt_right,vt_front;
     float f_left, f_right,f_front;
     vector leftwish, rightwish,frontwish, v_left;
@@ -381,7 +381,7 @@ float beamsweep_badpoint(vector point,float waterok)
 
 //#define BEAMSTEER_VISUAL
 float beamsweep(vector from, vector dir,float length, float step,float step_up, float step_down)
-{
+{SELFPARAM();
     float i;
     vector a,b,u,d;
 
@@ -421,7 +421,7 @@ float beamsweep(vector from, vector dir,float length, float step,float step_up,
 }
 
 vector steerlib_beamsteer(vector dir, float length, float step, float step_up, float step_down)
-{
+{SELFPARAM();
     float bm_forward, bm_right, bm_left,p;
     vector vr,vl;
 
@@ -497,7 +497,7 @@ vector steerlib_beamsteer(vector dir, float length, float step, float step_up, f
 //#define TLIBS_TETSLIBS
 #ifdef TLIBS_TETSLIBS
 void flocker_die()
-{
+{SELFPARAM();
        Send_Effect(EFFECT_ROCKET_EXPLODE, self.origin, '0 0 0', 1);
 
     self.owner.cnt += 1;
@@ -509,7 +509,7 @@ void flocker_die()
 
 
 void flocker_think()
-{
+{SELFPARAM();
     vector dodgemove,swarmmove;
     vector reprellmove,wandermove,newmove;
 
@@ -547,7 +547,7 @@ void flocker_think()
 
 
 void spawn_flocker()
-{
+{SELFPARAM();
     entity flocker;
 
     flocker = spawn ();
@@ -574,7 +574,7 @@ void spawn_flocker()
 }
 
 void flockerspawn_think()
-{
+{SELFPARAM();
 
 
     if(self.cnt > 0)
@@ -585,7 +585,7 @@ void flockerspawn_think()
 }
 
 void flocker_hunter_think()
-{
+{SELFPARAM();
     vector dodgemove,attractmove,newmove;
     entity e,ee;
     float d,bd;
@@ -640,7 +640,7 @@ void flocker_hunter_think()
 
 float globflockcnt;
 void spawnfunc_flockerspawn()
-{
+{SELFPARAM();
     precache_model ( "models/turrets/rocket.md3");
     precache_model("models/turrets/c512.md3");
     ++globflockcnt;
index 1f629af5cfe06eb0e5815127c9d8bd75fb6d3c78..948e2d37435cdc392bce62b4bb52045fdb2f4054 100644 (file)
 .float lastground;
 
 void CreatureFrame (void)
-{
-       entity oldself;
+{SELFPARAM();
        float dm;
 
-       oldself = self;
-       for(self = world; (self = findfloat(self, damagedbycontents, true)); )
+       for(entity e = world; (e = findfloat(e, damagedbycontents, true)); )
        {
+               setself(e);
                if (self.movetype == MOVETYPE_NOCLIP) { continue; }
 
                float vehic = IS_VEHICLE(self);
@@ -169,7 +168,7 @@ void CreatureFrame (void)
 
         self.oldvelocity = self.velocity;
        }
-       self = oldself;
+       setself(this);
 }
 
 
@@ -186,7 +185,7 @@ float game_delay_last;
 
 float RedirectionThink();
 void StartFrame (void)
-{
+{SELFPARAM();
        execute_next_frame();
 
        remove = remove_unsafely; // not during spawning!
@@ -218,8 +217,7 @@ void StartFrame (void)
        }
 #endif
 
-       entity e;
-       for(e = world; (e = findfloat(e, csqcprojectile_clientanimate, 1)); )
+       for(entity e = world; (e = findfloat(e, csqcprojectile_clientanimate, 1)); )
                CSQCProjectile_Check(e);
 
        if(RedirectionThink())
@@ -264,8 +262,9 @@ void StartFrame (void)
 
        bot_serverframe();
 
-       FOR_EACH_PLAYER(self)
-               self.porto_forbidden = max(0, self.porto_forbidden - 1);
+       entity e;
+       FOR_EACH_PLAYER(e)
+               e.porto_forbidden = max(0, e.porto_forbidden - 1);
 
        anticheat_startframe();
 
@@ -279,7 +278,7 @@ void StartFrame (void)
 .string cvarfilter;
 float DoesQ3ARemoveThisEntity();
 void SV_OnEntityPreSpawnFunction()
-{
+{SELFPARAM();
        if (self)
        if (self.gametypefilter != "")
        if (!isGametypeInFilter(MapInfo_LoadedGametype, teamplay, have_team_spawns, self.gametypefilter))
index 5d392fd84a24c8fc64a025fc4d2f1ae0aa2c2f4e..671f1d0eda5cc63d49f9e380ddab6cd56ddf3310 100644 (file)
@@ -29,7 +29,7 @@
 
 #ifdef CSQC
 void ItemDraw()
-{
+{SELFPARAM();
     if(self.gravity)
     {
         Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
@@ -65,7 +65,7 @@ void ItemDraw()
 }
 
 void ItemDrawSimple()
-{
+{SELFPARAM();
     if(self.gravity)
     {
         Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
@@ -96,7 +96,7 @@ void Item_PreDraw()
 }
 
 void ItemRead(float _IsNew)
-{
+{SELFPARAM();
     int sf = ReadByte();
 
     if(sf & ISF_LOCATION)
@@ -247,7 +247,7 @@ void ItemRead(float _IsNew)
 
 #ifdef SVQC
 bool ItemSend(entity to, int sf)
-{
+{SELFPARAM();
        if(self.gravity)
                sf |= ISF_DROP;
        else
@@ -310,7 +310,7 @@ void ItemUpdate(entity item)
 }
 
 float have_pickup_item(void)
-{
+{SELFPARAM();
        if(self.flags & FL_POWERUP)
        {
                if(autocvar_g_powerups > 0)
@@ -416,7 +416,7 @@ void Item_Show (entity e, float mode)
 }
 
 void Item_Think()
-{
+{SELFPARAM();
        self.nextthink = time;
        if(self.origin != self.oldorigin)
        {
@@ -432,7 +432,7 @@ void Item_ItemsTime_SetTime(entity e, float t);
 void Item_ItemsTime_SetTimesForAllPlayers();
 
 void Item_Respawn (void)
-{
+{SELFPARAM();
        Item_Show(self, 1);
        // this is ugly...
        if(self.items == ITEM_Strength.m_itemid)
@@ -458,7 +458,7 @@ void Item_Respawn (void)
 }
 
 void Item_RespawnCountdown (void)
-{
+{SELFPARAM();
        if(self.count >= ITEM_RESPAWN_TICKS)
        {
                if(self.waypointsprite_attached)
@@ -492,16 +492,15 @@ void Item_RespawnCountdown (void)
 
                if(self.waypointsprite_attached)
                {
+                       setself(self.waypointsprite_attached);
                        entity e;
-                       entity it = self;
-                       self = self.waypointsprite_attached;
                        FOR_EACH_REALCLIENT(e)
                                if(self.waypointsprite_visible_for_player(e))
                                {
                                        msg_entity = e;
-                                       soundto(MSG_ONE, it, CH_TRIGGER, "misc/itemrespawncountdown.wav", VOL_BASE, ATTEN_NORM);        // play respawn sound
+                                       soundto(MSG_ONE, this, CH_TRIGGER, "misc/itemrespawncountdown.wav", VOL_BASE, ATTEN_NORM);      // play respawn sound
                                }
-                       self = it;
+                       setself(this);
 
                        WaypointSprite_Ping(self.waypointsprite_attached);
                        //WaypointSprite_UpdateHealth(self.waypointsprite_attached, self.count);
@@ -512,7 +511,7 @@ void Item_RespawnCountdown (void)
 }
 
 void Item_RespawnThink()
-{
+{SELFPARAM();
        self.nextthink = time;
        if(self.origin != self.oldorigin)
        {
@@ -699,7 +698,7 @@ float Item_GiveTo(entity item, entity player)
 }
 
 void Item_Touch (void)
-{
+{SELFPARAM();
        entity e, head;
 
        // remove the item if it's currnetly in a NODROP brush or hits a NOIMPACT surface (such as sky)
@@ -779,7 +778,7 @@ void Item_Touch (void)
 }
 
 void Item_Reset()
-{
+{SELFPARAM();
        Item_Show(self, !self.state);
        setorigin (self, self.origin);
 
@@ -797,7 +796,7 @@ void Item_Reset()
 }
 
 void Item_FindTeam()
-{
+{SELFPARAM();
        entity head, e;
 
        if(self.effects & EF_NODRAW)
@@ -833,7 +832,7 @@ void Item_FindTeam()
 // Savage: used for item garbage-collection
 // TODO: perhaps nice special effect?
 void RemoveItem(void)
-{
+{SELFPARAM();
        if(wasfreed(self) || !self) { return; }
        Send_Effect(EFFECT_ITEM_PICKUP, CENTER_OR_VIEWOFS(self), '0 0 0', 1);
        remove(self);
@@ -967,7 +966,7 @@ void Item_Damage(entity inflictor, entity attacker, float damage, int deathtype,
 }
 
 void StartItem (string itemmodel, string pickupsound, float defaultrespawntime, float defaultrespawntimejitter, string itemname, float itemid, float weaponid, float itemflags, float(entity player, entity item) pickupevalfunc, float pickupbasevalue)
-{
+{SELFPARAM();
        startitem_failed = false;
 
        if(self.model == "")
@@ -1205,12 +1204,13 @@ string Item_Model(string item_mdl)
 }
 
 void StartItemA (entity a)
-{
+{SELFPARAM();
     self.itemdef = a;
     StartItem(Item_Model(a.m_model), a.m_sound, a.m_respawntime(), a.m_respawntimejitter(), a.m_name, a.m_itemid, 0, a.m_itemflags, a.m_pickupevalfunc, a.m_botvalue);
 }
 
-void spawnfunc_item_rockets (void) {
+void spawnfunc_item_rockets()
+{SELFPARAM();
        if(!self.ammo_rockets)
                self.ammo_rockets = g_pickup_rockets;
        if(!self.pickup_anyway)
@@ -1218,7 +1218,8 @@ void spawnfunc_item_rockets (void) {
     StartItemA (ITEM_Rockets);
 }
 
-void spawnfunc_item_bullets (void) {
+void spawnfunc_item_bullets()
+{SELFPARAM();
        if(!weaponswapping)
        if(autocvar_sv_q3acompat_machineshotgunswap)
        if(self.classname != "droppedweapon")
@@ -1236,7 +1237,8 @@ void spawnfunc_item_bullets (void) {
     StartItemA (ITEM_Bullets);
 }
 
-void spawnfunc_item_cells (void) {
+void spawnfunc_item_cells()
+{SELFPARAM();
        if(!self.ammo_cells)
                self.ammo_cells = g_pickup_cells;
        if(!self.pickup_anyway)
@@ -1245,7 +1247,7 @@ void spawnfunc_item_cells (void) {
 }
 
 void spawnfunc_item_plasma()
-{
+{SELFPARAM();
        if(!self.ammo_plasma)
                self.ammo_plasma = g_pickup_plasma;
        if(!self.pickup_anyway)
@@ -1253,7 +1255,8 @@ void spawnfunc_item_plasma()
        StartItemA (ITEM_Plasma);
 }
 
-void spawnfunc_item_shells (void) {
+void spawnfunc_item_shells()
+{SELFPARAM();
        if(!weaponswapping)
        if(autocvar_sv_q3acompat_machineshotgunswap)
        if(self.classname != "droppedweapon")
@@ -1271,7 +1274,8 @@ void spawnfunc_item_shells (void) {
        StartItemA (ITEM_Shells);
 }
 
-void spawnfunc_item_armor_small (void) {
+void spawnfunc_item_armor_small()
+{SELFPARAM();
        if(!self.armorvalue)
                self.armorvalue = g_pickup_armorsmall;
        if(!self.max_armorvalue)
@@ -1281,7 +1285,8 @@ void spawnfunc_item_armor_small (void) {
        StartItemA (ITEM_ArmorSmall);
 }
 
-void spawnfunc_item_armor_medium (void) {
+void spawnfunc_item_armor_medium()
+{SELFPARAM();
        if(!self.armorvalue)
                self.armorvalue = g_pickup_armormedium;
        if(!self.max_armorvalue)
@@ -1291,7 +1296,8 @@ void spawnfunc_item_armor_medium (void) {
        StartItemA (ITEM_ArmorMedium);
 }
 
-void spawnfunc_item_armor_big (void) {
+void spawnfunc_item_armor_big()
+{SELFPARAM();
        if(!self.armorvalue)
                self.armorvalue = g_pickup_armorbig;
        if(!self.max_armorvalue)
@@ -1301,7 +1307,8 @@ void spawnfunc_item_armor_big (void) {
        StartItemA (ITEM_ArmorLarge);
 }
 
-void spawnfunc_item_armor_large (void) {
+void spawnfunc_item_armor_large()
+{SELFPARAM();
        if(!self.armorvalue)
                self.armorvalue = g_pickup_armorlarge;
        if(!self.max_armorvalue)
@@ -1311,7 +1318,8 @@ void spawnfunc_item_armor_large (void) {
        StartItemA (ITEM_ArmorMega);
 }
 
-void spawnfunc_item_health_small (void) {
+void spawnfunc_item_health_small()
+{SELFPARAM();
        if(!self.max_health)
                self.max_health = g_pickup_healthsmall_max;
        if(!self.health)
@@ -1321,7 +1329,8 @@ void spawnfunc_item_health_small (void) {
        StartItemA (ITEM_HealthSmall);
 }
 
-void spawnfunc_item_health_medium (void) {
+void spawnfunc_item_health_medium()
+{SELFPARAM();
        if(!self.max_health)
                self.max_health = g_pickup_healthmedium_max;
        if(!self.health)
@@ -1331,7 +1340,8 @@ void spawnfunc_item_health_medium (void) {
     StartItemA (ITEM_HealthMedium);
 }
 
-void spawnfunc_item_health_large (void) {
+void spawnfunc_item_health_large()
+{SELFPARAM();
        if(!self.max_health)
                self.max_health = g_pickup_healthlarge_max;
        if(!self.health)
@@ -1341,7 +1351,8 @@ void spawnfunc_item_health_large (void) {
        StartItemA (ITEM_HealthLarge);
 }
 
-void spawnfunc_item_health_mega (void) {
+void spawnfunc_item_health_mega()
+{SELFPARAM();
     if(!self.max_health)
         self.max_health = g_pickup_healthmega_max;
     if(!self.health)
@@ -1358,24 +1369,26 @@ void spawnfunc_item_health1() { spawnfunc_item_health_small(); }
 void spawnfunc_item_health25() { spawnfunc_item_health_medium(); }
 void spawnfunc_item_health100() { spawnfunc_item_health_mega(); }
 
-void spawnfunc_item_strength (void) {
+void spawnfunc_item_strength()
+{SELFPARAM();
                precache_sound("weapons/strength_fire.wav");
                if(!self.strength_finished)
                        self.strength_finished = autocvar_g_balance_powerup_strength_time;
                StartItemA (ITEM_Strength);
 }
 
-void spawnfunc_item_invincible (void) {
+void spawnfunc_item_invincible()
+{SELFPARAM();
                if(!self.invincible_finished)
                        self.invincible_finished = autocvar_g_balance_powerup_invincible_time;
                StartItemA (ITEM_Shield);
 }
 
 // compatibility:
-void spawnfunc_item_quad (void) {self.classname = "item_strength";spawnfunc_item_strength();}
+void spawnfunc_item_quad() {SELFPARAM(); self.classname = "item_strength";spawnfunc_item_strength();}
 
-void target_items_use (void)
-{
+void target_items_use()
+{SELFPARAM();
        if(activator.classname == "droppedweapon")
        {
                EXACTTRIGGER_TOUCH;
@@ -1399,7 +1412,7 @@ void target_items_use (void)
 }
 
 void spawnfunc_target_items (void)
-{
+{SELFPARAM();
        float n, i, j;
        entity e;
        string s;
@@ -1524,7 +1537,7 @@ void spawnfunc_target_items (void)
 }
 
 void spawnfunc_item_fuel(void)
-{
+{SELFPARAM();
        if(!self.ammo_fuel)
                self.ammo_fuel = g_pickup_fuel;
        if(!self.pickup_anyway)
@@ -1543,7 +1556,7 @@ void spawnfunc_item_fuel_regen(void)
 }
 
 void spawnfunc_item_jetpack(void)
-{
+{SELFPARAM();
        if(!self.ammo_fuel)
                self.ammo_fuel = g_pickup_fuel_jetpack;
        if(start_items & ITEM_Jetpack.m_itemid)
@@ -1664,7 +1677,7 @@ void GiveRot(entity e, float v0, float v1, .float rotfield, float rottime, .floa
                e.(regenfield) = max(e.(regenfield), time + regentime);
 }
 float GiveItems(entity e, float beginarg, float endarg)
-{
+{SELFPARAM();
        float got, i, j, val, op;
        float _switchweapon;
        entity wi;
index 517b8808225f50773e2e9b303af7ff717ac33f3c..74a324b98193ad4918fbab1d853d6528e2a9ddcd 100644 (file)
@@ -14,15 +14,15 @@ void spawnfunc_item_health_medium();
 //***********************
 //QUAKE 1 ENTITIES - So people can play quake1 maps with the xonotic weapons
 //***********************
-void spawnfunc_weapon_nailgun (void) {spawnfunc_weapon_electro();}
-void spawnfunc_weapon_supernailgun (void) {spawnfunc_weapon_hagar();}
-void spawnfunc_weapon_supershotgun (void) {spawnfunc_weapon_machinegun();}
-
-void spawnfunc_item_spikes (void) {spawnfunc_item_bullets();}
-//void spawnfunc_item_armor1 (void) {spawnfunc_item_armor_medium;}  // FIXME: in Quake this is green armor, in Xonotic maps it is an armor shard
-void spawnfunc_item_armor2 (void) {spawnfunc_item_armor_large();}
-void item_armorInv (void) {spawnfunc_item_armor_large();}
-void spawnfunc_item_health (void) {if (self.spawnflags & 2) spawnfunc_item_health_mega();else spawnfunc_item_health_medium();}
+void spawnfunc_weapon_nailgun() {spawnfunc_weapon_electro();}
+void spawnfunc_weapon_supernailgun() {spawnfunc_weapon_hagar();}
+void spawnfunc_weapon_supershotgun() {spawnfunc_weapon_machinegun();}
+
+void spawnfunc_item_spikes() {spawnfunc_item_bullets();}
+//void spawnfunc_item_armor1() {spawnfunc_item_armor_medium;}  // FIXME: in Quake this is green armor, in Xonotic maps it is an armor shard
+void spawnfunc_item_armor2() {spawnfunc_item_armor_large();}
+void item_armorInv() {spawnfunc_item_armor_large();}
+void spawnfunc_item_health() {SELFPARAM();if (self.spawnflags & 2) spawnfunc_item_health_mega();else spawnfunc_item_health_medium();}
 
 //spawnfunc_item_spikes
 //spawnfunc_item_health
index 6908b6dbf18500f2927971f6441f2cbd04602831..d20c90055dfcdd91024d68d9a2ee5f6cc3270588 100644 (file)
@@ -85,7 +85,7 @@ void target_init_verify()
 }
 
 void spawnfunc_target_init()
-{
+{SELFPARAM();
        self.spawnflags = 0; // remove all weapons except the ones listed below
        self.netname = "shotgun"; // keep these weapons through the remove trigger
        spawnfunc_target_items();
@@ -94,7 +94,7 @@ void spawnfunc_target_init()
 
 // weapon give ent from defrag
 void target_give_init()
-{
+{SELFPARAM();
        entity targ;
        for (targ = world; (targ = find(targ, targetname, self.target)); ) {
                if (targ.classname == "weapon_rocketlauncher" || targ.classname == "weapon_devastator") {
@@ -136,7 +136,7 @@ void target_give_init()
 }
 
 void spawnfunc_target_give()
-{
+{SELFPARAM();
        InitializeEntity(self, target_give_init, INITPRIO_FINDTARGET);
 }
 
@@ -152,7 +152,7 @@ void spawnfunc_target_give()
 // CTF spawnfuncs handled in mutators/gamemode_ctf.qc now
 
 void spawnfunc_item_flight()
-{
+{SELFPARAM();
        if(!cvar("g_buffs") || !cvar("g_buffs_flight"))
                spawnfunc_item_jetpack();
        else
@@ -166,7 +166,7 @@ void spawnfunc_item_flight()
 .float notta;
 .string gametype;
 float DoesQ3ARemoveThisEntity()
-{
+{SELFPARAM();
        // Q3 style filters (DO NOT USE, THIS IS COMPAT ONLY)
 
        if(self.notq3a)
index b41ebaca9f6c4b3606808dc58394a53ff9b8d279..22dbac33284a32b53f7d91a65515e4c764cf746e 100644 (file)
@@ -269,7 +269,8 @@ void InitGameplayMode()
        InitializeEntity(world, default_delayedinit, INITPRIO_GAMETYPE_FALLBACK);
 }
 
-string GetClientVersionMessage() {
+string GetClientVersionMessage()
+{SELFPARAM();
        string versionmsg;
        if (self.version_mismatch) {
                if(self.version < autocvar_gameversion) {
@@ -404,7 +405,7 @@ void SetPlayerTeam(entity pl, float t, float s, float noprint)
 
 // set c1...c4 to show what teams are allowed
 void CheckAllowedTeams (entity for_whom)
-{
+{SELFPARAM();
        float dm;
        entity head;
        string teament_name;
@@ -710,7 +711,7 @@ float FindSmallestTeam(entity pl, float ignore_pl)
 }
 
 float JoinBestTeam(entity pl, float only_return_best, float forcebestteam)
-{
+{SELFPARAM();
        float smallest, selectedteam;
 
        // don't join a team if we're not playing a team game
@@ -787,7 +788,7 @@ float JoinBestTeam(entity pl, float only_return_best, float forcebestteam)
 
 //void() ctf_playerchanged;
 void SV_ChangeTeam(float _color)
-{
+{SELFPARAM();
        float scolor, dcolor, steam, dteam; //, dbotcount, scount, dcount;
 
        // in normal deathmatch we can just apply the color and we're done
index d0dda35af10cc979ca3296adc0b6883d8ac6c746..d78d93c873e33760c29f84c6c46509a541f62ffe 100644 (file)
@@ -18,7 +18,7 @@ float accuracy_byte(float n, float d)
 }
 
 float accuracy_send(entity to, int sf)
-{
+{SELFPARAM();
        int w, f;
        entity a;
        WriteByte(MSG_ENTITY, ENT_CLIENT_ACCURACY);
index 8c3c883815e80816849267c47e37180769432d79..db712933d0bd4c31359071ceb26c831de5e34104 100644 (file)
@@ -9,21 +9,19 @@
 #include "../../common/weapons/all.qh"
 
 void W_GiveWeapon (entity e, float wep)
-{
-       entity oldself;
+{SELFPARAM();
 
        if (!wep)
                return;
 
        e.weapons |= WepSet_FromWeapon(wep);
 
-       oldself = self;
-       self = e;
+       setself(e);
 
        if(IS_PLAYER(other))
                { Send_Notification(NOTIF_ONE, other, MSG_MULTI, ITEM_WEAPON_GOT, wep); }
 
-       self = oldself;
+       setself(this);
 }
 
 void W_PlayStrengthSound(entity player) // void W_PlayStrengthSound
@@ -81,7 +79,7 @@ float W_CheckProjectileDamage(entity inflictor, entity projowner, int deathtype,
 }
 
 void W_PrepareExplosionByDamage(entity attacker, void() explode)
-{
+{SELFPARAM();
        self.takedamage = DAMAGE_NO;
        self.event_damage = func_null;
 
index 507fc4a413b792d6d5450d3591c6442c6d438036..36d037167bacb5d2fef195abf0b0b3ec4622eb90 100644 (file)
@@ -11,7 +11,7 @@
 .float csqcprojectile_type;
 
 bool CSQCProjectile_SendEntity(entity to, int sf)
-{
+{SELFPARAM();
        float ft, fr;
 
        // note: flag 0x08 = no trail please (teleport bit)
index d563ac2d84eb3cd01ebf85e8ac8a054c53432b5e..de240ce2ef66997ddbec1bf6d5d50c437f51ee7e 100644 (file)
@@ -18,9 +18,8 @@ void Send_WeaponComplain(entity e, float wpn, float type)
 }
 
 float client_hasweapon(entity cl, float wpn, float andammo, float complain)
-{
+{SELFPARAM();
        float f;
-       entity oldself;
 
        if(time < self.hasweapon_complain_spam)
                complain = 0;
@@ -47,8 +46,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                        }
                        else
                        {
-                               oldself = self;
-                               self = cl;
+                               setself(cl);
                                f = WEP_ACTION(wpn, WR_CHECKAMMO1);
                                f = f + WEP_ACTION(wpn, WR_CHECKAMMO2);
 
@@ -58,7 +56,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                                for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.owner == self)
                                        f = 1;
 
-                               self = oldself;
+                               setself(this);
                        }
                        if (!f)
                        {
@@ -115,7 +113,7 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
 }
 
 float W_GetCycleWeapon(entity pl, string weaponorder, float dir, float imp, float complain, float skipmissing)
-{
+{SELFPARAM();
        // We cannot tokenize in this function, as GiveItems calls this
        // function. Thus we must use car/cdr.
        float weaponwant, first_valid, prev_valid, switchtonext, switchtolast;
@@ -254,7 +252,7 @@ void W_SwitchToOtherWeapon(entity pl)
 }
 
 void W_SwitchWeapon(float imp)
-{
+{SELFPARAM();
        if (self.switchweapon != imp)
        {
                if (client_hasweapon(self, imp, true, true))
@@ -266,7 +264,7 @@ void W_SwitchWeapon(float imp)
 }
 
 void W_CycleWeapon(string weaponorder, float dir)
-{
+{SELFPARAM();
        float w;
        w = W_GetCycleWeapon(self, weaponorder, dir, -1, 1, true);
        if(w > 0)
@@ -274,7 +272,7 @@ void W_CycleWeapon(string weaponorder, float dir)
 }
 
 void W_NextWeaponOnImpulse(float imp)
-{
+{SELFPARAM();
        float w;
        w = W_GetCycleWeapon(self, self.cvar_cl_weaponpriority, +1, imp, 1, (self.cvar_cl_weaponimpulsemode == 0));
        if(w > 0)
@@ -283,7 +281,7 @@ void W_NextWeaponOnImpulse(float imp)
 
 // next weapon
 void W_NextWeapon(float list)
-{
+{SELFPARAM();
        if(list == 0)
                W_CycleWeapon(weaponorder_byid, -1);
        else if(list == 1)
@@ -294,7 +292,7 @@ void W_NextWeapon(float list)
 
 // prev weapon
 void W_PreviousWeapon(float list)
-{
+{SELFPARAM();
        if(list == 0)
                W_CycleWeapon(weaponorder_byid, +1);
        else if(list == 1)
@@ -305,7 +303,7 @@ void W_PreviousWeapon(float list)
 
 // previously used if exists and has ammo, (second) best otherwise
 void W_LastWeapon(void)
-{
+{SELFPARAM();
        if(client_hasweapon(self, self.cnt, true, false))
                W_SwitchWeapon(self.cnt);
        else
index 3c3c9d80695fde47bfb984a548919eb643cc19d2..202b29fda738118ae1e2d282350993e2db822a30 100644 (file)
@@ -35,11 +35,10 @@ string W_Apply_Weaponreplace(string in)
 }
 
 void weapon_defaultspawnfunc(float wpn)
-{
+{SELFPARAM();
        entity e;
        float t;
        string s;
-       entity oldself;
        float i, j;
        int f;
 
@@ -67,7 +66,6 @@ void weapon_defaultspawnfunc(float wpn)
                if(t >= 2)
                {
                        self.team = --internalteam;
-                       oldself = self;
                        for(i = 1; i < t; ++i)
                        {
                                s = argv(i);
@@ -76,8 +74,8 @@ void weapon_defaultspawnfunc(float wpn)
                                        e = get_weaponinfo(j);
                                        if(e.netname == s)
                                        {
-                                               self = spawn();
-                                               copyentity(oldself, self);
+                                               setself(spawn());
+                                               copyentity(this, self);
                                                self.classname = "replacedweapon";
                                                weapon_defaultspawnfunc(j);
                                                break;
@@ -85,10 +83,10 @@ void weapon_defaultspawnfunc(float wpn)
                                }
                                if(j > WEP_LAST)
                                {
-                                       LOG_INFO("The weapon replace list for ", oldself.classname, " contains an unknown weapon ", s, ". Skipped.\n");
+                                       LOG_INFO("The weapon replace list for ", this.classname, " contains an unknown weapon ", s, ". Skipped.\n");
                                }
                        }
-                       self = oldself;
+                       setself(this);
                }
                if(t >= 1) // always the case!
                {
index 89ec52f2179f5114230addfe9eb567aa6909c55a..2fb19609eaf71685cc33a15d7d9ca700fb870cc2 100644 (file)
@@ -11,7 +11,7 @@
 #include "../../common/weapons/all.qh"
 
 void thrown_wep_think()
-{
+{SELFPARAM();
        self.nextthink = time;
        if(self.oldorigin != self.origin)
        {
@@ -30,13 +30,12 @@ void thrown_wep_think()
 
 // returns amount of ammo used as string, or -1 for failure, or 0 for no ammo count
 string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo)
-{
-       entity oldself, wep;
+{SELFPARAM();
        float thisammo, i;
        string s;
        var .int ammotype = (get_weaponinfo(wpn)).ammo_field;
 
-       wep = spawn();
+       entity wep = spawn();
 
        setorigin(wep, org);
        wep.classname = "droppedweapon";
@@ -75,10 +74,7 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
                }
        }
 
-       oldself = self;
-       self = wep;
-       weapon_defaultspawnfunc(wpn);
-       self = oldself;
+       WITH(entity, self, wep, weapon_defaultspawnfunc(wpn));
        if(startitem_failed)
                return string_null;
        wep.glowmod = own.weaponentity_glowmod;
@@ -166,7 +162,7 @@ float W_IsWeaponThrowable(float w)
 
 // toss current weapon
 void W_ThrowWeapon(vector velo, vector delta, float doreduce)
-{
+{SELFPARAM();
        float w;
        string a;
 
@@ -194,7 +190,7 @@ void W_ThrowWeapon(vector velo, vector delta, float doreduce)
 }
 
 void SpawnThrownWeapon(vector org, float w)
-{
+{SELFPARAM();
        if(self.weapons & WepSet_FromWeapon(self.weapon))
                if(W_IsWeaponThrowable(self.weapon))
                        W_ThrowNewWeapon(self, self.weapon, false, org, randomvec() * 125 + '0 0 200');
index eec32a3e51ac0339bf9c764d992b15aa3b942b90..7c033fa889113363cbbd2626138a347ea8e0f697 100644 (file)
@@ -194,7 +194,7 @@ void W_SetupProjVelocity_Explicit(entity proj, vector dir, vector upDir, float p
 // ====================
 
 void FireRailgunBullet (vector start, vector end, float bdamage, float bforce, float mindist, float maxdist, float halflifedist, float forcehalflifedist, int deathtype)
-{
+{SELFPARAM();
        vector hitloc, force, endpoint, dir;
        entity ent, endent;
        float endq3surfaceflags;
@@ -345,7 +345,7 @@ void fireBullet_trace_callback(vector start, vector hit, vector end)
 }
 
 void fireBullet(vector start, vector dir, float spread, float max_solid_penetration, float damage, float force, float dtype, int tracereffects)
-{
+{SELFPARAM();
        vector  end;
 
        dir = normalize(dir + randomvec() * spread);
index f53e3c53d09119c21b6c5542d640197dc9cf0b37..b725cbd195c60caab1521c659abad2763b7e14f0 100644 (file)
@@ -50,7 +50,7 @@ float W_WeaponSpeedFactor()
 void(float fr, float t, void() func) weapon_thinkf;
 
 float CL_Weaponentity_CustomizeEntityForClient()
-{
+{SELFPARAM();
        self.viewmodelforclient = self.owner;
        if(IS_SPEC(other))
                if(other.enemy == self.owner)
@@ -110,7 +110,7 @@ float CL_Weaponentity_CustomizeEntityForClient()
 //   call again with ""
 //   remove the ent
 void CL_WeaponEntity_SetModel(string name)
-{
+{SELFPARAM();
        float v_shot_idx;
        if (name != "")
        {
@@ -269,22 +269,19 @@ void CL_WeaponEntity_SetModel(string name)
 }
 
 vector CL_Weapon_GetShotOrg(float wpn)
-{
-       entity wi, oldself;
-       vector ret;
-       wi = get_weaponinfo(wpn);
-       oldself = self;
-       self = spawn();
+{SELFPARAM();
+       entity wi = get_weaponinfo(wpn);
+       setself(spawn());
        CL_WeaponEntity_SetModel(wi.mdl);
-       ret = self.movedir;
+       vector ret = self.movedir;
        CL_WeaponEntity_SetModel("");
        remove(self);
-       self = oldself;
+       setself(this);
        return ret;
 }
 
 void CL_Weaponentity_Think()
-{
+{SELFPARAM();
        int tb;
        self.nextthink = time;
        if (intermission_running)
@@ -360,7 +357,7 @@ void CL_Weaponentity_Think()
 }
 
 void CL_ExteriorWeaponentity_Think()
-{
+{SELFPARAM();
        float tag_found;
        self.nextthink = time;
        if (self.owner.exteriorweaponentity != self)
@@ -404,46 +401,41 @@ void CL_ExteriorWeaponentity_Think()
        self.glowmod = self.owner.weaponentity_glowmod;
        self.colormap = self.owner.colormap;
 
-       CSQCMODEL_AUTOUPDATE();
+       CSQCMODEL_AUTOUPDATE(self);
 }
 
 // spawning weaponentity for client
-void CL_SpawnWeaponentity()
+void CL_SpawnWeaponentity(entity e)
 {
-       self.weaponentity = spawn();
-       self.weaponentity.classname = "weaponentity";
-       self.weaponentity.solid = SOLID_NOT;
-       self.weaponentity.owner = self;
-       setmodel(self.weaponentity, ""); // precision set when changed
-       setorigin(self.weaponentity, '0 0 0');
-       self.weaponentity.angles = '0 0 0';
-       self.weaponentity.viewmodelforclient = self;
-       self.weaponentity.flags = 0;
-       self.weaponentity.think = CL_Weaponentity_Think;
-       self.weaponentity.customizeentityforclient = CL_Weaponentity_CustomizeEntityForClient;
-       self.weaponentity.nextthink = time;
-
-       self.exteriorweaponentity = spawn();
-       self.exteriorweaponentity.classname = "exteriorweaponentity";
-       self.exteriorweaponentity.solid = SOLID_NOT;
-       self.exteriorweaponentity.exteriorweaponentity = self.exteriorweaponentity;
-       self.exteriorweaponentity.owner = self;
-       setorigin(self.exteriorweaponentity, '0 0 0');
-       self.exteriorweaponentity.angles = '0 0 0';
-       self.exteriorweaponentity.think = CL_ExteriorWeaponentity_Think;
-       self.exteriorweaponentity.nextthink = time;
-
-       {
-               entity oldself = self;
-               self = self.exteriorweaponentity;
-               CSQCMODEL_AUTOINIT();
-               self = oldself;
-       }
+       entity view = e.weaponentity = spawn();
+       view.classname = "weaponentity";
+       view.solid = SOLID_NOT;
+       view.owner = e;
+       setmodel(view, ""); // precision set when changed
+       setorigin(view, '0 0 0');
+       view.angles = '0 0 0';
+       view.viewmodelforclient = e;
+       view.flags = 0;
+       view.think = CL_Weaponentity_Think;
+       view.customizeentityforclient = CL_Weaponentity_CustomizeEntityForClient;
+       view.nextthink = time;
+
+       entity exterior = e.exteriorweaponentity = spawn();
+       exterior.classname = "exteriorweaponentity";
+       exterior.solid = SOLID_NOT;
+       exterior.exteriorweaponentity = exterior;
+       exterior.owner = e;
+       setorigin(exterior, '0 0 0');
+       exterior.angles = '0 0 0';
+       exterior.think = CL_ExteriorWeaponentity_Think;
+       exterior.nextthink = time;
+
+       CSQCMODEL_AUTOINIT(exterior);
 }
 
 // Weapon subs
 void w_clear()
-{
+{SELFPARAM();
        if (self.weapon != -1)
        {
                self.weapon = 0;
@@ -457,7 +449,7 @@ void w_clear()
 }
 
 void w_ready()
-{
+{SELFPARAM();
        if (self.weaponentity)
                self.weaponentity.state = WS_READY;
        weapon_thinkf(WFRAME_IDLE, 1000000, w_ready);
@@ -466,7 +458,7 @@ void w_ready()
 .float prevdryfire;
 .float prevwarntime;
 float weapon_prepareattack_checkammo(float secondary)
-{
+{SELFPARAM();
        if (!(self.items & IT_UNLIMITED_WEAPON_AMMO))
        if (!WEP_ACTION(self.weapon, WR_CHECKAMMO1 + secondary))
        {
@@ -513,7 +505,7 @@ float weapon_prepareattack_checkammo(float secondary)
 }
 .float race_penalty;
 float weapon_prepareattack_check(float secondary, float attacktime)
-{
+{SELFPARAM();
        if(!weapon_prepareattack_checkammo(secondary))
                return false;
 
@@ -543,7 +535,7 @@ float weapon_prepareattack_check(float secondary, float attacktime)
        return true;
 }
 float weapon_prepareattack_do(float secondary, float attacktime)
-{
+{SELFPARAM();
        self.weaponentity.state = WS_INUSE;
 
        self.spawnshieldtime = min(self.spawnshieldtime, time); // kill spawn shield when you fire
@@ -574,7 +566,7 @@ float weapon_prepareattack(float secondary, float attacktime)
 }
 
 void weapon_thinkf(float fr, float t, void() func)
-{
+{SELFPARAM();
        vector a;
        vector of, or, ou;
        float restartanim;
@@ -665,7 +657,7 @@ float forbidWeaponUse(entity player)
 }
 
 void W_WeaponFrame()
-{
+{SELFPARAM();
        vector fo, ri, up;
 
        if (frametime)
@@ -796,7 +788,7 @@ void W_WeaponFrame()
 }
 
 void W_AttachToShotorg(entity flash, vector offset)
-{
+{SELFPARAM();
        entity xflash;
        flash.owner = self;
        flash.angles_z = random() * 360;
@@ -828,7 +820,7 @@ void W_AttachToShotorg(entity flash, vector offset)
 }
 
 void W_DecreaseAmmo(float ammo_use)
-{
+{SELFPARAM();
        entity wep = get_weaponinfo(self.weapon);
 
        if(cvar("g_overkill"))
@@ -872,7 +864,7 @@ void W_DecreaseAmmo(float ammo_use)
 .string reload_sound;
 
 void W_ReloadedAndReady()
-{
+{SELFPARAM();
        // finish the reloading process, and do the ammo transfer
 
        self.clip_load = self.old_clip_load; // restore the ammo counter, in case we still had ammo in the weapon before reloading
@@ -899,7 +891,7 @@ void W_ReloadedAndReady()
 }
 
 void W_Reload(float sent_ammo_min, string sent_sound)
-{
+{SELFPARAM();
        // set global values to work with
        entity e;
        e = get_weaponinfo(self.weapon);
@@ -976,10 +968,9 @@ void W_Reload(float sent_ammo_min, string sent_sound)
 }
 
 void W_DropEvent(float event, entity player, float weapon_type, entity weapon_item)
-{
-       entity oldself = self;
-       self = player;
+{SELFPARAM();
+       setself(player);
        weapon_dropevent_item = weapon_item;
        WEP_ACTION(weapon_type, event);
-       self = oldself;
+       setself(this);
 }
index e466449e6e841f2d93a3fa2d86540d508652a2c6..41b382d971aa6794e30eac00124eee646e7ae446 100644 (file)
@@ -14,7 +14,7 @@ const float WFRAME_FIRE2 = 1;
 const float WFRAME_IDLE = 2;
 const float WFRAME_RELOAD = 3;
 
-void CL_SpawnWeaponentity();
+void CL_SpawnWeaponentity(entity e);
 
 vector CL_Weapon_GetShotOrg(float wpn);
 
index e0bb6434584efb034b554b9985febc3ff39a8280..85fbdd933e6e2453447d1b144f2663d92bc4a598 100644 (file)
@@ -10,7 +10,7 @@
 #endif
 
 void WarpZone_Fade_PreDraw()
-{
+{SELFPARAM();
        vector org;
        org = getpropertyvec(VF_ORIGIN);
        if(!checkpvs(org, self)) // this makes sense as long as we don't support recursive warpzones
@@ -27,7 +27,7 @@ void WarpZone_Fade_PreDraw()
 }
 
 void WarpZone_Read(float isnew)
-{
+{SELFPARAM();
        warpzone_warpzones_exist = 1;
        if (!self.enemy)
        {
@@ -92,7 +92,7 @@ void WarpZone_Read(float isnew)
 }
 
 void WarpZone_Camera_Read(float isnew)
-{
+{SELFPARAM();
        warpzone_cameras_exist = 1;
        self.classname = "func_warpzone_camera";
 
@@ -149,7 +149,7 @@ void WarpZone_Camera_Read(float isnew)
 
 void CL_RotateMoves(vector ang) = #638;
 void WarpZone_Teleported_Read(float isnew)
-{
+{SELFPARAM();
        vector v;
        self.classname = "warpzone_teleported";
        v.x = ReadCoord();
index d04b768f8810e8b3b5d2b431b54ba135cafc0fe8..7b0b9e723f40a8848fdefb16751f4a8ab8c39c89 100644 (file)
@@ -43,7 +43,7 @@ void WarpZone_Accumulator_AddInverse(entity acc, entity wz)
 .vector(vector, vector) camera_transform;
 float autocvar_cl_warpzone_usetrace = 1;
 vector WarpZone_camera_transform(vector org, vector ang)
-{
+{SELFPARAM();
        vector vf, vr, vu;
        if(self.warpzone_fadestart)
                if(vlen(org - self.origin - 0.5 * (self.mins + self.maxs)) > self.warpzone_fadeend + 400)
@@ -81,7 +81,7 @@ void WarpZone_SetUp(entity e, vector my_org, vector my_ang, vector other_org, ve
 }
 
 vector WarpZone_Camera_camera_transform(vector org, vector ang)
-{
+{SELFPARAM();
        // a fixed camera view
        if(self.warpzone_fadestart)
                if(vlen(org - self.origin - 0.5 * (self.mins + self.maxs)) > self.warpzone_fadeend + 400)
@@ -698,7 +698,7 @@ entity WarpZone_FindRadius(vector org, float rad, float needlineofsight)
 
 .entity WarpZone_refsys;
 void WarpZone_RefSys_GC()
-{
+{SELFPARAM();
        // garbage collect unused reference systems
        self.nextthink = time + 1;
        if(self.owner.WarpZone_refsys != self)
@@ -818,7 +818,7 @@ entity WarpZone_RefSys_SpawnSameRefSys(entity me)
 }
 
 float WarpZoneLib_ExactTrigger_Touch()
-{
+{SELFPARAM();
        return !WarpZoneLib_BoxTouchesBrush(other.absmin, other.absmax, self, other);
 }
 
index b5c6f656a44e1410514f83da79f19aa5ce23a082..bda756bba4b3a57ba106ec2dd3815a135a831312 100644 (file)
@@ -54,7 +54,7 @@ void WarpZone_TeleportPlayer(entity teleporter, entity player, vector to, vector
 }
 
 bool WarpZone_Teleported_Send(entity to, int sf)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_WARPZONE_TELEPORTED);
        WriteCoord(MSG_ENTITY, self.angles.x);
        WriteCoord(MSG_ENTITY, self.angles.y);
@@ -158,9 +158,7 @@ float WarpZone_Teleport(entity wz, entity player, float f0, float f1)
 }
 
 void WarpZone_Touch (void)
-{
-       entity oldself;
-
+{SELFPARAM();
        if(other.classname == "trigger_warpzone")
                return;
 
@@ -205,14 +203,13 @@ void WarpZone_Touch (void)
                if (!self.target) self.target = save1;
                if (!self.target3) self.target3 = save2;
 
-               oldself = self;
-               self = self.enemy;
+               setself(self.enemy);
                save1 = self.target; self.target = string_null;
                save2 = self.target2; self.target2 = string_null;
                SUB_UseTargets();
                if (!self.target) self.target = save1;
                if (!self.target2) self.target2 = save2;
-               self = oldself;
+               setself(this);
        }
        else
        {
@@ -221,7 +218,7 @@ void WarpZone_Touch (void)
 }
 
 bool WarpZone_Send(entity to, int sendflags)
-{
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_WARPZONE);
 
        // we must send this flag for clientside to match properly too
@@ -275,7 +272,7 @@ bool WarpZone_Send(entity to, int sendflags)
 }
 
 bool WarpZone_Camera_Send(entity to, int sendflags)
-{
+{SELFPARAM();
        int f = 0;
        WriteByte(MSG_ENTITY, ENT_CLIENT_WARPZONE_CAMERA);
 
@@ -321,7 +318,7 @@ bool WarpZone_Camera_Send(entity to, int sendflags)
 
 #ifdef WARPZONELIB_KEEPDEBUG
 float WarpZone_CheckProjectileImpact(entity player)
-{
+{SELFPARAM();
        vector o0, v0;
 
        o0 = player.origin + player.view_ofs;
@@ -388,7 +385,7 @@ float WarpZone_CheckProjectileImpact(entity player)
 #endif
 
 float WarpZone_Projectile_Touch()
-{
+{SELFPARAM();
        if(other.classname == "trigger_warpzone")
                return true;
 
@@ -456,7 +453,7 @@ float WarpZone_Projectile_Touch()
 }
 
 void WarpZone_InitStep_FindOriginTarget()
-{
+{SELFPARAM();
        if(self.killtarget != "")
        {
                self.aiment = find(world, targetname, self.killtarget);
@@ -470,7 +467,7 @@ void WarpZone_InitStep_FindOriginTarget()
 }
 
 void WarpZonePosition_InitStep_FindTarget()
-{
+{SELFPARAM();
        if(self.target == "")
        {
                error("Warp zone position with no target");
@@ -492,7 +489,7 @@ void WarpZonePosition_InitStep_FindTarget()
 }
 
 void WarpZoneCamera_Think(void)
-{
+{SELFPARAM();
        if(self.warpzone_save_origin != self.origin
        || self.warpzone_save_angles != self.angles
        || self.warpzone_save_eorigin != self.enemy.origin
@@ -508,7 +505,7 @@ void WarpZoneCamera_Think(void)
 }
 
 void WarpZoneCamera_InitStep_FindTarget()
-{
+{SELFPARAM();
        entity e;
        float i;
        if(self.target == "")
@@ -538,7 +535,7 @@ void WarpZoneCamera_InitStep_FindTarget()
 }
 
 void WarpZone_InitStep_UpdateTransform()
-{
+{SELFPARAM();
        vector org, ang, norm, point;
        float area;
        vector tri, a, b, c, n;
@@ -619,7 +616,7 @@ void WarpZone_InitStep_UpdateTransform()
 }
 
 void WarpZone_InitStep_ClearTarget()
-{
+{SELFPARAM();
        if(self.enemy)
                self.enemy.enemy = world;
        self.enemy = world;
@@ -627,7 +624,7 @@ void WarpZone_InitStep_ClearTarget()
 
 entity warpzone_first; .entity warpzone_next;
 void WarpZone_InitStep_FindTarget()
-{
+{SELFPARAM();
        float i;
        entity e, e2;
 
@@ -658,7 +655,7 @@ void WarpZone_InitStep_FindTarget()
 
 void WarpZone_Think();
 void WarpZone_InitStep_FinalizeTransform()
-{
+{SELFPARAM();
        if(!self.enemy || self.enemy.enemy != self)
        {
                error("Invalid warp zone detected. Killed.");
@@ -684,7 +681,7 @@ entity warpzone_position_first;
 entity warpzone_camera_first;
 .entity warpzone_next;
 void spawnfunc_misc_warpzone_position(void)
-{
+{SELFPARAM();
        // "target", "angles", "origin"
        self.warpzone_next = warpzone_position_first;
        warpzone_position_first = self;
@@ -694,7 +691,7 @@ void spawnfunc_trigger_warpzone_position(void)
        spawnfunc_misc_warpzone_position();
 }
 void spawnfunc_trigger_warpzone(void)
-{
+{SELFPARAM();
        // warp zone entities must have:
        // "killtarget" pointing to a target_position with a direction arrow
        //              that points AWAY from the warp zone, and that is inside
@@ -732,7 +729,7 @@ void spawnfunc_trigger_warpzone(void)
        warpzone_first = self;
 }
 void spawnfunc_func_camera(void)
-{
+{SELFPARAM();
        if(!self.scale)
                self.scale = self.modelscale;
        if(!self.scale)
@@ -757,37 +754,33 @@ void spawnfunc_func_camera(void)
        warpzone_camera_first = self;
 }
 void WarpZones_Reconnect()
-{
-       entity e;
-       e = self;
-       for(self = warpzone_first; self; self = self.warpzone_next)
+{SELFPARAM();
+       for(setself(warpzone_first); self; setself(self.warpzone_next))
                WarpZone_InitStep_ClearTarget();
-       for(self = warpzone_first; self; self = self.warpzone_next)
+       for(setself(warpzone_first); self; setself(self.warpzone_next))
                WarpZone_InitStep_FindTarget();
-       for(self = warpzone_camera_first; self; self = self.warpzone_next)
+       for(setself(warpzone_camera_first); self; setself(self.warpzone_next))
                WarpZoneCamera_InitStep_FindTarget();
-       for(self = warpzone_first; self; self = self.warpzone_next)
+       for(setself(warpzone_first); self; setself(self.warpzone_next))
                WarpZone_InitStep_FinalizeTransform();
-       self = e;
+       setself(this);
 }
 
 void WarpZone_Think()
-{
+{SELFPARAM();
        if(self.warpzone_save_origin != self.origin
        || self.warpzone_save_angles != self.angles
        || self.warpzone_save_eorigin != self.enemy.origin
        || self.warpzone_save_eangles != self.enemy.angles)
        {
-               entity oldself;
-               oldself = self;
                WarpZone_InitStep_UpdateTransform();
-               self = self.enemy;
+               setself(self.enemy);
                WarpZone_InitStep_UpdateTransform();
-               self = oldself;
+               setself(this);
                WarpZone_InitStep_FinalizeTransform();
-               self = self.enemy;
+               setself(self.enemy);
                WarpZone_InitStep_FinalizeTransform();
-               self = oldself;
+               setself(this);
                self.warpzone_save_origin = self.origin;
                self.warpzone_save_angles = self.angles;
                self.warpzone_save_eorigin = self.enemy.origin;
@@ -797,25 +790,23 @@ void WarpZone_Think()
 }
 
 void WarpZone_StartFrame()
-{
+{SELFPARAM();
        entity e;
        if(warpzone_initialized == 0)
        {
                warpzone_initialized = 1;
-               e = self;
-               for(self = warpzone_first; self; self = self.warpzone_next)
+               for(setself(warpzone_first); self; setself(self.warpzone_next))
                        WarpZone_InitStep_FindOriginTarget();
-               for(self = warpzone_position_first; self; self = self.warpzone_next)
+               for(setself(warpzone_position_first); self; setself(self.warpzone_next))
                        WarpZonePosition_InitStep_FindTarget();
-               for(self = warpzone_first; self; self = self.warpzone_next)
+               for(setself(warpzone_first); self; setself(self.warpzone_next))
                        WarpZone_InitStep_UpdateTransform();
-               self = e;
+               setself(this);
                WarpZones_Reconnect();
                WarpZone_PostInitialize_Callback();
        }
 
-       entity oldself, oldother;
-       oldself = self;
+       entity oldother;
        oldother = other;
        for(e = world; (e = nextent(e)); )
        {
@@ -830,14 +821,14 @@ void WarpZone_StartFrame()
 
                                // warpzones
                                if(warpzone_warpzones_exist) {
-                               self = WarpZone_Find(e.origin + e.mins, e.origin + e.maxs);
+                               setself(WarpZone_Find(e.origin + e.mins, e.origin + e.maxs));
                                if(self)
                                if(!WarpZoneLib_ExactTrigger_Touch())
                                        if(WarpZone_PlaneDist(self, e.origin + e.view_ofs) <= 0)
                                                WarpZone_Teleport(self, e, -1, 0); } // NOT triggering targets by this!
 
                                // teleporters
-                               self = Teleport_Find(e.origin + e.mins, e.origin + e.maxs);
+                               setself(Teleport_Find(e.origin + e.mins, e.origin + e.maxs));
                                if(self)
                                if(!WarpZoneLib_ExactTrigger_Touch())
                                        Simple_TeleportPlayer(self, other); // NOT triggering targets by this!
@@ -852,7 +843,7 @@ void WarpZone_StartFrame()
                        break;
                }
        }
-       self = oldself;
+       setself(this);
        other = oldother;
 }
 
@@ -867,32 +858,32 @@ float visible_to_some_client(entity ent)
        return 0;
 }
 void trigger_warpzone_reconnect_use()
-{
+{SELFPARAM();
        entity e;
        e = self;
        // NOTE: this matches for target, not targetname, but of course
        // targetname must be set too on the other entities
-       for(self = warpzone_first; self; self = self.warpzone_next)
+       for(setself(warpzone_first); self; setself(self.warpzone_next))
                self.warpzone_reconnecting = ((e.target == "" || self.target == e.target) && !((e.spawnflags & 1) && (visible_to_some_client(self) || visible_to_some_client(self.enemy))));
-       for(self = warpzone_camera_first; self; self = self.warpzone_next)
+       for(setself(warpzone_camera_first); self; setself(self.warpzone_next))
                self.warpzone_reconnecting = ((e.target == "" || self.target == e.target) && !((e.spawnflags & 1) && visible_to_some_client(self)));
-       for(self = warpzone_first; self; self = self.warpzone_next)
+       for(setself(warpzone_first); self; setself(self.warpzone_next))
                if(self.warpzone_reconnecting)
                        WarpZone_InitStep_ClearTarget();
-       for(self = warpzone_first; self; self = self.warpzone_next)
+       for(setself(warpzone_first); self; setself(self.warpzone_next))
                if(self.warpzone_reconnecting)
                        WarpZone_InitStep_FindTarget();
-       for(self = warpzone_camera_first; self; self = self.warpzone_next)
+       for(setself(warpzone_camera_first); self; setself(self.warpzone_next))
                if(self.warpzone_reconnecting)
                        WarpZoneCamera_InitStep_FindTarget();
-       for(self = warpzone_first; self; self = self.warpzone_next)
+       for(setself(warpzone_first); self; setself(self.warpzone_next))
                if(self.warpzone_reconnecting || self.enemy.warpzone_reconnecting)
                        WarpZone_InitStep_FinalizeTransform();
-       self = e;
+       setself(e);
 }
 
 void spawnfunc_trigger_warpzone_reconnect()
-{
+{SELFPARAM();
        self.use = trigger_warpzone_reconnect_use;
 }
 
@@ -902,7 +893,7 @@ void spawnfunc_target_warpzone_reconnect()
 }
 
 void WarpZone_PlayerPhysics_FixVAngle(void)
-{
+{SELFPARAM();
 #ifndef WARPZONE_DONT_FIX_VANGLE
        if(IS_REAL_CLIENT(self))
        if(self.v_angle.z <= 360) // if not already adjusted
index 0af6d3c0dcd44dacfb266a3f3ed9f400b0ee7bf4..29bbecce4e3b7468a11dbd588091ca0f7052b127 100644 (file)
@@ -12,7 +12,7 @@
 #include "common.qh"
 
 void WarpZoneLib_ExactTrigger_Init()
-{
+{SELFPARAM();
        vector mi, ma;
        if (self.movedir == '0 0 0')
        if (self.angles != '0 0 0')