From: TimePath Date: Sat, 15 Aug 2015 06:38:11 +0000 (+1000) Subject: Convert some calls X-Git-Tag: xonotic-v0.8.2~2071^2~6 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=1bbaf70ab8695a98bca03502634de79bc9fe3d02;p=xonotic%2Fxonotic-data.pk3dir.git Convert some calls --- diff --git a/qcsrc/common/physics.qc b/qcsrc/common/physics.qc index 6153d80ae..0cac08bb0 100644 --- a/qcsrc/common/physics.qc +++ b/qcsrc/common/physics.qc @@ -553,12 +553,12 @@ bool PlayerJump (void) bool doublejump = false; float mjumpheight = PHYS_JUMPVELOCITY; - player_multijump = doublejump; - player_jumpheight = mjumpheight; #ifdef SVQC - if (MUTATOR_CALLHOOK(PlayerJump)) + if (MUTATOR_CALLHOOK(PlayerJump, doublejump, mjumpheight)) #elif defined(CSQC) - if(PM_multijump_checkjump()) + player_multijump = doublejump; + player_jumpheight = mjumpheight; + if (PM_multijump_checkjump()) #endif return true; diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 6d3d786ae..06bed1fc0 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -422,7 +422,7 @@ void PutClientInServer (void) // reset player keys self.itemkeys = 0; - MUTATOR_CALLHOOK(PutClientInServer); + MUTATOR_CALLHOOK(PutClientInServer, self); if(gameover) self.classname = "observer"; @@ -644,8 +644,7 @@ void PutClientInServer (void) Unfreeze(self); - spawn_spot = spot; - MUTATOR_CALLHOOK(PlayerSpawn); + MUTATOR_CALLHOOK(PlayerSpawn, spot); if(autocvar_spawn_debug) { diff --git a/qcsrc/server/cl_player.qc b/qcsrc/server/cl_player.qc index aae39ea66..1411ea339 100644 --- a/qcsrc/server/cl_player.qc +++ b/qcsrc/server/cl_player.qc @@ -549,11 +549,7 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, int deathtyp if(accuracy_isgooddamage(attacker, self)) attacker.accuracy.(accuracy_frags[w-1]) += 1; - frag_attacker = attacker; - frag_inflictor = inflictor; - frag_target = self; - frag_deathtype = deathtype; - MUTATOR_CALLHOOK(PlayerDies); + MUTATOR_CALLHOOK(PlayerDies, inflictor, attacker, self, deathtype); WEP_ACTION(self.weapon, WR_PLAYERDEATH); diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index c5bbfcab5..49dbae90a 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -147,10 +147,7 @@ void GiveFrags (entity attacker, entity targ, float f, int deathtype) entity oldself; oldself = self; self = attacker; - frag_attacker = attacker; - frag_target = targ; - frag_score = f; - if(MUTATOR_CALLHOOK(GiveFragsForKill)) + if(MUTATOR_CALLHOOK(GiveFragsForKill, attacker, targ, f)) { f = frag_score; self = oldself; diff --git a/qcsrc/server/mutators/base.qh b/qcsrc/server/mutators/base.qh index 4aea08447..8f22ef2f5 100644 --- a/qcsrc/server/mutators/base.qh +++ b/qcsrc/server/mutators/base.qh @@ -62,7 +62,7 @@ void Mutator_Remove(mutatorfunc_t func, string name); // calls error() on fail #define HANDLE_POPOUT(type, id) id = out_##id; #define MUTATOR_HOOKABLE(id, params) \ - _MUTATOR_HOOKABLE(id, int params(HANDLE_PARAMS, HANDLE_PARAMS)) { \ + _MUTATOR_HOOKABLE(id, int params(HANDLE_PARAMS, HANDLE_NOP)) { \ params(HANDLE_PUSHTMP, HANDLE_NOP) \ params(HANDLE_PREPARE, HANDLE_NOP) \ bool ret = CallbackChain_Call(HOOK_##id); \ @@ -79,49 +79,77 @@ void Mutator_Remove(mutatorfunc_t func, string name); // calls error() on fail #define EV_NO_ARGS(i, o) -MUTATOR_HOOKABLE(MakePlayerObserver, EV_NO_ARGS) - // called when a player becomes observer, after shared setup - -MUTATOR_HOOKABLE(PutClientInServer, EV_NO_ARGS); -// entity self; // client wanting to spawn - -MUTATOR_HOOKABLE(PlayerSpawn, EV_NO_ARGS); - entity spawn_spot; // spot that was used, or world - // called when a player spawns as player, after shared setup, before his weapon is chosen (so items may be changed in here) - -MUTATOR_HOOKABLE(reset_map_global, EV_NO_ARGS); - // called in reset_map - -MUTATOR_HOOKABLE(reset_map_players, EV_NO_ARGS); - // called in reset_map - -MUTATOR_HOOKABLE(ForbidPlayerScore_Clear, EV_NO_ARGS); - // returns 1 if clearing player score shall not be allowed - -MUTATOR_HOOKABLE(ClientDisconnect, EV_NO_ARGS); - // called when a player disconnects - -MUTATOR_HOOKABLE(PlayerDies, EV_NO_ARGS); - // called when a player dies to e.g. remove stuff he was carrying. - // INPUT: - entity frag_inflictor; - entity frag_attacker; - entity frag_target; // same as self - int frag_deathtype; - -MUTATOR_HOOKABLE(PlayerJump, EV_NO_ARGS); - // called when a player presses the jump key - // INPUT, OUTPUT: - float player_multijump; - float player_jumpheight; - -MUTATOR_HOOKABLE(GiveFragsForKill, EV_NO_ARGS); - // called when someone was fragged by "self", and is expected to change frag_score to adjust scoring for the kill - // INPUT: -// entity frag_attacker; // same as self -// entity frag_target; - // INPUT, OUTPUT: - float frag_score; +/** called when a player becomes observer, after shared setup */ +#define EV_MakePlayerObserver(i, o) \ + /**/ +MUTATOR_HOOKABLE(MakePlayerObserver, EV_MakePlayerObserver) + +/** */ +#define EV_PutClientInServer(i, o) \ + /** client wanting to spawn */ i(entity, self) \ + /**/ +MUTATOR_HOOKABLE(PutClientInServer, EV_PutClientInServer); + +/** called when a player spawns as player, after shared setup, before his weapon is chosen (so items may be changed in here) */ +#define EV_PlayerSpawn(i, o) \ + /** spot that was used, or world */ i(entity, spawn_spot) \ + /**/ +entity spawn_spot; +MUTATOR_HOOKABLE(PlayerSpawn, EV_PlayerSpawn); + +/** called in reset_map */ +#define EV_reset_map_global(i, o) \ + /**/ +MUTATOR_HOOKABLE(reset_map_global, EV_reset_map_global); + +/** called in reset_map */ +#define EV_reset_map_players(i, o) \ + /**/ +MUTATOR_HOOKABLE(reset_map_players, EV_reset_map_players); + +/** returns 1 if clearing player score shall not be allowed */ +#define EV_ForbidPlayerScore_Clear(i, o) \ + /**/ +MUTATOR_HOOKABLE(ForbidPlayerScore_Clear, EV_ForbidPlayerScore_Clear); + +/** called when a player disconnects */ +#define EV_ClientDisconnect(i, o) \ + /**/ +MUTATOR_HOOKABLE(ClientDisconnect, EV_ClientDisconnect); + +/** called when a player dies to e.g. remove stuff he was carrying. */ +#define EV_PlayerDies(i, o) \ + /**/ i(entity, frag_inflictor) \ + /**/ i(entity, frag_attacker) \ + /** same as self */ i(entity, frag_target) \ + /**/ i(int, frag_deathtype) \ + /**/ +entity frag_inflictor; +entity frag_attacker; +entity frag_target; +int frag_deathtype; +MUTATOR_HOOKABLE(PlayerDies, EV_PlayerDies); + +/** called when a player presses the jump key */ +#define EV_PlayerJump(i, o) \ + /**/ i(float, player_multijump) \ + /**/ i(float, player_jumpheight) \ + /**/ o(float, player_multijump) \ + /**/ o(float, player_jumpheight) \ + /**/ +float player_multijump; +float player_jumpheight; +MUTATOR_HOOKABLE(PlayerJump, EV_PlayerJump); + +/** called when someone was fragged by "self", and is expected to change frag_score to adjust scoring for the kill */ +#define EV_GiveFragsForKill(i, o) \ + /** same as self */ i(entity, frag_attacker) \ + /**/ i(entity, frag_target) \ + /**/ i(float, frag_score) \ + /**/ o(float, frag_score) \ + /**/ +float frag_score; +MUTATOR_HOOKABLE(GiveFragsForKill, EV_GiveFragsForKill); MUTATOR_HOOKABLE(MatchEnd, EV_NO_ARGS); // called when the match ends