Server thread: the owner's commands run with the hub in place

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 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-21 18:32:41 +02:00
parent 7e0b202374
commit 87d5cd27c1
+13 -8
View File
@@ -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,