Skip to content

Commit 07e1142

Browse files
octacianparamat
authored andcommittedMar 17, 2017
Keys: Fix crash when using unconfigured default:key
Since meta secret field is blank on any keys (default:key) obtained using /give, the game will crash if you attempt to use one of these. This follows along the principle that the game should never have any reason to crash.
1 parent 6821296 commit 07e1142

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

‎mods/default/functions.lua

+6-1
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,12 @@ function default.can_interact_with_node(player, pos)
562562
local key_meta = item:get_meta()
563563

564564
if key_meta:get_string("secret") == "" then
565-
key_meta:set_string("secret", minetest.parse_json(item:get_metadata()).secret)
565+
local key_oldmeta = item:get_metadata()
566+
if key_oldmeta == "" or not minetest.parse_json(key_oldmeta) then
567+
return false
568+
end
569+
570+
key_meta:set_string("secret", minetest.parse_json(key_oldmeta).secret)
566571
item:set_metadata("")
567572
end
568573

0 commit comments

Comments
 (0)
Please sign in to comment.