Skip to content

Commit e7a5573

Browse files
committed
Tnt: Avoid divide-by-zero errors in calc_velocity()
1 parent b36b154 commit e7a5573

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

mods/tnt/init.lua

+5
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ end
110110

111111

112112
local function calc_velocity(pos1, pos2, old_vel, power)
113+
-- Avoid errors caused by a vector of zero length
114+
if vector.equals(pos1, pos2) then
115+
return old_vel
116+
end
117+
113118
local vel = vector.direction(pos1, pos2)
114119
vel = vector.normalize(vel)
115120
vel = vector.multiply(vel, power)

0 commit comments

Comments
 (0)