From 6213aa0e9f5b5a9fcbc95062ae081788dd29d68e Mon Sep 17 00:00:00 2001 From: TimePath Date: Sat, 15 Aug 2015 17:15:57 +1000 Subject: [PATCH] Convert more calls --- qcsrc/common/monsters/sv_monsters.qc | 3 +- qcsrc/common/weapons/w_blaster.qc | 2 +- qcsrc/common/weapons/w_crylink.qc | 4 +- qcsrc/common/weapons/w_devastator.qc | 2 +- qcsrc/common/weapons/w_electro.qc | 4 +- qcsrc/common/weapons/w_fireball.qc | 4 +- qcsrc/common/weapons/w_hagar.qc | 6 +- qcsrc/common/weapons/w_hlac.qc | 4 +- qcsrc/common/weapons/w_hook.qc | 2 +- qcsrc/common/weapons/w_minelayer.qc | 2 +- qcsrc/common/weapons/w_mortar.qc | 4 +- qcsrc/common/weapons/w_porto.qc | 2 +- qcsrc/common/weapons/w_rpc.qc | 2 +- qcsrc/common/weapons/w_seeker.qc | 6 +- qcsrc/server/miscfunctions.qc | 5 +- qcsrc/server/mutators/base.qh | 61 ++++++++++++--------- qcsrc/server/tturrets/system/system_main.qc | 2 +- 17 files changed, 61 insertions(+), 54 deletions(-) diff --git a/qcsrc/common/monsters/sv_monsters.qc b/qcsrc/common/monsters/sv_monsters.qc index 239f8fe9a..540ad5ac7 100644 --- a/qcsrc/common/monsters/sv_monsters.qc +++ b/qcsrc/common/monsters/sv_monsters.qc @@ -1039,9 +1039,8 @@ void monsters_damage (entity inflictor, entity attacker, float damage, int death WaypointSprite_Kill(self.sprite); - frag_attacker = attacker; frag_target = self; - MUTATOR_CALLHOOK(MonsterDies); + MUTATOR_CALLHOOK(MonsterDies, attacker); if(self.health <= -100 || deathtype == DEATH_KILL) // check if we're already gibbed { diff --git a/qcsrc/common/weapons/w_blaster.qc b/qcsrc/common/weapons/w_blaster.qc index a776edbf4..1e41f9df8 100644 --- a/qcsrc/common/weapons/w_blaster.qc +++ b/qcsrc/common/weapons/w_blaster.qc @@ -136,7 +136,7 @@ void W_Blaster_Attack( missile.think = W_Blaster_Think; missile.nextthink = time + atk_delay; - other = missile; MUTATOR_CALLHOOK(EditProjectile); + MUTATOR_CALLHOOK(EditProjectile, self, missile); if(time >= missile.nextthink) { diff --git a/qcsrc/common/weapons/w_crylink.qc b/qcsrc/common/weapons/w_crylink.qc index 4d4430206..0825103d4 100644 --- a/qcsrc/common/weapons/w_crylink.qc +++ b/qcsrc/common/weapons/w_crylink.qc @@ -437,7 +437,7 @@ void W_Crylink_Attack(void) CSQCProjectile(proj, true, (proj.cnt ? PROJECTILE_CRYLINK_BOUNCING : PROJECTILE_CRYLINK), true); - other = proj; MUTATOR_CALLHOOK(EditProjectile); + MUTATOR_CALLHOOK(EditProjectile, self, proj); } if(WEP_CVAR_PRI(crylink, joinspread) != 0) { @@ -553,7 +553,7 @@ void W_Crylink_Attack2(void) CSQCProjectile(proj, true, (proj.cnt ? PROJECTILE_CRYLINK_BOUNCING : PROJECTILE_CRYLINK), true); - other = proj; MUTATOR_CALLHOOK(EditProjectile); + MUTATOR_CALLHOOK(EditProjectile, self, proj); } if(WEP_CVAR_SEC(crylink, joinspread) != 0) { diff --git a/qcsrc/common/weapons/w_devastator.qc b/qcsrc/common/weapons/w_devastator.qc index e9e0467e2..0dd8f80f7 100644 --- a/qcsrc/common/weapons/w_devastator.qc +++ b/qcsrc/common/weapons/w_devastator.qc @@ -388,7 +388,7 @@ void W_Devastator_Attack(void) W_AttachToShotorg(flash, '5 0 0'); // common properties - other = missile; MUTATOR_CALLHOOK(EditProjectile); + MUTATOR_CALLHOOK(EditProjectile, self, missile); } bool W_Devastator(int req) diff --git a/qcsrc/common/weapons/w_electro.qc b/qcsrc/common/weapons/w_electro.qc index e3b809296..0a219392e 100644 --- a/qcsrc/common/weapons/w_electro.qc +++ b/qcsrc/common/weapons/w_electro.qc @@ -284,7 +284,7 @@ void W_Electro_Attack_Bolt(void) CSQCProjectile(proj, true, PROJECTILE_ELECTRO_BEAM, true); - other = proj; MUTATOR_CALLHOOK(EditProjectile); + MUTATOR_CALLHOOK(EditProjectile, self, proj); } void W_Electro_Orb_Touch(void) @@ -400,7 +400,7 @@ void W_Electro_Attack_Orb(void) CSQCProjectile(proj, true, PROJECTILE_ELECTRO, false); // no culling, it has sound - other = proj; MUTATOR_CALLHOOK(EditProjectile); + MUTATOR_CALLHOOK(EditProjectile, self, proj); } void W_Electro_CheckAttack(void) diff --git a/qcsrc/common/weapons/w_fireball.qc b/qcsrc/common/weapons/w_fireball.qc index 7bb5ccb66..112b6524e 100644 --- a/qcsrc/common/weapons/w_fireball.qc +++ b/qcsrc/common/weapons/w_fireball.qc @@ -213,7 +213,7 @@ void W_Fireball_Attack1(void) CSQCProjectile(proj, true, PROJECTILE_FIREBALL, true); - other = proj; MUTATOR_CALLHOOK(EditProjectile); + MUTATOR_CALLHOOK(EditProjectile, self, proj); } void W_Fireball_AttackEffect(float i, vector f_diff) @@ -344,7 +344,7 @@ void W_Fireball_Attack2(void) CSQCProjectile(proj, true, PROJECTILE_FIREMINE, true); - other = proj; MUTATOR_CALLHOOK(EditProjectile); + MUTATOR_CALLHOOK(EditProjectile, self, proj); } bool W_Fireball(int req) diff --git a/qcsrc/common/weapons/w_hagar.qc b/qcsrc/common/weapons/w_hagar.qc index 4c9f66498..808d7733a 100644 --- a/qcsrc/common/weapons/w_hagar.qc +++ b/qcsrc/common/weapons/w_hagar.qc @@ -160,7 +160,7 @@ void W_Hagar_Attack(void) CSQCProjectile(missile, true, PROJECTILE_HAGAR, true); - other = missile; MUTATOR_CALLHOOK(EditProjectile); + MUTATOR_CALLHOOK(EditProjectile, self, missile); } void W_Hagar_Attack2(void) @@ -204,7 +204,7 @@ void W_Hagar_Attack2(void) CSQCProjectile(missile, true, PROJECTILE_HAGAR_BOUNCING, true); - other = missile; MUTATOR_CALLHOOK(EditProjectile); + MUTATOR_CALLHOOK(EditProjectile, self, missile); } .float hagar_loadstep, hagar_loadblock, hagar_loadbeep, hagar_warning; @@ -280,7 +280,7 @@ void W_Hagar_Attack2_Load_Release(void) CSQCProjectile(missile, true, PROJECTILE_HAGAR, true); - other = missile; MUTATOR_CALLHOOK(EditProjectile); + MUTATOR_CALLHOOK(EditProjectile, self, missile); } weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(hagar, load_animtime), w_ready); diff --git a/qcsrc/common/weapons/w_hlac.qc b/qcsrc/common/weapons/w_hlac.qc index 7f7d7a27b..e9c7ffee4 100644 --- a/qcsrc/common/weapons/w_hlac.qc +++ b/qcsrc/common/weapons/w_hlac.qc @@ -110,7 +110,7 @@ void W_HLAC_Attack(void) CSQCProjectile(missile, true, PROJECTILE_HLAC, true); - other = missile; MUTATOR_CALLHOOK(EditProjectile); + MUTATOR_CALLHOOK(EditProjectile, self, missile); } void W_HLAC_Attack2(void) @@ -154,7 +154,7 @@ void W_HLAC_Attack2(void) CSQCProjectile(missile, true, PROJECTILE_HLAC, true); - other = missile; MUTATOR_CALLHOOK(EditProjectile); + MUTATOR_CALLHOOK(EditProjectile, self, missile); } // weapon frames diff --git a/qcsrc/common/weapons/w_hook.qc b/qcsrc/common/weapons/w_hook.qc index 1c05c23d6..0c002bfc7 100644 --- a/qcsrc/common/weapons/w_hook.qc +++ b/qcsrc/common/weapons/w_hook.qc @@ -170,7 +170,7 @@ void W_Hook_Attack2(void) CSQCProjectile(gren, true, PROJECTILE_HOOKBOMB, true); - other = gren; MUTATOR_CALLHOOK(EditProjectile); + MUTATOR_CALLHOOK(EditProjectile, self, gren); } bool W_Hook(int req) diff --git a/qcsrc/common/weapons/w_minelayer.qc b/qcsrc/common/weapons/w_minelayer.qc index d4ef95547..32d999612 100644 --- a/qcsrc/common/weapons/w_minelayer.qc +++ b/qcsrc/common/weapons/w_minelayer.qc @@ -374,7 +374,7 @@ void W_MineLayer_Attack(void) // common properties - other = mine; MUTATOR_CALLHOOK(EditProjectile); + MUTATOR_CALLHOOK(EditProjectile, self, mine); self.minelayer_mines = W_MineLayer_Count(self); } diff --git a/qcsrc/common/weapons/w_mortar.qc b/qcsrc/common/weapons/w_mortar.qc index c958372af..a8c6a2c59 100644 --- a/qcsrc/common/weapons/w_mortar.qc +++ b/qcsrc/common/weapons/w_mortar.qc @@ -267,7 +267,7 @@ void W_Mortar_Attack(void) else CSQCProjectile(gren, true, PROJECTILE_GRENADE_BOUNCING, true); - other = gren; MUTATOR_CALLHOOK(EditProjectile); + MUTATOR_CALLHOOK(EditProjectile, self, gren); } void W_Mortar_Attack2(void) @@ -315,7 +315,7 @@ void W_Mortar_Attack2(void) else CSQCProjectile(gren, true, PROJECTILE_GRENADE_BOUNCING, true); - other = gren; MUTATOR_CALLHOOK(EditProjectile); + MUTATOR_CALLHOOK(EditProjectile, self, gren); } .float bot_secondary_grenademooth; diff --git a/qcsrc/common/weapons/w_porto.qc b/qcsrc/common/weapons/w_porto.qc index 82baf07bd..40964891d 100644 --- a/qcsrc/common/weapons/w_porto.qc +++ b/qcsrc/common/weapons/w_porto.qc @@ -283,7 +283,7 @@ void W_Porto_Attack(float type) else CSQCProjectile(gren, true, PROJECTILE_PORTO_RED, true); - other = gren; MUTATOR_CALLHOOK(EditProjectile); + MUTATOR_CALLHOOK(EditProjectile, self, gren); } bool w_nexball_weapon(int req); // WEAPONTODO diff --git a/qcsrc/common/weapons/w_rpc.qc b/qcsrc/common/weapons/w_rpc.qc index d641572c3..b7f7a4f87 100644 --- a/qcsrc/common/weapons/w_rpc.qc +++ b/qcsrc/common/weapons/w_rpc.qc @@ -143,7 +143,7 @@ void W_RocketPropelledChainsaw_Attack (void) W_AttachToShotorg(flash, '5 0 0'); missile.pos1 = missile.velocity; - other = missile; MUTATOR_CALLHOOK(EditProjectile); + MUTATOR_CALLHOOK(EditProjectile, self, missile); } bool W_RocketPropelledChainsaw(int req) diff --git a/qcsrc/common/weapons/w_seeker.qc b/qcsrc/common/weapons/w_seeker.qc index f338ed7ea..2dce3165b 100644 --- a/qcsrc/common/weapons/w_seeker.qc +++ b/qcsrc/common/weapons/w_seeker.qc @@ -293,7 +293,7 @@ void W_Seeker_Fire_Missile(vector f_diff, entity m_target) CSQCProjectile(missile, false, PROJECTILE_SEEKER, true); - other = missile; MUTATOR_CALLHOOK(EditProjectile); + MUTATOR_CALLHOOK(EditProjectile, self, missile); } // ============================ @@ -371,7 +371,7 @@ void W_Seeker_Fire_Flac(void) W_SetupProjVelocity_UP_PRE(missile, seeker, flac_); CSQCProjectile(missile, true, PROJECTILE_FLAC, true); - other = missile; MUTATOR_CALLHOOK(EditProjectile); + MUTATOR_CALLHOOK(EditProjectile, self, missile); } // ============================ @@ -589,7 +589,7 @@ void W_Seeker_Fire_Tag(void) CSQCProjectile(missile, true, PROJECTILE_TAG, false); // has sound - other = missile; MUTATOR_CALLHOOK(EditProjectile); + MUTATOR_CALLHOOK(EditProjectile, self, missile); } // ============================ diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 2354e128e..fa7cc0771 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -425,10 +425,7 @@ void GetCvars(float f) if (f > 0) s = strcat1(argv(f)); - get_cvars_f = f; - get_cvars_s = s; - - MUTATOR_CALLHOOK(GetCvars); + MUTATOR_CALLHOOK(GetCvars, f, s); Notification_GetCvars(); diff --git a/qcsrc/server/mutators/base.qh b/qcsrc/server/mutators/base.qh index b999ce3d7..2a9a48adb 100644 --- a/qcsrc/server/mutators/base.qh +++ b/qcsrc/server/mutators/base.qh @@ -212,46 +212,57 @@ MUTATOR_HOOKABLE(BuildMutatorsPrettyString, EV_BuildMutatorsPrettyString); /**/ MUTATOR_HOOKABLE(CustomizeWaypoint, EV_CustomizeWaypoint); +/** + * checks if the current item may be spawned (self.items and self.weapons may be read and written to, as well as the ammo_ fields) + * return error to request removal + */ MUTATOR_HOOKABLE(FilterItem, EV_NO_ARGS); - // checks if the current item may be spawned (self.items and self.weapons may be read and written to, as well as the ammo_ fields) - // return error to request removal -MUTATOR_HOOKABLE(TurretSpawn, EV_NO_ARGS); - // return error to request removal - // INPUT: self - turret +/** return error to request removal */ +#define EV_TurretSpawn(i, o) \ + /** turret */ i(entity, self) \ + /**/ +MUTATOR_HOOKABLE(TurretSpawn, EV_TurretSpawn); +/** return error to prevent entity spawn, or modify the entity */ MUTATOR_HOOKABLE(OnEntityPreSpawn, EV_NO_ARGS); - // return error to prevent entity spawn, or modify the entity +/** runs in the event loop for players; is called for ALL player entities, also bots, also the dead, or spectators */ MUTATOR_HOOKABLE(PlayerPreThink, EV_NO_ARGS); - // runs in the event loop for players; is called for ALL player entities, also bots, also the dead, or spectators +/** TODO change this into a general PlayerPostThink hook? */ MUTATOR_HOOKABLE(GetPressedKeys, EV_NO_ARGS); - // TODO change this into a general PlayerPostThink hook? +/** + * called before any player physics, may adjust variables for movement, + * is run AFTER bot code and idle checking + */ MUTATOR_HOOKABLE(PlayerPhysics, EV_NO_ARGS); - // called before any player physics, may adjust variables for movement, - // is run AFTER bot code and idle checking -MUTATOR_HOOKABLE(GetCvars, EV_NO_ARGS); - // is meant to call GetCvars_handle*(get_cvars_s, get_cvars_f, cvarfield, "cvarname") for cvars this mutator needs from the client - // INPUT: - float get_cvars_f; - string get_cvars_s; +/** is meant to call GetCvars_handle*(get_cvars_s, get_cvars_f, cvarfield, "cvarname") for cvars this mutator needs from the client */ +#define EV_GetCvars(i, o) \ + /**/ i(float, get_cvars_f) \ + /**/ i(string, get_cvars_s) \ + /**/ +float get_cvars_f; +string get_cvars_s; +MUTATOR_HOOKABLE(GetCvars, EV_GetCvars); -MUTATOR_HOOKABLE(EditProjectile, EV_NO_ARGS); - // can edit any "just fired" projectile - // INPUT: -// entity self; -// entity other; +/** can edit any "just fired" projectile */ +#define EV_EditProjectile(i, o) \ + /**/ i(entity, self) \ + /**/ i(entity, other) \ + /**/ +MUTATOR_HOOKABLE(EditProjectile, EV_EditProjectile); +/** called when a monster spawns */ MUTATOR_HOOKABLE(MonsterSpawn, EV_NO_ARGS); - // called when a monster spawns -MUTATOR_HOOKABLE(MonsterDies, EV_NO_ARGS); - // called when a monster dies - // INPUT: -// entity frag_attacker; +/** called when a monster dies */ +#define EV_MonsterDies(i, o) \ + /**/ i(entity, frag_attacker) \ + /**/ +MUTATOR_HOOKABLE(MonsterDies, EV_MonsterDies); MUTATOR_HOOKABLE(MonsterRespawn, EV_NO_ARGS); // called when a monster wants to respawn diff --git a/qcsrc/server/tturrets/system/system_main.qc b/qcsrc/server/tturrets/system/system_main.qc index 694ff5d45..7e843142b 100644 --- a/qcsrc/server/tturrets/system/system_main.qc +++ b/qcsrc/server/tturrets/system/system_main.qc @@ -1271,7 +1271,7 @@ float turret_stdproc_init (string cvar_base_name, string base, string head, floa self.health = 150; // Game hooks - if(MUTATOR_CALLHOOK(TurretSpawn)) + if(MUTATOR_CALLHOOK(TurretSpawn, self)) return 0; // End of default & sanety checks, start building the turret. -- 2.39.2