diff --git a/game/ato/flightstate/uninitialized.py b/game/ato/flightstate/uninitialized.py index 4b76f75f..e3f0b09a 100644 --- a/game/ato/flightstate/uninitialized.py +++ b/game/ato/flightstate/uninitialized.py @@ -25,7 +25,7 @@ class Uninitialized(FlightState): @property def is_waiting_for_start(self) -> bool: - raise RuntimeError("Attempted to simulate flight that is not fully initialized") + return True def estimate_position(self) -> Point: raise RuntimeError("Attempted to simulate flight that is not fully initialized") diff --git a/game/ato/package.py b/game/ato/package.py index 8190def4..d9b10906 100644 --- a/game/ato/package.py +++ b/game/ato/package.py @@ -117,6 +117,17 @@ class Package: def set_tot_asap(self, now: datetime) -> None: self.time_over_target = TotEstimator(self).earliest_tot(now) + def clamp_tot_for_current_time(self, now: datetime) -> None: + if not self.all_flights_waiting_for_start(): + return + + if not self.flights: + return + + earliest_startup_time = min(f.flight_plan.startup_time() for f in self.flights) + if earliest_startup_time < now: + self.time_over_target += now - earliest_startup_time + def add_flight(self, flight: Flight) -> None: """Adds a flight to the package.""" self.flights.append(flight) diff --git a/qt_ui/models.py b/qt_ui/models.py index 127a8447..707b5e4e 100644 --- a/qt_ui/models.py +++ b/qt_ui/models.py @@ -187,14 +187,7 @@ class PackageModel(QAbstractListModel): def set_tot(self, tot: datetime.datetime) -> datetime: with self.game_model.sim_controller.paused_sim(): - previous_tot = self.package.time_over_target self.package.time_over_target = tot - for flight in self.package.flights: - if ( - flight.flight_plan.startup_time() - < self.game_model.sim_controller.current_time_in_sim - ): - self.package.time_over_target = previous_tot self.update_tot() return self.package.time_over_target @@ -209,6 +202,9 @@ class PackageModel(QAbstractListModel): self.package.set_tot_asap( self.game_model.sim_controller.current_time_in_sim ) + self.package.clamp_tot_for_current_time( + self.game_model.sim_controller.current_time_in_sim + ) self.tot_changed.emit() # For some reason this is needed to make the UI update quickly. self.layoutChanged.emit()