Skip to content

Commit

Permalink
fix: divide by zero
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Vaiko committed Jan 27, 2025
1 parent bf2940d commit 33a06c2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions scripts/ai/turns/TurnManeuver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ end
-- startDir and stopDir are points (x,z). The arc starts where the line from the center of the circle
-- to startDir intersects the circle and ends where the line from the center of the circle to stopDir
-- intersects the circle.
--
-- TODO: this is relic from probably FS15 and should be refactored
function TurnManeuver:generateTurnCircle(center, startDir, stopDir, radius, clockwise, addEndPoint, reverse)
-- Convert clockwise to the right format
if clockwise == nil then
Expand Down Expand Up @@ -167,7 +167,12 @@ function TurnManeuver:generateTurnCircle(center, startDir, stopDir, radius, cloc
-- Get the number of waypoints
numWP = math.ceil(degreeToTurn / degreeStep)
-- Recalculate degreeStep
degreeStep = (degreeToTurn / numWP) * clockwise
if numWP >= 1 then
degreeStep = (degreeToTurn / numWP) * clockwise
else
self:debug("generateTurnCircle: numberOfWaypoints=%d, skipping", numWP)
return
end
-- Add extra waypoint if addEndPoint is true
if addEndPoint then
numWP = numWP + 1
Expand Down

0 comments on commit 33a06c2

Please sign in to comment.