bool queuePlayer(entity this, int team_index)
{
- if(IS_BOT_CLIENT(this) || !IS_QUEUE_NEEDED(this) || QueuedPlayersReady(this, false))
+ if(IS_BOT_CLIENT(this) || !QueueNeeded(this) || QueuedPlayersReady(this, false))
return false;
if(team_index <= 0)
// g_balance_teams_queue: before joining the queue,
// check if a queued player already chose the selected team
- if (!IS_BOT_CLIENT(player) && IS_QUEUE_NEEDED(player))
+ if (!IS_BOT_CLIENT(player) && QueueNeeded(player))
{
FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != player && it.wants_join == team_index,
{
}
Player_SetTeamIndexChecked(player, Team_TeamToIndex((new_color & 0x0F) + 1));
}
+
+bool QueueNeeded(entity ignore)
+{
+ if (!teamplay || warmup_stage || !autocvar_g_balance_teams_queue || autocvar_g_campaign)
+ return false;
+
+ int human_clients = 0;
+ FOREACH_CLIENT(IS_REAL_CLIENT(it),
+ {
+ if (++human_clients > 1)
+ return TeamBalance_AreEqual(ignore, true);
+ });
+ return false;
+}
.int team_forced; // can be a team number to force a team, or 0 for default action, or -1 for forced spectator
-#define IS_QUEUE_NEEDED(ignore) \
- (teamplay && !warmup_stage && autocvar_g_balance_teams_queue && !autocvar_g_campaign \
- && TeamBalance_AreEqual(ignore, true))
// ========================== Global teams API ================================
/// \param[in,out] player Player that requested a new color.
/// \param[in] new_color Requested color.
void SV_ChangeTeam(entity player, int new_color);
+
+
+bool QueueNeeded(entity ignore);
set g_balance_teams 1 "automatically balance out players entering instead of asking them for their preferred team"
set g_balance_teams_prevent_imbalance 1 "prevent players from changing to larger teams during the match"
-set g_balance_teams_queue 0 "queue players to maintain balance when they join during the match"
+set g_balance_teams_queue 0 "queue players to maintain balance when they join during the match, any bots should be added with minplayers_per_team instead of bot_number so humans can replace them instead of waiting in queue while a bot plays"
set g_balance_teams_remove 0 "remove excess players from teams to maintain balance when someone leaves (currently does nothing in matches with more than 2 teams)"
set g_balance_teams_remove_wait 10 "seconds to warn everyone before removing an excess player (0 = immediately)"
set g_changeteam_banned 0 "not allowed to change team"