diff --git a/game/ato/flightstate/inflight.py b/game/ato/flightstate/inflight.py index 0f97d635..541c9f27 100644 --- a/game/ato/flightstate/inflight.py +++ b/game/ato/flightstate/inflight.py @@ -29,6 +29,7 @@ class InFlight(FlightState, ABC): self.next_waypoint = waypoints[self.waypoint_index + 1] self.total_time_to_next_waypoint = self.travel_time_between_waypoints() self.elapsed_time = timedelta() + self.current_waypoint_elapsed = False @property def in_flight(self) -> bool: @@ -91,6 +92,7 @@ class InFlight(FlightState, ABC): def advance_to_next_waypoint(self) -> None: self.flight.set_state(self.next_waypoint_state()) + self.current_waypoint_elapsed = True def on_game_tick( self, events: GameUpdateEvents, time: datetime, duration: timedelta diff --git a/game/ato/flightstate/navigating.py b/game/ato/flightstate/navigating.py index 4ea5a14c..11c9c750 100644 --- a/game/ato/flightstate/navigating.py +++ b/game/ato/flightstate/navigating.py @@ -22,7 +22,11 @@ class Navigating(InFlight): self, events: GameUpdateEvents, time: datetime, duration: timedelta ) -> None: super().on_game_tick(events, time, duration) - events.update_flight_position(self.flight, self.estimate_position()) + + # If the parent tick caused this waypoint to become inactive don't update the + # position based on our now invalid state. + if not self.current_waypoint_elapsed: + events.update_flight_position(self.flight, self.estimate_position()) def progress(self) -> float: return (