From: paramat Date: Sun, 8 May 2016 21:26:18 +0000 (+0100) Subject: Tnt: Avoid divide-by-zero errors in calc_velocity() X-Git-Tag: 0.4.14^0 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=e7a55734d3de051d6565ebe28a9dd53043f9b352;p=oweals%2Fminetest_game.git Tnt: Avoid divide-by-zero errors in calc_velocity() --- diff --git a/mods/tnt/init.lua b/mods/tnt/init.lua index 2f0ffdc4..9fd97f49 100644 --- 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)