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.
This commit is contained in:
parent
9d47484fe1
commit
a8dcd683b2
2 changed files with 27 additions and 3 deletions
|
|
@ -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())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -203,7 +203,11 @@ impl GameApi for GameService {
|
|||
ShopCycle,
|
||||
Vec<String>,
|
||||
) = {
|
||||
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::<Vec<_>>(),
|
||||
"battle turn"
|
||||
);
|
||||
}
|
||||
tracing::debug!(
|
||||
%account,
|
||||
tick = turn.tick,
|
||||
|
|
|
|||
Loading…
Reference in a new issue