From 5708fe625bc0146fccd05017e661a42c84623f65 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Sun, 5 Feb 2023 13:11:31 -0800 Subject: [PATCH] Don't generate runway data for heliports. Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2710. (cherry picked from commit c33a0d5deb727b4a0307ecdce8bd99afdfcc395d) --- changelog.md | 1 + game/theater/controlpoint.py | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/changelog.md b/changelog.md index d808717b..6277b355 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,7 @@ * **[Data]** Fixed unit ID for the KS-19 AAA. KS-19 would not previously generate correctly in missions. A new game is required for this fix to take effect. * **[Flight Planning]** Automatic flight planning will no longer accidentally plan a recovery tanker instead of a theater refueling package. This fixes a potential crash during mission generation when opfor plans a refueling task at a sunk carrier. You'll need to skip the current turn to force opfor to replan their flights to get the fix. +* **[Mission Generation]** Using heliports (airports without any runways) will no longer cause mission generation to fail. # 6.1.0 diff --git a/game/theater/controlpoint.py b/game/theater/controlpoint.py index d004b294..2ed0fd49 100644 --- a/game/theater/controlpoint.py +++ b/game/theater/controlpoint.py @@ -878,6 +878,11 @@ class ControlPoint(MissionTarget, SidcDescribable, ABC): ) -> RunwayData: ... + def stub_runway_data(self) -> RunwayData: + return RunwayData( + self.full_name, runway_heading=Heading.from_degrees(0), runway_name="" + ) + @property def airdrome_id_for_landing(self) -> Optional[int]: return None @@ -1134,6 +1139,14 @@ class Airfield(ControlPoint): conditions: Conditions, dynamic_runways: Dict[str, RunwayData], ) -> RunwayData: + if not self.airport.runways: + # Some airfields are heliports and don't have any runways. This isn't really + # the best fix, since we should still try to generate partial data for TACAN + # beacons, but it'll do for a bug fix, and the proper fix probably involves + # making heliports their own CP type. + # https://github.com/dcs-liberation/dcs_liberation/issues/2710 + return self.stub_runway_data() + assigner = RunwayAssigner(conditions) return assigner.get_preferred_runway(theater, self.airport) @@ -1269,8 +1282,6 @@ class Carrier(NavalControlPoint): return SymbolSet.SEA_SURFACE, SeaSurfaceEntity.CARRIER def mission_types(self, for_player: bool) -> Iterator[FlightType]: - from game.ato import FlightType - yield from super().mission_types(for_player) if self.is_friendly(for_player): yield from [ @@ -1375,9 +1386,7 @@ class OffMapSpawn(ControlPoint): dynamic_runways: Dict[str, RunwayData], ) -> RunwayData: logging.warning("TODO: Off map spawns have no runways.") - return RunwayData( - self.full_name, runway_heading=Heading.from_degrees(0), runway_name="" - ) + return self.stub_runway_data() @property def runway_status(self) -> RunwayStatus: @@ -1419,9 +1428,7 @@ class Fob(ControlPoint): dynamic_runways: Dict[str, RunwayData], ) -> RunwayData: logging.warning("TODO: FOBs have no runways.") - return RunwayData( - self.full_name, runway_heading=Heading.from_degrees(0), runway_name="" - ) + return self.stub_runway_data() @property def runway_status(self) -> RunwayStatus: