From 87d5cd27c147dfdbc83d588c5533297e1cfb70a8 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Wed, 21 Oct 2026 18:32:41 +0200 Subject: [PATCH] Server thread: the owner's commands run with the hub in place MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit owner_console_command ran the window's commands as the world's owner with the hub taken out, so a selector saw only the owner (`team join … @a` left the guests out, and friendly fire still hurt) and `defaultgamemode` never reached the hub (guests joined in the world's old mode). It now puts the hub back while the command runs, as run_guest_commands does for a guest. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/game/integrated.rs | 21 ++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/crates/horizon-client/src/game/integrated.rs b/crates/horizon-client/src/game/integrated.rs index f46a28ba8..f07d2cda3 100644 --- a/crates/horizon-client/src/game/integrated.rs +++ b/crates/horizon-client/src/game/integrated.rs @@ -455,18 +455,23 @@ impl Game<'_> { // Commands.performCommand runs in the player's level. let (back, theirs) = (self.dim, super::Dim::from_id(&g.dimension)); let entered = theirs == back || self.enter_level(Some(&mut host), theirs).is_ok(); - if entered { + if entered && let Some(swap) = self.enter_guest(&mut host, conn) { let command = command.trim_start_matches('/').to_owned(); - let lines = self.as_guest(&mut host, conn, |g| { - g.as_console(|g| { - g.chat_capture = Some(Vec::new()); - g.run_command(&command); - g.chat_capture.take().unwrap_or_default() - }) + // The hub is back in place while the command runs, as for a + // guest's own (`run_guest_commands`): selectors see every + // player (`team join … @a`), and `defaultgamemode` reaches it. + self.lan = Some(host); + let lines = self.as_console(|g| { + g.chat_capture = Some(Vec::new()); + g.run_command(&command); + g.chat_capture.take().unwrap_or_default() }); + host = self.lan.take().expect("a command puts the hub back"); + self.leave_guest(&mut host, swap); + host.hub.sync_all_effects(); // A teleport into another level happens before its feedback is sent. self.run_level_teleports(&mut host); - for line in lines.unwrap_or_default() { + for line in lines { out.push(line.plain()); host.hub.send_to( conn,