stop the home logic once the battle starts
the client sends EndClientTurnMessage during the battle too, but its tick and checksum belong to the battle, not to the home. we kept comparing them against the home checksum and answered with OutOfSyncMessage, which is the "Client and server are out of sync!" dialog on tick 60. HomeMode carries the stopped flag now and returns an empty turn result while it is set, and sector_state_for raises it, so both the mission and the matchmaking entry points are covered.
This commit is contained in:
parent
6c5295bc07
commit
4477b12f0a
2 changed files with 17 additions and 1 deletions
|
|
@ -32,6 +32,7 @@ pub struct TurnResult {
|
||||||
}
|
}
|
||||||
pub struct HomeMode {
|
pub struct HomeMode {
|
||||||
logic: LogicHomeMode,
|
logic: LogicHomeMode,
|
||||||
|
home_logic_stopped: bool,
|
||||||
}
|
}
|
||||||
impl HomeMode {
|
impl HomeMode {
|
||||||
pub fn from_profile(profile: &PlayerProfile, current_timestamp: i32) -> Self {
|
pub fn from_profile(profile: &PlayerProfile, current_timestamp: i32) -> Self {
|
||||||
|
|
@ -43,7 +44,13 @@ impl HomeMode {
|
||||||
logic.restore_free_chest_timer(profile.free_chest_end_timestamp);
|
logic.restore_free_chest_timer(profile.free_chest_end_timestamp);
|
||||||
let cycle = ShopCycle::at(current_timestamp);
|
let cycle = ShopCycle::at(current_timestamp);
|
||||||
logic.set_shop(cycle.seed, cycle.seconds_to_cycle, cycle.weekday_index);
|
logic.set_shop(cycle.seed, cycle.seconds_to_cycle, cycle.weekday_index);
|
||||||
Self { logic }
|
Self {
|
||||||
|
logic,
|
||||||
|
home_logic_stopped: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn stop_home_logic(&mut self) {
|
||||||
|
self.home_logic_stopped = true;
|
||||||
}
|
}
|
||||||
pub fn shop_cycle(&self) -> ShopCycle {
|
pub fn shop_cycle(&self) -> ShopCycle {
|
||||||
ShopCycle::at(self.logic.current_timestamp())
|
ShopCycle::at(self.logic.current_timestamp())
|
||||||
|
|
@ -164,6 +171,9 @@ impl HomeMode {
|
||||||
shop: &ShopCatalog,
|
shop: &ShopCatalog,
|
||||||
) -> TurnResult {
|
) -> TurnResult {
|
||||||
let mut result = TurnResult::default();
|
let mut result = TurnResult::default();
|
||||||
|
if self.home_logic_stopped {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
let ticked = self
|
let ticked = self
|
||||||
.logic
|
.logic
|
||||||
.fast_forward_to_tick(turn.tick, MAX_FAST_FORWARD_TICKS);
|
.fast_forward_to_tick(turn.tick, MAX_FAST_FORWARD_TICKS);
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,12 @@ impl GameService {
|
||||||
) -> RpcResult<Vec<WireMessage>> {
|
) -> RpcResult<Vec<WireMessage>> {
|
||||||
let profile = self.profile(account).await?;
|
let profile = self.profile(account).await?;
|
||||||
let avatar = build_avatar(&profile);
|
let avatar = build_avatar(&profile);
|
||||||
|
self.sessions
|
||||||
|
.get_or_open(account, &profile, unix_seconds() as i32)
|
||||||
|
.await
|
||||||
|
.lock()
|
||||||
|
.await
|
||||||
|
.stop_home_logic();
|
||||||
let location = npc
|
let location = npc
|
||||||
.data()
|
.data()
|
||||||
.map(|row| LogicDataRef::by_name(table::LOCATIONS, row.string("Location")))
|
.map(|row| LogicDataRef::by_name(table::LOCATIONS, row.string("Location")))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue