From: Lyberta Date: Wed, 25 Jul 2018 23:57:08 +0000 (+0300) Subject: Restore forced team functionality. X-Git-Tag: xonotic-v0.8.5~1946^2~2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=163423796ccb7940697a972bb070927f568659ac;p=xonotic%2Fxonotic-data.pk3dir.git Restore forced team functionality. --- 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))