From: TimePath Date: Sun, 12 Jun 2016 03:35:42 +0000 (+1000) Subject: Remove uses of WITHSELF X-Git-Tag: xonotic-v0.8.2~819 X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=8cbf0e84432e075e617f43c037c645ea9846eba0 Remove uses of WITHSELF --- diff --git a/qcsrc/client/shownames.qc b/qcsrc/client/shownames.qc index e9db990c82..6700ba61c7 100644 --- a/qcsrc/client/shownames.qc +++ b/qcsrc/client/shownames.qc @@ -177,7 +177,7 @@ void Draw_ShowNames_All() } make_impure(it); assert(getthink(entcs), eprint(entcs)); - WITHSELF(entcs, getthink(entcs)(entcs)); + getthink(entcs)(entcs); if (!entcs.has_origin) continue; if (entcs.m_entcs_private) { diff --git a/qcsrc/common/ent_cs.qc b/qcsrc/common/ent_cs.qc index 75deb92eaf..cafef4868b 100644 --- a/qcsrc/common/ent_cs.qc +++ b/qcsrc/common/ent_cs.qc @@ -187,7 +187,7 @@ #undef X this.iflags |= IFLAG_ORIGIN; InterpolateOrigin_Note(this); - WITHSELF(this, getthink(this)(this)); + getthink(this)(this); return true; } diff --git a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc index 2a431c721d..6ef9ca5ab6 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc @@ -109,7 +109,7 @@ void nexball_setstatus(entity this) bprint("The ", Team_ColoredFullName(this.team), " held the ball for too long.\n"); DropBall(this.ballcarried, this.ballcarried.owner.origin, '0 0 0'); entity e = this.ballcarried; - WITHSELF(e, ResetBall(e)); + ResetBall(e); } else this.items |= IT_KEY1; diff --git a/qcsrc/common/monsters/sv_monsters.qc b/qcsrc/common/monsters/sv_monsters.qc index 1ae7e83a91..945a1de35e 100644 --- a/qcsrc/common/monsters/sv_monsters.qc +++ b/qcsrc/common/monsters/sv_monsters.qc @@ -48,7 +48,7 @@ void monster_dropitem(entity this, entity attacker) if(e && e.monster_loot) { e.noalign = true; - WITHSELF(e, e.monster_loot(e)); + e.monster_loot(e); e.gravity = 1; e.movetype = MOVETYPE_TOSS; e.reset = SUB_Remove; diff --git a/qcsrc/common/mutators/mutator/buffs/buffs.qc b/qcsrc/common/mutators/mutator/buffs/buffs.qc index cd72bb46b6..15aa8eeb13 100644 --- a/qcsrc/common/mutators/mutator/buffs/buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/buffs.qc @@ -907,7 +907,7 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink) { entity oldother = other; other = player; - WITHSELF(it, gettouch(it)(it)); + gettouch(it)(it); other = oldother; } } diff --git a/qcsrc/common/mutators/mutator/instagib/instagib.qc b/qcsrc/common/mutators/mutator/instagib/instagib.qc index 89bbf5fae0..dc871d694a 100644 --- a/qcsrc/common/mutators/mutator/instagib/instagib.qc +++ b/qcsrc/common/mutators/mutator/instagib/instagib.qc @@ -389,7 +389,7 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, FilterItem) e.cnt = item.cnt; e.team = item.team; e.spawnfunc_checked = true; - WITHSELF(e, spawnfunc_item_minst_cells(e)); + spawnfunc_item_minst_cells(e); return true; } diff --git a/qcsrc/common/mutators/mutator/overkill/overkill.qc b/qcsrc/common/mutators/mutator/overkill/overkill.qc index 323286bbe9..2fb75b3f8d 100644 --- a/qcsrc/common/mutators/mutator/overkill/overkill.qc +++ b/qcsrc/common/mutators/mutator/overkill/overkill.qc @@ -128,7 +128,7 @@ void ok_DropItem(entity this, entity targ) e.noalign = true; e.pickup_anyway = true; e.spawnfunc_checked = true; - WITHSELF(e, spawnfunc_item_armor_small(e)); + spawnfunc_item_armor_small(e); if (!wasfreed(e)) { // might have been blocked by a mutator e.movetype = MOVETYPE_TOSS; e.gravity = 1; diff --git a/qcsrc/common/physics/movetypes/movetypes.qc b/qcsrc/common/physics/movetypes/movetypes.qc index ce7d04d1da..06ccde2a57 100644 --- a/qcsrc/common/physics/movetypes/movetypes.qc +++ b/qcsrc/common/physics/movetypes/movetypes.qc @@ -321,7 +321,7 @@ void _Movetype_Impact(entity this, entity oth) // SV_Impact { other = oth; - WITHSELF(this, gettouch(this)(this)); + gettouch(this)(this); other = oldother; } @@ -330,7 +330,7 @@ void _Movetype_Impact(entity this, entity oth) // SV_Impact { other = this; - WITHSELF(oth, gettouch(oth)(oth)); + gettouch(oth)(oth); other = oldother; } @@ -360,7 +360,7 @@ void _Movetype_LinkEdict_TouchAreaGrid(entity this) // SV_LinkEdict_TouchAreaGr trace_plane_dist = 0; trace_ent = this; - WITHSELF(it, gettouch(it)(it)); + gettouch(it)(it); } }); diff --git a/qcsrc/common/physics/movetypes/push.qc b/qcsrc/common/physics/movetypes/push.qc index 276b10476f..29ce131064 100644 --- a/qcsrc/common/physics/movetypes/push.qc +++ b/qcsrc/common/physics/movetypes/push.qc @@ -149,6 +149,6 @@ void _Movetype_Physics_Pusher(entity this, float dt) // SV_Physics_Pusher this.move_nextthink = 0; this.move_time = time; other = world; - WITHSELF(this, this.move_think(this)); + this.move_think(this); } } diff --git a/qcsrc/common/triggers/func/conveyor.qc b/qcsrc/common/triggers/func/conveyor.qc index e86eefb2c1..b8980a1561 100644 --- a/qcsrc/common/triggers/func/conveyor.qc +++ b/qcsrc/common/triggers/func/conveyor.qc @@ -147,7 +147,7 @@ spawnfunc(func_conveyor) #elif defined(CSQC) -void conveyor_draw(entity this) { WITHSELF(this, conveyor_think(this)); } +void conveyor_draw(entity this) { conveyor_think(this); } void conveyor_init(entity this) { diff --git a/qcsrc/common/triggers/subs.qc b/qcsrc/common/triggers/subs.qc index a71267b0cc..51ef002736 100644 --- a/qcsrc/common/triggers/subs.qc +++ b/qcsrc/common/triggers/subs.qc @@ -145,7 +145,7 @@ void SUB_CalcMove_controller_think (entity this) entity own = this.owner; SUB_THINK(own, this.think1); remove(this); - WITHSELF(own, SUB_THUNK(own)(own)); + SUB_THUNK(own)(own); } } @@ -236,7 +236,7 @@ void SUB_CalcMove_Bezier (entity this, vector tcontrol, vector tdest, float tspe this.SUB_NEXTTHINK = this.SUB_LTIME + traveltime; // invoke controller - WITHSELF(controller, getthink(controller)(controller)); + getthink(controller)(controller); } void SUB_CalcMove (entity this, vector tdest, float tspeedtype, float tspeed, void(entity this) func) diff --git a/qcsrc/common/triggers/target/spawn.qc b/qcsrc/common/triggers/target/spawn.qc index a570c2a644..679d66e733 100644 --- a/qcsrc/common/triggers/target/spawn.qc +++ b/qcsrc/common/triggers/target/spawn.qc @@ -217,7 +217,7 @@ void target_spawn_edit_entity(entity this, entity e, string msg, entity kt, enti value = strcat("target_spawn_helper", value); putentityfieldstring(target_spawn_spawnfunc_field, e, value); - WITHSELF(e, e.target_spawn_spawnfunc(e)); + e.target_spawn_spawnfunc(e); // We called an external function, so we have to re-tokenize msg. n = tokenize_console(msg); diff --git a/qcsrc/common/triggers/trigger/gamestart.qc b/qcsrc/common/triggers/trigger/gamestart.qc index 6fa27cf1a7..efddf8c77f 100644 --- a/qcsrc/common/triggers/trigger/gamestart.qc +++ b/qcsrc/common/triggers/trigger/gamestart.qc @@ -10,11 +10,10 @@ void gamestart_use_this(entity this) gamestart_use(this, NULL, NULL); } -void self_spawnfunc_trigger_gamestart(entity this); spawnfunc(trigger_gamestart) { this.use = gamestart_use; - this.reset2 = self_spawnfunc_trigger_gamestart; + this.reset2 = spawnfunc_trigger_gamestart; if(this.wait) { @@ -24,6 +23,5 @@ spawnfunc(trigger_gamestart) else InitializeEntity(this, gamestart_use_this, INITPRIO_FINDTARGET); } -void self_spawnfunc_trigger_gamestart(entity this) { WITHSELF(this, spawnfunc_trigger_gamestart(this)); } #endif diff --git a/qcsrc/common/vehicles/vehicle/raptor.qc b/qcsrc/common/vehicles/vehicle/raptor.qc index 9dbf5825ff..18dd356df7 100644 --- a/qcsrc/common/vehicles/vehicle/raptor.qc +++ b/qcsrc/common/vehicles/vehicle/raptor.qc @@ -391,7 +391,7 @@ bool raptor_frame(entity this) if (wep1.wr_checkammo1(wep1, vehic)) { .entity weaponentity = weaponentities[0]; - WITHSELF(vehic, wep1.wr_think(wep1, vehic, weaponentity, 1)); + wep1.wr_think(wep1, vehic, weaponentity, 1); } if(vehic.vehicle_flags & VHF_SHIELDREGEN) diff --git a/qcsrc/common/weapons/all.qh b/qcsrc/common/weapons/all.qh index b86b77fadf..dd691a6921 100644 --- a/qcsrc/common/weapons/all.qh +++ b/qcsrc/common/weapons/all.qh @@ -114,7 +114,8 @@ void W_PROP_think(entity this) STATIC_INIT_LATE(W_PROP_reloader) { entity e = W_PROP_reloader = new_pure(W_PROP_reloader); - WITHSELF(e, (setthink(e, W_PROP_think))(e)); + setthink(e, W_PROP_think); + W_PROP_think(e); } #endif diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index 4908a7ee5c..b7d471f5a3 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -691,7 +691,7 @@ void W_Arc_Beam(float burst, entity actor) beam.beam_bursting = burst; Net_LinkEntity(beam, false, 0, W_Arc_Beam_Send); - WITHSELF(beam, getthink(beam)(beam)); + getthink(beam)(beam); } void Arc_Smoke(entity actor) { diff --git a/qcsrc/common/weapons/weapon/blaster.qc b/qcsrc/common/weapons/weapon/blaster.qc index 59cb4618bc..ca305f7ba7 100644 --- a/qcsrc/common/weapons/weapon/blaster.qc +++ b/qcsrc/common/weapons/weapon/blaster.qc @@ -146,7 +146,7 @@ void W_Blaster_Attack( if (time >= missile.nextthink) { - WITHSELF(missile, getthink(missile)(missile)); + getthink(missile)(missile); } } diff --git a/qcsrc/dpdefs/post.qh b/qcsrc/dpdefs/post.qh index fe465e5933..db8752d2bb 100644 --- a/qcsrc/dpdefs/post.qh +++ b/qcsrc/dpdefs/post.qh @@ -1,3 +1,16 @@ #pragma once +#undef ChangeYaw +#undef checkclient +#undef droptofloor +#undef error +#undef movetogoal #undef objerror +#undef walkmove + +#ifdef MENUQC + #define NULL (0, null_entity) + #define world NULL +#else + #define NULL (0, world) +#endif diff --git a/qcsrc/dpdefs/pre.qh b/qcsrc/dpdefs/pre.qh index f63f0aa830..b24d0120a4 100644 --- a/qcsrc/dpdefs/pre.qh +++ b/qcsrc/dpdefs/pre.qh @@ -1,3 +1,9 @@ #pragma once +#define ChangeYaw builtin_ChangeYaw +#define checkclient builtin_checkclient +#define droptofloor builtin_droptofloor +#define error builtin_error +#define movetogoal builtin_movetogoal #define objerror builtin_objerror +#define walkmove builtin_walkmove diff --git a/qcsrc/lib/_all.inc b/qcsrc/lib/_all.inc index 23b55cb69d..03b9436258 100644 --- a/qcsrc/lib/_all.inc +++ b/qcsrc/lib/_all.inc @@ -29,6 +29,8 @@ #include +#include "self.qh" + #define USING(name, T) typedef T name #include "bool.qh" @@ -94,7 +96,6 @@ void isnt_bool( float this) { print(ftos(this)); } #include "registry.qh" #include "registry_net.qh" #include "replicate.qh" -#include "self.qh" #include "sortlist.qc" #include "sort.qh" #include "spawnfunc.qh" diff --git a/qcsrc/lib/macro.qh b/qcsrc/lib/macro.qh index 809708d743..dff3710a5f 100644 --- a/qcsrc/lib/macro.qh +++ b/qcsrc/lib/macro.qh @@ -1,7 +1,7 @@ #pragma once #if 1 - void voidfunc() { error("voidfunc"); } + void voidfunc() { } #define MACRO_BEGIN if (1) { #define MACRO_END } else voidfunc() #else diff --git a/qcsrc/lib/oo.qh b/qcsrc/lib/oo.qh index fd6ca20365..3708552d59 100644 --- a/qcsrc/lib/oo.qh +++ b/qcsrc/lib/oo.qh @@ -4,13 +4,6 @@ #include "nil.qh" #include "static.qh" -#ifdef MENUQC - #define NULL (0, null_entity) - #define world NULL -#else - #define NULL (0, world) -#endif - .vector origin; .bool pure_data; /** @deprecated use new_pure or NEW(class) */ diff --git a/qcsrc/lib/self.qh b/qcsrc/lib/self.qh index 4af4b8ab02..37f0c50d21 100644 --- a/qcsrc/lib/self.qh +++ b/qcsrc/lib/self.qh @@ -87,19 +87,21 @@ SELFWRAP(camera_transform, vector, (vector org, vector ang), (entity this, vecto SELFWRAP(SendEntity, bool, (entity to, int sendflags), (entity this, entity to, int sendflags), (this, to, sendflags)) #define setSendEntity(e, f) SELFWRAP_SET(SendEntity, e, f) -#ifdef SVQC -void make_safe_for_remove(entity this); +#define ChangeYaw(e, ...) (__self = (e), builtin_ChangeYaw(__VA_ARGS__)) +#define checkclient(e, ...) (__self = (e), builtin_checkclient(__VA_ARGS__)) +#ifndef SVQC + #define droptofloor(e, ...) (__self = (e), builtin_droptofloor(__VA_ARGS__)) #endif - -void objerror(entity this, string s) -{ -#ifdef SVQC - make_safe_for_remove(this); +#define error(...) (__self = (NULL), builtin_error(__VA_ARGS__)) +#define movetogoal(e, ...) (__self = (e), builtin_movetogoal(__VA_ARGS__)) +#ifndef SVQC + #define objerror(e, ...) (__self = (e), builtin_objerror(__VA_ARGS__)) +#else + void make_safe_for_remove(entity this); + #define objerror(e, ...) (__self = (e), make_safe_for_remove(__self), builtin_objerror(__VA_ARGS__)) #endif - WITHSELF(this, builtin_objerror(s)); -} +#define walkmove(e, ...) (__self = (e), builtin_walkmove(__VA_ARGS__)) #ifndef MENUQC -void adaptor_think2touch(entity this) { WITH(entity, other, NULL, gettouch(this)(this)); } void adaptor_think2use(entity this) { if (this.use) this.use(this, NULL, NULL); } #endif diff --git a/qcsrc/lib/spawnfunc.qh b/qcsrc/lib/spawnfunc.qh index 22047bbc9d..0463979c1a 100644 --- a/qcsrc/lib/spawnfunc.qh +++ b/qcsrc/lib/spawnfunc.qh @@ -27,6 +27,7 @@ noref bool require_spawnfunc_prefix; #define _spawnfunc_check(fld) \ if (fieldname == #fld) continue; + noref bool __spawnfunc_expecting; noref entity __spawnfunc_expect; bool __spawnfunc_unreachable_workaround = true; @@ -35,11 +36,12 @@ noref bool require_spawnfunc_prefix; void __spawnfunc_##id(entity this); \ [[accumulate]] void spawnfunc_##id(entity this) \ { \ - if (__self == __spawnfunc_expect) \ + if (__spawnfunc_expecting) \ { \ /* engine call */ \ + __spawnfunc_expecting = false; \ + this = __spawnfunc_expect; \ __spawnfunc_expect = NULL; \ - this = __self; \ } \ else \ { \ diff --git a/qcsrc/server/cheats.qc b/qcsrc/server/cheats.qc index e92a6082a7..987a86db4f 100644 --- a/qcsrc/server/cheats.qc +++ b/qcsrc/server/cheats.qc @@ -357,7 +357,7 @@ float CheatCommand(entity this, int argc) e.angles = fixedvectoangles2(trace_plane_normal, v_forward); e.angles = AnglesTransform_ApplyToAngles(e.angles, '-90 0 0'); // so unrotated models work } - WITHSELF(e, spawnfunc_func_breakable(e)); + spawnfunc_func_breakable(e); // now, is it valid? if(f == 0) { diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index b1482999d1..d02caa390f 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -340,7 +340,7 @@ void reset_map(bool dorespawn) FOREACH_ENTITY_ORDERED(IS_NOT_A_CLIENT(it), { if (it.reset) { - WITHSELF(it, it.reset(it)); // needs WITHSELF, as some spawnfuncs are set to .reset + it.reset(it); continue; } if (it.team_saved) it.team = it.team_saved; diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 8e2f74c720..7cb5f69803 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -528,7 +528,7 @@ void RandomSeed_Spawn() setthink(randomseed, RandomSeed_Think); Net_LinkEntity(randomseed, false, 0, RandomSeed_Send); - WITHSELF(randomseed, getthink(randomseed)(randomseed)); // sets random seed and nextthink + getthink(randomseed)(randomseed); // sets random seed and nextthink } spawnfunc(__init_dedicated_server) @@ -1562,7 +1562,7 @@ void NextLevel() bprint(it.netname, " ^7wins.\n"); )); - WITHSELF(NULL, target_music_kill()); + target_music_kill(); if(autocvar_g_campaign) CampaignPreIntermission(); diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index d4c4bb7e56..c150d38a83 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -903,7 +903,7 @@ void InitializeEntitiesRun() //dprint("Delayed initialization: ", e.classname, "\n"); if (func) { - WITHSELF(e, func(e)); + func(e); } else { @@ -957,7 +957,7 @@ void adaptor_think2use_hittype_splash(entity this) // for timed projectile deton { if(!(IS_ONGROUND(this))) // if onground, we ARE touching something, but HITTYPE_SPLASH is to be networked if the damage causing projectile is not touching ANYTHING this.projectiledeathtype |= HITTYPE_SPLASH; - WITHSELF(this, adaptor_think2use(this)); + adaptor_think2use(this); } // deferred dropping @@ -1033,7 +1033,7 @@ bool SUB_NoImpactCheck(entity this, entity toucher) { //dprint("A hit happened with zero hit contents... DEBUG THIS, this should never happen for projectiles! Projectile will self-destruct.\n"); LOG_TRACEF("A hit from a projectile happened with no hit contents! DEBUG THIS, this should never happen for projectiles! Profectile will self-destruct. (edict: %d, classname: %s, origin: %s)\n", etof(this), this.classname, vtos(this.origin)); - WITHSELF(this, checkclient()); + checkclient(this); } if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT) return true; diff --git a/qcsrc/server/mutators/mutator/gamemode_ctf.qc b/qcsrc/server/mutators/mutator/gamemode_ctf.qc index b827f10eae..ade9cfa3b6 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ctf.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ctf.qc @@ -2563,7 +2563,7 @@ void ctf_SpawnTeam (string teamname, int teamcolor) this.netname = teamname; this.cnt = teamcolor; this.spawnfunc_checked = true; - WITHSELF(this, spawnfunc_ctf_team(this)); + spawnfunc_ctf_team(this); } void ctf_DelayedInit(entity this) // Do this check with a delay so we can wait for teams to be set up. diff --git a/qcsrc/server/mutators/mutator/gamemode_tdm.qc b/qcsrc/server/mutators/mutator/gamemode_tdm.qc index 2eeaafa306..d245721cb8 100644 --- a/qcsrc/server/mutators/mutator/gamemode_tdm.qc +++ b/qcsrc/server/mutators/mutator/gamemode_tdm.qc @@ -64,7 +64,7 @@ void tdm_SpawnTeam (string teamname, float teamcolor) this.netname = teamname; this.cnt = teamcolor; this.spawnfunc_checked = true; - WITHSELF(this, spawnfunc_tdm_team(this)); + spawnfunc_tdm_team(this); } void tdm_DelayedInit(entity this) diff --git a/qcsrc/server/sv_main.qc b/qcsrc/server/sv_main.qc index e1bf5c0be2..c842dac3f9 100644 --- a/qcsrc/server/sv_main.qc +++ b/qcsrc/server/sv_main.qc @@ -239,12 +239,14 @@ void StartFrame() bool DoesQ3ARemoveThisEntity(entity this); void SV_OnEntityPreSpawnFunction() {ENGINE_EVENT(); + __spawnfunc_expecting = true; __spawnfunc_expect = this; if (this) if (this.gametypefilter != "") if (!isGametypeInFilter(MapInfo_LoadedGametype, teamplay, have_team_spawns, this.gametypefilter)) { remove(this); + __spawnfunc_expecting = false; return; } if(this.cvarfilter != "") @@ -353,6 +355,7 @@ LABEL(cvar_fail) { //print("cvarfilter fail\n"); remove(this); + __spawnfunc_expecting = false; return; } } @@ -360,6 +363,7 @@ LABEL(cvar_fail) if(DoesQ3ARemoveThisEntity(this)) { remove(this); + __spawnfunc_expecting = false; return; } @@ -387,6 +391,7 @@ LABEL(cvar_fail) if(MUTATOR_CALLHOOK(OnEntityPreSpawn, this)) { remove(this); + __spawnfunc_expecting = false; return; } }