From: Tim Date: Fri, 5 Aug 2016 20:57:02 +0000 (+0200) Subject: Add checks to enchanting table formspec/inventory to prevent crashing in some situations. X-Git-Tag: 1.0~32 X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=4c06f81ae086ef5cce816f8bc5232059cffc0957;p=xdecor.git Add checks to enchanting table formspec/inventory to prevent crashing in some situations. --- diff --git a/enchanting.lua b/enchanting.lua index 63641cd..028a5b4 100644 --- a/enchanting.lua +++ b/enchanting.lua @@ -59,7 +59,9 @@ function enchanting.on_put(pos, listname, _, stack) end function enchanting.fields(pos, _, fields, sender) - if fields.quit then return end + if not next(fields) or fields.quit then + return + end local inv = minetest.get_meta(pos):get_inventory() local tool = inv:get_stack("tool", 1) local mese = inv:get_stack("mese", 1) @@ -83,6 +85,9 @@ function enchanting.dig(pos) end local function allowed(tool) + if not tool then + return false + end for item in pairs(minetest.registered_tools) do if item:find("enchanted_"..tool) then return true end end