From b74f60fe0e099d1516e07f415c75001fe8d063bc Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Sat, 5 Jun 2021 13:50:28 -0700 Subject: [PATCH] Stagger packages in units of seconds, not minutes. Missions with very large numbers of packages and short mission windows would raise an exception here because we couldn't schedule more frequently than once a minute. Switch to using seconds instead of minutes to avoid that problem. If there are more packages than there are seconds in the mission the game is broken for other reasons. Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1154 --- gen/flights/ai_flight_planner.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gen/flights/ai_flight_planner.py b/gen/flights/ai_flight_planner.py index 85f5209c..58260dfd 100644 --- a/gen/flights/ai_flight_planner.py +++ b/gen/flights/ai_flight_planner.py @@ -1006,7 +1006,7 @@ class CoalitionMissionPlanner: interval = (latest - earliest) // count for time in range(earliest, latest, interval): error = random.randint(-margin, margin) - yield timedelta(minutes=max(0, time + error)) + yield timedelta(seconds=max(0, time + error)) dca_types = { FlightType.BARCAP, @@ -1020,11 +1020,11 @@ class CoalitionMissionPlanner: start_time = start_time_generator( count=len(non_dca_packages), - earliest=5, + earliest=5 * 60, latest=int( - self.game.settings.desired_player_mission_duration.total_seconds() / 60 + self.game.settings.desired_player_mission_duration.total_seconds() ), - margin=5, + margin=5 * 60, ) for package in self.ato.packages: tot = TotEstimator(package).earliest_tot()