Skip to content

Commit

Permalink
Tnt: Avoid divide-by-zero errors in calc_velocity()
Browse files Browse the repository at this point in the history
  • Loading branch information
paramat committed May 8, 2016
1 parent b36b154 commit e7a5573
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions mods/tnt/init.lua
Expand Up @@ -110,6 +110,11 @@ end


local function calc_velocity(pos1, pos2, old_vel, power)
-- Avoid errors caused by a vector of zero length
if vector.equals(pos1, pos2) then
return old_vel
end

local vel = vector.direction(pos1, pos2)
vel = vector.normalize(vel)
vel = vector.multiply(vel, power)
Expand Down

0 comments on commit e7a5573

Please sign in to comment.