mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Prevent past startup when adding new flights.
When a new flight is added to a package, if the TOT is early enough the new flight might have a startup time in the past. Clamp the TOT when adding new flights to the package to avoid this. https://github.com/dcs-liberation/dcs_liberation/issues/1680
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user