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 33a06c2 commit 6a8bf38
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion scripts/ai/strategies/AIDriveStrategyCombineCourse.lua
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,13 @@ function AIDriveStrategyCombineCourse:estimateDistanceUntilFull(ix)
if ix > 1 then
local dToNext = self.course:getDistanceToNextWaypoint(ix - 1)
if self.fillLevelAtLastWaypoint and self.fillLevelAtLastWaypoint > 0 and self.fillLevelAtLastWaypoint <= fillLevel then
local litersPerMeter = (fillLevel - self.fillLevelAtLastWaypoint) / dToNext
local litersPerMeter
if dToNext > 0.1 then
litersPerMeter = (fillLevel - self.fillLevelAtLastWaypoint) / dToNext
else
-- use the last known liters per meter if the distance is too short
litersPerMeter = self.litersPerMeter
end
local litersPerSecond = 0
if self.fillLevelLastCheckedTime and (self.fillLevelLastCheckedTime < g_currentMission.time) then
litersPerSecond = (fillLevel - self.fillLevelAtLastWaypoint) /
Expand Down

0 comments on commit 6a8bf38

Please sign in to comment.