]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Cleanse the last of the server side mutator hooks
authorMario <mario@smbclan.net>
Fri, 10 Jun 2016 08:34:27 +0000 (18:34 +1000)
committerMario <mario@smbclan.net>
Fri, 10 Jun 2016 08:34:27 +0000 (18:34 +1000)
qcsrc/common/gamemodes/gamemode/nexball/nexball.qc
qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc
qcsrc/common/monsters/all.qc
qcsrc/server/bot/bot.qc
qcsrc/server/cl_client.qc
qcsrc/server/mutators/events.qh
qcsrc/server/mutators/mutator/gamemode_ca.qc
qcsrc/server/mutators/mutator/gamemode_lms.qc

index a7528d5a1945588d8a1d2eb7873a44f40aecf92c..110141476dfff629cd8c2e63b573b455bf851515 100644 (file)
@@ -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)
index e91958d289e56028a4b9844224d83f420338eb62..96c3ac719bb71f13dc0a14c89b43834b7d609b9f 100644 (file)
@@ -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);
 }
 
 
index ce0a9023d494e2cf14367532c5305f9ec4d7af37..fa3f65193ae5725bc0e4a87806433875344a23f3 100644 (file)
@@ -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
index ef08e308c0223767729e93005e2df70b36d83a55..cde59c6de13687387084eea936fc274cdd65611f 100644 (file)
@@ -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))
index 903d1de255e0d1a34ab31d568ee78c410a4ac06d..43298c026e57ee5ae2723c67dae80e42ba9fd0d3 100644 (file)
@@ -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:
index 0d692ba2f2e2bd7203b37efa99b5fab423af7c9d..f7782504b9efa79fc51a68feacd62cb0f9510344 100644 (file)
@@ -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);
index 0695f1d0d2af0efe14841e1ef0c9c790f2a58caf..ebd964077984c9caa12b30dc6dfcdaa418e33934 100644 (file)
@@ -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;
        }
 
index 4e89f2b27d72a87a210510aa50f0e04fe45499e9..05ff73f3d9c892666f9f814a11e6f7465b3c5377 100644 (file)
@@ -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;