#pragma once
+int autocvar_teamplay_mode;
+
+bool autocvar_g_changeteam_banned;
+bool autocvar_teamplay_lockonrestart;
+
+bool autocvar_g_balance_teams;
+bool autocvar_g_balance_teams_prevent_imbalance;
+
+string autocvar_g_forced_team_otherwise;
+
bool lockteams;
+.int team_forced; // can be a team number to force a team, or 0 for default action, or -1 for forced spectator
+
// ========================== Global teams API ================================
+void Team_InitTeams();
+
/// \brief Returns the global team entity at the given index.
/// \param[in] index Index of the team.
/// \return Global team entity at the given index.
/// \param[in] number Number of players to set.
void Team_SetNumberOfAlivePlayers(entity team_ent, int number);
+/// \brief Returns the winner team.
+/// \return Winner team or 0 if 2 or more teams have alive players or -1 if no team has any alive players.
+int Team_GetWinnerAliveTeam();
+
/// \brief Returns the number of alive teams.
/// \return Number of alive teams.
int Team_GetNumberOfAliveTeams();
+/// \brief Returns the winner team.
+/// \param[in] min_control_points Minimum number of control points the winner team must have.
+/// \return Winner team or 0 if 2 or more teams have control points or -1 if no team has any control points.
+int Team_GetWinnerTeam_WIthControlPoints(int min_control_points);
+
/// \brief Returns the number of control points owned by a team.
/// \param[in] team_ent Team entity.
/// \return Number of control points owned by a team.
/// \return True if team switch was successful, false otherwise.
bool SetPlayerTeam(entity player, int team_index, int type);
+/// \brief Sets the team of the player with all sanity checks.
+/// \param[in,out] player Player to adjust.
+/// \param[in] team_index Index of the team to set.
+void Player_SetTeamIndexChecked(entity player, int team_index);
+
/// \brief Moves player to the specified team.
/// \param[in,out] client Client to move.
/// \param[in] team_index Index of the team.
/// function.
int TeamBalance_CompareTeamsInternal(entity team_a, entity team_index_b,
entity player, bool use_score);
+
+/// \brief Called when the player changes color with the "color" command.
+/// Note that the "color" command is always called early on player connection
+/// \param[in,out] player Player that requested a new color.
+/// \param[in] new_color Requested color.
+void SV_ChangeTeam(entity player, int new_color);