From: bones_was_here Date: Sun, 9 Jun 2024 18:09:31 +0000 (+1000) Subject: join queue: disable in singleplayer, improve description X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5d8e0bcaa8d393b61b1e2a199ecec7dd94fbe991;p=xonotic%2Fxonotic-data.pk3dir.git join queue: disable in singleplayer, improve description Fixes https://gitlab.com/xonotic/xonotic-data.pk3dir/-/issues/2905 --- diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index e41cd9d4d..0a4a08502 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -2148,7 +2148,7 @@ int nJoinAllowed(entity this, entity ignore) 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) diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index feee31c9b..f2c35665c 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -353,7 +353,7 @@ void Player_SetTeamIndexChecked(entity player, int team_index) // 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, { @@ -1390,3 +1390,17 @@ void SV_ChangeTeam(entity player, int new_color) } 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; +} diff --git a/qcsrc/server/teamplay.qh b/qcsrc/server/teamplay.qh index 9a75a03d9..b1f1255c1 100644 --- a/qcsrc/server/teamplay.qh +++ b/qcsrc/server/teamplay.qh @@ -17,9 +17,6 @@ bool lockteams; .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 ================================ @@ -361,3 +358,6 @@ int TeamBalance_CompareTeamsInternal(entity team_a, entity team_index_b, /// \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); diff --git a/xonotic-server.cfg b/xonotic-server.cfg index 5e4ec73c2..f160255de 100644 --- a/xonotic-server.cfg +++ b/xonotic-server.cfg @@ -281,7 +281,7 @@ set g_teamdamage_resetspeed 20 "for teamplay_mode 4: how fast player's team 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"