From: bones_was_here Date: Thu, 20 Oct 2022 15:29:21 +0000 (+1000) Subject: Refactor ReadyCount() and handle bots properly X-Git-Tag: xonotic-v0.8.6~179^2~11 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ac2341714d9b86ba34b1d8086090041f34319214;p=xonotic%2Fxonotic-data.pk3dir.git Refactor ReadyCount() and handle bots properly --- diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index 795ea09e5..3db86c4c1 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 04a6da704..3d194acff 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