/// \brief Indicates that the player is not allowed to join a team.
const int TEAM_NOT_ALLOWED = -1;
-.float team_forced; // can be a team number to force a team, or 0 for default action, or -1 for forced spectator
-
.int m_team_balance_state; ///< Holds the state of the team balance entity.
.entity m_team_balance_team[NUM_TEAMS]; ///< ???
team_ent.m_num_players_alive = number;
}
+int Team_GetWinnerAliveTeam()
+{
+ int winner = 0;
+ for (int i = 0; i < NUM_TEAMS; ++i)
+ {
+ if (g_team_entities[i].m_num_players_alive > 0)
+ {
+ if (winner)
+ return 0;
+ winner = Team_IndexToTeam(i + 1);
+ }
+ }
+ return (winner ? winner : -1);
+}
+
int Team_GetNumberOfAliveTeams()
{
int result = 0;
return result;
}
+int Team_GetWinnerTeam_WIthControlPoints(int min_control_points)
+{
+ int winner = 0;
+ for (int i = 0; i < NUM_TEAMS; ++i)
+ {
+ if (g_team_entities[i].m_num_control_points >= min_control_points)
+ {
+ if (winner)
+ return 0;
+ winner = Team_IndexToTeam(i + 1);
+ }
+ }
+ return (winner ? winner : -1);
+}
+
int Team_GetNumberOfControlPoints(entity team_ent)
{
return team_ent.m_num_control_points;
bool SetPlayerTeam(entity player, int team_index, int type)
{
int old_team_index = Entity_GetTeamIndex(player);
+
if (!Player_SetTeamIndex(player, team_index))
- {
return false;
- }
+
LogTeamChange(player.playerid, player.team, type);
+
+ if (team_index != old_team_index)
+ {
+ KillPlayerForTeamChange(player);
+ PlayerScore_Clear(player);
+ CS(player).parm_idlesince = time;
+
+ if (!IS_BOT_CLIENT(player))
+ TeamBalance_AutoBalanceBots();
+
+ if (team_index != -1)
+ Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(player.team, INFO_JOIN_PLAY_TEAM), player.netname);
+ }
+
if (team_index == -1)
{
if (autocvar_sv_maxidle_playertospectator > 0 && CS(player).idlekick_lasttimeleft)
{
- // centerprint is killed and timestamps are reset here to ensure
- // it's done even when manually speccing during the countdown
+ // this done here so it happens even when manually speccing during the countdown
Kill_Notification(NOTIF_ONE_ONLY, player, MSG_CENTER, CPID_IDLING);
- CS(player).parm_idlesince = time;
CS(player).idlekick_lasttimeleft = 0;
}
else if (!CS(player).just_joined && player.frags != FRAGS_SPECTATOR)
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_SPECTATE, player.netname);
}
}
- else if (team_index != old_team_index)
- {
- PlayerScore_Clear(player);
- Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(player.team, INFO_JOIN_PLAY_TEAM), player.netname);
- KillPlayerForTeamChange(player);
- if (!IS_BOT_CLIENT(player))
- {
- TeamBalance_AutoBalanceBots();
- }
- }
+
return true;
}