]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Restore forced team functionality.
authorLyberta <lyberta@lyberta.net>
Wed, 25 Jul 2018 23:57:08 +0000 (02:57 +0300)
committerLyberta <lyberta@lyberta.net>
Wed, 25 Jul 2018 23:57:08 +0000 (02:57 +0300)
qcsrc/server/teamplay.qc

index 400943a636b3ad5c0b22c0d4fe960b792f4c26f3..d19ae95be8236d3a4fd81a33318bc755c3cb01d6 100644 (file)
@@ -634,22 +634,37 @@ int TeamBalance_FindBestTeams(entity balance, entity player, bool use_score)
 void TeamBalance_JoinBestTeam(entity this)
 {
        //PrintToChatAll(sprintf("JoinBestTeam: %s", this.netname));
-       // don't join a team if we're not playing a team game
        if (!teamplay)
        {
                return;
        }
-
-       // find out what teams are available
-       entity balance = TeamBalance_CheckAllowedTeams(this);
-
        if (this.bot_forced_team)
        {
+               return;
+       }
+       int old_team_index = Team_TeamToIndex(this.team);
+       entity balance = TeamBalance_CheckAllowedTeams(this);
+       if (this.team_forced > 0)
+       {
+               int forced_team_index = Team_TeamToIndex(this.team_forced);
+               bool is_team_allowed = TeamBalance_IsTeamAllowedInternal(balance,
+                       forced_team_index);
                TeamBalance_Destroy(balance);
+               if (!is_team_allowed)
+               {
+                       return;
+               }
+               if (!SetPlayerTeam(this, forced_team_index, TEAM_CHANGE_AUTO))
+               {
+                       return;
+               }
+               if ((old_team_index != -1) && !IS_BOT_CLIENT(this))
+               {
+                       TeamBalance_AutoBalanceBots(forced_team_index, old_team_index);
+               }
                return;
        }
        int best_team_index = TeamBalance_FindBestTeam(balance, this, true);
-       int old_team_index = Team_TeamToIndex(this.team);
        TeamBalance_Destroy(balance);
        PlayerScore_Clear(this);
        if (!SetPlayerTeam(this, best_team_index, TEAM_CHANGE_AUTO))