mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Streamlining
This commit is contained in:
parent
59673e7911
commit
ea726bbf06
@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
from datetime import timedelta, datetime
|
||||
from typing import Type
|
||||
|
||||
from .airassault import AirAssaultLayout
|
||||
@ -17,7 +17,7 @@ from ...utils import feet
|
||||
|
||||
class EscortFlightPlan(FormationAttackFlightPlan):
|
||||
@property
|
||||
def push_time(self) -> timedelta:
|
||||
def push_time(self) -> datetime:
|
||||
hold2join_time = (
|
||||
self.travel_time_between_waypoints(
|
||||
self.layout.hold,
|
||||
|
||||
@ -287,27 +287,6 @@ class FlightPlan(ABC, Generic[LayoutT]):
|
||||
+ 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:
|
||||
return (
|
||||
self.takeoff_time() - self.estimate_startup() - self.estimate_ground_ops()
|
||||
@ -334,9 +313,11 @@ class FlightPlan(ABC, Generic[LayoutT]):
|
||||
def is_airassault(self) -> bool:
|
||||
return False
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def mission_begin_on_station_time(self) -> datetime | None:
|
||||
"""The time that the mission is first on-station."""
|
||||
...
|
||||
|
||||
@property
|
||||
def is_custom(self) -> bool:
|
||||
|
||||
@ -93,8 +93,8 @@ class FormationFlightPlan(LoiterFlightPlan, ABC):
|
||||
@property
|
||||
def push_time(self) -> datetime:
|
||||
return self.join_time - self.travel_time_between_waypoints(
|
||||
self.layout.hold.position,
|
||||
self.layout.join.position,
|
||||
self.layout.hold,
|
||||
self.layout.join,
|
||||
)
|
||||
|
||||
@property
|
||||
|
||||
@ -88,7 +88,7 @@ class PatrollingFlightPlan(StandardFlightPlan[LayoutT], UiZoneDisplay, ABC):
|
||||
return self.layout.patrol_start
|
||||
|
||||
@property
|
||||
def mission_begin_on_station_time(self) -> datetime:
|
||||
def mission_begin_on_station_time(self) -> datetime | None:
|
||||
return self.patrol_start_time
|
||||
|
||||
@property
|
||||
|
||||
@ -79,14 +79,15 @@ class SweepFlightPlan(LoiterFlightPlan):
|
||||
@property
|
||||
def push_time(self) -> datetime:
|
||||
return self.sweep_end_time - self.travel_time_between_waypoints(
|
||||
self.layout.hold.position,
|
||||
self.layout.sweep_end.position,
|
||||
self.layout.hold,
|
||||
self.layout.sweep_end,
|
||||
)
|
||||
|
||||
@property
|
||||
def mission_begin_on_station_time(self) -> datetime | None:
|
||||
return None
|
||||
|
||||
@property
|
||||
def mission_departure_time(self) -> datetime:
|
||||
return self.sweep_end_time
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import typing
|
||||
from datetime import datetime
|
||||
from datetime import timedelta
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from dcs.countries import countries_by_name
|
||||
@ -68,9 +68,9 @@ class Migrator:
|
||||
for p in c.ato.packages:
|
||||
try_set_attr(p, "custom_name")
|
||||
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 - self.game.conditions.start_time
|
||||
p.time_over_target + self.game.conditions.start_time
|
||||
)
|
||||
|
||||
def _update_control_points(self) -> None:
|
||||
|
||||
@ -286,7 +286,7 @@ class FlotGenerator:
|
||||
if len(tots) == 0
|
||||
else min(
|
||||
[
|
||||
x.time_over_target
|
||||
x.time_over_target - self.mission.start_time
|
||||
for x in self.game.ato_for(player).packages
|
||||
if x.primary_task == FlightType.CAS
|
||||
]
|
||||
|
||||
@ -33,8 +33,8 @@ class AwacsInfo(GroupInfo):
|
||||
"""AWACS information for the kneeboard."""
|
||||
|
||||
depature_location: Optional[str]
|
||||
start_time: datetime | None
|
||||
end_time: datetime | None
|
||||
start_time: datetime
|
||||
end_time: datetime
|
||||
|
||||
|
||||
@dataclass
|
||||
@ -43,8 +43,8 @@ class TankerInfo(GroupInfo):
|
||||
|
||||
variant: str
|
||||
tacan: Optional[TacanChannel]
|
||||
start_time: datetime | None
|
||||
end_time: datetime | None
|
||||
start_time: datetime
|
||||
end_time: datetime
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
@ -384,6 +384,7 @@ class Squadron:
|
||||
|
||||
def plan_relocation(self, destination: ControlPoint, now: datetime) -> None:
|
||||
from game.theater import ParkingType
|
||||
|
||||
if destination == self.location:
|
||||
logging.warning(
|
||||
f"Attempted to plan relocation of {self} to current location "
|
||||
|
||||
@ -94,7 +94,7 @@ class QFactionUnits(QScrollArea):
|
||||
def updateFactionUnits(self, units: Union[set, list]):
|
||||
deletes = []
|
||||
for a in units:
|
||||
if not self.checkboxes[a.name].isChecked():
|
||||
if not self.checkboxes[str(a)].isChecked():
|
||||
deletes.append(a)
|
||||
for d in deletes:
|
||||
units.remove(d)
|
||||
|
||||
@ -20,7 +20,7 @@ iniconfig==2.0.0
|
||||
Jinja2==3.1.2
|
||||
lupa==2.0
|
||||
MarkupSafe==2.1.3
|
||||
mypy==1.4.1
|
||||
mypy==1.5.1
|
||||
mypy-extensions==1.0.0
|
||||
nodeenv==1.8.0
|
||||
packaging==23.1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user