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;
if(self.isplayermodel)
hitplayer = true; // this impact damaged a player
}
-
- self = oldself;
+ setself(oldself);
if(DEATH_ISVEHICLE(w_deathtype))
{
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;
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);
{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)
break;
// delete this oldest one and search again
- self = oldest;
- deleteproc();
- self = oldself;
+ SELFCALL(oldest, deleteproc());
+ SELFCALL_DONE();
}
}
int disownedcnt = 0;
for(i = WEP_FIRST; i <= WEP_LAST; ++i)
{
- self = get_weaponinfo(i);
+ setself(get_weaponinfo(i));
if(!self.weapon)
continue;
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];
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();
} 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();
{SELFPARAM();
if ( menuitem )
{
- entity e = self;
- self = menuitem;
- menuitem.use();
- self = e;
+ SELFCALL(menuitem, menuitem.use());
+ SELFCALL_DONE();
}
}
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;
}
// 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;
}
if(e && e.monster_loot)
{
- self = e;
+ setself(e);
e.noalign = true;
e.monster_loot();
e.gravity = 1;
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);
}
}
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)
void _Movetype_Impact(entity oth) // SV_Impact
{SELFPARAM();
- entity oldself = self;
entity oldother = other;
if(self.move_touch)
if(oth.move_touch)
{
other = self;
- self = oth;
- self.move_touch();
+ SELFCALL(oth, oth.move_touch());
+ SELFCALL_DONE();
- self = oldself;
other = oldother;
}
}
{
if(e.move_touch && boxesoverlap(e.absmin, e.absmax, oldself.absmin, oldself.absmax))
{
- self = e;
+ setself(e);
other = oldself;
trace_allsolid = false;
}
other = oldother;
- self = oldself;
+ setself(oldself);
}
void _Movetype_LinkEdict(bool touch_triggers) // SV_LinkEdict
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;
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);
}
{
door_rotating_go_down ();
}
- self = self.enemy;
+ setself(self.enemy);
} while ( (self != starte) && (self != world) );
- self = oself;
+ setself(oself);
return;
}
}
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;
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();
}
}
activator = other;
- self = self.owner;
+ setself(self.owner);
door_use ();
}
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
void misc_laser_think()
{SELFPARAM();
vector o;
- entity oldself;
entity hitent;
vector hitloc;
{
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
{
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();
}
}
}
return;
#endif
- self = self.enemy;
+ setself(self.enemy);
if (self.state == 2)
plat_go_up ();
else if (self.state == 1)
return;
#endif
- self = self.enemy;
+ setself(self.enemy);
if (self.state == 1)
plat_go_down ();
}
// 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();
}
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)
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();
}
/*
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();
}
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
}
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
string key, value, valuefield, valueoffset, valueoffsetrandom;
entity valueent;
vector data, data2;
- entity oldself;
entity oldactivator;
n = tokenize_console(msg);
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.
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)
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)
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;
}
{SELFPARAM();
float domatch, dotrigger, matchstart, l;
string s, msg;
- entity oldself;
string savemessage;
magicear_matched = false;
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 != "")
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)
#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()
void Teleport_Touch (void)
{SELFPARAM();
- entity oldself;
string s;
if (self.active != ACTIVE_ACTIVE)
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()
{
if (t.classname == "func_clientwall" || t.classname == "func_clientillusionary")
t.antiwall_flag = aw_flag;
- self = t;
+ setself(t);
other = stemp;
activator = act;
self.use();
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;
}
entity oldself;
oldself = self;
- self = t_turret;
+ setself(t_turret);
enemy_pos = real_origin(self.enemy);
self.tur_impactent = trace_ent;
self.tur_impacttime = vlen(self.tur_shotorg - trace_endpos) / self.shot_speed;
- self = oldself;
+ setself(oldself);
}
/**
{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);
}
oldself.cnt = time + 0.5;
- self = oldself;
+ setself(this);
}
/*QUAKED turret_targettrigger (.5 .5 .5) ?
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,
oldself.shot_dmg,
0.75,
DEATH_TURRET_PHASER);
- self = oldself;
+ setself(oldself);
self.scale = vlen(self.owner.tur_shotorg - trace_endpos) / 256;
}
// 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)
// 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)
self.nextthink = time +1;
oldself = self;
- self = spawn();
+ setself(spawn());
setmodel(self, "null");
self.team = oldself.wp00.team;
self.wp00 = oldself.wp00;
}
if(oldself != world)
- self = oldself;
+ setself(oldself);
}
void vehicles_setreturn(entity veh)
if (_vehicle.vehicle_flags & VHF_PLAYERSLOT)
{
_vehicle.vehicle_exit(eject);
- self = _oldself;
+ setself(_oldself);
vehicles_exit_running = false;
return;
}
_player = _vehicle.owner;
- self = _vehicle;
+ setself(_vehicle);
if (_player)
{
CSQCMODEL_AUTOINIT(self);
- self = _oldself;
-
+ setself(_oldself);
vehicles_exit_running = false;
}
if(veh.owner)
{
entity oldself = self;
- self = veh;
+ setself(veh);
other = pl; // TODO: fix
if(!veh.gunner1)
if(veh.gun1.vehicle_enter)
if(veh.gun1.vehicle_enter())
{
- self = oldself;
+ setself(oldself);
return;
}
if(veh.gun2.vehicle_enter)
if(veh.gun2.vehicle_enter())
{
- self = oldself;
+ setself(oldself);
return;
}
- self = oldself;
+ setself(oldself);
}
if(teamplay)
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);
}
entity vehic = self.vehicle.owner;
entity gun = self.vehicle;
entity gunner = self;
- self = vehic;
+ setself(vehic);
vehic.solid = SOLID_NOT;
//setorigin(gunner, vehic.origin);
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;
}
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;
}
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;
}
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;
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;
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);
player = self;
racer = self.vehicle;
- self = racer;
+ setself(racer);
vehicles_painframe();
if(racer.deadflag != DEAD_NO)
{
- self = player;
+ setself(player);
player.BUTTON_ATCK = player.BUTTON_ATCK2 = 0;
return 1;
}
setorigin(player,racer.origin + '0 0 32');
player.velocity = racer.velocity;
- self = player;
+ setself(player);
return 1;
}
player = self;
raptor = self.vehicle;
- self = raptor;
+ setself(raptor);
vehicles_painframe();
/*
if(raptor.deadflag != DEAD_NO)
{
- self = player;
+ setself(player);
player.BUTTON_ATCK = player.BUTTON_ATCK2 = 0;
return 1;
}
player.BUTTON_ATCK = player.BUTTON_ATCK2 = player.BUTTON_CROUCH = 0;
- self = player;
+ setself(player);
return 1;
}
player = self;
raptor = self.vehicle;
- self = raptor;
+ setself(raptor);
self.nextthink = time;
CSQCMODEL_AUTOUPDATE(self);
VEHICLE_UPDATE_PLAYER(player, shield, raptor);
player.BUTTON_ATCK = player.BUTTON_ATCK2 = player.BUTTON_CROUCH = 0;
- self = player;
+ setself(player);
return 1;
}
player = self;
spider = self.vehicle;
- self = spider;
+ setself(spider);
vehicles_painframe();
vector v;
spider.misc_bulletcounter += 1;
- self = player;
+ setself(player);
gun = (spider.misc_bulletcounter % 2) ? spider.gun1 : spider.gun2;
//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;
if(self.vehicle_flags & VHF_HASSHIELD)
VEHICLE_UPDATE_PLAYER(player, shield, spiderbot);
- self = player;
+ setself(player);
return 1;
}
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;
}
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()
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)
newmine.flags = self.flags;
remove(self);
- self = newmine;
+ setself(newmine);
if(to)
SetMovetypeFollow(self, to);
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);
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);
{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();
}
}
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 = oldenemy;
- self = oldself;
+ setself(oldself);
}
void W_Seeker_Tracker_Think(void)
{
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();
}
}
{
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();
}
}
if(csqcplayer)
{
- entity oldself;
- oldself = self;
- self = csqcplayer;
+ entity oldself = self;
+ setself(csqcplayer);
if(servercommandframe == 0 || clientcommandframe == 0)
{
// relink
setorigin(self, self.origin);
- self = oldself;
+ setself(oldself);
}
entity view;
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)
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());
}
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;
}
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)
{
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);
{
Simple_TeleportPlayer(self, e);
remove(self);
- self = e;
+ setself(e);
DID_CHEAT();
}
else
- self = e;
+ setself(e);
break;
}
if(IS_PLAYER(self))
{
- entity spot, oldself;
+ entity spot;
accuracy_resend(self);
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);
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();
}
/*
if(self.cnt <= 0)
{
- self = self.owner;
+ setself(self.owner);
ClientKill_Now(); // no oldself needed
return;
}
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);
{
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)
if (self.effects & EF_NODRAW)
return;
oldself = self;
- self = spawn();
+ setself(spawn());
self.enemy = oldself;
self.lip = oldself.lip;
self.colormap = oldself.colormap;
animdecide_load_if_needed(self);
animdecide_setframes(self, false, frame, frame1time, frame2, frame2time);
- self = oldself;
+ setself(oldself);
}
float player_getspecies()
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")); }
if(accepted > 0)
{
- self = client;
- anticheat_report();
+ SELFCALL(client, anticheat_report());
+ SELFCALL_DONE();
return;
}
else
{
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);
}
return;
}
- self = client;
- playerdemo_open_read(argv(next_token));
+ SELFCALL(client, playerdemo_open_read(argv(next_token)));
+ SELFCALL_DONE();
return;
}
return;
}
- self = client;
- playerdemo_open_write(argv(next_token));
+ SELFCALL(client, playerdemo_open_write(argv(next_token)));
+ SELFCALL_DONE();
return;
}
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);
// 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
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)
}
// 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;
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);
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;
if(IS_PLAYER(targ))
if(SAME_TEAM(targ, attacker))
{
- self = oldself;
+ setself(oldself);
return;
}
}
Send_Effect(EFFECT_TELEPORT, targ.origin, '0 0 0', 1);
entity oldself = self;
- self = targ;
+ setself(targ);
entity spot = SelectSpawnPoint (false);
if(spot)
Send_Effect(EFFECT_TELEPORT, self.origin, '0 0 0', 1);
}
- self = oldself;
+ setself(oldself);
}
if(!g_instagib)
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)
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)
}
else
{
- entity oldself;
- oldself = self;
- self = ent;
- assault_new_round();
- self = oldself;
+ SELFCALL(ent, assault_new_round());
+ SELFCALL_DONE();
}
}
}
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);
// 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);
}
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")
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)
{
/** 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) \
//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)
entity oldself, oldactivator, head;
oldself = self;
- self = oldself.enemy;
+ setself(oldself.enemy);
if(self.message)
FOR_EACH_PLAYER(head)
centerprint(head, self.message);
activator = oldself;
SUB_UseTargets();
activator = oldactivator;
- self = oldself;
+ setself(oldself);
}
}
}
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()
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;
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))
{
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)
{
{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
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;
}
// 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.
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))
// 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;
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
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;
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;
}
{
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;
}
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)
// 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")
self.owner.team = 0;
oself = self;
- self = self.owner;
+ setself(self.owner);
activator = self;
SUB_UseTargets ();
- self = oself;
+ setself(oself);
self.owner.team = t;
// 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;
}
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
{
setorigin(cp, cp.origin + '0 0 20');
cp.noalign = false;
- self = cp;
+ setself(cp);
droptofloor();
cp.movetype = MOVETYPE_TOSS;
}
{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
gen.colormap = 1024 + (teamnumber - 1) * 17;
// generator placement
- self = gen;
+ setself(gen);
droptofloor();
// waypointsprites
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;
}
// 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()
entity buff = buff_FirstFromFlags(self.buffs);
- entity oldself = self;
- self = ent;
+ setself(ent);
if(!self.buffs || buff_Available(buff))
buff_NewType(self, 0);
if(cvar("g_buffs_random_location") || (self.spawnflags & 64))
buff_Respawn(self);
- self = oldself;
+ setself(this);
}
void buff_Init_Compat(entity ent, entity replacement)
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);
}
}
{
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;
}
other = world;
}
- self = spawn();
+ setself(spawn());
self.ok_item = true;
self.noalign = true;
self.pickup_anyway = true;
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;
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))
{
{
_spectate(other);
- self = _oldself;
+ setself(_oldself);
return MUT_ITEMTOUCH_CONTINUE;
}
}
}
}
- self = _oldself;
+ setself(_oldself);
return MUT_ITEMTOUCH_CONTINUE;
}
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);
}
}
- self = _old_self;
+ setself(this);
return false;
}
{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;
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;
{
// do not allow portalling through checkpoints
trace_plane_normal = normalize(-1 * other.velocity);
- self = other;
+ setself(other);
W_Porto_Fail(0);
return;
}
qual = g_race_qualifying;
oldself = self;
- self = spawn();
+ setself(spawn());
self.classname = "player";
if(g_race)
}
}
remove(self);
- self = oldself;
+ setself(oldself);
}
vector trigger_race_checkpoint_spawn_evalfunc(entity player, entity spot, vector current)
void race_ClearRecords()
{SELFPARAM();
float i;
- entity e;
for(i = 0; i < MAX_CHECKPOINTS; ++i)
{
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)
++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;
}
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);
self.oldvelocity = self.velocity;
}
- self = oldself;
+ setself(this);
}
}
#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())
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();
{
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);
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
else
{
oldself = self;
- self = cl;
+ setself(cl);
f = WEP_ACTION(wpn, WR_CHECKAMMO1);
f = f + WEP_ACTION(wpn, WR_CHECKAMMO2);
for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.owner == self)
f = 1;
- self = oldself;
+ setself(oldself);
}
if (!f)
{
e = get_weaponinfo(j);
if(e.netname == s)
{
- self = spawn();
+ setself(spawn());
copyentity(oldself, self);
self.classname = "replacedweapon";
weapon_defaultspawnfunc(j);
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!
{
// 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";
}
}
- 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;
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;
}
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);
}
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
{
}
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()
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;
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();
}
// 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!
break;
}
}
- self = oldself;
+ setself(oldself);
other = oldother;
}
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()