]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Refactor ReadyCount() and handle bots properly
authorbones_was_here <bones_was_here@xonotic.au>
Thu, 20 Oct 2022 15:29:21 +0000 (01:29 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Fri, 6 Jan 2023 07:16:10 +0000 (17:16 +1000)
qcsrc/server/command/vote.qc
xonotic-server.cfg

index 795ea09e5242f12fc0297a500e2b8a29efc8d601..3db86c4c1803383a1060b7357a9216ca0393335b 100644 (file)
@@ -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);
 }
 
 
index 04a6da7048241e2484a9ba262e1f85ae2c858f51..3d194acff90b2667de3ba614254a4971b52ae0ce 100644 (file)
@@ -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