diff options
author | metamuffin <metamuffin@disroot.org> | 2025-09-29 22:52:26 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-09-29 22:53:12 +0200 |
commit | 66d60ed9ab61efc176808b17fc26445dbf5be705 (patch) | |
tree | 7774a7625948659c037514e0848ddd3c292fcc54 /server/src/commands.rs | |
parent | c1e826625f3ca3116d482b27e2f0b230cbd55346 (diff) | |
download | hurrycurry-66d60ed9ab61efc176808b17fc26445dbf5be705.tar hurrycurry-66d60ed9ab61efc176808b17fc26445dbf5be705.tar.bz2 hurrycurry-66d60ed9ab61efc176808b17fc26445dbf5be705.tar.zst |
Implement ready packet + Refactor server pausing
Diffstat (limited to 'server/src/commands.rs')
-rw-r--r-- | server/src/commands.rs | 21 |
1 files changed, 20 insertions, 1 deletions
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() |