Ensure speed lock for waypoint 0.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3195.
This commit is contained in:
Dan Albert 2023-10-20 14:20:37 -07:00
parent 0e01aaf9cd
commit c5d5ea81de
3 changed files with 10 additions and 4 deletions

View File

@ -35,6 +35,7 @@ Saves from 8.x are not compatible with 9.0.0.
* **[Mission Generation]** Fixed AI flights flying far too slowly toward NAV points.
* **[Mission Generation]** Fixed Recovery Tanker mission type intermittently failing due to not being able to find the CVN.
* **[Mission Generation]** Fixed "division by zero" error on mission generation when a flight has an "In-Flight" start type and starts on top of a mission waypoint.
* **[Mission Generation]** Fixed flights not being selectable in the mission editor if fast-forward was used and they were generated at a waypoint that had a fixed TOT (such as a BARCAP that was on-station).
* **[Modding]** Unit variants can now actually override base unit type properties.
* **[New Game Wizard]** Factions are reset to default after clicking "Back" to Theater Configuration screen.
* **[Plugins]** Fixed Lua errors in Skynet plugin that would occur whenever one coalition had no IADS nodes.

View File

@ -82,7 +82,7 @@ class PydcsWaypointBuilder:
waypoint.alt_type = self.waypoint.alt_type
tot = self.flight.flight_plan.tot_for_waypoint(self.waypoint)
if tot is not None:
self.set_waypoint_tot(waypoint, tot)
self.set_waypoint_tot(waypoint, tot, self.generated_waypoint_idx)
self.add_tasks(waypoint)
return waypoint
@ -95,12 +95,18 @@ class PydcsWaypointBuilder:
for task in option.iter_tasks(ctx):
waypoint.add_task(task)
def set_waypoint_tot(self, waypoint: MovingPoint, tot: datetime) -> None:
def set_waypoint_tot(
self, waypoint: MovingPoint, tot: datetime, waypoint_index: int
) -> None:
self.waypoint.tot = tot
if not self._viggen_client_tot():
waypoint.ETA = int((tot - self.now).total_seconds())
waypoint.ETA_locked = True
waypoint.speed_locked = False
# The first waypoint must always have a locked speed (see the bug). Other
# waypoints cannot lock both a speed and an ETA, so we need to clear the
# speed lock when setting a TOT.
# https://github.com/dcs-liberation/dcs_liberation/issues/3195
waypoint.speed_locked = waypoint_index == 0
def _viggen_client_tot(self) -> bool:
"""Viggen player aircraft consider any waypoint with a TOT set to be a target ("M") waypoint.

View File

@ -55,7 +55,6 @@ class RaceTrackBuilder(PydcsWaypointBuilder):
)
racetrack = ControlledTask(orbit)
self.set_waypoint_tot(waypoint, flight_plan.patrol_start_time)
loiter_duration = flight_plan.patrol_end_time - self.now
racetrack.stop_after_time(int(loiter_duration.total_seconds()))
waypoint.add_task(racetrack)