]> git.lizzy.rs Git - mcl_enchanting.git/commitdiff
Add checks to enchanting table formspec/inventory to prevent crashing in some situations.
authorTim <t4im@users.noreply.github.com>
Fri, 5 Aug 2016 21:05:20 +0000 (23:05 +0200)
committerTim <t4im@users.noreply.github.com>
Fri, 5 Aug 2016 21:05:20 +0000 (23:05 +0200)
init.lua

index 086c457fd14bcea87343b3cfbd311e8152124358..3dc20e4b9c97d7ae3860ec5288ee1da32818a98e 100644 (file)
--- a/init.lua
+++ b/init.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