]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Added JoinBestTeam hook.
authorLyberta <lyberta@lyberta.net>
Sun, 2 Apr 2017 15:00:33 +0000 (18:00 +0300)
committerLyberta <lyberta@lyberta.net>
Sun, 2 Apr 2017 15:00:33 +0000 (18:00 +0300)
qcsrc/server/mutators/events.qh
qcsrc/server/teamplay.qc

index 6f5feb87c432fea018e343edfcfa4445632c3841..5a748d8811271a41aa40abb4b6a95086e8a32706 100644 (file)
@@ -124,6 +124,14 @@ MUTATOR_HOOKABLE(MatchEnd, EV_NO_ARGS);
     /**/
 MUTATOR_HOOKABLE(CheckAllowedTeams, EV_CheckAllowedTeams);
 
+/** allows overriding best team */
+#define EV_JoinBestTeam(i, o) \
+    /** player checked     */ i(entity, MUTATOR_ARGV_0_entity) \
+    /** team number        */ i(float, MUTATOR_ARGV_1_float) \
+    /**/                      o(float, MUTATOR_ARGV_1_float) \
+    /**/
+MUTATOR_HOOKABLE(JoinBestTeam, EV_JoinBestTeam);
+
 /** copies variables for spectating "spectatee" to "this" */
 #define EV_SpectateCopy(i, o) \
     /** spectatee   */ i(entity, MUTATOR_ARGV_0_entity) \
index 70dc937e58feb108eed0ce922caf09749aa30cc0..beb5169020565eb5d316487e72a343f6491ea0f7 100644 (file)
@@ -532,7 +532,7 @@ float FindSmallestTeam(entity pl, float ignore_pl)
 
 int JoinBestTeam(entity this, bool only_return_best, bool forcebestteam)
 {
-       float smallest, selectedteam;
+       float bestteam, selectedteam;
 
        // don't join a team if we're not playing a team game
        if(!teamplay)
@@ -571,15 +571,17 @@ int JoinBestTeam(entity this, bool only_return_best, bool forcebestteam)
                // otherwise end up on the smallest team (handled below)
        }
 
-       smallest = FindSmallestTeam(this, true);
+       bestteam = FindSmallestTeam(this, true);
+       MUTATOR_CALLHOOK(JoinBestTeam, this, bestteam);
+       bestteam = M_ARGV(1, float);
 
        if(!only_return_best && !this.bot_forced_team)
        {
-               smallest = Team_NumberToTeam(smallest);
-               if (smallest != -1)
+               bestteam = Team_NumberToTeam(bestteam);
+               if (bestteam != -1)
                {
                        TeamchangeFrags(this);
-                       SetPlayerTeamSimple(this, smallest);
+                       SetPlayerTeamSimple(this, bestteam);
                }
                else
                {
@@ -592,7 +594,7 @@ int JoinBestTeam(entity this, bool only_return_best, bool forcebestteam)
                        Damage(this, this, this, 100000, DEATH_TEAMCHANGE.m_id, this.origin, '0 0 0');
        }
 
-       return smallest;
+       return bestteam;
 }
 
 //void() ctf_playerchanged;