From 4a99b59a386398339da4e6521e43afc180eba0e8 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Mon, 24 Jan 2022 17:17:00 -0800 Subject: [PATCH] Fix helicopters at airfields breaking generation. Helipads at airfields don't work well right now because they are not counted as additional parking, but we should still allow them to take off from the airfield parking. Follow up work would be to fix the parking problem and allow adding helipads to airfields, or maybe to just "ground" start helicopters at airfields so they take off from parking rather than the runway. cherry-pick from 2499276b2afad2a3fa1e8674328a17eb0ed3dd6a --- gen/aircraft.py | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/gen/aircraft.py b/gen/aircraft.py index 46c9cc3b..b56118c1 100644 --- a/gen/aircraft.py +++ b/gen/aircraft.py @@ -76,6 +76,7 @@ from game.theater.controlpoint import ( Airfield, ControlPoint, ControlPointType, + Fob, NavalControlPoint, OffMapSpawn, ) @@ -778,22 +779,20 @@ class AircraftConflictGenerator: start_type=flight.start_type, at=carrier_group, ) - else: - # If the flight is an helicopter flight, then prioritize dedicated helipads - if flight.unit_type.helicopter: - return self._generate_at_cp_helipad( - name=name, - side=country, - unit_type=flight.unit_type.dcs_unit_type, - count=flight.count, - start_type=flight.start_type, - cp=cp, - ) - - if not isinstance(cp, Airfield): + elif isinstance(cp, Fob): + if not flight.unit_type.helicopter: raise RuntimeError( - f"Attempted to spawn at airfield for non-airfield {cp}" + f"Cannot spawn fixed-wing aircraft at {cp} because it is a FOB" ) + return self._generate_at_cp_helipad( + name=name, + side=country, + unit_type=flight.unit_type.dcs_unit_type, + count=flight.count, + start_type=flight.start_type, + cp=cp, + ) + elif isinstance(cp, Airfield): return self._generate_at_airport( name=name, side=country, @@ -802,6 +801,10 @@ class AircraftConflictGenerator: start_type=flight.start_type, airport=cp.airport, ) + else: + raise NotImplementedError( + f"Aircraft spawn behavior not implemented for {cp} ({cp.__class__})" + ) except Exception as e: # Generated when there is no place on Runway or on Parking Slots logging.error(e)