Streamlining

This commit is contained in:
Raffson 2023-10-07 21:37:49 +02:00
parent 59673e7911
commit ea726bbf06
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
11 changed files with 21 additions and 38 deletions

View File

@ -1,6 +1,6 @@
from __future__ import annotations from __future__ import annotations
from datetime import timedelta from datetime import timedelta, datetime
from typing import Type from typing import Type
from .airassault import AirAssaultLayout from .airassault import AirAssaultLayout
@ -17,7 +17,7 @@ from ...utils import feet
class EscortFlightPlan(FormationAttackFlightPlan): class EscortFlightPlan(FormationAttackFlightPlan):
@property @property
def push_time(self) -> timedelta: def push_time(self) -> datetime:
hold2join_time = ( hold2join_time = (
self.travel_time_between_waypoints( self.travel_time_between_waypoints(
self.layout.hold, self.layout.hold,

View File

@ -287,27 +287,6 @@ class FlightPlan(ABC, Generic[LayoutT]):
+ self.estimate_ground_ops() + self.estimate_ground_ops()
) )
# In case FP math has given us some barely below zero time, round to
# zero.
if math.isclose(start_time.total_seconds(), 0):
start_time = timedelta()
# Trim microseconds. DCS doesn't handle sub-second resolution for tasks,
# and they're not interesting from a mission planning perspective so we
# don't want them in the UI.
#
# Round down so *barely* above zero start times are just zero.
start_time = timedelta(seconds=math.floor(start_time.total_seconds()))
# Feature request #1309: Carrier planes should start at +1s
# This is a workaround to a DCS problem: some AI planes spawn on
# the 'sixpack' when start_time is zero and cause a deadlock.
# Workaround: force the start_time to 1 second for these planes.
if self.flight.departure.is_fleet and start_time.total_seconds() == 0:
start_time = timedelta(seconds=1)
return start_time
def startup_time(self) -> datetime: def startup_time(self) -> datetime:
return ( return (
self.takeoff_time() - self.estimate_startup() - self.estimate_ground_ops() self.takeoff_time() - self.estimate_startup() - self.estimate_ground_ops()
@ -334,9 +313,11 @@ class FlightPlan(ABC, Generic[LayoutT]):
def is_airassault(self) -> bool: def is_airassault(self) -> bool:
return False return False
@property
@abstractmethod @abstractmethod
def mission_begin_on_station_time(self) -> datetime | None: def mission_begin_on_station_time(self) -> datetime | None:
"""The time that the mission is first on-station.""" """The time that the mission is first on-station."""
...
@property @property
def is_custom(self) -> bool: def is_custom(self) -> bool:

View File

@ -93,8 +93,8 @@ class FormationFlightPlan(LoiterFlightPlan, ABC):
@property @property
def push_time(self) -> datetime: def push_time(self) -> datetime:
return self.join_time - self.travel_time_between_waypoints( return self.join_time - self.travel_time_between_waypoints(
self.layout.hold.position, self.layout.hold,
self.layout.join.position, self.layout.join,
) )
@property @property

View File

@ -88,7 +88,7 @@ class PatrollingFlightPlan(StandardFlightPlan[LayoutT], UiZoneDisplay, ABC):
return self.layout.patrol_start return self.layout.patrol_start
@property @property
def mission_begin_on_station_time(self) -> datetime: def mission_begin_on_station_time(self) -> datetime | None:
return self.patrol_start_time return self.patrol_start_time
@property @property

View File

@ -79,14 +79,15 @@ class SweepFlightPlan(LoiterFlightPlan):
@property @property
def push_time(self) -> datetime: def push_time(self) -> datetime:
return self.sweep_end_time - self.travel_time_between_waypoints( return self.sweep_end_time - self.travel_time_between_waypoints(
self.layout.hold.position, self.layout.hold,
self.layout.sweep_end.position, self.layout.sweep_end,
) )
@property @property
def mission_begin_on_station_time(self) -> datetime | None: def mission_begin_on_station_time(self) -> datetime | None:
return None return None
@property
def mission_departure_time(self) -> datetime: def mission_departure_time(self) -> datetime:
return self.sweep_end_time return self.sweep_end_time

View File

@ -1,7 +1,7 @@
from __future__ import annotations from __future__ import annotations
import typing import typing
from datetime import datetime from datetime import timedelta
from typing import TYPE_CHECKING, Any from typing import TYPE_CHECKING, Any
from dcs.countries import countries_by_name from dcs.countries import countries_by_name
@ -68,9 +68,9 @@ class Migrator:
for p in c.ato.packages: for p in c.ato.packages:
try_set_attr(p, "custom_name") try_set_attr(p, "custom_name")
try_set_attr(p, "frequency") try_set_attr(p, "frequency")
if self.is_liberation and isinstance(p.time_over_target, datetime): # type: ignore if isinstance(p.time_over_target, timedelta): # type: ignore
p.time_over_target = ( # type: ignore p.time_over_target = ( # type: ignore
p.time_over_target - self.game.conditions.start_time p.time_over_target + self.game.conditions.start_time
) )
def _update_control_points(self) -> None: def _update_control_points(self) -> None:

View File

@ -286,7 +286,7 @@ class FlotGenerator:
if len(tots) == 0 if len(tots) == 0
else min( else min(
[ [
x.time_over_target x.time_over_target - self.mission.start_time
for x in self.game.ato_for(player).packages for x in self.game.ato_for(player).packages
if x.primary_task == FlightType.CAS if x.primary_task == FlightType.CAS
] ]

View File

@ -33,8 +33,8 @@ class AwacsInfo(GroupInfo):
"""AWACS information for the kneeboard.""" """AWACS information for the kneeboard."""
depature_location: Optional[str] depature_location: Optional[str]
start_time: datetime | None start_time: datetime
end_time: datetime | None end_time: datetime
@dataclass @dataclass
@ -43,8 +43,8 @@ class TankerInfo(GroupInfo):
variant: str variant: str
tacan: Optional[TacanChannel] tacan: Optional[TacanChannel]
start_time: datetime | None start_time: datetime
end_time: datetime | None end_time: datetime
@dataclass @dataclass

View File

@ -384,6 +384,7 @@ class Squadron:
def plan_relocation(self, destination: ControlPoint, now: datetime) -> None: def plan_relocation(self, destination: ControlPoint, now: datetime) -> None:
from game.theater import ParkingType from game.theater import ParkingType
if destination == self.location: if destination == self.location:
logging.warning( logging.warning(
f"Attempted to plan relocation of {self} to current location " f"Attempted to plan relocation of {self} to current location "

View File

@ -94,7 +94,7 @@ class QFactionUnits(QScrollArea):
def updateFactionUnits(self, units: Union[set, list]): def updateFactionUnits(self, units: Union[set, list]):
deletes = [] deletes = []
for a in units: for a in units:
if not self.checkboxes[a.name].isChecked(): if not self.checkboxes[str(a)].isChecked():
deletes.append(a) deletes.append(a)
for d in deletes: for d in deletes:
units.remove(d) units.remove(d)

View File

@ -20,7 +20,7 @@ iniconfig==2.0.0
Jinja2==3.1.2 Jinja2==3.1.2
lupa==2.0 lupa==2.0
MarkupSafe==2.1.3 MarkupSafe==2.1.3
mypy==1.4.1 mypy==1.5.1
mypy-extensions==1.0.0 mypy-extensions==1.0.0
nodeenv==1.8.0 nodeenv==1.8.0
packaging==23.1 packaging==23.1