mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Convert TOTs to datetime.
https://github.com/dcs-liberation/dcs_liberation/issues/1680
This commit is contained in:
@@ -94,7 +94,6 @@ class FlightGroupConfigurator:
|
||||
self.flight,
|
||||
self.group,
|
||||
self.mission,
|
||||
self.game.conditions.start_time,
|
||||
self.time,
|
||||
self.game.settings,
|
||||
self.mission_data,
|
||||
|
||||
@@ -22,8 +22,6 @@ class HoldPointBuilder(PydcsWaypointBuilder):
|
||||
return
|
||||
push_time = self.flight.flight_plan.push_time
|
||||
self.waypoint.departure_time = push_time
|
||||
loiter.stop_after_time(
|
||||
int((push_time - self.elapsed_mission_time).total_seconds())
|
||||
)
|
||||
loiter.stop_after_time(int((push_time - self.now).total_seconds()))
|
||||
waypoint.add_task(loiter)
|
||||
waypoint.add_task(OptFormation.finger_four_close())
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
from datetime import datetime
|
||||
from typing import Any, Iterable, Union
|
||||
|
||||
from dcs import Mission
|
||||
@@ -28,7 +28,7 @@ class PydcsWaypointBuilder:
|
||||
group: FlyingGroup[Any],
|
||||
flight: Flight,
|
||||
mission: Mission,
|
||||
elapsed_mission_time: timedelta,
|
||||
now: datetime,
|
||||
mission_data: MissionData,
|
||||
unit_map: UnitMap,
|
||||
) -> None:
|
||||
@@ -37,7 +37,7 @@ class PydcsWaypointBuilder:
|
||||
self.package = flight.package
|
||||
self.flight = flight
|
||||
self.mission = mission
|
||||
self.elapsed_mission_time = elapsed_mission_time
|
||||
self.now = now
|
||||
self.mission_data = mission_data
|
||||
self.unit_map = unit_map
|
||||
|
||||
@@ -68,10 +68,10 @@ class PydcsWaypointBuilder:
|
||||
def add_tasks(self, waypoint: MovingPoint) -> None:
|
||||
pass
|
||||
|
||||
def set_waypoint_tot(self, waypoint: MovingPoint, tot: timedelta) -> None:
|
||||
def set_waypoint_tot(self, waypoint: MovingPoint, tot: datetime) -> None:
|
||||
self.waypoint.tot = tot
|
||||
if not self._viggen_client_tot():
|
||||
waypoint.ETA = int((tot - self.elapsed_mission_time).total_seconds())
|
||||
waypoint.ETA = int((tot - self.now).total_seconds())
|
||||
waypoint.ETA_locked = True
|
||||
waypoint.speed_locked = False
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ class RaceTrackBuilder(PydcsWaypointBuilder):
|
||||
|
||||
racetrack = ControlledTask(orbit)
|
||||
self.set_waypoint_tot(waypoint, flight_plan.patrol_start_time)
|
||||
loiter_duration = flight_plan.patrol_end_time - self.elapsed_mission_time
|
||||
loiter_duration = flight_plan.patrol_end_time - self.now
|
||||
racetrack.stop_after_time(int(loiter_duration.total_seconds()))
|
||||
waypoint.add_task(racetrack)
|
||||
|
||||
|
||||
@@ -25,13 +25,13 @@ from game.settings import Settings
|
||||
from game.unitmap import UnitMap
|
||||
from game.utils import pairwise
|
||||
from .baiingress import BaiIngressBuilder
|
||||
from .landingzone import LandingZoneBuilder
|
||||
from .casingress import CasIngressBuilder
|
||||
from .deadingress import DeadIngressBuilder
|
||||
from .default import DefaultWaypointBuilder
|
||||
from .holdpoint import HoldPointBuilder
|
||||
from .joinpoint import JoinPointBuilder
|
||||
from .landingpoint import LandingPointBuilder
|
||||
from .landingzone import LandingZoneBuilder
|
||||
from .ocaaircraftingress import OcaAircraftIngressBuilder
|
||||
from .ocarunwayingress import OcaRunwayIngressBuilder
|
||||
from .pydcswaypointbuilder import PydcsWaypointBuilder, TARGET_WAYPOINTS
|
||||
@@ -50,7 +50,6 @@ class WaypointGenerator:
|
||||
flight: Flight,
|
||||
group: FlyingGroup[Any],
|
||||
mission: Mission,
|
||||
turn_start_time: datetime,
|
||||
time: datetime,
|
||||
settings: Settings,
|
||||
mission_data: MissionData,
|
||||
@@ -59,7 +58,6 @@ class WaypointGenerator:
|
||||
self.flight = flight
|
||||
self.group = group
|
||||
self.mission = mission
|
||||
self.elapsed_mission_time = time - turn_start_time
|
||||
self.time = time
|
||||
self.settings = settings
|
||||
self.mission_data = mission_data
|
||||
@@ -150,7 +148,7 @@ class WaypointGenerator:
|
||||
self.group,
|
||||
self.flight,
|
||||
self.mission,
|
||||
self.elapsed_mission_time,
|
||||
self.time,
|
||||
self.mission_data,
|
||||
self.unit_map,
|
||||
)
|
||||
@@ -182,12 +180,29 @@ class WaypointGenerator:
|
||||
a.min_fuel = min_fuel
|
||||
|
||||
def set_takeoff_time(self, waypoint: FlightWaypoint) -> timedelta:
|
||||
force_delay = False
|
||||
if isinstance(self.flight.state, WaitingForStart):
|
||||
delay = self.flight.state.time_remaining(self.time)
|
||||
elif (
|
||||
# The first two clauses capture the flight states that we want to adjust. We
|
||||
# don't want to delay any flights that are already in flight or on the
|
||||
# runway.
|
||||
not self.flight.state.in_flight
|
||||
and self.flight.state.spawn_type is not StartType.RUNWAY
|
||||
and self.flight.departure.is_fleet
|
||||
and not self.flight.client_count
|
||||
):
|
||||
# https://github.com/dcs-liberation/dcs_liberation/issues/1309
|
||||
# Without a delay, AI aircraft will be spawned on the sixpack, which other
|
||||
# AI planes of course want to taxi through, deadlocking the carrier deck.
|
||||
# Delaying AI carrier deck spawns by one second for some reason causes DCS
|
||||
# to spawn those aircraft elsewhere, avoiding the traffic jam.
|
||||
delay = timedelta(seconds=1)
|
||||
force_delay = True
|
||||
else:
|
||||
delay = timedelta()
|
||||
|
||||
if self.should_delay_flight():
|
||||
if force_delay or self.should_delay_flight():
|
||||
if self.should_activate_late():
|
||||
# Late activation causes the aircraft to not be spawned
|
||||
# until triggered.
|
||||
|
||||
@@ -5,7 +5,6 @@ from __future__ import annotations
|
||||
|
||||
import os
|
||||
from dataclasses import dataclass
|
||||
from datetime import timedelta
|
||||
from typing import Dict, List, TYPE_CHECKING
|
||||
|
||||
from dcs.mission import Mission
|
||||
@@ -127,11 +126,9 @@ class MissionInfoGenerator:
|
||||
|
||||
def format_waypoint_time(waypoint: FlightWaypoint, depart_prefix: str) -> str:
|
||||
if waypoint.tot is not None:
|
||||
time = timedelta(seconds=int(waypoint.tot.total_seconds()))
|
||||
return f"T+{time} "
|
||||
return f"{waypoint.tot.time()} "
|
||||
elif waypoint.departure_time is not None:
|
||||
time = timedelta(seconds=int(waypoint.departure_time.total_seconds()))
|
||||
return f"{depart_prefix} T+{time} "
|
||||
return f"{depart_prefix} {waypoint.departure_time.time()} "
|
||||
return ""
|
||||
|
||||
|
||||
|
||||
@@ -254,11 +254,11 @@ class FlightPlanBuilder:
|
||||
]
|
||||
)
|
||||
|
||||
def _format_time(self, time: Optional[datetime.timedelta]) -> str:
|
||||
@staticmethod
|
||||
def _format_time(time: datetime.datetime | None) -> str:
|
||||
if time is None:
|
||||
return ""
|
||||
local_time = self.start_time + time
|
||||
return f"{local_time.strftime('%H:%M:%S')}{'Z' if local_time.tzinfo is not None else ''}"
|
||||
return f"{time.strftime('%H:%M:%S')}{'Z' if time.tzinfo is not None else ''}"
|
||||
|
||||
def _format_alt(self, alt: Distance) -> str:
|
||||
return f"{self.units.distance_short(alt):.0f}"
|
||||
@@ -583,11 +583,11 @@ class SupportPage(KneeboardPage):
|
||||
)
|
||||
return f"{channel_name}\n{frequency}"
|
||||
|
||||
def _format_time(self, time: Optional[datetime.timedelta]) -> str:
|
||||
@staticmethod
|
||||
def _format_time(time: datetime.datetime | None) -> str:
|
||||
if time is None:
|
||||
return ""
|
||||
local_time = self.start_time + time
|
||||
return f"{local_time.strftime('%H:%M:%S')}{'Z' if local_time.tzinfo is not None else ''}"
|
||||
return f"{time.strftime('%H:%M:%S')}{'Z' if time.tzinfo is not None else ''}"
|
||||
|
||||
|
||||
class SeadTaskPage(KneeboardPage):
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from datetime import timedelta
|
||||
from datetime import datetime
|
||||
from typing import Optional, TYPE_CHECKING
|
||||
|
||||
from game.dcs.aircrafttype import AircraftType
|
||||
from game.missiongenerator.aircraft.flightdata import FlightData
|
||||
|
||||
from game.runways import RunwayData
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -31,8 +31,8 @@ class AwacsInfo(GroupInfo):
|
||||
"""AWACS information for the kneeboard."""
|
||||
|
||||
depature_location: Optional[str]
|
||||
start_time: Optional[timedelta]
|
||||
end_time: Optional[timedelta]
|
||||
start_time: datetime | None
|
||||
end_time: datetime | None
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -41,8 +41,8 @@ class TankerInfo(GroupInfo):
|
||||
|
||||
variant: str
|
||||
tacan: TacanChannel
|
||||
start_time: Optional[timedelta]
|
||||
end_time: Optional[timedelta]
|
||||
start_time: datetime | None
|
||||
end_time: datetime | None
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
Reference in New Issue
Block a user