]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/teamplay.qc
Fixed JoinBestTeam.
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / teamplay.qc
index 3faa2d8a83cb24f00ce0472359ee7e5859224e62..c7fbacc488b2cf2935994851b7b437e96a215420 100644 (file)
@@ -9,10 +9,10 @@
 
 #include "command/vote.qh"
 
-#include "mutators/_mod.qh"
+#include <server/mutators/_mod.qh>
 
 #include "../common/deathtypes/all.qh"
-#include "../common/gamemodes/_mod.qh"
+#include <common/gamemodes/_mod.qh>
 #include "../common/teams.qh"
 
 /// \brief Describes a state of team balance entity.
@@ -185,7 +185,11 @@ bool Player_SetTeamIndex(entity player, int index)
                // Mutator has blocked team change.
                return false;
        }
-       if (new_team != -1)
+       if (new_team == -1)
+       {
+               player.team = -1;
+       }
+       else
        {
                SetPlayerColors(player, new_team - 1);
        }
@@ -260,6 +264,7 @@ entity TeamBalance_CheckAllowedTeams(entity for_whom)
                team_ent.m_num_players = TEAM_NOT_ALLOWED;
                team_ent.m_num_bots = 0;
        }
+       setthink(balance, TeamBalance_Destroy);
        
        int teams_mask = 0;     
        string teament_name = string_null;
@@ -626,9 +631,9 @@ int TeamBalance_FindBestTeams(entity balance, entity player, bool use_score)
        return team_bits;
 }
 
-void TeamBalance_JoinBestTeam(entity this, bool force_best_team)
+void TeamBalance_JoinBestTeam(entity this)
 {
-       //PrintToChatAll(sprintf("JoinBestTeam: %s, %f", this.netname, force_best_team));
+       PrintToChatAll(sprintf("JoinBestTeam: %s, %f", this.netname));
        // don't join a team if we're not playing a team game
        if (!teamplay)
        {
@@ -638,29 +643,6 @@ void TeamBalance_JoinBestTeam(entity this, bool force_best_team)
        // find out what teams are available
        entity balance = TeamBalance_CheckAllowedTeams(this);
 
-       // if we don't care what team they end up on, put them on whatever team they entered as.
-       // if they're not on a valid team, then let other code put them on the smallest team
-       if (!force_best_team)
-       {
-               int selected_team_index = -1;
-               for (int i = 1; i <= NUM_TEAMS; ++i)
-               {
-                       if (TeamBalance_IsTeamAllowedInternal(balance, i) &&
-                               (Team_TeamToIndex(this.team) == i))
-                       {
-                               selected_team_index = i;
-                               break;
-                       }
-               }
-               
-               if (Team_IsValidIndex(selected_team_index))
-               {
-                       SetPlayerTeam(this, selected_team_index, TEAM_CHANGE_AUTO_RELAXED);
-                       TeamBalance_Destroy(balance);
-                       return;
-               }
-       }
-       // otherwise end up on the smallest team (handled below)
        if (this.bot_forced_team)
        {
                TeamBalance_Destroy(balance);