From: sfan5 Date: Sun, 17 Mar 2019 12:56:23 +0000 (+0100) Subject: Dungeon loot: Don't crash on unknown items X-Git-Tag: 5.0.1~1 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=df387e2394425ca9a0d535ca18d821fe632f4c68;p=oweals%2Fminetest_game.git Dungeon loot: Don't crash on unknown items fixes #2228 --- diff --git a/mods/dungeon_loot/mapgen.lua b/mods/dungeon_loot/mapgen.lua index c6a45094..4394c510 100644 --- a/mods/dungeon_loot/mapgen.lua +++ b/mods/dungeon_loot/mapgen.lua @@ -88,7 +88,9 @@ local function populate_chest(pos, rand, dungeontype) amount = rand:next(loot.count[1], loot.count[2]) end - if itemdef.tool_capabilities then + if itemdef == nil then + -- item doesn't exist, do nothing + elseif itemdef.tool_capabilities then for n = 1, amount do local wear = rand:next(0.20 * 65535, 0.75 * 65535) -- 20% to 75% wear table.insert(items, ItemStack({name = loot.name, wear = wear}))