From f9916e47d8959be6233fb0c8b3587fba31aa4850 Mon Sep 17 00:00:00 2001 From: zhexu14 <64713351+zhexu14@users.noreply.github.com> Date: Mon, 2 Oct 2023 16:36:23 +1100 Subject: [PATCH] address issue 3175 by introducing special divide by zero handling --- changelog.md | 1 + game/ato/flightstate/navigating.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/changelog.md b/changelog.md index c644f982..ca0b749f 100644 --- a/changelog.md +++ b/changelog.md @@ -32,6 +32,7 @@ Saves from 8.x are not compatible with 9.0.0. * **[Mission Generation]** Fix generation of OCA Runway missions to allow LGBs to be used. * **[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. * **[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/ato/flightstate/navigating.py b/game/ato/flightstate/navigating.py index fc97c2be..dbaf67a5 100644 --- a/game/ato/flightstate/navigating.py +++ b/game/ato/flightstate/navigating.py @@ -29,6 +29,11 @@ class Navigating(InFlight): events.update_flight_position(self.flight, self.estimate_position()) def progress(self) -> float: + # if next waypoint is very close, assume we reach it immediately to avoid divide + # by zero error + if self.total_time_to_next_waypoint.total_seconds() < 1: + return 1.0 + return ( self.elapsed_time.total_seconds() / self.total_time_to_next_waypoint.total_seconds()