From a8dcd683b250558576a8b93d46b3e4f9b36cb252 Mon Sep 17 00:00:00 2001 From: WiseDev <83840010+wisedevik@users.noreply.github.com> Date: Sun, 23 Aug 2026 11:56:04 +0300 Subject: [PATCH] resume the home logic when the player comes back BattleScreen::createBattleEndHUD takes a null result message and builds the end screen from the local battle, then BattleScreen::sendGoHomeMessage fires - so in this mode the client decides the battle is over and asks to go home on its own. we now clear the stopped flag on that request instead of leaving the session wedged until the next login. battle turns are logged with their tick, checksum and command types while the flag is up, so the traffic at the end of a battle is visible. --- crates/game-service/src/home_mode.rs | 6 ++++++ crates/game-service/src/service.rs | 24 +++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/crates/game-service/src/home_mode.rs b/crates/game-service/src/home_mode.rs index e64f6f7..8a09333 100644 --- a/crates/game-service/src/home_mode.rs +++ b/crates/game-service/src/home_mode.rs @@ -52,6 +52,12 @@ impl HomeMode { pub fn stop_home_logic(&mut self) { self.home_logic_stopped = true; } + pub fn resume_home_logic(&mut self) { + self.home_logic_stopped = false; + } + pub fn is_home_logic_stopped(&self) -> bool { + self.home_logic_stopped + } pub fn shop_cycle(&self) -> ShopCycle { ShopCycle::at(self.logic.current_timestamp()) } diff --git a/crates/game-service/src/service.rs b/crates/game-service/src/service.rs index 7d3bf76..5ebba46 100644 --- a/crates/game-service/src/service.rs +++ b/crates/game-service/src/service.rs @@ -203,7 +203,11 @@ impl GameApi for GameService { ShopCycle, Vec, ) = { - let home = session.lock().await; + let mut home = session.lock().await; + if kind == HomeRequestKind::GoHome && home.is_home_logic_stopped() { + tracing::info!(%account, "client came back from the battle, resuming home logic"); + home.resume_home_logic(); + } ( home.own_home_data(self.config.random_seed), home.logic().checksum(), @@ -281,10 +285,24 @@ impl GameApi for GameService { .get_or_open(account, &profile, unix_seconds() as i32) .await; let roller = self.roller(account).await?; - let result = { + let (result, in_battle) = { let mut home = session.lock().await; - home.end_client_turn(&turn, &roller, &self.shop) + let in_battle = home.is_home_logic_stopped(); + (home.end_client_turn(&turn, &roller, &self.shop), in_battle) }; + if in_battle { + tracing::info!( + %account, + tick = turn.tick, + checksum = turn.checksum, + commands = ?turn + .commands + .iter() + .map(|command| command.command_type()) + .collect::>(), + "battle turn" + ); + } tracing::debug!( %account, tick = turn.tick,