From 194656933a8be480da90f07d90d2b2951f2a3bb6 Mon Sep 17 00:00:00 2001 From: "NG (Graham)" Date: Thu, 24 Jul 2025 22:40:19 -0400 Subject: [PATCH] Fix multiplayer not ending with only one player ever connected --- .../src/matches/modes/elimination.rs | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/rc_multiplayer/src/matches/modes/elimination.rs b/rc_multiplayer/src/matches/modes/elimination.rs index 45f92a4..d80c7e7 100644 --- a/rc_multiplayer/src/matches/modes/elimination.rs +++ b/rc_multiplayer/src/matches/modes/elimination.rs @@ -41,6 +41,17 @@ impl PlayerTracker { only_alive_team } + async fn alive_count(&self) -> std::collections::HashMap { + let alive_lock = self.alive.lock().await; + let mut alive_players = std::collections::HashMap::new(); + for (team, players) in alive_lock.iter() { + if !players.is_empty() { + alive_players.insert(*team, players.len() as u8); + } + } + alive_players + } + async fn teams(&self) -> std::collections::HashSet { self.alive.lock().await.keys().map(|x| *x).collect() } @@ -120,6 +131,10 @@ impl CustomGameLogic for EliminationLogic { } generic.game_done(); self.abort_timer_sync().await; + } else if self.tracked.alive_count().await.is_empty() { + log::debug!("Everyone is dead, so long and thanks for all the fish"); + generic.game_done(); + self.abort_timer_sync().await; } true } @@ -171,7 +186,10 @@ impl CustomGameLogic for EliminationLogic { &conn.connection.connection ).await); } - + } else if self.tracked.alive_count().await.is_empty() { + log::debug!("Everyone is dead, this must be the West Seth was talking about!"); + generic.game_done(); + self.abort_timer_sync().await; } true }