Merge pull request #1095 from ludovic111/fix/hub-default-game-mode
🤖 Agent: merged. Verify passes. The change runs only on the server thread (opt-in today), and the PR body's proof shows lan_e2e --server-thread going from 35/39 to 38/39. #1072's switch needs it.
This commit is contained in:
@@ -451,18 +451,23 @@ impl Game<'_> {
|
|||||||
// Commands.performCommand runs in the player's level.
|
// Commands.performCommand runs in the player's level.
|
||||||
let (back, theirs) = (self.dim, super::Dim::from_id(&g.dimension));
|
let (back, theirs) = (self.dim, super::Dim::from_id(&g.dimension));
|
||||||
let entered = theirs == back || self.enter_level(Some(&mut host), theirs).is_ok();
|
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 command = command.trim_start_matches('/').to_owned();
|
||||||
let lines = self.as_guest(&mut host, conn, |g| {
|
// The hub is back in place while the command runs, as for a
|
||||||
g.as_console(|g| {
|
// guest's own (`run_guest_commands`): selectors see every
|
||||||
g.chat_capture = Some(Vec::new());
|
// player (`team join … @a`), and `defaultgamemode` reaches it.
|
||||||
g.run_command(&command);
|
self.lan = Some(host);
|
||||||
g.chat_capture.take().unwrap_or_default()
|
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.
|
// A teleport into another level happens before its feedback is sent.
|
||||||
self.run_level_teleports(&mut host);
|
self.run_level_teleports(&mut host);
|
||||||
for line in lines.unwrap_or_default() {
|
for line in lines {
|
||||||
out.push(line.plain());
|
out.push(line.plain());
|
||||||
host.hub.send_to(
|
host.hub.send_to(
|
||||||
conn,
|
conn,
|
||||||
|
|||||||
Reference in New Issue
Block a user