mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Fix supply route clobbering, make immutable.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1083
This commit is contained in:
parent
7934463a53
commit
62b743025a
@ -8,7 +8,20 @@ from abc import ABC, abstractmethod
|
|||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from functools import total_ordering
|
from functools import total_ordering
|
||||||
from typing import Any, Dict, Iterator, List, Optional, Set, TYPE_CHECKING, Type, Union
|
from typing import (
|
||||||
|
Any,
|
||||||
|
Dict,
|
||||||
|
Iterator,
|
||||||
|
List,
|
||||||
|
Optional,
|
||||||
|
Set,
|
||||||
|
TYPE_CHECKING,
|
||||||
|
Type,
|
||||||
|
Union,
|
||||||
|
Sequence,
|
||||||
|
Iterable,
|
||||||
|
Tuple,
|
||||||
|
)
|
||||||
|
|
||||||
from dcs.mapping import Point
|
from dcs.mapping import Point
|
||||||
from dcs.ships import (
|
from dcs.ships import (
|
||||||
@ -306,8 +319,8 @@ class ControlPoint(MissionTarget, ABC):
|
|||||||
# TODO: Should be Airbase specific.
|
# TODO: Should be Airbase specific.
|
||||||
self.has_frontline = has_frontline
|
self.has_frontline = has_frontline
|
||||||
self.connected_points: List[ControlPoint] = []
|
self.connected_points: List[ControlPoint] = []
|
||||||
self.convoy_routes: Dict[ControlPoint, List[Point]] = {}
|
self.convoy_routes: Dict[ControlPoint, Tuple[Point, ...]] = {}
|
||||||
self.shipping_lanes: Dict[ControlPoint, List[Point]] = {}
|
self.shipping_lanes: Dict[ControlPoint, Tuple[Point, ...]] = {}
|
||||||
self.base: Base = Base()
|
self.base: Base = Base()
|
||||||
self.cptype = cptype
|
self.cptype = cptype
|
||||||
# TODO: Should be Airbase specific.
|
# TODO: Should be Airbase specific.
|
||||||
@ -445,16 +458,18 @@ class ControlPoint(MissionTarget, ABC):
|
|||||||
def convoy_origin_for(self, destination: ControlPoint) -> Point:
|
def convoy_origin_for(self, destination: ControlPoint) -> Point:
|
||||||
return self.convoy_route_to(destination)[0]
|
return self.convoy_route_to(destination)[0]
|
||||||
|
|
||||||
def convoy_route_to(self, destination: ControlPoint) -> List[Point]:
|
def convoy_route_to(self, destination: ControlPoint) -> Sequence[Point]:
|
||||||
return self.convoy_routes[destination]
|
return self.convoy_routes[destination]
|
||||||
|
|
||||||
def create_convoy_route(self, to: ControlPoint, waypoints: List[Point]) -> None:
|
def create_convoy_route(self, to: ControlPoint, waypoints: Iterable[Point]) -> None:
|
||||||
self.connected_points.append(to)
|
self.connected_points.append(to)
|
||||||
self.stances[to.id] = CombatStance.DEFENSIVE
|
self.stances[to.id] = CombatStance.DEFENSIVE
|
||||||
self.convoy_routes[to] = waypoints
|
self.convoy_routes[to] = tuple(waypoints)
|
||||||
|
|
||||||
def create_shipping_lane(self, to: ControlPoint, waypoints: List[Point]) -> None:
|
def create_shipping_lane(
|
||||||
self.shipping_lanes[to] = waypoints
|
self, to: ControlPoint, waypoints: Iterable[Point]
|
||||||
|
) -> None:
|
||||||
|
self.shipping_lanes[to] = tuple(waypoints)
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def runway_is_operational(self) -> bool:
|
def runway_is_operational(self) -> bool:
|
||||||
|
|||||||
@ -52,7 +52,7 @@ class FrontLine(MissionTarget):
|
|||||||
self.blue_cp = blue_point
|
self.blue_cp = blue_point
|
||||||
self.red_cp = red_point
|
self.red_cp = red_point
|
||||||
try:
|
try:
|
||||||
route = blue_point.convoy_route_to(red_point)
|
route = list(blue_point.convoy_route_to(red_point))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# Some campaigns are air only and the mission generator currently relies on
|
# Some campaigns are air only and the mission generator currently relies on
|
||||||
# *some* "front line" being drawn between these two. In this case there will
|
# *some* "front line" being drawn between these two. In this case there will
|
||||||
|
|||||||
@ -4,7 +4,17 @@ import logging
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from functools import singledispatchmethod
|
from functools import singledispatchmethod
|
||||||
from typing import Dict, Generic, Iterator, List, Optional, TYPE_CHECKING, Type, TypeVar
|
from typing import (
|
||||||
|
Dict,
|
||||||
|
Generic,
|
||||||
|
Iterator,
|
||||||
|
List,
|
||||||
|
Optional,
|
||||||
|
TYPE_CHECKING,
|
||||||
|
Type,
|
||||||
|
TypeVar,
|
||||||
|
Sequence,
|
||||||
|
)
|
||||||
|
|
||||||
from dcs.mapping import Point
|
from dcs.mapping import Point
|
||||||
from dcs.unittype import FlyingType, VehicleType
|
from dcs.unittype import FlyingType, VehicleType
|
||||||
@ -363,7 +373,7 @@ class CargoShip(MultiGroupTransport):
|
|||||||
yield from super().mission_types(for_player)
|
yield from super().mission_types(for_player)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def route(self) -> List[Point]:
|
def route(self) -> Sequence[Point]:
|
||||||
return self.origin.shipping_lanes[self.destination]
|
return self.origin.shipping_lanes[self.destination]
|
||||||
|
|
||||||
def description(self) -> str:
|
def description(self) -> str:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user