From: Mario Date: Fri, 10 Jun 2016 08:34:27 +0000 (+1000) Subject: Cleanse the last of the server side mutator hooks X-Git-Tag: xonotic-v0.8.2~863 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=60f1d438734b77eaa91b2cd3985edf216e34f0bf;p=xonotic%2Fxonotic-data.pk3dir.git Cleanse the last of the server side mutator hooks --- diff --git a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc index a7528d5a1..110141476 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc @@ -1096,8 +1096,7 @@ MUTATOR_HOOKFUNCTION(nb, DropSpecialItems) MUTATOR_HOOKFUNCTION(nb, SendWaypoint) { - wp_sendflags &= ~0x80; - return false; + M_ARGV(2, int) &= ~0x80; } REGISTER_MUTATOR(nb, g_nexball) diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc index e91958d28..96c3ac719 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc @@ -2130,25 +2130,29 @@ MUTATOR_HOOKFUNCTION(ons, PlayHitsound) MUTATOR_HOOKFUNCTION(ons, SendWaypoint) { - SELFPARAM(); - if(wp_sendflags & 16) + entity wp = M_ARGV(0, entity); + entity to = M_ARGV(1, entity); + int sf = M_ARGV(2, int); + int wp_flag = M_ARGV(3, int); + + if(sf & 16) { - if(self.owner.classname == "onslaught_controlpoint") + if(wp.owner.classname == "onslaught_controlpoint") { - entity wp_owner = self.owner; - entity e = WaypointSprite_getviewentity(wp_sendto); + entity wp_owner = wp.owner; + entity e = WaypointSprite_getviewentity(to); if(SAME_TEAM(e, wp_owner) && wp_owner.goalentity.health >= wp_owner.goalentity.max_health) { wp_flag |= 2; } if(!ons_ControlPoint_Attackable(wp_owner, e.team)) { wp_flag |= 2; } } - if(self.owner.classname == "onslaught_generator") + if(wp.owner.classname == "onslaught_generator") { - entity wp_owner = self.owner; + entity wp_owner = wp.owner; if(wp_owner.isshielded && wp_owner.health >= wp_owner.max_health) { wp_flag |= 2; } if(wp_owner.health <= 0) { wp_flag |= 2; } } } - return false; + M_ARGV(3, int) = wp_flag; } MUTATOR_HOOKFUNCTION(ons, TurretValidateTarget) @@ -2166,19 +2170,18 @@ MUTATOR_HOOKFUNCTION(ons, TurretValidateTarget) MUTATOR_HOOKFUNCTION(ons, TurretThink) { - SELFPARAM(); + entity turret = M_ARGV(0, entity); + // ONS uses somewhat backwards linking. - if(self.target) + if(turret.target) { - entity e = find(world, targetname, self.target); + entity e = find(world, targetname, turret.target); if (e != world) - self.team = e.team; + turret.team = e.team; } - if(self.team != self.tur_head.team) - turret_respawn(self); - - return false; + if(turret.team != turret.tur_head.team) + turret_respawn(turret); } diff --git a/qcsrc/common/monsters/all.qc b/qcsrc/common/monsters/all.qc index ce0a9023d..fa3f65193 100644 --- a/qcsrc/common/monsters/all.qc +++ b/qcsrc/common/monsters/all.qc @@ -6,7 +6,7 @@ string M_Model(string m_mdl) string output = strcat("models/monsters/", m_mdl); #ifdef SVQC MUTATOR_CALLHOOK(MonsterModel, m_mdl, output); - return monster_model_output; + return M_ARGV(1, string); #else return output; #endif diff --git a/qcsrc/server/bot/bot.qc b/qcsrc/server/bot/bot.qc index ef08e308c..cde59c6de 100644 --- a/qcsrc/server/bot/bot.qc +++ b/qcsrc/server/bot/bot.qc @@ -557,8 +557,8 @@ float bot_fixcount() int activerealplayers = 0; int realplayers = 0; if (MUTATOR_CALLHOOK(Bot_FixCount, activerealplayers, realplayers)) { - activerealplayers = bot_activerealplayers; - realplayers = bot_realplayers; + activerealplayers = M_ARGV(0, int); + realplayers = M_ARGV(1, int); } else { FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA( if(IS_PLAYER(it)) diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 903d1de25..43298c026 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -1698,7 +1698,7 @@ bool Spectate(entity pl) {SELFPARAM(); if(MUTATOR_CALLHOOK(SpectateSet, this, pl)) return false; - pl = spec_player; + pl = M_ARGV(1, entity); SetSpectatee(this, pl); return SpectateSet(); @@ -1709,7 +1709,7 @@ bool SpectateNext() other = find(this.enemy, classname, STR_PLAYER); if (MUTATOR_CALLHOOK(SpectateNext, this, other)) - other = spec_player; + other = M_ARGV(1, entity); else if (!other) other = find(other, classname, STR_PLAYER); @@ -1734,10 +1734,10 @@ bool SpectatePrev() switch (MUTATOR_CALLHOOK(SpectatePrev, this, other, first)) { case MUT_SPECPREV_FOUND: - other = spec_player; + other = M_ARGV(1, entity); break; case MUT_SPECPREV_RETURN: - other = spec_player; + other = M_ARGV(1, entity); return true; case MUT_SPECPREV_CONTINUE: default: diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index 0d692ba2f..f7782504b 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -123,7 +123,7 @@ MUTATOR_HOOKABLE(ForbidThrowCurrentWeapon, EV_ForbidThrowCurrentWeapon); /** returns true if dropping the current weapon shall not be allowed at any time including death */ #define EV_ForbidDropCurrentWeapon(i, o) \ - /** player */ i(entity, MUTATOR_ARGV_0_entity) \ + /** player */ i(entity, MUTATOR_ARGV_0_entity) \ /**/ MUTATOR_HOOKABLE(ForbidDropCurrentWeapon, EV_ForbidDropCurrentWeapon); @@ -656,27 +656,25 @@ MUTATOR_HOOKABLE(ClientKill, EV_ClientKill); MUTATOR_HOOKABLE(FixClientCvars, EV_FixClientCvars); #define EV_SpectateSet(i, o) \ - /**/ i(entity, __self) \ - /**/ i(entity, spec_player) \ - /**/ o(entity, spec_player) \ + /** client */ i(entity, MUTATOR_ARGV_0_entity) \ + /** target */ i(entity, MUTATOR_ARGV_1_entity) \ + /**/ o(entity, MUTATOR_ARGV_1_entity) \ /**/ -entity spec_player; MUTATOR_HOOKABLE(SpectateSet, EV_SpectateSet); #define EV_SpectateNext(i, o) \ - /**/ i(entity, __self) \ - /**/ i(entity, spec_player) \ - /**/ o(entity, spec_player) \ + /** client */ i(entity, MUTATOR_ARGV_0_entity) \ + /** target */ i(entity, MUTATOR_ARGV_1_entity) \ + /**/ o(entity, MUTATOR_ARGV_1_entity) \ /**/ MUTATOR_HOOKABLE(SpectateNext, EV_SpectateNext); #define EV_SpectatePrev(i, o) \ - /**/ i(entity, __self) \ - /**/ i(entity, spec_player) \ - /**/ o(entity, spec_player) \ - /**/ i(entity, spec_first) \ + /** client */ i(entity, MUTATOR_ARGV_0_entity) \ + /** target */ i(entity, MUTATOR_ARGV_1_entity) \ + /**/ o(entity, MUTATOR_ARGV_1_entity) \ + /** first */ i(entity, MUTATOR_ARGV_2_entity) \ /**/ -entity spec_first; MUTATOR_HOOKABLE(SpectatePrev, EV_SpectatePrev); enum { @@ -687,17 +685,15 @@ enum { /** called when player triggered kill (or is changing teams), return error to not do anything */ #define EV_Bot_FixCount(i, o) \ - /**/ i(int, bot_activerealplayers) \ - /**/ o(int, bot_activerealplayers) \ - /**/ i(int, bot_realplayers) \ - /**/ o(int, bot_realplayers) \ + /** active real players */ i(int, MUTATOR_ARGV_0_int) \ + /**/ o(int, MUTATOR_ARGV_0_int) \ + /** real players */ i(int, MUTATOR_ARGV_1_int) \ + /**/ o(int, MUTATOR_ARGV_1_int) \ /**/ -int bot_activerealplayers; -int bot_realplayers; MUTATOR_HOOKABLE(Bot_FixCount, EV_Bot_FixCount); #define EV_ClientCommand_Spectate(i, o) \ - /**/ i(entity, __self) \ + /** player */ i(entity, MUTATOR_ARGV_0_entity) \ /**/ MUTATOR_HOOKABLE(ClientCommand_Spectate, EV_ClientCommand_Spectate); @@ -762,16 +758,13 @@ MUTATOR_HOOKABLE(AllowMobButcher, EV_AllowMobButcher); MUTATOR_HOOKABLE(ReadLevelCvars, EV_NO_ARGS); #define EV_SendWaypoint(i, o) \ - /**/ i(entity, __self) \ - /**/ i(entity, wp_sendto) \ - /**/ i(int, wp_sendflags) \ - /**/ o(int, wp_sendflags) \ - /**/ i(int, wp_flag) \ - /**/ o(int, wp_flag) \ - /**/ -entity wp_sendto; -int wp_sendflags; -int wp_flag; + /** waypoint */ i(entity, MUTATOR_ARGV_0_entity) \ + /** to */ i(entity, MUTATOR_ARGV_1_entity) \ + /** send flags */ i(int, MUTATOR_ARGV_2_int) \ + /**/ o(int, MUTATOR_ARGV_2_int) \ + /** wp flag */ i(int, MUTATOR_ARGV_3_int) \ + /**/ o(int, MUTATOR_ARGV_3_int) \ + /**/ MUTATOR_HOOKABLE(SendWaypoint, EV_SendWaypoint); #define EV_TurretValidateTarget(i, o) \ @@ -783,7 +776,7 @@ MUTATOR_HOOKABLE(SendWaypoint, EV_SendWaypoint); MUTATOR_HOOKABLE(TurretValidateTarget, EV_TurretValidateTarget); #define EV_TurretThink(i, o) \ - /**/ i(entity, __self) \ + /** turret */ i(entity, MUTATOR_ARGV_0_entity) \ /**/ MUTATOR_HOOKABLE(TurretThink, EV_TurretThink); @@ -792,37 +785,30 @@ MUTATOR_HOOKABLE(Ent_Init, EV_NO_ARGS); /** */ #define EV_PrepareExplosionByDamage(i, o) \ /** projectile */ i(entity, MUTATOR_ARGV_0_entity) \ - /** attacker */ i(entity, MUTATOR_ARGV_1_entity) \ + /** attacker */ i(entity, MUTATOR_ARGV_1_entity) \ /**/ MUTATOR_HOOKABLE(PrepareExplosionByDamage, EV_PrepareExplosionByDamage); /** called when a monster model is about to be set, allows custom paths etc. */ #define EV_MonsterModel(i, o) \ - /**/ i(string, monster_model) \ - /**/ i(string, monster_model_output) \ - /**/ o(string, monster_model_output) \ + /** model */ i(string, MUTATOR_ARGV_0_string) \ + /** output */ i(string, MUTATOR_ARGV_1_string) \ + /**/ o(string, MUTATOR_ARGV_1_string) \ /**/ -string monster_model; -string monster_model_output; MUTATOR_HOOKABLE(MonsterModel, EV_MonsterModel); /**/ #define EV_Player_ChangeTeam(i, o) \ - /**/ i(entity, __self) \ - /**/ i(float, pct_curteam) \ - /**/ i(float, pct_newteam) \ + /** player */ i(entity, MUTATOR_ARGV_0_entity) \ + /** current team */ i(float, MUTATOR_ARGV_1_float) \ + /** new team */ i(float, MUTATOR_ARGV_2_float) \ /**/ -float pct_curteam; -float pct_newteam; MUTATOR_HOOKABLE(Player_ChangeTeam, EV_Player_ChangeTeam); /**/ #define EV_URI_GetCallback(i, o) \ - /**/ i(float, uricb_id) \ - /**/ i(float, uricb_status) \ - /**/ i(string, uricb_data) \ + /** id */ i(float, MUTATOR_ARGV_0_float) \ + /** status */ i(float, MUTATOR_ARGV_1_float) \ + /** data */ i(string, MUTATOR_ARGV_2_string) \ /**/ -float uricb_id; -float uricb_status; -string uricb_data; MUTATOR_HOOKABLE(URI_GetCallback, EV_URI_GetCallback); diff --git a/qcsrc/server/mutators/mutator/gamemode_ca.qc b/qcsrc/server/mutators/mutator/gamemode_ca.qc index 0695f1d0d..ebd964077 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ca.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ca.qc @@ -435,19 +435,24 @@ MUTATOR_HOOKFUNCTION(ca, Scores_CountFragsRemaining) MUTATOR_HOOKFUNCTION(ca, SpectateSet) { - SELFPARAM(); - if (!autocvar_g_ca_spectate_enemies && this.caplayer) - if (DIFF_TEAM(spec_player, this)) + entity client = M_ARGV(0, entity); + entity targ = M_ARGV(1, entity); + + if (!autocvar_g_ca_spectate_enemies && client.caplayer) + if (DIFF_TEAM(targ, client)) return true; + return false; } MUTATOR_HOOKFUNCTION(ca, SpectateNext) { - SELFPARAM(); - if (!autocvar_g_ca_spectate_enemies && this.caplayer) + entity client = M_ARGV(0, entity); + entity targ = M_ARGV(1, entity); + + if (!autocvar_g_ca_spectate_enemies && client.caplayer) { - spec_player = CA_SpectateNext(this, spec_player); + targ = CA_SpectateNext(client, targ); return true; } return false; @@ -455,17 +460,20 @@ MUTATOR_HOOKFUNCTION(ca, SpectateNext) MUTATOR_HOOKFUNCTION(ca, SpectatePrev) { - SELFPARAM(); - if (!autocvar_g_ca_spectate_enemies && this.caplayer) + entity client = M_ARGV(0, entity); + entity targ = M_ARGV(1, entity); + entity first = M_ARGV(2, entity); + + if (!autocvar_g_ca_spectate_enemies && client.caplayer) { - do { spec_player = spec_player.chain; } - while(spec_player && DIFF_TEAM(spec_player, this)); + do { targ = targ.chain; } + while(targ && DIFF_TEAM(targ, client)); - if (!spec_player) + if (!targ) { - for (spec_player = spec_first; spec_player && DIFF_TEAM(spec_player, this); spec_player = spec_player.chain); + for (targ = first; targ && DIFF_TEAM(targ, client); targ = targ.chain); - if (spec_player == this.enemy) + if (targ == client.enemy) return MUT_SPECPREV_RETURN; } } @@ -477,20 +485,21 @@ MUTATOR_HOOKFUNCTION(ca, Bot_FixCount, CBC_ORDER_EXCLUSIVE) { FOREACH_CLIENT(IS_REAL_CLIENT(it), { if (IS_PLAYER(it) || it.caplayer == 1) - ++bot_activerealplayers; - ++bot_realplayers; + ++M_ARGV(0, int); + ++M_ARGV(1, int); }); return true; } MUTATOR_HOOKFUNCTION(ca, ClientCommand_Spectate) { - SELFPARAM(); - if (this.caplayer) + entity player = M_ARGV(0, entity); + + if (player.caplayer) { // they're going to spec, we can do other checks - if (autocvar_sv_spectate && (IS_SPEC(this) || IS_OBSERVER(this))) - Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_CA_LEAVE); + if (autocvar_sv_spectate && (IS_SPEC(player) || IS_OBSERVER(player))) + Send_Notification(NOTIF_ONE_ONLY, player, MSG_INFO, INFO_CA_LEAVE); return MUT_SPECCMD_FORCE; } diff --git a/qcsrc/server/mutators/mutator/gamemode_lms.qc b/qcsrc/server/mutators/mutator/gamemode_lms.qc index 4e89f2b27..05ff73f3d 100644 --- a/qcsrc/server/mutators/mutator/gamemode_lms.qc +++ b/qcsrc/server/mutators/mutator/gamemode_lms.qc @@ -352,8 +352,8 @@ MUTATOR_HOOKFUNCTION(lms, ItemTouch) MUTATOR_HOOKFUNCTION(lms, Bot_FixCount, CBC_ORDER_EXCLUSIVE) { FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA( - ++bot_activerealplayers; - ++bot_realplayers; + ++M_ARGV(0, int); + ++M_ARGV(1, int); )); return true; @@ -361,18 +361,19 @@ MUTATOR_HOOKFUNCTION(lms, Bot_FixCount, CBC_ORDER_EXCLUSIVE) MUTATOR_HOOKFUNCTION(lms, ClientCommand_Spectate) { - SELFPARAM(); - if(self.lms_spectate_warning) + entity player = M_ARGV(0, entity); + + if(player.lms_spectate_warning) { // for the forfeit message... - self.lms_spectate_warning = 2; + player.lms_spectate_warning = 2; // mark player as spectator - PlayerScore_Add(self, SP_LMS_RANK, 666 - PlayerScore_Add(self, SP_LMS_RANK, 0)); + PlayerScore_Add(player, SP_LMS_RANK, 666 - PlayerScore_Add(player, SP_LMS_RANK, 0)); } else { - self.lms_spectate_warning = 1; - sprint(self, "WARNING: you won't be able to enter the game again after spectating in LMS. Use the same command again to spectate anyway.\n"); + player.lms_spectate_warning = 1; + sprint(player, "WARNING: you won't be able to enter the game again after spectating in LMS. Use the same command again to spectate anyway.\n"); return MUT_SPECCMD_RETURN; } return MUT_SPECCMD_CONTINUE;