From 3a035cb2732af064519135410c5664c2e1b3f501 Mon Sep 17 00:00:00 2001 From: TimePath Date: Mon, 31 Aug 2015 12:23:43 +1000 Subject: [PATCH] Replace all direct assignments to self with setself(e) --- qcsrc/client/damage.qc | 6 +-- qcsrc/client/hud.qc | 4 +- qcsrc/client/rubble.qc | 8 +-- qcsrc/client/scoreboard.qc | 4 +- qcsrc/client/view.qc | 18 +++---- qcsrc/common/minigames/cl_minigames_hud.qc | 6 +-- qcsrc/common/minigames/sv_minigames.qc | 6 +-- qcsrc/common/monsters/spawn.qc | 6 +-- qcsrc/common/monsters/sv_monsters.qc | 6 +-- qcsrc/common/movetypes/movetypes.qc | 10 ++-- qcsrc/common/movetypes/push.qc | 14 ++--- qcsrc/common/mutators/mutator/itemstime.qc | 5 +- qcsrc/common/triggers/func/door.qc | 29 ++++------ qcsrc/common/triggers/func/train.qc | 7 +-- qcsrc/common/triggers/misc/laser.qc | 17 +++--- qcsrc/common/triggers/platforms.qc | 4 +- qcsrc/common/triggers/subs.qc | 26 +++------ qcsrc/common/triggers/subs.qh | 6 +-- qcsrc/common/triggers/target/music.qc | 3 +- qcsrc/common/triggers/target/spawn.qc | 9 +--- qcsrc/common/triggers/teleporters.qc | 6 +-- qcsrc/common/triggers/trigger/jumppads.qc | 7 +-- qcsrc/common/triggers/trigger/keylock.qc | 4 +- qcsrc/common/triggers/trigger/magicear.qc | 11 ++-- .../triggers/trigger/relay_activators.qc | 16 +++--- qcsrc/common/triggers/trigger/teleport.qc | 10 ++-- qcsrc/common/triggers/triggers.qc | 6 +-- qcsrc/common/turrets/sv_turrets.qc | 4 +- qcsrc/common/turrets/targettrigger.qc | 7 ++- qcsrc/common/turrets/unit/phaser.qc | 4 +- qcsrc/common/util-post.qh | 2 + qcsrc/common/vehicles/sv_vehicles.qc | 23 ++++---- qcsrc/common/vehicles/unit/bumblebee.qc | 26 ++++----- qcsrc/common/vehicles/unit/racer.qc | 6 +-- qcsrc/common/vehicles/unit/raptor.qc | 10 ++-- qcsrc/common/vehicles/unit/spiderbot.qc | 8 +-- qcsrc/common/weapons/weapon/arc.qc | 10 ++-- qcsrc/common/weapons/weapon/blaster.qc | 7 +-- qcsrc/common/weapons/weapon/minelayer.qc | 14 ++--- qcsrc/common/weapons/weapon/porto.qc | 7 +-- qcsrc/common/weapons/weapon/seeker.qc | 4 +- qcsrc/common/weapons/weapon/tuba.qc | 12 ++--- qcsrc/csqcmodellib/cl_player.qc | 13 ++--- qcsrc/server/anticheat.qc | 11 ++-- qcsrc/server/bot/bot.qc | 8 ++- qcsrc/server/cheats.qc | 20 ++++--- qcsrc/server/cl_client.qc | 47 +++++++--------- qcsrc/server/cl_player.qc | 4 +- qcsrc/server/command/sv_cmd.qc | 30 +++++------ qcsrc/server/command/vote.qc | 53 +++++++++++-------- qcsrc/server/g_damage.qc | 30 ++++------- qcsrc/server/g_world.qc | 45 ++++++++-------- qcsrc/server/miscfunctions.qc | 48 ++++++++--------- qcsrc/server/mutators/events.qh | 1 + qcsrc/server/mutators/gamemode_assault.qc | 51 ++++++++---------- qcsrc/server/mutators/gamemode_ca.qc | 4 +- qcsrc/server/mutators/gamemode_ctf.qc | 15 +++--- qcsrc/server/mutators/gamemode_domination.qc | 18 +++---- qcsrc/server/mutators/gamemode_freezetag.qc | 10 ++-- qcsrc/server/mutators/gamemode_lms.qc | 10 ++-- qcsrc/server/mutators/gamemode_nexball.qc | 8 +-- qcsrc/server/mutators/gamemode_onslaught.qc | 30 ++++++----- qcsrc/server/mutators/gamemode_tdm.qc | 6 +-- qcsrc/server/mutators/mutator_buffs.qc | 12 ++--- qcsrc/server/mutators/mutator_instagib.qc | 7 +-- qcsrc/server/mutators/mutator_overkill.qc | 4 +- qcsrc/server/mutators/mutator_superspec.qc | 18 ++++--- qcsrc/server/mutators/sandbox.qc | 9 ++-- qcsrc/server/race.qc | 20 ++++--- qcsrc/server/spawnpoints.qc | 6 +-- qcsrc/server/sv_main.qc | 15 +++--- qcsrc/server/t_items.qc | 4 +- qcsrc/server/weapons/common.qc | 6 +-- qcsrc/server/weapons/selection.qc | 4 +- qcsrc/server/weapons/spawning.qc | 4 +- qcsrc/server/weapons/throwing.qc | 9 ++-- qcsrc/server/weapons/weaponsystem.qc | 16 +++--- qcsrc/warpzonelib/server.qc | 53 +++++++++---------- 78 files changed, 462 insertions(+), 585 deletions(-) diff --git a/qcsrc/client/damage.qc b/qcsrc/client/damage.qc index 8cb410d66..5d5de1566 100644 --- a/qcsrc/client/damage.qc +++ b/qcsrc/client/damage.qc @@ -159,8 +159,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 +212,7 @@ void Ent_DamageInfo(float isNew) if(self.isplayermodel) hitplayer = true; // this impact damaged a player } - - self = oldself; + setself(oldself); if(DEATH_ISVEHICLE(w_deathtype)) { diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index cbef45330..9a0f87b94 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -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); diff --git a/qcsrc/client/rubble.qc b/qcsrc/client/rubble.qc index 11f547625..8035fd76e 100644 --- a/qcsrc/client/rubble.qc +++ b/qcsrc/client/rubble.qc @@ -6,12 +6,9 @@ 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,8 @@ void RubbleLimit(string cname, float limit, void() deleteproc) break; // delete this oldest one and search again - self = oldest; - deleteproc(); - self = oldself; + SELFCALL(oldest, deleteproc()); + SELFCALL_DONE(); } } diff --git a/qcsrc/client/scoreboard.qc b/qcsrc/client/scoreboard.qc index 7d2a425f1..407c08747 100644 --- a/qcsrc/client/scoreboard.qc +++ b/qcsrc/client/scoreboard.qc @@ -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]; diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 3039c04a5..f53dbd6be 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -1466,11 +1466,10 @@ 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) { + SELFCALL(e, e.draw()); + SELFCALL_DONE(); + } addentities(MASK_NORMAL | MASK_ENGINE | MASK_ENGINEVIEWMODELS); renderscene(); @@ -1805,11 +1804,10 @@ 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) { + SELFCALL(e, e.draw2d()); + SELFCALL_DONE(); + } Draw_ShowNames_All(); scoreboard_active = HUD_WouldDrawScoreboard(); diff --git a/qcsrc/common/minigames/cl_minigames_hud.qc b/qcsrc/common/minigames/cl_minigames_hud.qc index 9ad706d1e..cedb98bd7 100644 --- a/qcsrc/common/minigames/cl_minigames_hud.qc +++ b/qcsrc/common/minigames/cl_minigames_hud.qc @@ -107,10 +107,8 @@ void HUD_MinigameMenu_Click(entity menuitem) {SELFPARAM(); if ( menuitem ) { - entity e = self; - self = menuitem; - menuitem.use(); - self = e; + SELFCALL(menuitem, menuitem.use()); + SELFCALL_DONE(); } } diff --git a/qcsrc/common/minigames/sv_minigames.qc b/qcsrc/common/minigames/sv_minigames.qc index db4209d92..95619a285 100644 --- a/qcsrc/common/minigames/sv_minigames.qc +++ b/qcsrc/common/minigames/sv_minigames.qc @@ -150,10 +150,8 @@ int minigame_addplayer(entity minigame_session, entity player) if ( !IS_OBSERVER(player) && autocvar_sv_minigames_observer ) { - entity e = self; - self = player; - PutObserverInServer(); - self = e; + SELFCALL(player, PutObserverInServer()); + SELFCALL_DONE(); } if ( autocvar_sv_minigames_observer == 2 ) player.team_forced = -1; diff --git a/qcsrc/common/monsters/spawn.qc b/qcsrc/common/monsters/spawn.qc index 2ed974b28..9e9810b46 100644 --- a/qcsrc/common/monsters/spawn.qc +++ b/qcsrc/common/monsters/spawn.qc @@ -64,10 +64,8 @@ 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; + SELFCALL(e, Monster_Spawn(monster_id)); + SELFCALL_DONE(); return e; } diff --git a/qcsrc/common/monsters/sv_monsters.qc b/qcsrc/common/monsters/sv_monsters.qc index 17bb1baf4..124fb7e85 100644 --- a/qcsrc/common/monsters/sv_monsters.qc +++ b/qcsrc/common/monsters/sv_monsters.qc @@ -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,7 +58,7 @@ 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(oldself); } } @@ -198,7 +198,7 @@ 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) diff --git a/qcsrc/common/movetypes/movetypes.qc b/qcsrc/common/movetypes/movetypes.qc index 74716dd9a..b3158b5f9 100644 --- a/qcsrc/common/movetypes/movetypes.qc +++ b/qcsrc/common/movetypes/movetypes.qc @@ -322,7 +322,6 @@ void _Movetype_CheckWaterTransition(entity ent) // SV_CheckWaterTransition void _Movetype_Impact(entity oth) // SV_Impact {SELFPARAM(); - entity oldself = self; entity oldother = other; if(self.move_touch) @@ -337,11 +336,10 @@ void _Movetype_Impact(entity oth) // SV_Impact if(oth.move_touch) { other = self; - self = oth; - self.move_touch(); + SELFCALL(oth, oth.move_touch()); + SELFCALL_DONE(); - self = oldself; other = oldother; } } @@ -355,7 +353,7 @@ void _Movetype_LinkEdict_TouchAreaGrid() // SV_LinkEdict_TouchAreaGrid { if(e.move_touch && boxesoverlap(e.absmin, e.absmax, oldself.absmin, oldself.absmax)) { - self = e; + setself(e); other = oldself; trace_allsolid = false; @@ -373,7 +371,7 @@ void _Movetype_LinkEdict_TouchAreaGrid() // SV_LinkEdict_TouchAreaGrid } other = oldother; - self = oldself; + setself(oldself); } void _Movetype_LinkEdict(bool touch_triggers) // SV_LinkEdict diff --git a/qcsrc/common/movetypes/push.qc b/qcsrc/common/movetypes/push.qc index 506edb5b6..29ac255d6 100644 --- a/qcsrc/common/movetypes/push.qc +++ b/qcsrc/common/movetypes/push.qc @@ -93,26 +93,22 @@ 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; + SELFCALL(check, _Movetype_LinkEdict(true)); + SELFCALL_DONE(); continue; } // try moving the contacted entity self.solid = SOLID_NOT; - entity oldself = self; - self = check; - if (!_Movetype_PushEntity(move, true)) + bool flag = SELFCALL(check, _Movetype_PushEntity(move, true)); + SELFCALL_DONE(); + 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; diff --git a/qcsrc/common/mutators/mutator/itemstime.qc b/qcsrc/common/mutators/mutator/itemstime.qc index ad6228d77..d7ca5a335 100644 --- a/qcsrc/common/mutators/mutator/itemstime.qc +++ b/qcsrc/common/mutators/mutator/itemstime.qc @@ -154,9 +154,10 @@ MUTATOR_HOOKFUNCTION(itemstime, reset_map_global) 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); } diff --git a/qcsrc/common/triggers/func/door.qc b/qcsrc/common/triggers/func/door.qc index 9688214e3..12e3c4dd1 100644 --- a/qcsrc/common/triggers/func/door.qc +++ b/qcsrc/common/triggers/func/door.qc @@ -236,9 +236,9 @@ void door_fire() { door_rotating_go_down (); } - self = self.enemy; + setself(self.enemy); } while ( (self != starte) && (self != world) ); - self = oself; + setself(oself); return; } } @@ -265,29 +265,24 @@ void door_fire() door_rotating_go_up (); } } - self = self.enemy; + setself(self.enemy); } while ( (self != starte) && (self != world) ); - self = oself; + setself(oself); } void door_use() {SELFPARAM(); - entity oself; - //dprint("door_use (model: ");dprint(self.model);dprint(")\n"); if (self.owner) { - oself = self; - self = self.owner; - door_fire (); - self = oself; + SELFCALL(self.owner, door_fire()); + SELFCALL_DONE(); } } void door_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) {SELFPARAM(); - entity oself; if(self.spawnflags & DOOR_NOSPLASH) if(!(DEATH_ISSPECIAL(deathtype)) && (deathtype & HITTYPE_SPLASH)) return; @@ -301,12 +296,10 @@ 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 + SELFCALL(self.owner, door_use()); + SELFCALL_DONE(); } } @@ -465,7 +458,7 @@ void door_trigger_touch() activator = other; - self = self.owner; + setself(self.owner); door_use (); } diff --git a/qcsrc/common/triggers/func/train.qc b/qcsrc/common/triggers/func/train.qc index f6059f74c..d06efdd94 100644 --- a/qcsrc/common/triggers/func/train.qc +++ b/qcsrc/common/triggers/func/train.qc @@ -2,11 +2,8 @@ void() train_next; void train_wait() {SELFPARAM(); - entity oldself; - oldself = self; - self = self.enemy; - SUB_UseTargets(); - self = oldself; + SELFCALL(self.enemy, SUB_UseTargets()); + SELFCALL_DONE(); self.enemy = world; // if turning is enabled, the train will turn toward the next point while waiting diff --git a/qcsrc/common/triggers/misc/laser.qc b/qcsrc/common/triggers/misc/laser.qc index 5dde1b4fa..196121430 100644 --- a/qcsrc/common/triggers/misc/laser.qc +++ b/qcsrc/common/triggers/misc/laser.qc @@ -59,7 +59,6 @@ void misc_laser_init() void misc_laser_think() {SELFPARAM(); vector o; - entity oldself; entity hitent; vector hitloc; @@ -98,11 +97,9 @@ void misc_laser_think() { self.count = 1; - oldself = self; - self = self.enemy; - activator = self.pusher; - SUB_UseTargets(); - self = oldself; + activator = self.enemy.pusher; + SELFCALL(self.enemy, SUB_UseTargets()); + SELFCALL_DONE(); } } else @@ -111,11 +108,9 @@ void misc_laser_think() { self.count = 0; - oldself = self; - self = self.enemy; - activator = self.pusher; - SUB_UseTargets(); - self = oldself; + activator = self.enemy.pusher; + SELFCALL(self.enemy, SUB_UseTargets()); + SELFCALL_DONE(); } } } diff --git a/qcsrc/common/triggers/platforms.qc b/qcsrc/common/triggers/platforms.qc index bf184193e..b4f387470 100644 --- a/qcsrc/common/triggers/platforms.qc +++ b/qcsrc/common/triggers/platforms.qc @@ -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) @@ -127,7 +127,7 @@ void plat_outside_touch() return; #endif - self = self.enemy; + setself(self.enemy); if (self.state == 1) plat_go_down (); } diff --git a/qcsrc/common/triggers/subs.qc b/qcsrc/common/triggers/subs.qc index 0fa48b83e..f70108e88 100644 --- a/qcsrc/common/triggers/subs.qc +++ b/qcsrc/common/triggers/subs.qc @@ -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(); } @@ -238,9 +238,9 @@ 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) @@ -294,14 +294,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) {SELFPARAM(); - entity oldself; - - oldself = self; - self = ent; - - SUB_CalcMove (tdest, tspeedtype, tspeed, func); - - self = oldself; + SELFCALL(ent, SUB_CalcMove (tdest, tspeedtype, tspeed, func)); + SELFCALL_DONE(); } /* @@ -369,12 +363,6 @@ void SUB_CalcAngleMove (vector destangle, float tspeedtype, float tspeed, void() void SUB_CalcAngleMoveEnt (entity ent, vector destangle, float tspeedtype, float tspeed, void() func) {SELFPARAM(); - entity oldself; - - oldself = self; - self = ent; - - SUB_CalcAngleMove (destangle, tspeedtype, tspeed, func); - - self = oldself; + SELFCALL(ent, SUB_CalcAngleMove (destangle, tspeedtype, tspeed, func)); + SELFCALL_DONE(); } diff --git a/qcsrc/common/triggers/subs.qh b/qcsrc/common/triggers/subs.qh index b9ae06f4e..ec9eb7607 100644 --- a/qcsrc/common/triggers/subs.qh +++ b/qcsrc/common/triggers/subs.qh @@ -29,10 +29,8 @@ void SUB_SETORIGIN(entity s, vector v) {SELFPARAM(); s.move_origin = v; - entity oldself = self; - self = s; - _Movetype_LinkEdict(true); - self = oldself; + SELFCALL(s, _Movetype_LinkEdict(true)); + SELFCALL_DONE(); } #endif diff --git a/qcsrc/common/triggers/target/music.qc b/qcsrc/common/triggers/target/music.qc index 091603d86..488ed0999 100644 --- a/qcsrc/common/triggers/target/music.qc +++ b/qcsrc/common/triggers/target/music.qc @@ -59,8 +59,9 @@ void spawnfunc_target_music() } void TargetMusic_RestoreGame() {SELFPARAM(); - for(self = world; (self = find(self, classname, "target_music")); ) + for(entity e = world; (e = find(e, classname, "target_music")); ) { + setself(e); if(self.targetname == "") target_music_sendto(MSG_INIT, 1); else diff --git a/qcsrc/common/triggers/target/spawn.qc b/qcsrc/common/triggers/target/spawn.qc index 020e404d3..38eabbab3 100644 --- a/qcsrc/common/triggers/target/spawn.qc +++ b/qcsrc/common/triggers/target/spawn.qc @@ -38,7 +38,6 @@ void target_spawn_edit_entity(entity e, string msg, entity kt, entity t2, entity string key, value, valuefield, valueoffset, valueoffsetrandom; entity valueent; vector data, data2; - entity oldself; entity oldactivator; n = tokenize_console(msg); @@ -220,15 +219,11 @@ 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; + SELFCALL(e, e.target_spawn_spawnfunc()); + SELFCALL_DONE(); activator = oldactivator; // We called an external function, so we have to re-tokenize msg. diff --git a/qcsrc/common/triggers/teleporters.qc b/qcsrc/common/triggers/teleporters.qc index 7d76b3f28..4b3861b35 100644 --- a/qcsrc/common/triggers/teleporters.qc +++ b/qcsrc/common/triggers/teleporters.qc @@ -229,10 +229,8 @@ void WarpZone_PostTeleportPlayer_Callback(entity pl) Reset_ArcBeam(pl, v_forward); UpdateCSQCProjectileAfterTeleport(pl); { - entity oldself = self; - self = pl; - anticheat_fixangle(); - self = oldself; + SELFCALL(pl, anticheat_fixangle()); + SELFCALL_DONE(); } // "disown" projectiles after teleport if(pl.owner) diff --git a/qcsrc/common/triggers/trigger/jumppads.qc b/qcsrc/common/triggers/trigger/jumppads.qc index 31bd98e5d..52a8798cd 100644 --- a/qcsrc/common/triggers/trigger/jumppads.qc +++ b/qcsrc/common/triggers/trigger/jumppads.qc @@ -218,12 +218,9 @@ void trigger_push_touch() if(self.enemy.target) { - entity oldself; - oldself = self; activator = other; - self = self.enemy; - SUB_UseTargets(); - self = oldself; + SELFCALL(self.enemy, SUB_UseTargets()); + SELFCALL_DONE(); } if (other.flags & FL_PROJECTILE) diff --git a/qcsrc/common/triggers/trigger/keylock.qc b/qcsrc/common/triggers/trigger/keylock.qc index 8d6d174cb..1c2bd70b5 100644 --- a/qcsrc/common/triggers/trigger/keylock.qc +++ b/qcsrc/common/triggers/trigger/keylock.qc @@ -11,13 +11,13 @@ void trigger_keylock_trigger(string s) for(t = world; (t = find(t, targetname, s)); ) if(t.use) { - self = t; + setself(t); other = stemp; activator = atemp; self.use(); } - self = stemp; + setself(stemp); other = otemp; activator = atemp; } diff --git a/qcsrc/common/triggers/trigger/magicear.qc b/qcsrc/common/triggers/trigger/magicear.qc index 7ca85876c..0c8a7d359 100644 --- a/qcsrc/common/triggers/trigger/magicear.qc +++ b/qcsrc/common/triggers/trigger/magicear.qc @@ -5,7 +5,6 @@ string trigger_magicear_processmessage(entity ear, entity source, float teamsay, {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) diff --git a/qcsrc/common/triggers/trigger/relay_activators.qc b/qcsrc/common/triggers/trigger/relay_activators.qc index e25253b84..b765151fd 100644 --- a/qcsrc/common/triggers/trigger/relay_activators.qc +++ b/qcsrc/common/triggers/trigger/relay_activators.qc @@ -1,28 +1,24 @@ #ifdef SVQC void relay_activators_use() {SELFPARAM(); - entity trg, os; - - os = self; - - for(trg = world; (trg = find(trg, targetname, os.target)); ) + 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() diff --git a/qcsrc/common/triggers/trigger/teleport.qc b/qcsrc/common/triggers/trigger/teleport.qc index 5adc1505c..36c4cd22d 100644 --- a/qcsrc/common/triggers/trigger/teleport.qc +++ b/qcsrc/common/triggers/trigger/teleport.qc @@ -10,7 +10,6 @@ void trigger_teleport_use() void Teleport_Touch (void) {SELFPARAM(); - entity oldself; string s; if (self.active != ACTIVE_ACTIVE) @@ -38,18 +37,15 @@ 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; + SELFCALL(e, SUB_UseTargets()); + SELFCALL_DONE(); } void spawnfunc_trigger_teleport() diff --git a/qcsrc/common/triggers/triggers.qc b/qcsrc/common/triggers/triggers.qc index 09c9fcd10..bd67c1479 100644 --- a/qcsrc/common/triggers/triggers.qc +++ b/qcsrc/common/triggers/triggers.qc @@ -223,7 +223,7 @@ void SUB_UseTargets() { if (t.classname == "func_clientwall" || t.classname == "func_clientillusionary") t.antiwall_flag = aw_flag; - self = t; + setself(t); other = stemp; activator = act; self.use(); @@ -234,14 +234,14 @@ void SUB_UseTargets() if(stemp.target_random && RandomSelection_chosen_ent) { - self = RandomSelection_chosen_ent; + setself(RandomSelection_chosen_ent); other = stemp; activator = act; self.use(); } activator = act; - self = stemp; + setself(stemp); other = otemp; } diff --git a/qcsrc/common/turrets/sv_turrets.qc b/qcsrc/common/turrets/sv_turrets.qc index a551ddde0..d03ee2a3d 100644 --- a/qcsrc/common/turrets/sv_turrets.qc +++ b/qcsrc/common/turrets/sv_turrets.qc @@ -498,7 +498,7 @@ void turret_do_updates(entity t_turret) entity oldself; oldself = self; - self = t_turret; + setself(t_turret); enemy_pos = real_origin(self.enemy); @@ -527,7 +527,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(oldself); } /** diff --git a/qcsrc/common/turrets/targettrigger.qc b/qcsrc/common/turrets/targettrigger.qc index 21e45a553..98c23c458 100644 --- a/qcsrc/common/turrets/targettrigger.qc +++ b/qcsrc/common/turrets/targettrigger.qc @@ -5,15 +5,14 @@ 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,7 +22,7 @@ void turret_targettrigger_touch() oldself.cnt = time + 0.5; - self = oldself; + setself(this); } /*QUAKED turret_targettrigger (.5 .5 .5) ? diff --git a/qcsrc/common/turrets/unit/phaser.qc b/qcsrc/common/turrets/unit/phaser.qc index cbb07070a..d188e99cd 100644 --- a/qcsrc/common/turrets/unit/phaser.qc +++ b/qcsrc/common/turrets/unit/phaser.qc @@ -45,7 +45,7 @@ void beam_think() 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, @@ -54,7 +54,7 @@ void beam_think() oldself.shot_dmg, 0.75, DEATH_TURRET_PHASER); - self = oldself; + setself(oldself); self.scale = vlen(self.owner.tur_shotorg - trace_endpos) / 256; } diff --git a/qcsrc/common/util-post.qh b/qcsrc/common/util-post.qh index afec8ed20..2789e1235 100644 --- a/qcsrc/common/util-post.qh +++ b/qcsrc/common/util-post.qh @@ -6,6 +6,7 @@ // Step 1: auto oldself #if 1 #define SELFPARAM() noref entity this = __self +#define setself(s) (__self = s) #define self __self #define SELFCALL(s, f) (__self = s, f) #define SELFCALL_DONE() (__self = this) @@ -14,6 +15,7 @@ // 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 #define SELFCALL(s, f) (this = s, f) #define SELFCALL_DONE() (this = this) diff --git a/qcsrc/common/vehicles/sv_vehicles.qc b/qcsrc/common/vehicles/sv_vehicles.qc index 894e0638a..0ed648f04 100644 --- a/qcsrc/common/vehicles/sv_vehicles.qc +++ b/qcsrc/common/vehicles/sv_vehicles.qc @@ -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; @@ -540,7 +540,7 @@ void vehicles_showwp() } if(oldself != world) - self = oldself; + setself(oldself); } void vehicles_setreturn(entity veh) @@ -844,7 +844,7 @@ void vehicles_exit(bool eject) if (_vehicle.vehicle_flags & VHF_PLAYERSLOT) { _vehicle.vehicle_exit(eject); - self = _oldself; + setself(_oldself); vehicles_exit_running = false; return; } @@ -854,7 +854,7 @@ void vehicles_exit(bool eject) _player = _vehicle.owner; - self = _vehicle; + setself(_vehicle); if (_player) { @@ -920,8 +920,7 @@ void vehicles_exit(bool eject) CSQCMODEL_AUTOINIT(self); - self = _oldself; - + setself(_oldself); vehicles_exit_running = false; } @@ -989,7 +988,7 @@ void vehicles_enter(entity pl, entity veh) if(veh.owner) { entity oldself = self; - self = veh; + setself(veh); other = pl; // TODO: fix if(!veh.gunner1) @@ -997,7 +996,7 @@ void vehicles_enter(entity pl, entity veh) if(veh.gun1.vehicle_enter) if(veh.gun1.vehicle_enter()) { - self = oldself; + setself(oldself); return; } @@ -1006,11 +1005,11 @@ void vehicles_enter(entity pl, entity veh) if(veh.gun2.vehicle_enter) if(veh.gun2.vehicle_enter()) { - self = oldself; + setself(oldself); return; } - self = oldself; + setself(oldself); } if(teamplay) @@ -1115,10 +1114,10 @@ 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(oldself); antilag_clear(pl); } diff --git a/qcsrc/common/vehicles/unit/bumblebee.qc b/qcsrc/common/vehicles/unit/bumblebee.qc index 0bb776b85..d88e3dfc0 100644 --- a/qcsrc/common/vehicles/unit/bumblebee.qc +++ b/qcsrc/common/vehicles/unit/bumblebee.qc @@ -115,7 +115,7 @@ float bumblebee_gunner_frame() 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; } @@ -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,7 +643,7 @@ 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; } @@ -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); diff --git a/qcsrc/common/vehicles/unit/racer.qc b/qcsrc/common/vehicles/unit/racer.qc index 1320d95b1..40dbfecb3 100644 --- a/qcsrc/common/vehicles/unit/racer.qc +++ b/qcsrc/common/vehicles/unit/racer.qc @@ -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,7 +545,7 @@ float racer_frame() setorigin(player,racer.origin + '0 0 32'); player.velocity = racer.velocity; - self = player; + setself(player); return 1; } diff --git a/qcsrc/common/vehicles/unit/raptor.qc b/qcsrc/common/vehicles/unit/raptor.qc index 14da2b320..263da161f 100644 --- a/qcsrc/common/vehicles/unit/raptor.qc +++ b/qcsrc/common/vehicles/unit/raptor.qc @@ -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,7 +642,7 @@ float raptor_frame() player.BUTTON_ATCK = player.BUTTON_ATCK2 = player.BUTTON_CROUCH = 0; - self = player; + setself(player); return 1; } @@ -652,7 +652,7 @@ float raptor_takeoff() player = self; raptor = self.vehicle; - self = raptor; + setself(raptor); self.nextthink = time; CSQCMODEL_AUTOUPDATE(self); @@ -698,7 +698,7 @@ 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; } diff --git a/qcsrc/common/vehicles/unit/spiderbot.qc b/qcsrc/common/vehicles/unit/spiderbot.qc index b08d1deac..7060b7815 100644 --- a/qcsrc/common/vehicles/unit/spiderbot.qc +++ b/qcsrc/common/vehicles/unit/spiderbot.qc @@ -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,7 +607,7 @@ float spiderbot_frame() if(self.vehicle_flags & VHF_HASSHIELD) VEHICLE_UPDATE_PLAYER(player, shield, spiderbot); - self = player; + setself(player); return 1; } diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index 6548f0879..52020901a 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -273,14 +273,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(oldself); remove(self); return; } @@ -593,10 +593,8 @@ 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; + SELFCALL(beam, beam.think()); + SELFCALL_DONE(); } void Arc_Smoke() diff --git a/qcsrc/common/weapons/weapon/blaster.qc b/qcsrc/common/weapons/weapon/blaster.qc index 9debcacc1..5c7fd8dfc 100644 --- a/qcsrc/common/weapons/weapon/blaster.qc +++ b/qcsrc/common/weapons/weapon/blaster.qc @@ -141,11 +141,8 @@ void W_Blaster_Attack( if(time >= missile.nextthink) { - entity oldself; - oldself = self; - self = missile; - self.think(); - self = oldself; + SELFCALL(missile, missile.think()); + SELFCALL_DONE(); } } bool W_Blaster(int request) diff --git a/qcsrc/common/weapons/weapon/minelayer.qc b/qcsrc/common/weapons/weapon/minelayer.qc index 0524a13b4..7d655615c 100644 --- a/qcsrc/common/weapons/weapon/minelayer.qc +++ b/qcsrc/common/weapons/weapon/minelayer.qc @@ -100,7 +100,7 @@ void W_MineLayer_Stick(entity to) newmine.flags = self.flags; remove(self); - self = newmine; + setself(newmine); if(to) SetMovetypeFollow(self, to); @@ -122,16 +122,14 @@ 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); @@ -149,16 +147,14 @@ 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); diff --git a/qcsrc/common/weapons/weapon/porto.qc b/qcsrc/common/weapons/weapon/porto.qc index 3903e087f..bb4795145 100644 --- a/qcsrc/common/weapons/weapon/porto.qc +++ b/qcsrc/common/weapons/weapon/porto.qc @@ -95,11 +95,8 @@ 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; + SELFCALL(p.porto_current, W_Porto_Fail(1)); + SELFCALL_DONE(); } } diff --git a/qcsrc/common/weapons/weapon/seeker.qc b/qcsrc/common/weapons/weapon/seeker.qc index 9708af05b..eaba831cc 100644 --- a/qcsrc/common/weapons/weapon/seeker.qc +++ b/qcsrc/common/weapons/weapon/seeker.qc @@ -426,7 +426,7 @@ 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; @@ -450,7 +450,7 @@ void W_Seeker_Vollycontroller_Think(void) // TODO: Merge this with W_Seeker_Atta } self.enemy = oldenemy; - self = oldself; + setself(oldself); } void W_Seeker_Tracker_Think(void) diff --git a/qcsrc/common/weapons/weapon/tuba.qc b/qcsrc/common/weapons/weapon/tuba.qc index 9baa0c615..05787ba58 100644 --- a/qcsrc/common/weapons/weapon/tuba.qc +++ b/qcsrc/common/weapons/weapon/tuba.qc @@ -336,10 +336,8 @@ 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; + SELFCALL(self.tuba_note, W_Tuba_NoteOff()); + SELFCALL_DONE(); } } @@ -406,10 +404,8 @@ bool W_Tuba(int req) { if(!self.BUTTON_ATCK && !self.BUTTON_ATCK2) { - entity oldself = self; - self = self.tuba_note; - W_Tuba_NoteOff(); - self = oldself; + SELFCALL(self.tuba_note, W_Tuba_NoteOff()); + SELFCALL_DONE(); } } diff --git a/qcsrc/csqcmodellib/cl_player.qc b/qcsrc/csqcmodellib/cl_player.qc index 945a27bff..da10d10ad 100644 --- a/qcsrc/csqcmodellib/cl_player.qc +++ b/qcsrc/csqcmodellib/cl_player.qc @@ -220,9 +220,8 @@ void CSQCPlayer_SetCamera() if(csqcplayer) { - entity oldself; - oldself = self; - self = csqcplayer; + entity oldself = self; + setself(csqcplayer); if(servercommandframe == 0 || clientcommandframe == 0) { @@ -299,7 +298,7 @@ void CSQCPlayer_SetCamera() // relink setorigin(self, self.origin); - self = oldself; + setself(oldself); } entity view; @@ -307,11 +306,9 @@ void CSQCPlayer_SetCamera() if(view && view != csqcplayer) { - entity oldself = self; - self = view; - InterpolateOrigin_Do(); + SELFCALL(view, InterpolateOrigin_Do()); self.view_ofs = '0 0 1' * getstati(STAT_VIEWHEIGHT); - self = oldself; + SELFCALL_DONE(); } if(view) diff --git a/qcsrc/server/anticheat.qc b/qcsrc/server/anticheat.qc index f795a1acb..370ef844e 100644 --- a/qcsrc/server/anticheat.qc +++ b/qcsrc/server/anticheat.qc @@ -234,11 +234,12 @@ void anticheat_fixangle() void anticheat_endframe() {SELFPARAM(); - entity oldself = self; - FOR_EACH_CLIENT(self) - if (self.fixangle) - anticheat_fixangle(); - self = oldself; + entity e; + FOR_EACH_CLIENT(e) + if (e.fixangle) { + SELFCALL(e, anticheat_fixangle()); + SELFCALL_DONE(); + } anticheat_div0_evade_evasion_delta += frametime * (0.5 + random()); } diff --git a/qcsrc/server/bot/bot.qc b/qcsrc/server/bot/bot.qc index 2a7081cdb..a6762c76d 100644 --- a/qcsrc/server/bot/bot.qc +++ b/qcsrc/server/bot/bot.qc @@ -39,17 +39,15 @@ entity bot_spawn() {SELFPARAM(); - entity oldself, bot; - bot = spawnclient(); + entity bot = spawnclient(); if (bot) { currentbots = currentbots + 1; - oldself = self; - self = bot; + setself(bot); bot_setnameandstuff(); ClientConnect(); PutClientInServer(); - self = oldself; + setself(this); } return bot; } diff --git a/qcsrc/server/cheats.qc b/qcsrc/server/cheats.qc index 62e968e89..9981749f0 100644 --- a/qcsrc/server/cheats.qc +++ b/qcsrc/server/cheats.qc @@ -373,10 +373,8 @@ 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; + SELFCALL(e, spawnfunc_func_breakable()); + SELFCALL_DONE(); // now, is it valid? if(f == 0) { @@ -698,29 +696,29 @@ float CheatCommand(float argc) case "usetarget": IS_CHEAT(0, argc, 0); e = self; - self = spawn(); + setself(spawn()); self.target = argv(1); activator = e; SUB_UseTargets(); remove(self); - self = e; + setself(e); DID_CHEAT(); break; case "killtarget": IS_CHEAT(0, argc, 0); e = self; - self = spawn(); + setself(spawn()); self.killtarget = argv(1); activator = e; SUB_UseTargets(); remove(self); - self = e; + setself(e); 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); @@ -729,11 +727,11 @@ float CheatCommand(float argc) { Simple_TeleportPlayer(self, e); remove(self); - self = e; + setself(e); DID_CHEAT(); } else - self = e; + setself(e); break; } diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 0cb1e4913..80d7aadce 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -432,7 +432,7 @@ void PutClientInServer() if(IS_PLAYER(self)) { - entity spot, oldself; + entity spot; accuracy_resend(self); @@ -628,16 +628,13 @@ void PutClientInServer() 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; + SELFCALL(spot, SUB_UseTargets()); + SELFCALL_DONE(); + activator = world; + spot.target = s; Unfreeze(self); @@ -734,17 +731,13 @@ void ClientInit_CheckUpdate() void ClientInit_Spawn() {SELFPARAM(); - entity o; - entity e; - e = spawn(); + 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; + SELFCALL(e, ClientInit_CheckUpdate()); + SELFCALL_DONE(); } /* @@ -854,7 +847,7 @@ void KillIndicator_Think() if(self.cnt <= 0) { - self = self.owner; + setself(self.owner); ClientKill_Now(); // no oldself needed return; } @@ -1268,10 +1261,8 @@ 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; + SELFCALL(e, e.init_for_player(this)); + SELFCALL_DONE(); } MUTATOR_CALLHOOK(ClientConnect, self); @@ -2626,15 +2617,15 @@ void PlayerPreThink (void) { self.teamkill_soundtime = 0; - entity oldpusher, oldself; - - oldself = self; self = self.teamkill_soundsource; - oldpusher = self.pusher; self.pusher = oldself; + entity oldself = self; + setself(self.teamkill_soundsource); + entity oldpusher = self.pusher; + self.pusher = oldself; PlayerSound(playersound_teamshoot, CH_VOICE, VOICETYPE_LASTATTACKER_ONLY); self.pusher = oldpusher; - self = oldself; + setself(oldself); } if(self.taunt_soundtime) diff --git a/qcsrc/server/cl_player.qc b/qcsrc/server/cl_player.qc index 6f7c8c2ba..4c35cbbe0 100644 --- a/qcsrc/server/cl_player.qc +++ b/qcsrc/server/cl_player.qc @@ -44,7 +44,7 @@ void CopyBody(float keepvelocity) if (self.effects & EF_NODRAW) return; oldself = self; - self = spawn(); + setself(spawn()); self.enemy = oldself; self.lip = oldself.lip; self.colormap = oldself.colormap; @@ -114,7 +114,7 @@ void CopyBody(float keepvelocity) animdecide_load_if_needed(self); animdecide_setframes(self, false, frame, frame1time, frame2, frame2time); - self = oldself; + setself(oldself); } float player_getspecies() diff --git a/qcsrc/server/command/sv_cmd.qc b/qcsrc/server/command/sv_cmd.qc index 136977ddc..6c3d4c669 100644 --- a/qcsrc/server/command/sv_cmd.qc +++ b/qcsrc/server/command/sv_cmd.qc @@ -207,10 +207,10 @@ 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; + SELFCALL(client, PutObserverInServer()); + SELFCALL_DONE(); ++i; } if(i) { bprint(strcat("Successfully forced all (", ftos(i), ") players to spectate", (reason ? strcat(" for reason: '", reason, "'") : ""), ".\n")); } @@ -240,8 +240,8 @@ void GameCommand_anticheat(float request, float argc) if(accepted > 0) { - self = client; - anticheat_report(); + SELFCALL(client, anticheat_report()); + SELFCALL_DONE(); return; } else @@ -1039,10 +1039,10 @@ 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; + SELFCALL(client, PutObserverInServer()); + SELFCALL_DONE(); successful = strcat(successful, (successful ? ", " : ""), client.netname); } @@ -1194,8 +1194,8 @@ void GameCommand_playerdemo(float request, float argc) return; } - self = client; - playerdemo_open_read(argv(next_token)); + SELFCALL(client, playerdemo_open_read(argv(next_token))); + SELFCALL_DONE(); return; } @@ -1210,8 +1210,8 @@ void GameCommand_playerdemo(float request, float argc) return; } - self = client; - playerdemo_open_write(argv(next_token)); + SELFCALL(client, playerdemo_open_write(argv(next_token))); + SELFCALL_DONE(); return; } @@ -1409,7 +1409,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); diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index 4d6c6ae8e..bd0b08657 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -349,51 +349,60 @@ void VoteThink() // Resets the state of all clients, items, weapons, waypoints, ... of the map. void reset_map(float dorespawn) {SELFPARAM(); - entity oldself; - oldself = self; 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) + { + SELFCALL(e, Unfreeze(self)); + SELFCALL_DONE(); + } // 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,7 +427,7 @@ 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) diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index 433167680..93005391f 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -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; @@ -584,11 +576,8 @@ 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; + SELFCALL(ice, Ice_Think()); + SELFCALL_DONE(); RemoveGrapplingHook(targ); @@ -635,9 +624,8 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d if (gameover || targ.killcount == -666) return; - entity oldself; - oldself = self; - self = targ; + entity oldself = self; + setself(targ); damage_targ = targ; damage_inflictor = inflictor; damage_attacker = attacker; @@ -655,7 +643,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(oldself); return; } } @@ -776,7 +764,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 +794,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(oldself); } if(!g_instagib) @@ -923,7 +911,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(oldself); // apply mirror damage if any if(mirrordamage > 0 || mirrorforce > 0) diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 3233f241a..4f3356b65 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -531,11 +531,8 @@ void 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; + SELFCALL(randomseed, randomseed.think()); // sets random seed and nextthink + SELFCALL_DONE(); } void spawnfunc___init_dedicated_server(void) @@ -1727,11 +1724,8 @@ float WinningCondition_Assault() } else { - entity oldself; - oldself = self; - self = ent; - assault_new_round(); - self = oldself; + SELFCALL(ent, assault_new_round()); + SELFCALL_DONE(); } } } @@ -2206,15 +2200,16 @@ void EndFrame() 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 +2218,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); } @@ -2263,8 +2262,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") diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 1ed405b34..2b1f42f0f 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -1178,47 +1178,45 @@ void InitializeEntitiesRun() startoflist = initialize_entity_first; initialize_entity_first = world; 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") + setself(e_); + entity e = e_.initialize_entity_next; + var void(void) func = e_.initialize_entity; + e_.initialize_entity_order = 0; + e_.initialize_entity = func_null; + e_.initialize_entity_next = world; + e_.remove_except_protected_forbidden = 0; + if (e_.classname == "initialize_entity") { - entity e_old; - e_old = self.enemy; - builtin_remove(self); - self = e_old; + entity e_old = e_.enemy; + builtin_remove(e_); + e_ = e_old; } - //dprint("Delayed initialization: ", self.classname, "\n"); + //dprint("Delayed initialization: ", e_.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_ = e; } remove = remove_unsafely; } void UncustomizeEntitiesRun() {SELFPARAM(); - entity oldself; - oldself = self; - for (self = world; (self = findfloat(self, uncustomizeentityforclient_set, 1)); ) - self.uncustomizeentityforclient(); - self = oldself; + for (entity e = world; (e = findfloat(e, uncustomizeentityforclient_set, 1)); ) + { + SELFCALL(e, e.uncustomizeentityforclient()); + SELFCALL_DONE(); + } } void SetCustomizer(entity e, float(void) customizer, void(void) uncustomizer) { diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index 44f926fa5..881938f06 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -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) \ diff --git a/qcsrc/server/mutators/gamemode_assault.qc b/qcsrc/server/mutators/gamemode_assault.qc index 8915b89bc..163e42360 100644 --- a/qcsrc/server/mutators/gamemode_assault.qc +++ b/qcsrc/server/mutators/gamemode_assault.qc @@ -13,16 +13,16 @@ void assault_objective_use() //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") + { + SELFCALL(e, target_objective_decrease_activate()); + SELFCALL_DONE(); + } } - self = oldself; + setself(this); } vector target_objective_spawn_evalfunc(entity player, entity spot, vector current) @@ -73,7 +73,7 @@ void assault_objective_decrease_use() entity oldself, oldactivator, head; oldself = self; - self = oldself.enemy; + setself(oldself.enemy); if(self.message) FOR_EACH_PLAYER(head) centerprint(head, self.message); @@ -82,7 +82,7 @@ void assault_objective_decrease_use() activator = oldself; SUB_UseTargets(); activator = oldactivator; - self = oldself; + setself(oldself); } } } @@ -170,26 +170,18 @@ void assault_roundstart_use() 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"); + SELFCALL(ent, turret_respawn()); + SELFCALL_DONE(); } - self = oldself; } void assault_wall_think() @@ -214,26 +206,27 @@ void vehicles_clearreturn(entity veh); void vehicles_spawn(); void assault_new_round() {SELFPARAM(); - entity oldself; //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) + { + SELFCALL(e, vehicles_exit(VHEF_RELEASE)); + SELFCALL_DONE(); + } } - 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; diff --git a/qcsrc/server/mutators/gamemode_ca.qc b/qcsrc/server/mutators/gamemode_ca.qc index 204c4f8ca..570fc3801 100644 --- a/qcsrc/server/mutators/gamemode_ca.qc +++ b/qcsrc/server/mutators/gamemode_ca.qc @@ -189,8 +189,10 @@ MUTATOR_HOOKFUNCTION(ca_PutClientInServer) MUTATOR_HOOKFUNCTION(ca_reset_map_players) {SELFPARAM(); - FOR_EACH_CLIENT(self) + entity e; + FOR_EACH_CLIENT(e) { + setself(e); self.killcount = 0; if(!self.caplayer && IS_BOT_CLIENT(self)) { diff --git a/qcsrc/server/mutators/gamemode_ctf.qc b/qcsrc/server/mutators/gamemode_ctf.qc index 55262c7ef..28775ea01 100644 --- a/qcsrc/server/mutators/gamemode_ctf.qc +++ b/qcsrc/server/mutators/gamemode_ctf.qc @@ -847,10 +847,10 @@ void ctf_FlagThink() 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(tmp_entity); } if(autocvar_g_ctf_stalemate) { @@ -1093,7 +1093,7 @@ void ctf_FlagSetup(int teamnumber, entity flag) // called when spawning a flag e {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 +1197,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; } @@ -2382,16 +2382,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) {SELFPARAM(); - entity oldself; - oldself = self; - self = spawn(); + entity oldself = self; + setself(spawn()); self.classname = "ctf_team"; self.netname = teamname; self.cnt = teamcolor; spawnfunc_ctf_team(); - self = oldself; + setself(oldself); } void ctf_DelayedInit() // Do this check with a delay so we can wait for teams to be set up. diff --git a/qcsrc/server/mutators/gamemode_domination.qc b/qcsrc/server/mutators/gamemode_domination.qc index aa49e8388..21179e912 100644 --- a/qcsrc/server/mutators/gamemode_domination.qc +++ b/qcsrc/server/mutators/gamemode_domination.qc @@ -410,8 +410,10 @@ 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)) @@ -542,9 +544,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) {SELFPARAM(); - entity oldself; - oldself = self; - self = spawn(); + entity oldself = self; + setself(spawn()); self.classname = "dom_team"; self.netname = teamname; self.cnt = teamcolor; @@ -564,20 +565,19 @@ void dom_spawnteam (string teamname, float teamcolor, string pointmodel, float p self.team = self.cnt + 1; //eprint(self); - self = oldself; + setself(oldself); } void dom_spawnpoint(vector org) {SELFPARAM(); - entity oldself; - oldself = self; - self = spawn(); + entity oldself = self; + setself(spawn()); self.classname = "dom_controlpoint"; self.think = spawnfunc_dom_controlpoint; self.nextthink = time; setorigin(self, org); spawnfunc_dom_controlpoint(); - self = oldself; + setself(oldself); } // spawn some default teams if the map is not set up for domination diff --git a/qcsrc/server/mutators/gamemode_freezetag.qc b/qcsrc/server/mutators/gamemode_freezetag.qc index 27c5e9cc0..e7790c974 100644 --- a/qcsrc/server/mutators/gamemode_freezetag.qc +++ b/qcsrc/server/mutators/gamemode_freezetag.qc @@ -407,12 +407,14 @@ MUTATOR_HOOKFUNCTION(freezetag_PlayerSpawn) MUTATOR_HOOKFUNCTION(freezetag_reset_map_players) {SELFPARAM(); - FOR_EACH_PLAYER(self) + 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; diff --git a/qcsrc/server/mutators/gamemode_lms.qc b/qcsrc/server/mutators/gamemode_lms.qc index 0db687f80..9c6033e9a 100644 --- a/qcsrc/server/mutators/gamemode_lms.qc +++ b/qcsrc/server/mutators/gamemode_lms.qc @@ -36,10 +36,14 @@ 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)) + { + SELFCALL(e, PlayerScore_Add(e, SP_LMS_LIVES, LMS_NewPlayerLives())); + SELFCALL_DONE(); + } return false; } diff --git a/qcsrc/server/mutators/gamemode_nexball.qc b/qcsrc/server/mutators/gamemode_nexball.qc index 2194922ab..5b1169913 100644 --- a/qcsrc/server/mutators/gamemode_nexball.qc +++ b/qcsrc/server/mutators/gamemode_nexball.qc @@ -67,10 +67,10 @@ void nexball_setstatus(void) { 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(oldself); } else self.items |= IT_KEY1; @@ -154,14 +154,14 @@ void GiveBall(entity plyr, entity ball) } ownr = self; - self = plyr; + setself(plyr); self.weaponentity.weapons = self.weapons; self.weaponentity.switchweapon = self.weapon; self.weapons = WEPSET_PORTO; WEP_ACTION(WEP_PORTO.m_id, WR_RESETPLAYER); self.switchweapon = WEP_PORTO.m_id; W_SwitchWeapon(WEP_PORTO.m_id); - self = ownr; + setself(ownr); } void DropBall(entity ball, vector org, vector vel) diff --git a/qcsrc/server/mutators/gamemode_onslaught.qc b/qcsrc/server/mutators/gamemode_onslaught.qc index d96c143f7..c069dc153 100644 --- a/qcsrc/server/mutators/gamemode_onslaught.qc +++ b/qcsrc/server/mutators/gamemode_onslaught.qc @@ -405,10 +405,10 @@ void ons_ControlPoint_Icon_Damage(entity inflictor, entity attacker, float damag // 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(oself); self.owner.waslinked = self.owner.islinked; if(self.owner.model != "models/onslaught/controlpoint_pad.md3") @@ -479,10 +479,10 @@ void ons_ControlPoint_Icon_Think() self.owner.team = 0; oself = self; - self = self.owner; + setself(self.owner); activator = self; SUB_UseTargets (); - self = oself; + setself(oself); self.owner.team = t; @@ -546,10 +546,10 @@ void ons_ControlPoint_Icon_BuildThink() // 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(oself); self.SendFlags |= CPSF_SETUP; } @@ -737,7 +737,7 @@ void ons_DelayedControlPoint_Setup(void) 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 +790,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; } @@ -1002,7 +1002,7 @@ void ons_GeneratorSetup(entity gen) // called when spawning a generator entity o {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 +1046,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 @@ -1703,11 +1703,13 @@ bool ons_Teleport(entity player, entity tele_target, float range, bool tele_effe MUTATOR_HOOKFUNCTION(ons_ResetMap) {SELFPARAM(); - FOR_EACH_PLAYER(self) + 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'; + SELFCALL(e, PutClientInServer()); + SELFCALL_DONE(); } return false; } diff --git a/qcsrc/server/mutators/gamemode_tdm.qc b/qcsrc/server/mutators/gamemode_tdm.qc index e9a95c1f8..996857db5 100644 --- a/qcsrc/server/mutators/gamemode_tdm.qc +++ b/qcsrc/server/mutators/gamemode_tdm.qc @@ -19,16 +19,14 @@ 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) {SELFPARAM(); - entity oldself; - oldself = self; - self = spawn(); + setself(spawn()); self.classname = "tdm_team"; self.netname = teamname; self.cnt = teamcolor; spawnfunc_tdm_team(); - self = oldself; + setself(this); } void tdm_DelayedInit() diff --git a/qcsrc/server/mutators/mutator_buffs.qc b/qcsrc/server/mutators/mutator_buffs.qc index 365c43ab4..62e4d9f53 100644 --- a/qcsrc/server/mutators/mutator_buffs.qc +++ b/qcsrc/server/mutators/mutator_buffs.qc @@ -337,8 +337,7 @@ void buff_Init(entity ent) 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) @@ -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); } } diff --git a/qcsrc/server/mutators/mutator_instagib.qc b/qcsrc/server/mutators/mutator_instagib.qc index c4ddfa12b..30810c82e 100644 --- a/qcsrc/server/mutators/mutator_instagib.qc +++ b/qcsrc/server/mutators/mutator_instagib.qc @@ -337,11 +337,8 @@ MUTATOR_HOOKFUNCTION(instagib_FilterItem) { entity e = spawn(); setorigin(e, self.origin); - entity oldself; - oldself = self; - self = e; - spawnfunc_item_minst_cells(); - self = oldself; + SELFCALL(e, spawnfunc_item_minst_cells()); + SELFCALL_DONE(); return true; } diff --git a/qcsrc/server/mutators/mutator_overkill.qc b/qcsrc/server/mutators/mutator_overkill.qc index 5410d6cd0..364fa01c4 100644 --- a/qcsrc/server/mutators/mutator_overkill.qc +++ b/qcsrc/server/mutators/mutator_overkill.qc @@ -81,7 +81,7 @@ MUTATOR_HOOKFUNCTION(ok_PlayerDies) other = world; } - self = spawn(); + setself(spawn()); self.ok_item = true; self.noalign = true; self.pickup_anyway = true; @@ -93,7 +93,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(oldself); self.ok_lastwep = self.switchweapon; diff --git a/qcsrc/server/mutators/mutator_superspec.qc b/qcsrc/server/mutators/mutator_superspec.qc index ea66e7da1..1bb5872a0 100644 --- a/qcsrc/server/mutators/mutator_superspec.qc +++ b/qcsrc/server/mutators/mutator_superspec.qc @@ -103,8 +103,10 @@ MUTATOR_HOOKFUNCTION(superspec_ItemTouch) entity _oldself = self; 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 +118,7 @@ MUTATOR_HOOKFUNCTION(superspec_ItemTouch) { _spectate(other); - self = _oldself; + setself(_oldself); return MUT_ITEMTOUCH_CONTINUE; } } @@ -146,7 +148,7 @@ MUTATOR_HOOKFUNCTION(superspec_ItemTouch) } } - self = _oldself; + setself(_oldself); return MUT_ITEMTOUCH_CONTINUE; } @@ -488,11 +490,11 @@ MUTATOR_HOOKFUNCTION(superspec_ClientConnect) MUTATOR_HOOKFUNCTION(superspec_PlayerDies) {SELFPARAM(); - entity _old_self = self; - - FOR_EACH_SPEC(self) + 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); @@ -501,7 +503,7 @@ MUTATOR_HOOKFUNCTION(superspec_PlayerDies) } } - self = _old_self; + setself(this); return false; } diff --git a/qcsrc/server/mutators/sandbox.qc b/qcsrc/server/mutators/sandbox.qc index a5d925d10..430271d80 100644 --- a/qcsrc/server/mutators/sandbox.qc +++ b/qcsrc/server/mutators/sandbox.qc @@ -143,8 +143,7 @@ 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,8 @@ entity sandbox_ObjectSpawn(float database) e.angles_y = self.v_angle.y; } - oldself = self; - self = e; - CSQCMODEL_AUTOINIT(self); - self = oldself; + SELFCALL(e, CSQCMODEL_AUTOINIT(e)); + SELFCALL_DONE(); object_count += 1; return e; diff --git a/qcsrc/server/race.qc b/qcsrc/server/race.qc index e32f8b03f..111303e8b 100644 --- a/qcsrc/server/race.qc +++ b/qcsrc/server/race.qc @@ -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; } @@ -747,7 +747,7 @@ void trigger_race_checkpoint_verify() qual = g_race_qualifying; oldself = self; - self = spawn(); + setself(spawn()); self.classname = "player"; if(g_race) @@ -895,7 +895,7 @@ void trigger_race_checkpoint_verify() } } remove(self); - self = oldself; + setself(oldself); } vector trigger_race_checkpoint_spawn_evalfunc(entity player, entity spot, vector current) @@ -1075,7 +1075,6 @@ void spawnfunc_info_player_race (void) void race_ClearRecords() {SELFPARAM(); float i; - entity e; for(i = 0; i < MAX_CHECKPOINTS; ++i) { @@ -1085,15 +1084,14 @@ 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; + SELFCALL(e, race_PreparePlayer()); + SELFCALL_DONE(); + e.race_place = p; } - self = e; } void race_ImposePenaltyTime(entity pl, float penalty, string reason) diff --git a/qcsrc/server/spawnpoints.qc b/qcsrc/server/spawnpoints.qc index 928be465d..177e4bc98 100644 --- a/qcsrc/server/spawnpoints.qc +++ b/qcsrc/server/spawnpoints.qc @@ -258,10 +258,8 @@ 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; + spawn_score = SELFCALL(ent, ent.spawn_evalfunc(this, spot, spawn_score)); + SELFCALL_DONE(); if(spawn_score.x < 0) return spawn_score; } diff --git a/qcsrc/server/sv_main.qc b/qcsrc/server/sv_main.qc index bfcf7ca3c..948e2d374 100644 --- a/qcsrc/server/sv_main.qc +++ b/qcsrc/server/sv_main.qc @@ -29,12 +29,11 @@ void CreatureFrame (void) {SELFPARAM(); - entity oldself; 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); } @@ -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(); diff --git a/qcsrc/server/t_items.qc b/qcsrc/server/t_items.qc index 49f0b1054..fc131e5b2 100644 --- a/qcsrc/server/t_items.qc +++ b/qcsrc/server/t_items.qc @@ -479,14 +479,14 @@ void Item_RespawnCountdown (void) { entity e; entity it = self; - self = self.waypointsprite_attached; + setself(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 } - self = it; + setself(it); WaypointSprite_Ping(self.waypointsprite_attached); //WaypointSprite_UpdateHealth(self.waypointsprite_attached, self.count); diff --git a/qcsrc/server/weapons/common.qc b/qcsrc/server/weapons/common.qc index f841fecf6..db712933d 100644 --- a/qcsrc/server/weapons/common.qc +++ b/qcsrc/server/weapons/common.qc @@ -10,20 +10,18 @@ void W_GiveWeapon (entity e, float wep) {SELFPARAM(); - entity oldself; 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 diff --git a/qcsrc/server/weapons/selection.qc b/qcsrc/server/weapons/selection.qc index f7fc6f9dc..83323f4bf 100644 --- a/qcsrc/server/weapons/selection.qc +++ b/qcsrc/server/weapons/selection.qc @@ -48,7 +48,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 +58,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(oldself); } if (!f) { diff --git a/qcsrc/server/weapons/spawning.qc b/qcsrc/server/weapons/spawning.qc index 73ce1de78..57302ee7f 100644 --- a/qcsrc/server/weapons/spawning.qc +++ b/qcsrc/server/weapons/spawning.qc @@ -76,7 +76,7 @@ void weapon_defaultspawnfunc(float wpn) e = get_weaponinfo(j); if(e.netname == s) { - self = spawn(); + setself(spawn()); copyentity(oldself, self); self.classname = "replacedweapon"; weapon_defaultspawnfunc(j); @@ -88,7 +88,7 @@ void weapon_defaultspawnfunc(float wpn) LOG_INFO("The weapon replace list for ", oldself.classname, " contains an unknown weapon ", s, ". Skipped.\n"); } } - self = oldself; + setself(oldself); } if(t >= 1) // always the case! { diff --git a/qcsrc/server/weapons/throwing.qc b/qcsrc/server/weapons/throwing.qc index 5c3b11dd3..25f464914 100644 --- a/qcsrc/server/weapons/throwing.qc +++ b/qcsrc/server/weapons/throwing.qc @@ -31,12 +31,11 @@ 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) {SELFPARAM(); - entity oldself, wep; 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,8 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto } } - oldself = self; - self = wep; - weapon_defaultspawnfunc(wpn); - self = oldself; + SELFCALL(wep, weapon_defaultspawnfunc(wpn)); + SELFCALL_DONE(); if(startitem_failed) return string_null; wep.glowmod = own.weaponentity_glowmod; diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index 8be3a668f..b725cbd19 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -270,16 +270,13 @@ void CL_WeaponEntity_SetModel(string name) vector CL_Weapon_GetShotOrg(float wpn) {SELFPARAM(); - entity wi, oldself; - vector ret; - wi = get_weaponinfo(wpn); - oldself = self; - self = spawn(); + 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; } @@ -972,9 +969,8 @@ void W_Reload(float sent_ammo_min, string sent_sound) void W_DropEvent(float event, entity player, float weapon_type, entity weapon_item) {SELFPARAM(); - entity oldself = self; - self = player; + setself(player); weapon_dropevent_item = weapon_item; WEP_ACTION(weapon_type, event); - self = oldself; + setself(this); } diff --git a/qcsrc/warpzonelib/server.qc b/qcsrc/warpzonelib/server.qc index 8d5a6b68a..ba17091ac 100644 --- a/qcsrc/warpzonelib/server.qc +++ b/qcsrc/warpzonelib/server.qc @@ -206,13 +206,13 @@ void WarpZone_Touch (void) 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(oldself); } else { @@ -758,17 +758,15 @@ void spawnfunc_func_camera(void) } void WarpZones_Reconnect() {SELFPARAM(); - entity e; - e = self; - for(self = warpzone_first; self; self = self.warpzone_next) + 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() @@ -781,13 +779,13 @@ void WarpZone_Think() entity oldself; oldself = self; WarpZone_InitStep_UpdateTransform(); - self = self.enemy; + setself(self.enemy); WarpZone_InitStep_UpdateTransform(); - self = oldself; + setself(oldself); WarpZone_InitStep_FinalizeTransform(); - self = self.enemy; + setself(self.enemy); WarpZone_InitStep_FinalizeTransform(); - self = oldself; + setself(oldself); self.warpzone_save_origin = self.origin; self.warpzone_save_angles = self.angles; self.warpzone_save_eorigin = self.enemy.origin; @@ -802,14 +800,13 @@ void WarpZone_StartFrame() 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(); } @@ -830,14 +827,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 +849,7 @@ void WarpZone_StartFrame() break; } } - self = oldself; + setself(oldself); other = oldother; } @@ -872,23 +869,23 @@ void trigger_warpzone_reconnect_use() 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() -- 2.39.2