// recursive predraw call to fix issues with forcemodels and LOD if bone indexes mismatch
if(self.tag_entity.classname == "csqcmodel")
{
- SELFCALL(self.tag_entity, CSQCModel_Hook_PreDraw((self.entnum >= 1 && self.entnum <= maxclients)));
- SELFCALL_DONE();
+ WITH(entity, self, self.tag_entity, CSQCModel_Hook_PreDraw((self.entnum >= 1 && self.entnum <= maxclients)));
}
if(self.tag_entity.modelindex != self.tag_entity_lastmodelindex)
break;
// delete this oldest one and search again
- SELFCALL(oldest, deleteproc());
- SELFCALL_DONE();
+ WITH(entity, self, oldest, deleteproc());
}
}
*/
for(entity e = NULL; (e = nextent(e)); ) if (e.draw) {
- SELFCALL(e, e.draw());
- SELFCALL_DONE();
+ WITH(entity, self, e, e.draw());
}
addentities(MASK_NORMAL | MASK_ENGINE | MASK_ENGINEVIEWMODELS);
// draw 2D entities
for (entity e = NULL; (e = nextent(e)); ) if (e.draw2d) {
- SELFCALL(e, e.draw2d());
- SELFCALL_DONE();
+ WITH(entity, self, e, e.draw2d());
}
Draw_ShowNames_All();
{SELFPARAM();
if ( menuitem )
{
- SELFCALL(menuitem, menuitem.use());
- SELFCALL_DONE();
+ WITH(entity, self, menuitem, menuitem.use());
}
}
if ( !IS_OBSERVER(player) && autocvar_sv_minigames_observer )
{
- SELFCALL(player, PutObserverInServer());
- SELFCALL_DONE();
+ WITH(entity, self, player, PutObserverInServer());
}
if ( autocvar_sv_minigames_observer == 2 )
player.team_forced = -1;
}
// Monster_Spawn checks if monster is valid
- SELFCALL(e, Monster_Spawn(monster_id));
- SELFCALL_DONE();
+ WITH(entity, self, e, Monster_Spawn(monster_id));
return e;
}
{
other = self;
- SELFCALL(oth, oth.move_touch());
- SELFCALL_DONE();
+ WITH(entity, self, oth, oth.move_touch());
other = oldother;
}
if (check.move_movetype == 32) // MOVETYPE_PHYSICS
{
check.move_origin = check.move_origin + move;
- SELFCALL(check, _Movetype_LinkEdict(true));
- SELFCALL_DONE();
+ WITH(entity, self, check, _Movetype_LinkEdict(true));
continue;
}
// try moving the contacted entity
self.solid = SOLID_NOT;
- bool flag = SELFCALL(check, _Movetype_PushEntity(move, true));
- SELFCALL_DONE();
+ bool flag;
+ WITH(entity, self, check, {
+ flag = _Movetype_PushEntity(move, true);
+ });
if (!flag)
{
// entity "check" got teleported
if (self.owner)
{
- SELFCALL(self.owner, door_fire());
- SELFCALL_DONE();
+ WITH(entity, self, self.owner, door_fire());
}
}
{
self.owner.health = self.owner.max_health;
self.owner.takedamage = DAMAGE_NO; // wil be reset upon return
- SELFCALL(self.owner, door_use());
- SELFCALL_DONE();
+ WITH(entity, self, self.owner, door_use());
}
}
void() train_next;
void train_wait()
{SELFPARAM();
- SELFCALL(self.enemy, SUB_UseTargets());
- SELFCALL_DONE();
+ WITH(entity, self, self.enemy, SUB_UseTargets());
self.enemy = world;
// if turning is enabled, the train will turn toward the next point while waiting
self.count = 1;
activator = self.enemy.pusher;
- SELFCALL(self.enemy, SUB_UseTargets());
- SELFCALL_DONE();
+ WITH(entity, self, self.enemy, SUB_UseTargets());
}
}
else
self.count = 0;
activator = self.enemy.pusher;
- SELFCALL(self.enemy, SUB_UseTargets());
- SELFCALL_DONE();
+ WITH(entity, self, self.enemy, SUB_UseTargets());
}
}
}
void SUB_CalcMoveEnt (entity ent, vector tdest, float tspeedtype, float tspeed, void() func)
{SELFPARAM();
- SELFCALL(ent, SUB_CalcMove (tdest, tspeedtype, tspeed, func));
- SELFCALL_DONE();
+ WITH(entity, self, ent, SUB_CalcMove(tdest, tspeedtype, tspeed, func));
}
/*
void SUB_CalcAngleMoveEnt (entity ent, vector destangle, float tspeedtype, float tspeed, void() func)
{SELFPARAM();
- SELFCALL(ent, SUB_CalcAngleMove (destangle, tspeedtype, tspeed, func));
- SELFCALL_DONE();
+ WITH(entity, self, ent, SUB_CalcAngleMove (destangle, tspeedtype, tspeed, func));
}
void SUB_SETORIGIN(entity s, vector v)
{SELFPARAM();
s.move_origin = v;
- SELFCALL(s, _Movetype_LinkEdict(true));
- SELFCALL_DONE();
+ WITH(entity, self, s, _Movetype_LinkEdict(true));
}
#endif
oldactivator = activator;
activator = act;
- SELFCALL(e, e.target_spawn_spawnfunc());
- SELFCALL_DONE();
+ WITH(entity, self, e, e.target_spawn_spawnfunc());
activator = oldactivator;
// We called an external function, so we have to re-tokenize msg.
Reset_ArcBeam(pl, v_forward);
UpdateCSQCProjectileAfterTeleport(pl);
{
- SELFCALL(pl, anticheat_fixangle());
- SELFCALL_DONE();
+ WITH(entity, self, pl, anticheat_fixangle());
}
// "disown" projectiles after teleport
if(pl.owner)
if(self.enemy.target)
{
activator = other;
- SELFCALL(self.enemy, SUB_UseTargets());
- SELFCALL_DONE();
+ WITH(entity, self, self.enemy, SUB_UseTargets());
}
if (other.flags & FL_PROJECTILE)
SUB_UseTargets();
if (!self.target) self.target = s;
- SELFCALL(e, SUB_UseTargets());
- SELFCALL_DONE();
+ WITH(entity, self, e, SUB_UseTargets());
}
void spawnfunc_trigger_teleport()
[[alias("self")]] entity __self;
+#define WITH(type, name, value, block) do { \
+ type __with_save = (name); \
+ name = (value); \
+ LAMBDA(block) \
+ name = __with_save; \
+} while (0)
+
// 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)
#endif
// Step 2: check SELFPARAM() is present for functions that use self
#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)
#endif
// Step 3: const self
entity setself(entity e) { return self = e; }
entity getself() { return self; }
#define self getself()
-#define SELFCALL(s, f) (__self = s, f)
-#define SELFCALL_DONE() (__self = this)
#endif
// Step 4: enable when possible
#if 0
#define SELFPARAM() noref const entity this = __self
#define self this
-#define SELFCALL(s, f) (__self = s, f)
-#define SELFCALL_DONE() (__self = this)
#endif
#define spawn() new(entity)
beam.beam_bursting = burst;
Net_LinkEntity(beam, false, 0, W_Arc_Beam_Send);
- SELFCALL(beam, beam.think());
- SELFCALL_DONE();
+ WITH(entity, self, beam, beam.think());
}
void Arc_Smoke()
if(time >= missile.nextthink)
{
- SELFCALL(missile, missile.think());
- SELFCALL_DONE();
+ WITH(entity, self, missile, missile.think());
}
}
bool W_Blaster(int request)
{SELFPARAM();
if(p.porto_current.realowner == p && p.porto_current.classname == "porto")
{
- SELFCALL(p.porto_current, W_Porto_Fail(1));
- SELFCALL_DONE();
+ WITH(entity, self, p.porto_current, W_Porto_Fail(1));
}
}
{
if(self.tuba_note.cnt != n || self.tuba_note.tuba_instrument != self.tuba_instrument)
{
- SELFCALL(self.tuba_note, W_Tuba_NoteOff());
- SELFCALL_DONE();
+ WITH(entity, self, self.tuba_note, W_Tuba_NoteOff());
}
}
{
if(!self.BUTTON_ATCK && !self.BUTTON_ATCK2)
{
- SELFCALL(self.tuba_note, W_Tuba_NoteOff());
- SELFCALL_DONE();
+ WITH(entity, self, self.tuba_note, W_Tuba_NoteOff());
}
}
setself(this);
}
- entity view;
- view = CSQCModel_server2csqc(player_localentnum);
+ entity view = CSQCModel_server2csqc(player_localentnum);
if(view && view != csqcplayer)
{
- SELFCALL(view, InterpolateOrigin_Do());
- self.view_ofs = '0 0 1' * getstati(STAT_VIEWHEIGHT);
- SELFCALL_DONE();
+ WITH(entity, self, view, InterpolateOrigin_Do());
+ view.view_ofs = '0 0 1' * getstati(STAT_VIEWHEIGHT);
}
if(view)
{SELFPARAM();
self.think = SUB_Remove;
self.nextthink = time;
- SELFCALL(self.owner, self.use());
- SELFCALL_DONE();
+ WITH(entity, self, self.owner, self.use());
}
/*
entity e;
FOR_EACH_CLIENT(e)
if (e.fixangle) {
- SELFCALL(e, anticheat_fixangle());
- SELFCALL_DONE();
+ WITH(entity, self, e, anticheat_fixangle());
}
anticheat_div0_evade_evasion_delta += frametime * (0.5 + random());
}
e.angles = fixedvectoangles2(trace_plane_normal, v_forward);
e.angles = AnglesTransform_ApplyToAngles(e.angles, '-90 0 0'); // so unrotated models work
}
- SELFCALL(e, spawnfunc_func_breakable());
- SELFCALL_DONE();
+ WITH(entity, self, e, spawnfunc_func_breakable());
// now, is it valid?
if(f == 0)
{
string s = spot.target;
spot.target = string_null;
activator = self;
- SELFCALL(spot, SUB_UseTargets());
- SELFCALL_DONE();
+ WITH(entity, self, spot, SUB_UseTargets());
activator = world;
spot.target = s;
e.think = ClientInit_CheckUpdate;
Net_LinkEntity(e, false, 0, ClientInit_SendEntity);
- SELFCALL(e, ClientInit_CheckUpdate());
- SELFCALL_DONE();
+ WITH(entity, self, e, ClientInit_CheckUpdate());
}
/*
if(self.cnt <= 0)
{
- SELFCALL(self.owner, ClientKill_Now());
- SELFCALL_DONE();
+ WITH(entity, self, self.owner, ClientKill_Now());
return;
}
else if(g_cts && self.health == 1) // health == 1 means that it's silent
sv_notice_join();
for (entity e = world; (e = findfloat(e, init_for_player_needed, 1)); ) {
- SELFCALL(e, e.init_for_player(this));
- SELFCALL_DONE();
+ WITH(entity, self, e, e.init_for_player(this));
}
MUTATOR_CALLHOOK(ClientConnect, self);
{
if (client.caplayer)
client.caplayer = 0;
- SELFCALL(client, PutObserverInServer());
- SELFCALL_DONE();
+ WITH(entity, self, client, PutObserverInServer());
++i;
}
if(i) { bprint(strcat("Successfully forced all (", ftos(i), ") players to spectate", (reason ? strcat(" for reason: '", reason, "'") : ""), ".\n")); }
if(accepted > 0)
{
- SELFCALL(client, anticheat_report());
- SELFCALL_DONE();
+ WITH(entity, self, client, anticheat_report());
return;
}
else
{
if (client.caplayer)
client.caplayer = 0;
- SELFCALL(client, PutObserverInServer());
- SELFCALL_DONE();
+ WITH(entity, self, client, PutObserverInServer());
successful = strcat(successful, (successful ? ", " : ""), client.netname);
}
return;
}
- SELFCALL(client, playerdemo_open_read(argv(next_token)));
- SELFCALL_DONE();
+ WITH(entity, self, client, playerdemo_open_read(argv(next_token)));
return;
}
return;
}
- SELFCALL(client, playerdemo_open_write(argv(next_token)));
- SELFCALL_DONE();
+ WITH(entity, self, client, playerdemo_open_write(argv(next_token)));
return;
}
FOR_EACH_PLAYER(e)
if(e.frozen)
{
- SELFCALL(e, Unfreeze(self));
- SELFCALL_DONE();
+ WITH(entity, self, e, Unfreeze(self));
}
// Moving the player reset code here since the player-reset depends
targ.iceblock = ice;
targ.revival_time = 0;
- SELFCALL(ice, Ice_Think());
- SELFCALL_DONE();
+ WITH(entity, self, ice, Ice_Think());
RemoveGrapplingHook(targ);
randomseed.think = RandomSeed_Think;
Net_LinkEntity(randomseed, false, 0, RandomSeed_Send);
- SELFCALL(randomseed, randomseed.think()); // sets random seed and nextthink
- SELFCALL_DONE();
+ WITH(entity, self, randomseed, randomseed.think()); // sets random seed and nextthink
}
void spawnfunc___init_dedicated_server(void)
}
else
{
- SELFCALL(ent, assault_new_round());
- SELFCALL_DONE();
+ WITH(entity, self, ent, assault_new_round());
}
}
}
//dprint("Delayed initialization: ", e.classname, "\n");
if (func)
{
- SELFCALL(e, func());
- SELFCALL_DONE();
+ WITH(entity, self, e, func());
}
else
{
{SELFPARAM();
for (entity e = NULL; (e = findfloat(e, uncustomizeentityforclient_set, 1)); )
{
- SELFCALL(e, e.uncustomizeentityforclient());
- SELFCALL_DONE();
+ WITH(entity, self, e, e.uncustomizeentityforclient());
}
}
void SetCustomizer(entity e, float(void) customizer, void(void) uncustomizer)
{
if (e.classname == "target_objective_decrease")
{
- SELFCALL(e, target_objective_decrease_activate());
- SELFCALL_DONE();
+ WITH(entity, self, e, target_objective_decrease_activate());
}
}
ent.team = NUM_TEAM_1;
// Dubbles as teamchange
- SELFCALL(ent, turret_respawn());
- SELFCALL_DONE();
+ WITH(entity, self, ent, turret_respawn());
}
}
{
if(e.vehicle)
{
- SELFCALL(e, vehicles_exit(VHEF_RELEASE));
- SELFCALL_DONE();
+ WITH(entity, self, e, vehicles_exit(VHEF_RELEASE));
}
}
FOR_EACH_CLIENT(e)
if(IS_PLAYER(e))
{
- SELFCALL(e, PlayerScore_Add(e, SP_LMS_LIVES, LMS_NewPlayerLives()));
- SELFCALL_DONE();
+ WITH(entity, self, e, PlayerScore_Add(e, SP_LMS_LIVES, LMS_NewPlayerLives()));
}
return false;
{
e.ons_roundlost = false;
e.ons_deathloc = '0 0 0';
- SELFCALL(e, PutClientInServer());
- SELFCALL_DONE();
+ WITH(entity, self, e, PutClientInServer());
}
return false;
}
e.noalign = self.noalign;
e.cnt = self.cnt;
e.team = self.team;
- SELFCALL(e, spawnfunc_item_minst_cells());
- SELFCALL_DONE();
+ WITH(entity, self, e, spawnfunc_item_minst_cells());
return true;
}
#include "../../common/items/item.qh"
-#define WITH(it) this.m_##it;
-#define CONFIGURE(...) MAP(WITH, __VA_ARGS__)
-
float instagib_respawntime_ammo = 45;
float instagib_respawntimejitter_ammo = 0;
GETTER(float, instagib_respawntime_ammo)
this.m_botvalue = BOT_PICKUP_RATING_HIGH;
#endif
}
-
-#undef WITH
-#undef CONFIGURE
e.angles_y = self.v_angle.y;
}
- SELFCALL(e, CSQCMODEL_AUTOINIT(e));
- SELFCALL_DONE();
+ WITH(entity, self, e, CSQCMODEL_AUTOINIT(e));
object_count += 1;
return e;
FOR_EACH_CLIENT(e)
{
float p = e.race_place;
- SELFCALL(e, race_PreparePlayer());
- SELFCALL_DONE();
+ WITH(entity, self, e, race_PreparePlayer());
e.race_place = p;
}
}
++found;
if(ent.spawn_evalfunc)
{
- spawn_score = SELFCALL(ent, ent.spawn_evalfunc(this, spot, spawn_score));
- SELFCALL_DONE();
+ WITH(entity, self, ent, {
+ spawn_score = ent.spawn_evalfunc(this, spot, spawn_score);
+ });
if(spawn_score.x < 0)
return spawn_score;
}
}
}
- SELFCALL(wep, weapon_defaultspawnfunc(wpn));
- SELFCALL_DONE();
+ WITH(entity, self, wep, weapon_defaultspawnfunc(wpn));
if(startitem_failed)
return string_null;
wep.glowmod = own.weaponentity_glowmod;