mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Remove weird single-CP supply route edge case.
A CP with a factory would be able to supply itself, but was not in a supply route if it was the only connected friendly CP. When the player starts with only one base against an enemy base this meant that it was in no supply route, causing it to not be a recruitment location or a place to buy more than a reserve of vehicles automatically.
This commit is contained in:
parent
bb3e83548c
commit
81d5cddac9
@ -551,8 +551,6 @@ class UnitsDeliveryEvent:
|
|||||||
return self.destination
|
return self.destination
|
||||||
|
|
||||||
supply_route = SupplyRoute.for_control_point(self.destination)
|
supply_route = SupplyRoute.for_control_point(self.destination)
|
||||||
if supply_route is None:
|
|
||||||
return None
|
|
||||||
|
|
||||||
sources = []
|
sources = []
|
||||||
for control_point in supply_route:
|
for control_point in supply_route:
|
||||||
|
|||||||
@ -346,11 +346,7 @@ class ControlPoint(MissionTarget, ABC):
|
|||||||
|
|
||||||
from game.theater.supplyroutes import SupplyRoute
|
from game.theater.supplyroutes import SupplyRoute
|
||||||
|
|
||||||
supply_route = SupplyRoute.for_control_point(self)
|
for cp in SupplyRoute.for_control_point(self):
|
||||||
if supply_route is None:
|
|
||||||
return False
|
|
||||||
|
|
||||||
for cp in supply_route:
|
|
||||||
if cp.can_recruit_ground_units(game):
|
if cp.can_recruit_ground_units(game):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|||||||
@ -42,11 +42,14 @@ class SupplyRoute:
|
|||||||
def __iter__(self) -> Iterator[ControlPoint]:
|
def __iter__(self) -> Iterator[ControlPoint]:
|
||||||
yield from self.control_points
|
yield from self.control_points
|
||||||
|
|
||||||
|
def __len__(self) -> int:
|
||||||
|
return len(self.control_points)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def for_control_point(cls, control_point: ControlPoint) -> Optional[SupplyRoute]:
|
def for_control_point(cls, control_point: ControlPoint) -> SupplyRoute:
|
||||||
connected_friendly_points = control_point.transitive_connected_friendly_points()
|
connected_friendly_points = control_point.transitive_connected_friendly_points()
|
||||||
if not connected_friendly_points:
|
if not connected_friendly_points:
|
||||||
return None
|
return SupplyRoute([control_point])
|
||||||
return SupplyRoute([control_point] + connected_friendly_points)
|
return SupplyRoute([control_point] + connected_friendly_points)
|
||||||
|
|
||||||
def shortest_path_between(
|
def shortest_path_between(
|
||||||
|
|||||||
@ -40,8 +40,6 @@ class RoadTransferOrder(TransferOrder):
|
|||||||
|
|
||||||
def path(self) -> List[ControlPoint]:
|
def path(self) -> List[ControlPoint]:
|
||||||
supply_route = SupplyRoute.for_control_point(self.position)
|
supply_route = SupplyRoute.for_control_point(self.position)
|
||||||
if supply_route is None:
|
|
||||||
raise RuntimeError(f"Supply route from {self.position.name} interrupted")
|
|
||||||
return supply_route.shortest_path_between(self.position, self.destination)
|
return supply_route.shortest_path_between(self.position, self.destination)
|
||||||
|
|
||||||
|
|
||||||
@ -83,7 +81,7 @@ class PendingTransfers:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
supply_route = SupplyRoute.for_control_point(transfer.destination)
|
supply_route = SupplyRoute.for_control_point(transfer.destination)
|
||||||
if supply_route is None or transfer.position not in supply_route:
|
if transfer.position not in supply_route:
|
||||||
logging.info(
|
logging.info(
|
||||||
f"Route from {transfer.position.name} to {transfer.destination.name} "
|
f"Route from {transfer.position.name} to {transfer.destination.name} "
|
||||||
"was cut off."
|
"was cut off."
|
||||||
|
|||||||
@ -105,7 +105,7 @@ class QBaseMenu2(QDialog):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def has_transfer_destinations(self) -> bool:
|
def has_transfer_destinations(self) -> bool:
|
||||||
return SupplyRoute.for_control_point(self.cp) is not None
|
return len(SupplyRoute.for_control_point(self.cp)) > 1
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def can_repair_runway(self) -> bool:
|
def can_repair_runway(self) -> bool:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user