Prevent divide by zero (#2106) stable-0.4 1966/head 2256/head 0.4.17 0.4.17.1 0.4.17.2
authorsofar <sofar+github@foo-projects.org>
Sun, 8 Apr 2018 16:57:00 +0000 (09:57 -0700)
committerSmallJoker <mk939@ymail.com>
Fri, 18 May 2018 10:50:47 +0000 (12:50 +0200)
This forces all explosions to damage entities within the 1 node
range. If that needs to be disabled, the damage_radius needs to
be set to 0.

mods/tnt/init.lua

index 7df9e27083bc438fafaac03afd061054d3e06cbf..d12e814175f0923c1b10d1f5010fef7bb4d37eb7 100644 (file)
@@ -399,7 +399,7 @@ function tnt.boom(pos, def)
        local drops, radius = tnt_explode(pos, def.radius, def.ignore_protection,
                        def.ignore_on_blast, owner, def.explode_center)
        -- append entity drops
-       local damage_radius = (radius / def.radius) * def.damage_radius
+       local damage_radius = (radius / math.max(1, def.radius)) * def.damage_radius
        entity_physics(pos, damage_radius, drops)
        if not def.disable_drops then
                eject_drops(drops, pos, radius)