Chests: Check 'def' of node above chest to avoid crash
authorparamat <paramat@users.noreply.github.com>
Fri, 16 Jun 2017 02:47:12 +0000 (03:47 +0100)
committerparamat <mat.gregory@virginmedia.com>
Fri, 16 Jun 2017 03:11:33 +0000 (04:11 +0100)
In 'chest_lid_obstructed(pos)' check for nil 'def' to avoid a crash caused by
an unknown node above the chest.

mods/default/nodes.lua

index f14e8b215f5816e91d706421a2fe61a38e8ed6a3..016b6aa8f2f99be1ef00bc0c84ccaacebd499306 100644 (file)
@@ -1783,13 +1783,14 @@ local function get_chest_formspec(pos)
 end
 
 local function chest_lid_obstructed(pos)
-       local above = { x = pos.x, y = pos.y + 1, z = pos.z }
+       local above = {x = pos.x, y = pos.y + 1, z = pos.z}
        local def = minetest.registered_nodes[minetest.get_node(above).name]
        -- allow ladders, signs, wallmounted things and torches to not obstruct
-       if def.drawtype == "airlike" or
+       if def and
+                       (def.drawtype == "airlike" or
                        def.drawtype == "signlike" or
                        def.drawtype == "torchlike" or
-                       (def.drawtype == "nodebox" and def.paramtype2 == "wallmounted") then
+                       (def.drawtype == "nodebox" and def.paramtype2 == "wallmounted")) then
                return false
        end
        return true