From 62753535d6ed2add1e707e6adc22774724574096 Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Mon, 26 Sep 2022 15:21:33 +1000 Subject: [PATCH] Fix inconsistent ReadyCount() calling logic timeout_status was checked at only 1 call site, and readiness changes during a timeout were sometimes ignored. ReadyCount() was sometimes called when not in warmup. --- qcsrc/server/client.qc | 6 +++--- qcsrc/server/command/cmd.qc | 4 +--- qcsrc/server/command/common.qc | 4 ++++ qcsrc/server/command/vote.qc | 3 +++ 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index a1195d52c..5843e02a3 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -256,7 +256,7 @@ void PutObserverInServer(entity this, bool is_forced, bool use_spawnpoint) { if (vote_called) { VoteCount(false); } this.ready = false; - recount_ready = true; + if (warmup_stage) recount_ready = true; } entcs_update_players(this); } @@ -307,7 +307,7 @@ void PutObserverInServer(entity this, bool is_forced, bool use_spawnpoint) TRANSMUTE(Observer, this); - if(recount_ready) ReadyCount(); + if(recount_ready) ReadyCount(); // FIXME: please add comment about why this is delayed WaypointSprite_PlayerDead(this); accuracy_resend(this); @@ -1236,7 +1236,7 @@ void ClientDisconnect(entity this) if (this.personal) delete(this.personal); this.playerid = 0; - ReadyCount(); + if (warmup_stage) ReadyCount(); if (vote_called && IS_REAL_CLIENT(this)) VoteCount(false); player_powerups_remove_all(this); // stop powerup sound diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index 552d870e6..e2d71597f 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -393,9 +393,7 @@ void ClientCommand_ready(entity caller, int request) } caller.last_ready = time; - - // cannot reset the game while a timeout is active! - if (!timeout_status) ReadyCount(); + ReadyCount(); } } return; // never fall through to usage diff --git a/qcsrc/server/command/common.qc b/qcsrc/server/command/common.qc index af7aeb059..6138bd8b5 100644 --- a/qcsrc/server/command/common.qc +++ b/qcsrc/server/command/common.qc @@ -187,6 +187,10 @@ void timeout_handler_reset(entity this) timeout_leadtime = 0; delete(this); + + // ReadyCount() does nothing when a timeout is active or pending + // so check readiness now to support g_warmup_allow_timeout + if (warmup_stage) ReadyCount(); } void timeout_handler_think(entity this) diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index 8d2debdd5..8c70ae6f9 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -506,6 +506,9 @@ void ReadyRestart(bool forceWarmupEnd) // Count the players who are ready and determine whether or not to restart the match 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; readycount = 0; -- 2.39.2