From c5d5ea81dee04ca830404d440a4e35275b839466 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Fri, 20 Oct 2023 14:20:37 -0700 Subject: [PATCH] Ensure speed lock for waypoint 0. Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3195. --- changelog.md | 1 + .../aircraft/waypoints/pydcswaypointbuilder.py | 12 +++++++++--- .../missiongenerator/aircraft/waypoints/racetrack.py | 1 - 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index c4d11d8f..6cdd505a 100644 --- a/changelog.md +++ b/changelog.md @@ -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. diff --git a/game/missiongenerator/aircraft/waypoints/pydcswaypointbuilder.py b/game/missiongenerator/aircraft/waypoints/pydcswaypointbuilder.py index 1c64e0e4..e003284d 100644 --- a/game/missiongenerator/aircraft/waypoints/pydcswaypointbuilder.py +++ b/game/missiongenerator/aircraft/waypoints/pydcswaypointbuilder.py @@ -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. diff --git a/game/missiongenerator/aircraft/waypoints/racetrack.py b/game/missiongenerator/aircraft/waypoints/racetrack.py index 24fefae7..5a14dd4d 100644 --- a/game/missiongenerator/aircraft/waypoints/racetrack.py +++ b/game/missiongenerator/aircraft/waypoints/racetrack.py @@ -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)