projects
/
oweals
/
minetest_game.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
b36b154
)
Tnt: Avoid divide-by-zero errors in calc_velocity()
0.4.14
author
paramat
<mat.gregory@virginmedia.com>
Sun, 8 May 2016 21:26:18 +0000
(22:26 +0100)
committer
paramat
<mat.gregory@virginmedia.com>
Sun, 8 May 2016 21:53:16 +0000
(22:53 +0100)
mods/tnt/init.lua
patch
|
blob
|
history
diff --git
a/mods/tnt/init.lua
b/mods/tnt/init.lua
index 2f0ffdc413ec7d6034c9c367c358f9091aad38b0..9fd97f4926b7414d41c5bee3e7ede6f0b0f5f487 100644
(file)
--- a/
mods/tnt/init.lua
+++ b/
mods/tnt/init.lua
@@
-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)