From 66d60ed9ab61efc176808b17fc26445dbf5be705 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 29 Sep 2025 22:52:26 +0200 Subject: Implement ready packet + Refactor server pausing --- server/src/commands.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'server/src/commands.rs') diff --git a/server/src/commands.rs b/server/src/commands.rs index 8e3d926a..1ffe4cd1 100644 --- a/server/src/commands.rs +++ b/server/src/commands.rs @@ -78,6 +78,13 @@ enum Command { Tile { name: String }, /// Show all possible demands for this map Demands, + /// Ready yourself + Ready { + #[arg(short, long)] + force: bool, + #[arg(short, long)] + unready: bool, + }, /// Reload the resource index ReloadIndex, #[clap(alias = "summon", alias = "bot")] @@ -167,9 +174,10 @@ impl Server { .map_err(|e| TrError::Plain(e.to_string()))?; self.load(data, timer.map(Duration::from_secs)); if !skip_announce { - self.start_pause_timer = 3.5; + self.announce_timer = 3.5; self.packet_out .push_back(PacketC::Menu(Menu::AnnounceStart)); + self.update_paused(); } } Command::End => { @@ -206,6 +214,17 @@ impl Server { None, ); } + Command::Ready { force, unready } => { + for c in self.connections.values_mut() { + if c.players.contains(&player) || force { + c.ready = true; + } + if unready && c.players.contains(&player) { + c.ready = false; + } + } + self.update_paused(); + } Command::ReloadIndex => { self.index .reload() -- cgit v1.2.3-70-g09d2