From ac2341714d9b86ba34b1d8086090041f34319214 Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Fri, 21 Oct 2022 01:29:21 +1000 Subject: [PATCH] Refactor ReadyCount() and handle bots properly --- qcsrc/server/command/vote.qc | 20 +++++++++++--------- xonotic-server.cfg | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index 795ea09e52..3db86c4c18 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -514,13 +514,17 @@ void ReadyCount() // cannot reset the game while a timeout is active or pending if (timeout_status) return; - float ready_needed_factor, ready_needed_count; - float t_players = 0; + int total_players = 0, human_players = 0, humans_ready = 0; readycount = 0; - FOREACH_CLIENT(IS_REAL_CLIENT(it) && (IS_PLAYER(it) || INGAME_JOINED(it)), { - ++t_players; + FOREACH_CLIENT(IS_PLAYER(it) || INGAME_JOINED(it), { + ++total_players; if (it.ready) ++readycount; + if (IS_REAL_CLIENT(it)) + { + ++human_players; + if (it.ready) ++humans_ready; + } }); Nagger_ReadyCounted(); @@ -530,7 +534,7 @@ void ReadyCount() // map_minplayers can only be > 0 if g_warmup was -1 at worldspawn int minplayers = autocvar_g_warmup > 1 ? autocvar_g_warmup : map_minplayers; - if (t_players < minplayers) + if (total_players < minplayers) { if (game_starttime > time) // someone bailed during countdown, back to warmup { @@ -556,10 +560,8 @@ void ReadyCount() // warmup continues until enough players AND enough RUPs (no time limit) } - ready_needed_factor = bound(0.5, cvar("g_warmup_majority_factor"), 1); - ready_needed_count = ceil(t_players * ready_needed_factor); - - if (readycount >= ready_needed_count) ReadyRestart(true); + if (humans_ready && humans_ready >= rint(human_players * bound(0.5, cvar("g_warmup_majority_factor"), 1))) + ReadyRestart(true); } diff --git a/xonotic-server.cfg b/xonotic-server.cfg index 04a6da7048..3d194acff9 100644 --- a/xonotic-server.cfg +++ b/xonotic-server.cfg @@ -34,7 +34,7 @@ set g_warmup 0 "splits the game into warmup and match stages, 1 means the match set g_warmup_limit 180 "limit warmup-stage to this time (in seconds); if set to -1 the warmup-stage is not affected by any timelimit, if set to 0 the usual timelimit also affects warmup-stage" set g_warmup_allow_timeout 0 "allow calling timeouts in the warmup-stage (if sv_timeout is set to 1)" set g_warmup_allguns 1 "provide more weapons on start while in warmup: 0 = normal start weapons, 1 = all guns available on the map, 2 = all normal weapons" -set g_warmup_majority_factor 0.8 "fraction of joined players sufficient to end warmup before g_warmup_limit by readying up" +set g_warmup_majority_factor 0.8 "fraction of joined players (not including bots) sufficient to end warmup before g_warmup_limit by readying up" alias sv_hook_warmupend -- 2.39.2