mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Fix carrier packages at beginning of campaign.
Fixes https://github.com/Khopa/dcs_liberation/issues/819
This commit is contained in:
parent
fee497219e
commit
7e415b3fd7
@ -15,11 +15,17 @@ class ClosestAirfields:
|
|||||||
def __init__(self, target: MissionTarget,
|
def __init__(self, target: MissionTarget,
|
||||||
all_control_points: List[ControlPoint]) -> None:
|
all_control_points: List[ControlPoint]) -> None:
|
||||||
self.target = target
|
self.target = target
|
||||||
airfields = (c for c in all_control_points if c.runway_is_operational())
|
# This cache is configured once on load, so it's important that it is
|
||||||
|
# complete and deterministic to avoid different behaviors across loads.
|
||||||
|
# E.g. https://github.com/Khopa/dcs_liberation/issues/819
|
||||||
self.closest_airfields: List[ControlPoint] = sorted(
|
self.closest_airfields: List[ControlPoint] = sorted(
|
||||||
airfields, key=lambda c: self.target.distance_to(c)
|
all_control_points, key=lambda c: self.target.distance_to(c)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def operational_airfields(self) -> Iterator[ControlPoint]:
|
||||||
|
return (c for c in self.closest_airfields if c.runway_is_operational())
|
||||||
|
|
||||||
def airfields_within(self, distance: Distance) -> Iterator[ControlPoint]:
|
def airfields_within(self, distance: Distance) -> Iterator[ControlPoint]:
|
||||||
"""Iterates over all airfields within the given range of the target.
|
"""Iterates over all airfields within the given range of the target.
|
||||||
|
|
||||||
|
|||||||
@ -1041,7 +1041,7 @@ class FlightPlanBuilder:
|
|||||||
def racetrack_for_objective(self, location: MissionTarget,
|
def racetrack_for_objective(self, location: MissionTarget,
|
||||||
barcap: bool) -> Tuple[Point, Point]:
|
barcap: bool) -> Tuple[Point, Point]:
|
||||||
closest_cache = ObjectiveDistanceCache.get_closest_airfields(location)
|
closest_cache = ObjectiveDistanceCache.get_closest_airfields(location)
|
||||||
for airfield in closest_cache.closest_airfields:
|
for airfield in closest_cache.operational_airfields:
|
||||||
# If the mission is a BARCAP of an enemy airfield, find the *next*
|
# If the mission is a BARCAP of an enemy airfield, find the *next*
|
||||||
# closest enemy airfield.
|
# closest enemy airfield.
|
||||||
if airfield == self.package.target:
|
if airfield == self.package.target:
|
||||||
@ -1517,7 +1517,7 @@ class FlightPlanBuilder:
|
|||||||
cache = ObjectiveDistanceCache.get_closest_airfields(
|
cache = ObjectiveDistanceCache.get_closest_airfields(
|
||||||
self.package.target
|
self.package.target
|
||||||
)
|
)
|
||||||
for airfield in cache.closest_airfields:
|
for airfield in cache.operational_airfields:
|
||||||
for flight in self.package.flights:
|
for flight in self.package.flights:
|
||||||
if flight.departure == airfield:
|
if flight.departure == airfield:
|
||||||
return airfield
|
return airfield
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user