From 704e0c494980a0c8489d4d8c8b34f98ba0d1b17c Mon Sep 17 00:00:00 2001 From: TimePath Date: Sat, 15 Aug 2015 20:00:31 +1000 Subject: [PATCH] Convert remaining calls --- qcsrc/server/bot/aim.qc | 3 +- qcsrc/server/bot/havocbot/roles.qc | 2 +- qcsrc/server/cheats.qc | 2 +- qcsrc/server/cl_client.qc | 2 +- qcsrc/server/cl_impulse.qc | 2 +- qcsrc/server/mutators/base.qh | 151 ++++++++++++++++++----------- qcsrc/server/t_items.qc | 6 +- qcsrc/server/vehicles/bumblebee.qc | 12 +-- qcsrc/server/vehicles/vehicle.qc | 14 +-- qcsrc/server/weapons/accuracy.qc | 4 +- 10 files changed, 105 insertions(+), 93 deletions(-) diff --git a/qcsrc/server/bot/aim.qc b/qcsrc/server/bot/aim.qc index c889a2f9a..e0dbdae26 100644 --- a/qcsrc/server/bot/aim.qc +++ b/qcsrc/server/bot/aim.qc @@ -143,8 +143,7 @@ float bot_shouldattack(entity e) if(e.flags & FL_NOTARGET) return false; - checkentity = e; - if(MUTATOR_CALLHOOK(BotShouldAttack)) + if(MUTATOR_CALLHOOK(BotShouldAttack, e)) return false; return true; diff --git a/qcsrc/server/bot/havocbot/roles.qc b/qcsrc/server/bot/havocbot/roles.qc index 65ea2a809..df6b8de91 100644 --- a/qcsrc/server/bot/havocbot/roles.qc +++ b/qcsrc/server/bot/havocbot/roles.qc @@ -242,7 +242,7 @@ void havocbot_chooserole() { dprint("choosing a role...\n"); self.bot_strategytime = 0; - if (MUTATOR_CALLHOOK(HavocBot_ChooseRole)) + if (MUTATOR_CALLHOOK(HavocBot_ChooseRole, self)) return; else if (g_keyhunt) havocbot_chooserole_kh(); diff --git a/qcsrc/server/cheats.qc b/qcsrc/server/cheats.qc index 0c6fc7f39..eb5538319 100644 --- a/qcsrc/server/cheats.qc +++ b/qcsrc/server/cheats.qc @@ -212,7 +212,7 @@ float CheatImpulse(float i) self.angles = self.personal.v_angle; self.fixangle = true; - MUTATOR_CALLHOOK(AbortSpeedrun); + MUTATOR_CALLHOOK(AbortSpeedrun, self); } self.ammo_rockets = self.personal.ammo_rockets; diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index b2080b76d..aa02de5b0 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -1279,7 +1279,7 @@ void ClientConnect (void) self = oldself; } - MUTATOR_CALLHOOK(ClientConnect); + MUTATOR_CALLHOOK(ClientConnect, self); } /* ============= diff --git a/qcsrc/server/cl_impulse.qc b/qcsrc/server/cl_impulse.qc index bb4c171c8..f37e8a462 100644 --- a/qcsrc/server/cl_impulse.qc +++ b/qcsrc/server/cl_impulse.qc @@ -186,7 +186,7 @@ void ImpulseCommands (void) case 33: if(self.deadflag == DEAD_NO && teamplay) { - if (!MUTATOR_CALLHOOK(HelpMePing)) + if (!MUTATOR_CALLHOOK(HelpMePing, self)) { wp = WaypointSprite_Attach("helpme", true, RADARICON_HELPME, '1 0.5 0'); if(!wp) diff --git a/qcsrc/server/mutators/base.qh b/qcsrc/server/mutators/base.qh index 9ffd08e8c..c12050caf 100644 --- a/qcsrc/server/mutators/base.qh +++ b/qcsrc/server/mutators/base.qh @@ -450,84 +450,117 @@ MUTATOR_HOOKABLE(Item_Spawn, EV_Item_Spawn); MUTATOR_HOOKABLE(SetWeaponreplace, EV_SetWeaponreplace); /** called when an item is about to respawn */ -MUTATOR_HOOKABLE(Item_RespawnCountdown, EV_NO_ARGS); - // INPUT+OUTPUT: - string item_name; - vector item_color; +#define EV_Item_RespawnCountdown(i, o) \ + /**/ i(string, item_name) \ + /**/ o(string, item_name) \ + /**/ i(vector, item_color) \ + /**/ o(vector, item_color) \ + /**/ +string item_name; +vector item_color; +MUTATOR_HOOKABLE(Item_RespawnCountdown, EV_Item_RespawnCountdown); /** called when a bot checks a target to attack */ -MUTATOR_HOOKABLE(BotShouldAttack, EV_NO_ARGS); - // INPUT - entity checkentity; +#define EV_BotShouldAttack(i, o) \ + /**/ i(entity, checkentity) \ + /**/ +entity checkentity; +MUTATOR_HOOKABLE(BotShouldAttack, EV_BotShouldAttack); /** * called whenever a player goes through a portal gun teleport * allows you to strip a player of an item if they go through the teleporter to help prevent cheating */ - #define EV_PortalTeleport(i, o) \ - /**/ i(entity, self) \ - /**/ +#define EV_PortalTeleport(i, o) \ + /**/ i(entity, self) \ + /**/ MUTATOR_HOOKABLE(PortalTeleport, EV_PortalTeleport); -MUTATOR_HOOKABLE(HelpMePing, EV_NO_ARGS); - // called whenever a player uses impulse 33 (help me) in cl_impulse.qc - // normally help me ping uses self.waypointsprite_attachedforcarrier, - // but if your mutator uses something different then you can handle it - // in a special manner using this hook - // INPUT -// entity self; // the player who pressed impulse 33 +/** + * called whenever a player uses impulse 33 (help me) in cl_impulse.qc + * normally help me ping uses self.waypointsprite_attachedforcarrier, + * but if your mutator uses something different then you can handle it + * in a special manner using this hook + */ +#define EV_HelpMePing(i, o) \ + /** the player who pressed impulse 33 */ i(entity, self) \ + /**/ +MUTATOR_HOOKABLE(HelpMePing, EV_HelpMePing); +/** + * called when a vehicle initializes + * return true to remove the vehicle + */ MUTATOR_HOOKABLE(VehicleSpawn, EV_NO_ARGS); - // called when a vehicle initializes - // return true to remove the vehicle - -MUTATOR_HOOKABLE(VehicleEnter, EV_NO_ARGS); - // called when a player enters a vehicle - // allows mutators to set special settings in this event - // INPUT - entity vh_player; // player - entity vh_vehicle; // vehicle - -MUTATOR_HOOKABLE(VehicleTouch, EV_NO_ARGS); - // called when a player touches a vehicle - // return true to stop player from entering the vehicle - // INPUT -// entity self; // vehicle -// entity other; // player - -MUTATOR_HOOKABLE(VehicleExit, EV_NO_ARGS); - // called when a player exits a vehicle - // allows mutators to set special settings in this event - // INPUT -// entity vh_player; // player -// entity vh_vehicle; // vehicle - -MUTATOR_HOOKABLE(AbortSpeedrun, EV_NO_ARGS); - // called when a speedrun is aborted and the player is teleported back to start position - // INPUT -// entity self; // player - -MUTATOR_HOOKABLE(ItemTouch, EV_NO_ARGS); - // called at when a item is touched. Called early, can edit item properties. -// entity self; // item -// entity other; // player + +/** + * called when a player enters a vehicle + * allows mutators to set special settings in this event + */ +#define EV_VehicleEnter(i, o) \ + /** player */ i(entity, vh_player) \ + /** vehicle */ i(entity, vh_vehicle) \ + /**/ +entity vh_player; +entity vh_vehicle; +MUTATOR_HOOKABLE(VehicleEnter, EV_VehicleEnter); + +/** + * called when a player touches a vehicle + * return true to stop player from entering the vehicle + */ +#define EV_VehicleTouch(i, o) \ + /** vehicle */ i(entity, self) \ + /** player */ i(entity, other) \ + /**/ +MUTATOR_HOOKABLE(VehicleTouch, EV_VehicleTouch); + +/** + * called when a player exits a vehicle + * allows mutators to set special settings in this event + */ +#define EV_VehicleExit(i, o) \ + /** player */ i(entity, vh_player) \ + /** vehicle */ i(entity, vh_vehicle) \ + /**/ +MUTATOR_HOOKABLE(VehicleExit, EV_VehicleExit); + +/** called when a speedrun is aborted and the player is teleported back to start position */ +#define EV_AbortSpeedrun(i, o) \ + /** player */ i(entity, self) \ + /**/ +MUTATOR_HOOKABLE(AbortSpeedrun, EV_AbortSpeedrun); + +/** called at when a item is touched. Called early, can edit item properties. */ +#define EV_ItemTouch(i, o) \ + /** item */ i(entity, self) \ + /** player */ i(entity, other) \ + /**/ +MUTATOR_HOOKABLE(ItemTouch, EV_ItemTouch); + enum { MUT_ITEMTOUCH_CONTINUE, // return this flag to make the function continue as normal MUT_ITEMTOUCH_RETURN, // return this flag to make the function return (handled entirely by mutator) MUT_ITEMTOUCH_PICKUP // return this flag to have the item "picked up" and taken even after mutator handled it }; -MUTATOR_HOOKABLE(ClientConnect, EV_NO_ARGS); - // called at when a player connect -// entity self; // player +/** called at when a player connect */ +#define EV_ClientConnect(i, o) \ + /** player */ i(entity, self) \ + /**/ +MUTATOR_HOOKABLE(ClientConnect, EV_ClientConnect); -MUTATOR_HOOKABLE(HavocBot_ChooseRole, EV_NO_ARGS); -// entity self; +#define EV_HavocBot_ChooseRole(i, o) \ + /**/ i(entity, self) \ + /**/ +MUTATOR_HOOKABLE(HavocBot_ChooseRole, EV_HavocBot_ChooseRole); -MUTATOR_HOOKABLE(AccuracyTargetValid, EV_NO_ARGS); - // called when a target is checked for accuracy -// entity frag_attacker; // attacker -// entity frag_target; // target +/** called when a target is checked for accuracy */ +#define EV_AccuracyTargetValid(i, o) \ + /** attacker */ i(entity, frag_attacker) \ + /** target */ i(entity, frag_target) \ + /**/ +MUTATOR_HOOKABLE(AccuracyTargetValid, EV_AccuracyTargetValid); enum { MUT_ACCADD_VALID, // return this flag to make the function continue if target is a client MUT_ACCADD_INVALID, // return this flag to make the function always continue diff --git a/qcsrc/server/t_items.qc b/qcsrc/server/t_items.qc index ffcf7624d..37af9ee86 100644 --- a/qcsrc/server/t_items.qc +++ b/qcsrc/server/t_items.qc @@ -644,9 +644,7 @@ void Item_RespawnCountdown (void) {name = "item_armor_large"; rgb = '0 1 0';} break; } - item_name = name; - item_color = rgb; - MUTATOR_CALLHOOK(Item_RespawnCountdown); + MUTATOR_CALLHOOK(Item_RespawnCountdown, name, rgb); name = item_name; rgb = item_color; if(self.flags & FL_WEAPON) @@ -903,7 +901,7 @@ void Item_Touch (void) if (time < self.item_spawnshieldtime) return; - switch(MUTATOR_CALLHOOK(ItemTouch)) + switch(MUTATOR_CALLHOOK(ItemTouch, self, other)) { case MUT_ITEMTOUCH_RETURN: { return; } case MUT_ITEMTOUCH_PICKUP: { goto pickup; } diff --git a/qcsrc/server/vehicles/bumblebee.qc b/qcsrc/server/vehicles/bumblebee.qc index 79eac74bb..5f124ff3b 100644 --- a/qcsrc/server/vehicles/bumblebee.qc +++ b/qcsrc/server/vehicles/bumblebee.qc @@ -162,11 +162,7 @@ void bumb_gunner_exit(float _exitflag) self.hud = HUD_NORMAL; self.switchweapon = self.vehicle.switchweapon; - vh_player = self; - vh_vehicle = self.vehicle; - MUTATOR_CALLHOOK(VehicleExit); - self = vh_player; - self.vehicle = vh_vehicle; + MUTATOR_CALLHOOK(VehicleExit, self, self.vehicle); self.vehicle.vehicle_hudmodel.viewmodelforclient = self.vehicle; @@ -250,11 +246,7 @@ float bumb_gunner_enter() CSQCVehicleSetup(other, other.hud); - vh_player = other; - vh_vehicle = _gun; - MUTATOR_CALLHOOK(VehicleEnter); - other = vh_player; - _gun = vh_vehicle; + MUTATOR_CALLHOOK(VehicleEnter, other, _gun); return true; } diff --git a/qcsrc/server/vehicles/vehicle.qc b/qcsrc/server/vehicles/vehicle.qc index e6a0f9c0e..50f355d73 100644 --- a/qcsrc/server/vehicles/vehicle.qc +++ b/qcsrc/server/vehicles/vehicle.qc @@ -550,7 +550,7 @@ void vehicles_impact(float _minspeed, float _speedfac, float _maxpain) void vehicles_touch() { - if(MUTATOR_CALLHOOK(VehicleTouch)) + if(MUTATOR_CALLHOOK(VehicleTouch, self, other)) return; // Vehicle currently in use @@ -683,11 +683,7 @@ void vehicles_enter() CSQCVehicleSetup(self.owner, self.hud); - vh_player = other; - vh_vehicle = self; - MUTATOR_CALLHOOK(VehicleEnter); - other = vh_player; - self = vh_vehicle; + MUTATOR_CALLHOOK(VehicleEnter, other, self); self.vehicle_enter(); antilag_clear(other); @@ -823,11 +819,7 @@ void vehicles_exit(float eject) if(!teamplay) _vehicle.team = 0; - vh_player = _player; - vh_vehicle = _vehicle; - MUTATOR_CALLHOOK(VehicleExit); - _player = vh_player; - _vehicle = vh_vehicle; + MUTATOR_CALLHOOK(VehicleExit, _player, _vehicle); _vehicle.team = _vehicle.tur_head.team; diff --git a/qcsrc/server/weapons/accuracy.qc b/qcsrc/server/weapons/accuracy.qc index 1ef81a409..d0dda35af 100644 --- a/qcsrc/server/weapons/accuracy.qc +++ b/qcsrc/server/weapons/accuracy.qc @@ -113,9 +113,7 @@ void accuracy_add(entity e, int w, float fired, float hit) float accuracy_isgooddamage(entity attacker, entity targ) { - frag_attacker = attacker; - frag_target = targ; - float mutator_check = MUTATOR_CALLHOOK(AccuracyTargetValid); + float mutator_check = MUTATOR_CALLHOOK(AccuracyTargetValid, attacker, targ); if(!warmup_stage) if(targ.deadflag == DEAD_NO) -- 2.39.2