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
This commit is contained in:
Dan Albert 2022-01-24 17:17:00 -08:00 committed by RndName
parent 9b125a644e
commit 4a99b59a38
No known key found for this signature in database
GPG Key ID: 5EF516FD9537F7C0

View File

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