From 989562b90fbe405062849a797ec2f13c149dfd3b Mon Sep 17 00:00:00 2001 From: Raffson Date: Thu, 5 Jan 2023 18:37:09 +0100 Subject: [PATCH] Avoid appending triggers without actions Resolves #67 The problem turned out to be split-triggers with no actions, which occurs when a STRIKE flight has no escorts in its package. Added a guard for this so the trigger isn't pushed to the mission in such a case. --- changelog.md | 3 +++ game/missiongenerator/aircraft/aircraftgenerator.py | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index 1ff66a3f..cf9874ab 100644 --- a/changelog.md +++ b/changelog.md @@ -17,6 +17,9 @@ * **[Mission Generation]** Avoid aircraft from being assigned to helicopter parking spots, resulting into air starts that usually crash. * **[Mission Generation]** Use stacking algorithm to create vertical separation between flights spawning mid-mission over their departure, usually resulting into mid-air collisions. +# Retribution 1.0.1 (hotfix) +* **[Mission Generation]** Fix serialization issue when STRIKE flight has no escorts + # Retribution 1.0.0 ## Features/Improvements diff --git a/game/missiongenerator/aircraft/aircraftgenerator.py b/game/missiongenerator/aircraft/aircraftgenerator.py index 1b8d1084..231a66b6 100644 --- a/game/missiongenerator/aircraft/aircraftgenerator.py +++ b/game/missiongenerator/aircraft/aircraftgenerator.py @@ -124,9 +124,13 @@ class AircraftGenerator: splittrigger.add_condition(FlagIsFalse(flag=f"split-{id(package)}")) splittrigger.add_condition(GroupDead(package.primary_flight.group_id)) for flight in package.flights: - if flight is not package.primary_flight: + if flight.flight_type in [ + FlightType.ESCORT, + FlightType.SEAD_ESCORT, + ]: splittrigger.add_action(AITaskPush(flight.group_id, 1)) - self.mission.triggerrules.triggers.append(splittrigger) + if len(splittrigger.actions) > 0: + self.mission.triggerrules.triggers.append(splittrigger) def spawn_unused_aircraft( self, player_country: Country, enemy_country: Country