From 163423796ccb7940697a972bb070927f568659ac Mon Sep 17 00:00:00 2001 From: Lyberta Date: Thu, 26 Jul 2018 02:57:08 +0300 Subject: [PATCH] Restore forced team functionality. --- qcsrc/server/teamplay.qc | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index 400943a63..d19ae95be 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -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)) -- 2.39.2