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
This commit is contained in:
Dan Albert 2021-06-05 13:50:28 -07:00
parent 34f3a50234
commit b74f60fe0e

View File

@ -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()