#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.
// Mutator has blocked team change.
return false;
}
- if (new_team != -1)
+ if (new_team == -1)
+ {
+ player.team = -1;
+ }
+ else
{
SetPlayerColors(player, new_team - 1);
}
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;
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));
- // don't join a team if we're not playing a team game
+ //PrintToChatAll(sprintf("JoinBestTeam: %s", this.netname));
if (!teamplay)
{
return;
}
-
- // find out what teams are available
+ if (this.bot_forced_team)
+ {
+ return;
+ }
+ int old_team_index = Team_TeamToIndex(this.team);
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)
+ if (this.team_forced > 0)
{
- int selected_team_index = -1;
- for (int i = 1; i <= NUM_TEAMS; ++i)
+ 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)
{
- if (TeamBalance_IsTeamAllowedInternal(balance, i) &&
- (Team_TeamToIndex(this.team) == i))
- {
- selected_team_index = i;
- break;
- }
+ return;
}
-
- if (Team_IsValidIndex(selected_team_index))
+ if (!SetPlayerTeam(this, forced_team_index, TEAM_CHANGE_AUTO))
{
- 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);
+ 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))
{
return;
}
+ if (source_team_index == -1)
+ {
+ return;
+ }
TeamBalance_AutoBalanceBots(destination_team_index, source_team_index);
}