Fix heli spawn/landing at FOB/FARP

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2719.

(cherry picked from commit 34de855b8f889b72406c101d0cea385988e24bf9)
(cherry picked from commit b41ef0ab13fad0969eef321f71377ae6eb800d36)
This commit is contained in:
Raffson 2023-02-05 18:10:07 +01:00 committed by Dan Albert
parent 5708fe625b
commit 801e9efe8c
3 changed files with 20 additions and 4 deletions

View File

@ -5,6 +5,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.
* **[Mission Generation]** Prevent helicopters from spawning into collisions at FARPs when more than one flight uses the same FARP.
# 6.1.0

View File

@ -26,6 +26,7 @@ from game.settings import Settings
from game.theater.controlpoint import (
Airfield,
ControlPoint,
Fob,
)
from game.unitmap import UnitMap
from .aircraftpainter import AircraftPainter
@ -180,4 +181,12 @@ class AircraftGenerator:
self.unit_map,
).configure()
)
wpt = group.waypoint("LANDING")
if flight.is_helo and isinstance(flight.arrival, Fob) and wpt:
hpad = self.helipads[flight.arrival].units.pop(0)
wpt.helipad_id = hpad.id
wpt.link_unit = hpad.id
self.helipads[flight.arrival].units.append(hpad)
return group

View File

@ -230,16 +230,22 @@ class FlightGroupSpawner:
def _generate_at_cp_helipad(self, name: str, cp: ControlPoint) -> FlyingGroup[Any]:
try:
helipad = self.helipads[cp]
except IndexError as ex:
except IndexError:
raise NoParkingSlotError()
group = self._generate_at_group(name, helipad)
if self.start_type is not StartType.COLD:
if self.start_type is StartType.WARM:
group.points[0].type = "TakeOffParkingHot"
hpad = helipad.units[0]
for i in range(self.flight.count):
group.units[i].position = helipad.units[i].position
group.units[i].heading = helipad.units[i].heading
group.units[i].position = hpad.position
group.units[i].heading = hpad.heading
# pydcs has just `parking_id = None`, so mypy thinks str is invalid. Ought
# to fix pydcs, but that's not the kind of change we want to pull into the
# 6.1 branch, and frankly we should probably just improve pydcs's handling
# of FARPs instead.
group.units[i].parking_id = str(i + 1) # type: ignore
return group
def dcs_start_type(self) -> DcsStartType: