From f00146a481475e0fb4516f421fc471739cee3d29 Mon Sep 17 00:00:00 2001 From: TimePath Date: Sun, 27 Mar 2016 19:22:43 +1100 Subject: [PATCH] Propagate this --- .../gamemodes/gamemode/nexball/nexball.qc | 2 +- .../gamemodes/gamemode/onslaught/onslaught.qc | 22 +++++++++---------- qcsrc/common/mutators/mutator/buffs/buffs.qc | 4 ++-- qcsrc/common/net_notice.qc | 3 +-- qcsrc/common/t_items.qc | 4 ++-- qcsrc/common/t_items.qh | 2 +- qcsrc/common/triggers/func/door.qc | 12 +++++----- qcsrc/common/triggers/func/door_rotating.qc | 4 ++-- qcsrc/common/triggers/func/plat.qc | 2 +- qcsrc/common/triggers/func/train.qc | 4 ++-- qcsrc/common/triggers/func/vectormamamam.qc | 4 ++-- qcsrc/common/triggers/misc/follow.qc | 4 ++-- qcsrc/common/triggers/misc/laser.qc | 4 ++-- qcsrc/common/triggers/target/spawn.qc | 4 ++-- qcsrc/common/triggers/teleporters.qc | 3 +-- qcsrc/common/triggers/teleporters.qh | 2 +- qcsrc/common/triggers/trigger/gamestart.qc | 6 ++--- qcsrc/common/triggers/trigger/jumppads.qc | 10 ++++----- qcsrc/common/triggers/trigger/jumppads.qh | 2 +- qcsrc/common/triggers/trigger/viewloc.qc | 4 ++-- qcsrc/common/turrets/turret/walker.qc | 8 +++---- qcsrc/lib/defer.qh | 14 ++++++------ qcsrc/lib/self.qh | 12 ++++++++++ qcsrc/server/cheats.qc | 6 ++--- qcsrc/server/g_lights.qc | 9 +++----- qcsrc/server/g_models.qc | 10 ++++----- qcsrc/server/g_subs.qc | 4 ++-- qcsrc/server/g_subs.qh | 2 +- qcsrc/server/miscfunctions.qc | 12 +++++----- qcsrc/server/miscfunctions.qh | 4 ++-- .../mutators/mutator/gamemode_assault.qc | 21 +++++++++++------- qcsrc/server/mutators/mutator/gamemode_ctf.qc | 6 ++--- .../mutators/mutator/gamemode_domination.qc | 2 +- .../mutators/mutator/gamemode_invasion.qc | 2 +- .../mutators/mutator/gamemode_keepaway.qc | 14 ++++++------ qcsrc/server/mutators/mutator/gamemode_tdm.qc | 4 ++-- qcsrc/server/race.qc | 4 ++-- qcsrc/server/t_quake3.qc | 6 ++--- qcsrc/server/teamplay.qc | 2 +- qcsrc/server/teamplay.qh | 2 +- qcsrc/server/tests.qc | 4 ++-- 41 files changed, 131 insertions(+), 119 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc index 14ab8b470..1d500c1a6 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc @@ -498,7 +498,7 @@ void nb_spawnteams() } } -void nb_delayedinit() +void nb_delayedinit(entity this) { if(find(world, classname, "nexball_team") == world) nb_spawnteams(); diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc index 4fc4a982c..5271beba1 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc @@ -414,8 +414,8 @@ void ons_Link_CheckUpdate() self.nextthink = time; } -void ons_DelayedLinkSetup() -{SELFPARAM(); +void ons_DelayedLinkSetup(entity this) +{ self.goalentity = find(world, targetname, self.target); self.enemy = find(world, targetname, self.target2); if(!self.goalentity) { objerror("can not find target\n"); } @@ -855,8 +855,8 @@ void ons_ControlPoint_Reset(entity this) CSQCMODEL_AUTOUPDATE(this); } -void ons_DelayedControlPoint_Setup() -{SELFPARAM(); +void ons_DelayedControlPoint_Setup(entity this) +{ onslaught_updatelinks(); // captureshield setup @@ -1081,8 +1081,8 @@ void ons_GeneratorReset(entity this) onslaught_updatelinks(); } -void ons_DelayedGeneratorSetup() -{SELFPARAM(); +void ons_DelayedGeneratorSetup(entity this) +{ // bot waypoints waypoint_spawnforitem_force(self, self.origin); self.nearestwaypointtimeout = 0; // activate waypointing again @@ -1951,8 +1951,8 @@ MUTATOR_HOOKFUNCTION(ons, MonsterMove) return false; } -void ons_MonsterSpawn_Delayed() -{SELFPARAM(); +void ons_MonsterSpawn_Delayed(entity this) +{ entity e, own = self.owner; if(!own) { remove(self); return; } @@ -1981,8 +1981,8 @@ MUTATOR_HOOKFUNCTION(ons, MonsterSpawn) return false; } -void ons_TurretSpawn_Delayed() -{SELFPARAM(); +void ons_TurretSpawn_Delayed(entity this) +{ entity e, own = self.owner; if(!own) { remove(self); return; } @@ -2253,7 +2253,7 @@ void ons_ScoreRules() ScoreRules_basics_end(); } -void ons_DelayedInit() // Do this check with a delay so we can wait for teams to be set up +void ons_DelayedInit(entity this) // Do this check with a delay so we can wait for teams to be set up { ons_ScoreRules(); diff --git a/qcsrc/common/mutators/mutator/buffs/buffs.qc b/qcsrc/common/mutators/mutator/buffs/buffs.qc index 7de2a9062..15b725ee4 100644 --- a/qcsrc/common/mutators/mutator/buffs/buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/buffs.qc @@ -82,7 +82,7 @@ const vector BUFF_MAX = ('16 16 20'); #include .float buff_time = _STAT(BUFF_TIME); -void buffs_DelayedInit(); +void buffs_DelayedInit(entity this); REGISTER_MUTATOR(buffs, cvar("g_buffs")) { @@ -1045,7 +1045,7 @@ MUTATOR_HOOKFUNCTION(buffs, BuildMutatorsPrettyString) return false; } -void buffs_DelayedInit() +void buffs_DelayedInit(entity this) { if(autocvar_g_buffs_spawn_count > 0) if(find(world, classname, "item_buff") == world) diff --git a/qcsrc/common/net_notice.qc b/qcsrc/common/net_notice.qc index d67a1de3d..1e1726ae4 100644 --- a/qcsrc/common/net_notice.qc +++ b/qcsrc/common/net_notice.qc @@ -3,9 +3,8 @@ REGISTER_NET_TEMP(TE_CSQC_SVNOTICE) #ifdef SVQC -void sv_notice_join_think() +void sv_notice_join_think(entity this) { - SELFPARAM(); int argc = tokenizebyseparator(autocvar_sv_join_notices, "|"); if (argc <= 0) return; for (int i = 0; i < argc; ++i) diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index 75fec0103..87623da36 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -863,8 +863,8 @@ void Item_Reset(entity this) } void Item_Reset_self() { SELFPARAM(); Item_Reset(this); } -void Item_FindTeam() -{SELFPARAM(); +void Item_FindTeam(entity this) +{ entity e; if(self.effects & EF_NODRAW) diff --git a/qcsrc/common/t_items.qh b/qcsrc/common/t_items.qh index d6c97445f..1eb4b182d 100644 --- a/qcsrc/common/t_items.qh +++ b/qcsrc/common/t_items.qh @@ -92,7 +92,7 @@ void Item_Touch(); void Item_Reset(entity this); -void Item_FindTeam(); +void Item_FindTeam(entity this); // Savage: used for item garbage-collection bool ItemSend(entity this, entity to, int sf); diff --git a/qcsrc/common/triggers/func/door.qc b/qcsrc/common/triggers/func/door.qc index 0b250ef32..1e19dfafc 100644 --- a/qcsrc/common/triggers/func/door.qc +++ b/qcsrc/common/triggers/func/door.qc @@ -506,8 +506,8 @@ bool LinkDoors_isconnected(entity e1, entity e2, entity pass) #ifdef SVQC void door_link(); #endif -void LinkDoors() -{SELFPARAM(); +void LinkDoors(entity this) +{ entity t; vector cmins, cmaxs; @@ -693,8 +693,8 @@ void door_link() } #endif -void door_init_startopen() -{SELFPARAM(); +void door_init_startopen(entity this) +{ SUB_SETORIGIN(self, self.pos2); self.pos2 = self.pos1; self.pos1 = self.origin; @@ -850,10 +850,10 @@ NET_HANDLE(ENT_CLIENT_DOOR, bool isnew) this.drawmask = MASK_NORMAL; this.use = door_use; - LinkDoors(); + LinkDoors(this); if(this.spawnflags & DOOR_START_OPEN) - door_init_startopen(); + door_init_startopen(this); this.move_time = time; this.move_origin = this.origin; diff --git a/qcsrc/common/triggers/func/door_rotating.qc b/qcsrc/common/triggers/func/door_rotating.qc index 4f88e9e9b..4c97fe6a8 100644 --- a/qcsrc/common/triggers/func/door_rotating.qc +++ b/qcsrc/common/triggers/func/door_rotating.qc @@ -36,8 +36,8 @@ void door_rotating_reset(entity this) this.nextthink = 0; } -void door_rotating_init_startopen() -{SELFPARAM(); +void door_rotating_init_startopen(entity this) +{ self.angles = self.movedir; self.pos2 = '0 0 0'; self.pos1 = self.movedir; diff --git a/qcsrc/common/triggers/func/plat.qc b/qcsrc/common/triggers/func/plat.qc index ea546164c..14cfa5641 100644 --- a/qcsrc/common/triggers/func/plat.qc +++ b/qcsrc/common/triggers/func/plat.qc @@ -3,7 +3,7 @@ REGISTER_NET_LINKED(ENT_CLIENT_PLAT) #ifdef SVQC void plat_link(); -void plat_delayedinit() +void plat_delayedinit(entity this) { plat_link(); plat_spawn_inside_trigger(); // the "start moving" trigger diff --git a/qcsrc/common/triggers/func/train.qc b/qcsrc/common/triggers/func/train.qc index 26ecc81f1..2b27c7355 100644 --- a/qcsrc/common/triggers/func/train.qc +++ b/qcsrc/common/triggers/func/train.qc @@ -184,8 +184,8 @@ void train_use() self.use = func_null; // not again } -void func_train_find() -{SELFPARAM(); +void func_train_find(entity this) +{ entity targ; targ = find(world, targetname, self.target); self.target = targ.target; diff --git a/qcsrc/common/triggers/func/vectormamamam.qc b/qcsrc/common/triggers/func/vectormamamam.qc index 5c2086477..2dfa1ac98 100644 --- a/qcsrc/common/triggers/func/vectormamamam.qc +++ b/qcsrc/common/triggers/func/vectormamamam.qc @@ -71,8 +71,8 @@ void func_vectormamamam_controller_think() self.owner.velocity = (self.owner.destvec + func_vectormamamam_origin(self.owner, 0.1) - self.owner.origin) * 10; } -void func_vectormamamam_findtarget() -{SELFPARAM(); +void func_vectormamamam_findtarget(entity this) +{ if(self.target != "") self.wp00 = find(world, targetname, self.target); diff --git a/qcsrc/common/triggers/misc/follow.qc b/qcsrc/common/triggers/misc/follow.qc index 842248a4b..2ac304a21 100644 --- a/qcsrc/common/triggers/misc/follow.qc +++ b/qcsrc/common/triggers/misc/follow.qc @@ -1,8 +1,8 @@ // the way this entity works makes it no use to CSQC, as it removes itself instantly #ifdef SVQC -void follow_init() -{SELFPARAM(); +void follow_init(entity this) +{ entity src, dst; src = world; dst = world; diff --git a/qcsrc/common/triggers/misc/laser.qc b/qcsrc/common/triggers/misc/laser.qc index 0f05ce72a..48e23a287 100644 --- a/qcsrc/common/triggers/misc/laser.qc +++ b/qcsrc/common/triggers/misc/laser.qc @@ -49,8 +49,8 @@ void misc_laser_aim() } } -void misc_laser_init() -{SELFPARAM(); +void misc_laser_init(entity this) +{ if(self.target != "") self.enemy = find(world, targetname, self.target); } diff --git a/qcsrc/common/triggers/target/spawn.qc b/qcsrc/common/triggers/target/spawn.qc index 960e818b6..82793c936 100644 --- a/qcsrc/common/triggers/target/spawn.qc +++ b/qcsrc/common/triggers/target/spawn.qc @@ -297,8 +297,8 @@ void target_spawn_use() } } -void target_spawn_spawnfirst() -{SELFPARAM(); +void target_spawn_spawnfirst(entity this) +{ activator = self.target_spawn_activator; if(self.spawnflags & 2) target_spawn_use(); diff --git a/qcsrc/common/triggers/teleporters.qc b/qcsrc/common/triggers/teleporters.qc index afeabfcdd..04667f4cc 100644 --- a/qcsrc/common/triggers/teleporters.qc +++ b/qcsrc/common/triggers/teleporters.qc @@ -247,9 +247,8 @@ entity Simple_TeleportPlayer(entity teleporter, entity player) return e; } -void teleport_findtarget() +void teleport_findtarget(entity this) { - SELFPARAM(); int n = 0; entity e; for(e = world; (e = find(e, targetname, self.target)); ) diff --git a/qcsrc/common/triggers/teleporters.qh b/qcsrc/common/triggers/teleporters.qh index 0e9e23572..b0571dc31 100644 --- a/qcsrc/common/triggers/teleporters.qh +++ b/qcsrc/common/triggers/teleporters.qh @@ -19,7 +19,7 @@ entity Simple_TeleportPlayer(entity teleporter, entity player); void Teleport_Touch (); -void teleport_findtarget(); +void teleport_findtarget(entity this); entity Teleport_Find(vector mi, vector ma); diff --git a/qcsrc/common/triggers/trigger/gamestart.qc b/qcsrc/common/triggers/trigger/gamestart.qc index d90e3418c..9c0c0791a 100644 --- a/qcsrc/common/triggers/trigger/gamestart.qc +++ b/qcsrc/common/triggers/trigger/gamestart.qc @@ -1,6 +1,6 @@ #ifdef SVQC -void gamestart_use() -{SELFPARAM(); +void gamestart_use(entity this) +{ activator = self; SUB_UseTargets(); remove(self); @@ -9,7 +9,7 @@ void gamestart_use() void self_spawnfunc_trigger_gamestart(); spawnfunc(trigger_gamestart) { - this.use = gamestart_use; + setuse(this, gamestart_use); this.reset2 = self_spawnfunc_trigger_gamestart; if(this.wait) diff --git a/qcsrc/common/triggers/trigger/jumppads.qc b/qcsrc/common/triggers/trigger/jumppads.qc index 7b82c3959..556fe6635 100644 --- a/qcsrc/common/triggers/trigger/jumppads.qc +++ b/qcsrc/common/triggers/trigger/jumppads.qc @@ -274,10 +274,10 @@ void trigger_push_touch() #ifdef SVQC void trigger_push_link(); -void trigger_push_updatelink(); +void trigger_push_updatelink(entity this); #endif -void trigger_push_findtarget() -{SELFPARAM(); +void trigger_push_findtarget(entity this) +{ entity t; vector org; @@ -354,8 +354,8 @@ float trigger_push_send(entity this, entity to, float sf) return true; } -void trigger_push_updatelink() -{SELFPARAM(); +void trigger_push_updatelink(entity this) +{ this.SendFlags |= 1; } diff --git a/qcsrc/common/triggers/trigger/jumppads.qh b/qcsrc/common/triggers/trigger/jumppads.qh index 0c4180849..07973614b 100644 --- a/qcsrc/common/triggers/trigger/jumppads.qh +++ b/qcsrc/common/triggers/trigger/jumppads.qh @@ -38,7 +38,7 @@ vector trigger_push_calculatevelocity(vector org, entity tgt, float ht); void trigger_push_touch(); .vector dest; -void trigger_push_findtarget(); +void trigger_push_findtarget(entity this); /* * ENTITY PARAMETERS: diff --git a/qcsrc/common/triggers/trigger/viewloc.qc b/qcsrc/common/triggers/trigger/viewloc.qc index f7e694952..db75434bf 100644 --- a/qcsrc/common/triggers/trigger/viewloc.qc +++ b/qcsrc/common/triggers/trigger/viewloc.qc @@ -55,8 +55,8 @@ bool trigger_viewloc_send(entity this, entity to, int sf) return true; } -void viewloc_init() -{SELFPARAM(); +void viewloc_init(entity this) +{ entity e; for(e = world; (e = find(e, targetname, self.target)); ) if(e.classname == "target_viewlocation_start") diff --git a/qcsrc/common/turrets/turret/walker.qc b/qcsrc/common/turrets/turret/walker.qc index 491b5bbd9..918ce4ca3 100644 --- a/qcsrc/common/turrets/turret/walker.qc +++ b/qcsrc/common/turrets/turret/walker.qc @@ -73,8 +73,8 @@ float walker_firecheck() return turret_firecheck(); } -void walker_melee_do_dmg() -{SELFPARAM(); +void walker_melee_do_dmg(entity this) +{ vector where; entity e; @@ -92,8 +92,8 @@ void walker_melee_do_dmg() } } -void walker_setnoanim() -{SELFPARAM(); +void walker_setnoanim(entity this) +{ turrets_setframe(ANIM_NO, false); self.animflag = self.frame; } diff --git a/qcsrc/lib/defer.qh b/qcsrc/lib/defer.qh index 56014121f..d4c1eadac 100644 --- a/qcsrc/lib/defer.qh +++ b/qcsrc/lib/defer.qh @@ -28,18 +28,18 @@ SELFPARAM(); this.think = SUB_Remove_self; this.nextthink = time; - WITHSELF(this.owner, this.use()); + WITHSELF(this.owner, this.selfthink(this)); } -/* - Execute func() after time + fdelay. - self when func is executed = self when defer is called -*/ - void defer(entity this, float fdelay, void() func) + /** + * Execute func() after time + fdelay. + * self when func is executed = self when defer is called + */ + void defer(entity this, float fdelay, void(entity this) func) { entity e = new_pure(deferred); e.owner = this; - e.use = func; + setthink(e, func); e.think = defer_think; e.nextthink = time + fdelay; } diff --git a/qcsrc/lib/self.qh b/qcsrc/lib/self.qh index 5d53694c7..76607c7e4 100644 --- a/qcsrc/lib/self.qh +++ b/qcsrc/lib/self.qh @@ -32,3 +32,15 @@ #endif // Step 6: Remove SELFPARAM in favor of a parameter + +.void(entity this) selftouch; +void touch_self() { SELFPARAM(); this.selftouch(this); } +#define settouch(e, f) (e.use = touch_self, e.selftouch = f) + +.void(entity this) selfuse; +void use_self() { SELFPARAM(); this.selfuse(this); } +#define setuse(e, f) (e.use = use_self, e.selfuse = f) + +.void(entity this) selfthink; +void think_self() { SELFPARAM(); this.selfthink(this); } +#define setthink(e, f) (e.think = think_self, e.selfthink = f) diff --git a/qcsrc/server/cheats.qc b/qcsrc/server/cheats.qc index 933f4ac63..e13678dce 100644 --- a/qcsrc/server/cheats.qc +++ b/qcsrc/server/cheats.qc @@ -104,8 +104,8 @@ float CheatsAllowed(float i, float argc, float fr) // the cheat gets passed as a break float num_autoscreenshot; -void info_autoscreenshot_findtarget() -{SELFPARAM(); +void info_autoscreenshot_findtarget(entity this) +{ entity e; e = find(world, targetname, self.target); if(!e) @@ -696,7 +696,7 @@ float CheatCommand(float argc) setself(new(cheattriggerteleport)); setorigin(self, self.origin); self.target = argv(1); - teleport_findtarget(); + teleport_findtarget(self); if(!wasfreed(self)) { Simple_TeleportPlayer(self, this); diff --git a/qcsrc/server/g_lights.qc b/qcsrc/server/g_lights.qc index 74e03b7a0..5e9273f7c 100644 --- a/qcsrc/server/g_lights.qc +++ b/qcsrc/server/g_lights.qc @@ -42,9 +42,8 @@ void dynlight_think() self.nextthink = time + 0.1; } -void dynlight_find_aiment() +void dynlight_find_aiment(entity this) { - SELFPARAM(); entity targ; if (!self.target) objerror ("dynlight: no target to follow"); @@ -59,9 +58,8 @@ void dynlight_find_aiment() self.think = dynlight_think; self.nextthink = time + 0.1; } -void dynlight_find_path() +void dynlight_find_path(entity this) { - SELFPARAM(); entity targ; if (!self.target) objerror ("dynlight: no target to follow"); @@ -72,9 +70,8 @@ void dynlight_find_path() self.think = train_next; self.nextthink = time + 0.1; } -void dynlight_find_target() +void dynlight_find_target(entity this) { - SELFPARAM(); entity targ; if (!self.target) objerror ("dynlight: no target to follow"); diff --git a/qcsrc/server/g_models.qc b/qcsrc/server/g_models.qc index 6612b837c..baca56178 100644 --- a/qcsrc/server/g_models.qc +++ b/qcsrc/server/g_models.qc @@ -51,8 +51,8 @@ void g_clientmodel_use() g_clientmodel_setcolormaptoactivator(); } -void g_model_dropbyspawnflags() -{SELFPARAM(); +void g_model_dropbyspawnflags(entity this) +{ if((self.spawnflags & 3) == 1) // ALIGN_ORIGIN { traceline(self.origin, self.origin - '0 0 4096', MOVE_NOMONSTERS, self); @@ -70,11 +70,11 @@ void g_model_dropbyspawnflags() } } -void g_clientmodel_dropbyspawnflags() -{SELFPARAM(); +void g_clientmodel_dropbyspawnflags(entity this) +{ vector o0; o0 = self.origin; - g_model_dropbyspawnflags(); + g_model_dropbyspawnflags(self); if(self.origin != o0) self.SendFlags |= 2; } diff --git a/qcsrc/server/g_subs.qc b/qcsrc/server/g_subs.qc index c6a9d787f..a2cbc5a43 100644 --- a/qcsrc/server/g_subs.qc +++ b/qcsrc/server/g_subs.qc @@ -265,8 +265,8 @@ void LOD_uncustomize() this.modelindex = this.lodmodelindex0; } -void LODmodel_attach() -{SELFPARAM(); +void LODmodel_attach(entity this) +{ entity e; if(!this.loddistance1) diff --git a/qcsrc/server/g_subs.qh b/qcsrc/server/g_subs.qh index 90378d510..49bcd8904 100644 --- a/qcsrc/server/g_subs.qh +++ b/qcsrc/server/g_subs.qh @@ -143,7 +143,7 @@ float LOD_customize(); void LOD_uncustomize(); -void LODmodel_attach(); +void LODmodel_attach(entity this); void ApplyMinMaxScaleAngles(entity e); diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index bb5f176b6..72747037d 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -851,7 +851,7 @@ void remove_safely(entity e) builtin_remove(e); } -void InitializeEntity(entity e, void() func, float order) +void InitializeEntity(entity e, void(entity this) func, float order) { entity prev, cur; @@ -885,7 +885,7 @@ void InitializeEntity(entity e, void() func, float order) } } void InitializeEntitiesRun() -{SELFPARAM(); +{ entity startoflist = initialize_entity_first; initialize_entity_first = NULL; remove = remove_except_protected; @@ -899,7 +899,7 @@ void InitializeEntitiesRun() e.initialize_entity_order = 0; entity next = e.initialize_entity_next; e.initialize_entity_next = NULL; - var void() func = e.initialize_entity; + var void(entity this) func = e.initialize_entity; e.initialize_entity = func_null; if (e.classname == "initialize_entity") { @@ -910,7 +910,7 @@ void InitializeEntitiesRun() //dprint("Delayed initialization: ", e.classname, "\n"); if (func) { - WITHSELF(e, func()); + WITHSELF(e, func(e)); } else { @@ -987,8 +987,8 @@ void adaptor_think2use_hittype_splash() // for timed projectile detonation } // deferred dropping -void DropToFloor_Handler() -{SELFPARAM(); +void DropToFloor_Handler(entity this) +{ builtin_droptofloor(); self.dropped_origin = self.origin; } diff --git a/qcsrc/server/miscfunctions.qh b/qcsrc/server/miscfunctions.qh index d828d70f9..04221e439 100644 --- a/qcsrc/server/miscfunctions.qh +++ b/qcsrc/server/miscfunctions.qh @@ -357,7 +357,7 @@ const float INITPRIO_SETLOCATION = 90; const float INITPRIO_LINKDOORS = 91; const float INITPRIO_LAST = 99; -.void() initialize_entity; +.void(entity this) initialize_entity; .float initialize_entity_order; .entity initialize_entity_next; entity initialize_entity_first; @@ -367,5 +367,5 @@ entity initialize_entity_first; float sound_allowed(float dest, entity e); -void InitializeEntity(entity e, void() func, float order); +void InitializeEntity(entity e, void(entity this) func, float order); void SetCustomizer(entity e, float() customizer, void() uncustomizer); diff --git a/qcsrc/server/mutators/mutator/gamemode_assault.qc b/qcsrc/server/mutators/mutator/gamemode_assault.qc index e017f8a17..34c19d425 100644 --- a/qcsrc/server/mutators/mutator/gamemode_assault.qc +++ b/qcsrc/server/mutators/mutator/gamemode_assault.qc @@ -147,8 +147,8 @@ void assault_objective_decrease_use() } } -void assault_setenemytoobjective() -{SELFPARAM(); +void assault_setenemytoobjective(entity this) +{ entity objective; for(objective = world; (objective = find(objective, targetname, self.target)); ) { @@ -208,9 +208,9 @@ void target_objective_decrease_activate() } } -void target_objective_decrease_findtarget() +void target_objective_decrease_findtarget(entity this) { - assault_setenemytoobjective(); + assault_setenemytoobjective(this); } void target_assault_roundend_reset(entity this) @@ -225,8 +225,8 @@ void target_assault_roundend_use() self.winning = 1; // round has been won by attackers } -void assault_roundstart_use() -{SELFPARAM(); +void assault_roundstart_use(entity this) +{ activator = self; SUB_UseTargets(); @@ -242,6 +242,11 @@ void assault_roundstart_use() WITHSELF(it, turret_respawn()); )); } +void assault_roundstart_use_self() +{ + SELFPARAM(); + assault_roundstart_use(this); +} void assault_wall_think() {SELFPARAM(); @@ -432,8 +437,8 @@ spawnfunc(target_assault_roundstart) assault_attacker_team = NUM_TEAM_1; self.classname = "target_assault_roundstart"; - self.use = assault_roundstart_use; - self.reset2 = assault_roundstart_use; + self.use = assault_roundstart_use_self; + self.reset2 = assault_roundstart_use_self; InitializeEntity(self, assault_roundstart_use, INITPRIO_FINDTARGET); } diff --git a/qcsrc/server/mutators/mutator/gamemode_ctf.qc b/qcsrc/server/mutators/mutator/gamemode_ctf.qc index 9cd6e3772..a7d6fb2a1 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ctf.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ctf.qc @@ -1158,8 +1158,8 @@ void ctf_Reset(entity this) ctf_RespawnFlag(this); } -void ctf_DelayedFlagSetup() // called after a flag is placed on a map by ctf_FlagSetup() -{SELFPARAM(); +void ctf_DelayedFlagSetup(entity this) // called after a flag is placed on a map by ctf_FlagSetup() +{ // bot waypoints waypoint_spawnforitem_force(self, self.origin); self.nearestwaypointtimeout = 0; // activate waypointing again @@ -2554,7 +2554,7 @@ void ctf_SpawnTeam (string teamname, int teamcolor) WITHSELF(this, spawnfunc_ctf_team(this)); } -void ctf_DelayedInit() // Do this check with a delay so we can wait for teams to be set up. +void ctf_DelayedInit(entity this) // Do this check with a delay so we can wait for teams to be set up. { ctf_teams = 2; diff --git a/qcsrc/server/mutators/mutator/gamemode_domination.qc b/qcsrc/server/mutators/mutator/gamemode_domination.qc index ba6a48f35..01f17ec9f 100644 --- a/qcsrc/server/mutators/mutator/gamemode_domination.qc +++ b/qcsrc/server/mutators/mutator/gamemode_domination.qc @@ -681,7 +681,7 @@ void dom_spawnteams(int teams) dom_spawnteam("", 0, "models/domination/dom_unclaimed.md3", 0, SND_Null, "", ""); } -void dom_DelayedInit() // Do this check with a delay so we can wait for teams to be set up. +void dom_DelayedInit(entity this) // Do this check with a delay so we can wait for teams to be set up. { // if no teams are found, spawn defaults if(find(world, classname, "dom_team") == world || autocvar_g_domination_teams_override >= 2) diff --git a/qcsrc/server/mutators/mutator/gamemode_invasion.qc b/qcsrc/server/mutators/mutator/gamemode_invasion.qc index 7b2972c84..efb6842e5 100644 --- a/qcsrc/server/mutators/mutator/gamemode_invasion.qc +++ b/qcsrc/server/mutators/mutator/gamemode_invasion.qc @@ -482,7 +482,7 @@ void invasion_ScoreRules(float inv_teams) ScoreRules_basics_end(); } -void invasion_DelayedInit() // Do this check with a delay so we can wait for teams to be set up. +void invasion_DelayedInit(entity this) // Do this check with a delay so we can wait for teams to be set up. { if(autocvar_g_invasion_teams) invasion_teams = bound(2, autocvar_g_invasion_teams, 4); diff --git a/qcsrc/server/mutators/mutator/gamemode_keepaway.qc b/qcsrc/server/mutators/mutator/gamemode_keepaway.qc index 465479560..66ac8a80e 100644 --- a/qcsrc/server/mutators/mutator/gamemode_keepaway.qc +++ b/qcsrc/server/mutators/mutator/gamemode_keepaway.qc @@ -82,8 +82,8 @@ void ka_EventLog(string mode, entity actor) // use an alias for easy changing an } void ka_TouchEvent(); -void ka_RespawnBall() // runs whenever the ball needs to be relocated -{SELFPARAM(); +void ka_RespawnBall(entity this) // runs whenever the ball needs to be relocated +{ if(gameover) { return; } vector oldballorigin = self.origin; @@ -100,7 +100,7 @@ void ka_RespawnBall() // runs whenever the ball needs to be relocated self.angles = '0 0 0'; self.effects = autocvar_g_keepawayball_effects; self.touch = ka_TouchEvent; - self.think = ka_RespawnBall; + setthink(self, ka_RespawnBall); self.nextthink = time + autocvar_g_keepawayball_respawntime; Send_Effect(EFFECT_ELECTRO_COMBO, oldballorigin, '0 0 0', 1); @@ -130,7 +130,7 @@ void ka_TouchEvent() // runs any time that the ball comes in contact with someth if(!self) { return; } if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT) { // The ball fell off the map, respawn it since players can't get to it - ka_RespawnBall(); + ka_RespawnBall(self); return; } if(IS_DEAD(other)) { return; } @@ -193,7 +193,7 @@ void ka_DropEvent(entity plyr) // runs any time that a player is supposed to los ball.movetype = MOVETYPE_BOUNCE; ball.wait = time + 1; ball.touch = ka_TouchEvent; - ball.think = ka_RespawnBall; + setthink(ball, ka_RespawnBall); ball.nextthink = time + autocvar_g_keepawayball_respawntime; ball.takedamage = DAMAGE_YES; ball.effects &= ~EF_NODRAW; @@ -230,12 +230,12 @@ void ka_Reset(entity this) if(time < game_starttime) { - this.think = ka_RespawnBall; + setthink(this, ka_RespawnBall); this.touch = func_null; this.nextthink = game_starttime; } else - ka_RespawnBall(); + ka_RespawnBall(this); } diff --git a/qcsrc/server/mutators/mutator/gamemode_tdm.qc b/qcsrc/server/mutators/mutator/gamemode_tdm.qc index 2ba975c0d..078e3517d 100644 --- a/qcsrc/server/mutators/mutator/gamemode_tdm.qc +++ b/qcsrc/server/mutators/mutator/gamemode_tdm.qc @@ -5,7 +5,7 @@ int autocvar_g_tdm_point_limit; int autocvar_g_tdm_point_leadlimit; bool autocvar_g_tdm_team_spawns; -void tdm_DelayedInit(); +void tdm_DelayedInit(entity this); REGISTER_MUTATOR(tdm, false) { @@ -67,7 +67,7 @@ void tdm_SpawnTeam (string teamname, float teamcolor) WITHSELF(this, spawnfunc_tdm_team(this)); } -void tdm_DelayedInit() +void tdm_DelayedInit(entity this) { // if no teams are found, spawn defaults if(find(world, classname, "tdm_team") == world) diff --git a/qcsrc/server/race.qc b/qcsrc/server/race.qc index 8b46c210b..79dc8d4b8 100644 --- a/qcsrc/server/race.qc +++ b/qcsrc/server/race.qc @@ -727,8 +727,8 @@ float race_waypointsprite_visible_for_player(entity e) } float have_verified; -void trigger_race_checkpoint_verify() -{SELFPARAM(); +void trigger_race_checkpoint_verify(entity this) +{ entity cp; float i, p; float qual; diff --git a/qcsrc/server/t_quake3.qc b/qcsrc/server/t_quake3.qc index d6f3559cd..ef614c7ac 100644 --- a/qcsrc/server/t_quake3.qc +++ b/qcsrc/server/t_quake3.qc @@ -68,7 +68,7 @@ spawnfunc(item_enviro) { spawnfunc_item_invincible(this); } .float delay; // weapon remove ent from df -void target_init_verify() +void target_init_verify(entity this) { entity trigger, targ; for(trigger = world; (trigger = find(trigger, classname, "trigger_multiple")); ) @@ -95,8 +95,8 @@ spawnfunc(target_init) } // weapon give ent from defrag -void target_give_init() -{SELFPARAM(); +void target_give_init(entity this) +{ entity targ; for (targ = world; (targ = find(targ, targetname, self.target)); ) { if (targ.classname == "weapon_rocketlauncher" || targ.classname == "weapon_devastator") { diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index fabeaeced..8dd466711 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -31,7 +31,7 @@ void LogTeamchange(float player_id, float team_number, float type) GameLogEcho(strcat(":team:", ftos(player_id), ":", ftos(team_number), ":", ftos(type))); } -void default_delayedinit() +void default_delayedinit(entity this) { if(!scores_initialized) ScoreRules_generic(); diff --git a/qcsrc/server/teamplay.qh b/qcsrc/server/teamplay.qh index e24005a32..2a3a528fe 100644 --- a/qcsrc/server/teamplay.qh +++ b/qcsrc/server/teamplay.qh @@ -16,7 +16,7 @@ void TeamchangeFrags(entity e); void LogTeamchange(float player_id, float team_number, float type); -void default_delayedinit(); +void default_delayedinit(entity this); void ActivateTeamplay(); diff --git a/qcsrc/server/tests.qc b/qcsrc/server/tests.qc index b0e21e746..7bbf00dc5 100644 --- a/qcsrc/server/tests.qc +++ b/qcsrc/server/tests.qc @@ -1,7 +1,7 @@ #include "tests.qh" -void test_weapons_hurt() { - SELFPARAM(); +void test_weapons_hurt(entity this) +{ EXPECT_NE(100, this.health); remove(this.enemy); remove(this); -- 2.39.2