Fix kneeboard crash for small strike missions.

When we don't coalesce target points on the kneeboard we call
add_waypoint_row multiple times, so calls after the first were using
the travel time from one strike target to the next. Since they were so
close that rounded down to zero and caused a divide by zero error.

Update the last waypoint in add_waypoint instead.
This commit is contained in:
Dan Albert 2020-10-23 22:41:28 -07:00
parent 15db12fb21
commit 5f02febb6c

View File

@ -124,6 +124,7 @@ class FlightPlanBuilder:
self.target_points = []
self.add_waypoint_row(NumberedWaypoint(waypoint_num, waypoint))
self.last_waypoint = waypoint
def coalesce_target_points(self) -> None:
if len(self.target_points) <= 4:
@ -155,7 +156,6 @@ class FlightPlanBuilder:
self._format_time(waypoint.waypoint.tot),
self._format_time(waypoint.waypoint.departure_time),
])
self.last_waypoint = waypoint.waypoint
def _format_time(self, time: Optional[int]) -> str:
if time is None: