Skip to content

Commit bbb8cab

Browse files
committed
Fix corner case for wandering boat carrier
When we are already at the goal `WanderOnWater` changes the state to reflect it. So we must ensure to change the state only before, not after the call to this function.
1 parent f4dd915 commit bbb8cab

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

libs/s25main/figures/nofCarrier.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,9 +642,10 @@ void nofCarrier::LostWork()
642642
// Ok let's paddle to the coast
643643
rs_pos = 0;
644644
cur_rs = nullptr;
645-
if(state == CarrierState::WaitForWare || state == CarrierState::WaitForWareSpace)
646-
WanderOnWater();
645+
const auto oldState = state;
647646
state = CarrierState::BoatcarrierWanderOnWater;
647+
if(oldState == CarrierState::WaitForWare || oldState == CarrierState::WaitForWareSpace)
648+
WanderOnWater();
648649
return;
649650
}
650651
}

0 commit comments

Comments
 (0)