From: TimePath Date: Wed, 2 Sep 2015 09:44:38 +0000 (+1000) Subject: Combine `SELFCALL` and `SELFCALL_DONE` with `WITH` X-Git-Tag: xonotic-v0.8.2~1931^2~4 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=eeec5ec4584c71acbb89db6eea843b48d6ca4c26;p=xonotic%2Fxonotic-data.pk3dir.git Combine `SELFCALL` and `SELFCALL_DONE` with `WITH` --- diff --git a/qcsrc/client/csqcmodel_hooks.qc b/qcsrc/client/csqcmodel_hooks.qc index 4379f52c2..7e36cabec 100644 --- a/qcsrc/client/csqcmodel_hooks.qc +++ b/qcsrc/client/csqcmodel_hooks.qc @@ -423,8 +423,7 @@ void CSQCModel_AutoTagIndex_Apply(void) // recursive predraw call to fix issues with forcemodels and LOD if bone indexes mismatch if(self.tag_entity.classname == "csqcmodel") { - 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) diff --git a/qcsrc/client/rubble.qc b/qcsrc/client/rubble.qc index 8035fd76e..5af2e2350 100644 --- a/qcsrc/client/rubble.qc +++ b/qcsrc/client/rubble.qc @@ -39,8 +39,7 @@ void RubbleLimit(string cname, float limit, void() deleteproc) break; // delete this oldest one and search again - SELFCALL(oldest, deleteproc()); - SELFCALL_DONE(); + WITH(entity, self, oldest, deleteproc()); } } diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index f53dbd6be..1e4d666e9 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -1467,8 +1467,7 @@ void CSQC_UpdateView(float w, float h) */ 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); @@ -1805,8 +1804,7 @@ void CSQC_UpdateView(float w, float h) // 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(); diff --git a/qcsrc/common/minigames/cl_minigames_hud.qc b/qcsrc/common/minigames/cl_minigames_hud.qc index cedb98bd7..51155f236 100644 --- a/qcsrc/common/minigames/cl_minigames_hud.qc +++ b/qcsrc/common/minigames/cl_minigames_hud.qc @@ -107,8 +107,7 @@ void HUD_MinigameMenu_Click(entity menuitem) {SELFPARAM(); if ( menuitem ) { - SELFCALL(menuitem, menuitem.use()); - SELFCALL_DONE(); + WITH(entity, self, menuitem, menuitem.use()); } } diff --git a/qcsrc/common/minigames/sv_minigames.qc b/qcsrc/common/minigames/sv_minigames.qc index 95619a285..44653ae94 100644 --- a/qcsrc/common/minigames/sv_minigames.qc +++ b/qcsrc/common/minigames/sv_minigames.qc @@ -150,8 +150,7 @@ int minigame_addplayer(entity minigame_session, entity player) 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; diff --git a/qcsrc/common/monsters/spawn.qc b/qcsrc/common/monsters/spawn.qc index 9e9810b46..dfa318fe3 100644 --- a/qcsrc/common/monsters/spawn.qc +++ b/qcsrc/common/monsters/spawn.qc @@ -64,8 +64,7 @@ entity spawnmonster (string monster, float monster_id, entity spawnedby, entity } // 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; } diff --git a/qcsrc/common/movetypes/movetypes.qc b/qcsrc/common/movetypes/movetypes.qc index defa3718f..3de5bc9e3 100644 --- a/qcsrc/common/movetypes/movetypes.qc +++ b/qcsrc/common/movetypes/movetypes.qc @@ -337,8 +337,7 @@ void _Movetype_Impact(entity oth) // SV_Impact { other = self; - SELFCALL(oth, oth.move_touch()); - SELFCALL_DONE(); + WITH(entity, self, oth, oth.move_touch()); other = oldother; } diff --git a/qcsrc/common/movetypes/push.qc b/qcsrc/common/movetypes/push.qc index 29ac255d6..aeb75ded3 100644 --- a/qcsrc/common/movetypes/push.qc +++ b/qcsrc/common/movetypes/push.qc @@ -93,15 +93,16 @@ void _Movetype_PushMove(float dt) // SV_PushMove 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 diff --git a/qcsrc/common/triggers/func/door.qc b/qcsrc/common/triggers/func/door.qc index 0ea2f6dfe..053f0f5f6 100644 --- a/qcsrc/common/triggers/func/door.qc +++ b/qcsrc/common/triggers/func/door.qc @@ -273,8 +273,7 @@ void door_use() if (self.owner) { - SELFCALL(self.owner, door_fire()); - SELFCALL_DONE(); + WITH(entity, self, self.owner, door_fire()); } } @@ -295,8 +294,7 @@ void door_damage(entity inflictor, entity attacker, float damage, int deathtype, { 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()); } } diff --git a/qcsrc/common/triggers/func/train.qc b/qcsrc/common/triggers/func/train.qc index d06efdd94..6469d17e6 100644 --- a/qcsrc/common/triggers/func/train.qc +++ b/qcsrc/common/triggers/func/train.qc @@ -2,8 +2,7 @@ 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 diff --git a/qcsrc/common/triggers/misc/laser.qc b/qcsrc/common/triggers/misc/laser.qc index 196121430..52d2caf65 100644 --- a/qcsrc/common/triggers/misc/laser.qc +++ b/qcsrc/common/triggers/misc/laser.qc @@ -98,8 +98,7 @@ void misc_laser_think() self.count = 1; activator = self.enemy.pusher; - SELFCALL(self.enemy, SUB_UseTargets()); - SELFCALL_DONE(); + WITH(entity, self, self.enemy, SUB_UseTargets()); } } else @@ -109,8 +108,7 @@ void misc_laser_think() self.count = 0; activator = self.enemy.pusher; - SELFCALL(self.enemy, SUB_UseTargets()); - SELFCALL_DONE(); + WITH(entity, self, self.enemy, SUB_UseTargets()); } } } diff --git a/qcsrc/common/triggers/subs.qc b/qcsrc/common/triggers/subs.qc index f70108e88..b313c4999 100644 --- a/qcsrc/common/triggers/subs.qc +++ b/qcsrc/common/triggers/subs.qc @@ -294,8 +294,7 @@ 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(); - SELFCALL(ent, SUB_CalcMove (tdest, tspeedtype, tspeed, func)); - SELFCALL_DONE(); + WITH(entity, self, ent, SUB_CalcMove(tdest, tspeedtype, tspeed, func)); } /* @@ -363,6 +362,5 @@ void SUB_CalcAngleMove (vector destangle, float tspeedtype, float tspeed, void() 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)); } diff --git a/qcsrc/common/triggers/subs.qh b/qcsrc/common/triggers/subs.qh index ec9eb7607..98491820f 100644 --- a/qcsrc/common/triggers/subs.qh +++ b/qcsrc/common/triggers/subs.qh @@ -29,8 +29,7 @@ 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 diff --git a/qcsrc/common/triggers/target/spawn.qc b/qcsrc/common/triggers/target/spawn.qc index 38eabbab3..6572221f7 100644 --- a/qcsrc/common/triggers/target/spawn.qc +++ b/qcsrc/common/triggers/target/spawn.qc @@ -222,8 +222,7 @@ void target_spawn_edit_entity(entity e, string msg, entity kt, entity t2, entity 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. diff --git a/qcsrc/common/triggers/teleporters.qc b/qcsrc/common/triggers/teleporters.qc index 4b3861b35..bc4398601 100644 --- a/qcsrc/common/triggers/teleporters.qc +++ b/qcsrc/common/triggers/teleporters.qc @@ -229,8 +229,7 @@ void WarpZone_PostTeleportPlayer_Callback(entity pl) 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) diff --git a/qcsrc/common/triggers/trigger/jumppads.qc b/qcsrc/common/triggers/trigger/jumppads.qc index 52a8798cd..5eb252218 100644 --- a/qcsrc/common/triggers/trigger/jumppads.qc +++ b/qcsrc/common/triggers/trigger/jumppads.qc @@ -219,8 +219,7 @@ void trigger_push_touch() 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) diff --git a/qcsrc/common/triggers/trigger/teleport.qc b/qcsrc/common/triggers/trigger/teleport.qc index 36c4cd22d..129f4e387 100644 --- a/qcsrc/common/triggers/trigger/teleport.qc +++ b/qcsrc/common/triggers/trigger/teleport.qc @@ -44,8 +44,7 @@ void Teleport_Touch (void) SUB_UseTargets(); if (!self.target) self.target = s; - SELFCALL(e, SUB_UseTargets()); - SELFCALL_DONE(); + WITH(entity, self, e, SUB_UseTargets()); } void spawnfunc_trigger_teleport() diff --git a/qcsrc/common/util-post.qh b/qcsrc/common/util-post.qh index 2789e1235..dd20cf8f5 100644 --- a/qcsrc/common/util-post.qh +++ b/qcsrc/common/util-post.qh @@ -3,13 +3,18 @@ [[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 @@ -17,8 +22,6 @@ #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 @@ -27,16 +30,12 @@ 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) diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index a9829f612..fe8c20c7a 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -592,8 +592,7 @@ void W_Arc_Beam(float burst) 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() diff --git a/qcsrc/common/weapons/weapon/blaster.qc b/qcsrc/common/weapons/weapon/blaster.qc index 5c7fd8dfc..e3edb492e 100644 --- a/qcsrc/common/weapons/weapon/blaster.qc +++ b/qcsrc/common/weapons/weapon/blaster.qc @@ -141,8 +141,7 @@ void W_Blaster_Attack( if(time >= missile.nextthink) { - SELFCALL(missile, missile.think()); - SELFCALL_DONE(); + WITH(entity, self, missile, missile.think()); } } bool W_Blaster(int request) diff --git a/qcsrc/common/weapons/weapon/porto.qc b/qcsrc/common/weapons/weapon/porto.qc index bb4795145..03a77f0cb 100644 --- a/qcsrc/common/weapons/weapon/porto.qc +++ b/qcsrc/common/weapons/weapon/porto.qc @@ -95,8 +95,7 @@ void W_Porto_Remove(entity p) {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)); } } diff --git a/qcsrc/common/weapons/weapon/tuba.qc b/qcsrc/common/weapons/weapon/tuba.qc index 05787ba58..2987d0b81 100644 --- a/qcsrc/common/weapons/weapon/tuba.qc +++ b/qcsrc/common/weapons/weapon/tuba.qc @@ -336,8 +336,7 @@ void W_Tuba_NoteOn(float hittype) { 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()); } } @@ -404,8 +403,7 @@ bool W_Tuba(int req) { 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()); } } diff --git a/qcsrc/csqcmodellib/cl_player.qc b/qcsrc/csqcmodellib/cl_player.qc index a5afdac8f..1a96e23dd 100644 --- a/qcsrc/csqcmodellib/cl_player.qc +++ b/qcsrc/csqcmodellib/cl_player.qc @@ -300,14 +300,12 @@ void CSQCPlayer_SetCamera() 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) diff --git a/qcsrc/lib/Defer.qh b/qcsrc/lib/Defer.qh index ce12478b5..ca626dd7b 100644 --- a/qcsrc/lib/Defer.qh +++ b/qcsrc/lib/Defer.qh @@ -24,8 +24,7 @@ void defer_think() {SELFPARAM(); self.think = SUB_Remove; self.nextthink = time; - SELFCALL(self.owner, self.use()); - SELFCALL_DONE(); + WITH(entity, self, self.owner, self.use()); } /* diff --git a/qcsrc/server/anticheat.qc b/qcsrc/server/anticheat.qc index 370ef844e..32742d82d 100644 --- a/qcsrc/server/anticheat.qc +++ b/qcsrc/server/anticheat.qc @@ -237,8 +237,7 @@ void anticheat_endframe() 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()); } diff --git a/qcsrc/server/cheats.qc b/qcsrc/server/cheats.qc index 5e2586cd6..2b72368fa 100644 --- a/qcsrc/server/cheats.qc +++ b/qcsrc/server/cheats.qc @@ -372,8 +372,7 @@ float CheatCommand(float argc) e.angles = fixedvectoangles2(trace_plane_normal, v_forward); e.angles = AnglesTransform_ApplyToAngles(e.angles, '-90 0 0'); // so unrotated models work } - SELFCALL(e, spawnfunc_func_breakable()); - SELFCALL_DONE(); + WITH(entity, self, e, spawnfunc_func_breakable()); // now, is it valid? if(f == 0) { diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index fda43661c..036d417d5 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -631,8 +631,7 @@ void PutClientInServer() 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; @@ -736,8 +735,7 @@ void ClientInit_Spawn() e.think = ClientInit_CheckUpdate; Net_LinkEntity(e, false, 0, ClientInit_SendEntity); - SELFCALL(e, ClientInit_CheckUpdate()); - SELFCALL_DONE(); + WITH(entity, self, e, ClientInit_CheckUpdate()); } /* @@ -847,8 +845,7 @@ void KillIndicator_Think() 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 @@ -1261,8 +1258,7 @@ void ClientConnect (void) 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); diff --git a/qcsrc/server/command/sv_cmd.qc b/qcsrc/server/command/sv_cmd.qc index 6c3d4c669..8287643b9 100644 --- a/qcsrc/server/command/sv_cmd.qc +++ b/qcsrc/server/command/sv_cmd.qc @@ -209,8 +209,7 @@ void GameCommand_allspec(float request, float argc) { 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")); } @@ -240,8 +239,7 @@ void GameCommand_anticheat(float request, float argc) if(accepted > 0) { - SELFCALL(client, anticheat_report()); - SELFCALL_DONE(); + WITH(entity, self, client, anticheat_report()); return; } else @@ -1041,8 +1039,7 @@ void GameCommand_moveplayer(float request, float argc) { if (client.caplayer) client.caplayer = 0; - SELFCALL(client, PutObserverInServer()); - SELFCALL_DONE(); + WITH(entity, self, client, PutObserverInServer()); successful = strcat(successful, (successful ? ", " : ""), client.netname); } @@ -1194,8 +1191,7 @@ void GameCommand_playerdemo(float request, float argc) return; } - SELFCALL(client, playerdemo_open_read(argv(next_token))); - SELFCALL_DONE(); + WITH(entity, self, client, playerdemo_open_read(argv(next_token))); return; } @@ -1210,8 +1206,7 @@ void GameCommand_playerdemo(float request, float argc) return; } - SELFCALL(client, playerdemo_open_write(argv(next_token))); - SELFCALL_DONE(); + WITH(entity, self, client, playerdemo_open_write(argv(next_token))); return; } diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index bd0b08657..3e9f12962 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -392,8 +392,7 @@ void reset_map(float dorespawn) 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 diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index 70100db99..5e10f41a0 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -576,8 +576,7 @@ void Freeze (entity targ, float freeze_time, float frozen_type, float show_waypo targ.iceblock = ice; targ.revival_time = 0; - SELFCALL(ice, Ice_Think()); - SELFCALL_DONE(); + WITH(entity, self, ice, Ice_Think()); RemoveGrapplingHook(targ); diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 4f3356b65..b15e847c5 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -531,8 +531,7 @@ void RandomSeed_Spawn() 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) @@ -1724,8 +1723,7 @@ float WinningCondition_Assault() } else { - SELFCALL(ent, assault_new_round()); - SELFCALL_DONE(); + WITH(entity, self, ent, assault_new_round()); } } } diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index c3891bf24..e76545c73 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -1196,8 +1196,7 @@ void InitializeEntitiesRun() //dprint("Delayed initialization: ", e.classname, "\n"); if (func) { - SELFCALL(e, func()); - SELFCALL_DONE(); + WITH(entity, self, e, func()); } else { @@ -1213,8 +1212,7 @@ void UncustomizeEntitiesRun() {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) diff --git a/qcsrc/server/mutators/gamemode_assault.qc b/qcsrc/server/mutators/gamemode_assault.qc index 2cab4918d..239c3d3b4 100644 --- a/qcsrc/server/mutators/gamemode_assault.qc +++ b/qcsrc/server/mutators/gamemode_assault.qc @@ -17,8 +17,7 @@ void assault_objective_use() { if (e.classname == "target_objective_decrease") { - SELFCALL(e, target_objective_decrease_activate()); - SELFCALL_DONE(); + WITH(entity, self, e, target_objective_decrease_activate()); } } @@ -178,8 +177,7 @@ void assault_roundstart_use() ent.team = NUM_TEAM_1; // Dubbles as teamchange - SELFCALL(ent, turret_respawn()); - SELFCALL_DONE(); + WITH(entity, self, ent, turret_respawn()); } } @@ -213,8 +211,7 @@ void assault_new_round() { if(e.vehicle) { - SELFCALL(e, vehicles_exit(VHEF_RELEASE)); - SELFCALL_DONE(); + WITH(entity, self, e, vehicles_exit(VHEF_RELEASE)); } } diff --git a/qcsrc/server/mutators/gamemode_lms.qc b/qcsrc/server/mutators/gamemode_lms.qc index 08a8ce4b6..b9395b913 100644 --- a/qcsrc/server/mutators/gamemode_lms.qc +++ b/qcsrc/server/mutators/gamemode_lms.qc @@ -41,8 +41,7 @@ MUTATOR_HOOKFUNCTION(lms_ResetPlayers) 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; diff --git a/qcsrc/server/mutators/gamemode_onslaught.qc b/qcsrc/server/mutators/gamemode_onslaught.qc index 1372bd09d..76a7a65d5 100644 --- a/qcsrc/server/mutators/gamemode_onslaught.qc +++ b/qcsrc/server/mutators/gamemode_onslaught.qc @@ -1701,8 +1701,7 @@ MUTATOR_HOOKFUNCTION(ons_ResetMap) { e.ons_roundlost = false; e.ons_deathloc = '0 0 0'; - SELFCALL(e, PutClientInServer()); - SELFCALL_DONE(); + WITH(entity, self, e, PutClientInServer()); } return false; } diff --git a/qcsrc/server/mutators/mutator_instagib.qc b/qcsrc/server/mutators/mutator_instagib.qc index 384c29780..3295255de 100644 --- a/qcsrc/server/mutators/mutator_instagib.qc +++ b/qcsrc/server/mutators/mutator_instagib.qc @@ -345,8 +345,7 @@ MUTATOR_HOOKFUNCTION(instagib_FilterItem) 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; } diff --git a/qcsrc/server/mutators/mutator_instagib_items.qc b/qcsrc/server/mutators/mutator_instagib_items.qc index 339dc49aa..7a6f255ef 100644 --- a/qcsrc/server/mutators/mutator_instagib_items.qc +++ b/qcsrc/server/mutators/mutator_instagib_items.qc @@ -1,8 +1,5 @@ #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) @@ -31,6 +28,3 @@ REGISTER_ITEM(ExtraLife, Powerup) { this.m_botvalue = BOT_PICKUP_RATING_HIGH; #endif } - -#undef WITH -#undef CONFIGURE diff --git a/qcsrc/server/mutators/sandbox.qc b/qcsrc/server/mutators/sandbox.qc index 430271d80..da4f68d58 100644 --- a/qcsrc/server/mutators/sandbox.qc +++ b/qcsrc/server/mutators/sandbox.qc @@ -178,8 +178,7 @@ entity sandbox_ObjectSpawn(float database) 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; diff --git a/qcsrc/server/race.qc b/qcsrc/server/race.qc index c83f5252f..1638dc985 100644 --- a/qcsrc/server/race.qc +++ b/qcsrc/server/race.qc @@ -1087,8 +1087,7 @@ void race_ClearRecords() 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; } } diff --git a/qcsrc/server/spawnpoints.qc b/qcsrc/server/spawnpoints.qc index d349405bd..3a574b28b 100644 --- a/qcsrc/server/spawnpoints.qc +++ b/qcsrc/server/spawnpoints.qc @@ -258,8 +258,9 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck) ++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; } diff --git a/qcsrc/server/weapons/throwing.qc b/qcsrc/server/weapons/throwing.qc index 25f464914..2fb19609e 100644 --- a/qcsrc/server/weapons/throwing.qc +++ b/qcsrc/server/weapons/throwing.qc @@ -74,8 +74,7 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto } } - 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;