From df387e2394425ca9a0d535ca18d821fe632f4c68 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Sun, 17 Mar 2019 13:56:23 +0100 Subject: [PATCH 1/6] Dungeon loot: Don't crash on unknown items fixes #2228 --- mods/dungeon_loot/mapgen.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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})) From 86782651253b757a633b473a56a56ff11c76982e Mon Sep 17 00:00:00 2001 From: Paramat Date: Sat, 23 Mar 2019 23:16:41 +0000 Subject: [PATCH 2/6] Dungeon loot: Avoid empty 'if' branch to satisfy lua check --- mods/dungeon_loot/mapgen.lua | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/mods/dungeon_loot/mapgen.lua b/mods/dungeon_loot/mapgen.lua index 4394c510..366d4ce4 100644 --- a/mods/dungeon_loot/mapgen.lua +++ b/mods/dungeon_loot/mapgen.lua @@ -88,20 +88,20 @@ local function populate_chest(pos, rand, dungeontype) amount = rand:next(loot.count[1], loot.count[2]) end - 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})) + if itemdef then + if 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})) + end + elseif itemdef.stack_max == 1 then + -- not stackable, add separately + for n = 1, amount do + table.insert(items, loot.name) + end + else + table.insert(items, ItemStack({name = loot.name, count = amount})) end - elseif itemdef.stack_max == 1 then - -- not stackable, add separately - for n = 1, amount do - table.insert(items, loot.name) - end - else - table.insert(items, ItemStack({name = loot.name, count = amount})) end end end From 0ad8222b97c433bbfce2c303f23a70b732b514ce Mon Sep 17 00:00:00 2001 From: bell07 Date: Thu, 3 Feb 2022 09:10:53 +0100 Subject: [PATCH 3/6] player_api - fix compatibility code get_animation does not return the data if called from outside without this change --- mods/player_api/api.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/player_api/api.lua b/mods/player_api/api.lua index d7aab4ed..b3e3f5ee 100644 --- a/mods/player_api/api.lua +++ b/mods/player_api/api.lua @@ -218,6 +218,6 @@ for _, api_function in pairs({"get_animation", "set_animation", "set_model", "se minetest.log("warning", api_function .. " called on offline player") return end - original_function(player, ...) + return original_function(player, ...) end end From d294ef757ef4a400d27ae2d3a73d72fc93f2227c Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Sun, 13 Mar 2022 00:00:28 +0100 Subject: [PATCH 4/6] player_api: Fix crash for players without model --- mods/player_api/api.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/player_api/api.lua b/mods/player_api/api.lua index b3e3f5ee..a80cecb9 100644 --- a/mods/player_api/api.lua +++ b/mods/player_api/api.lua @@ -182,7 +182,7 @@ minetest.register_globalstep(function() for _, player in pairs(minetest.get_connected_players()) do local name = player:get_player_name() local player_data = players[name] - local model = models[player_data.model] + local model = player_data and models[player_data.model] if model and not player_attached[name] then local controls = player:get_player_control() local animation_speed_mod = model.animation_speed or 30 From 5549b9585dc9d5dcf41aab192c2a6d7048965f34 Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Sat, 26 Mar 2022 19:55:12 +0100 Subject: [PATCH 5/6] Fix incorrectly negated comparisons --- mods/carts/cart_entity.lua | 2 +- mods/doors/init.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/carts/cart_entity.lua b/mods/carts/cart_entity.lua index 8008bcfb..b3b4ae41 100644 --- a/mods/carts/cart_entity.lua +++ b/mods/carts/cart_entity.lua @@ -398,7 +398,7 @@ minetest.register_craftitem("carts:cart", { pointed_thing) or itemstack end - if not pointed_thing.type == "node" then + if pointed_thing.type ~= "node" then return end if carts:is_rail(pointed_thing.under) then diff --git a/mods/doors/init.lua b/mods/doors/init.lua index 403ad5ab..0c0f0896 100644 --- a/mods/doors/init.lua +++ b/mods/doors/init.lua @@ -260,7 +260,7 @@ function doors.register(name, def) on_place = function(itemstack, placer, pointed_thing) local pos - if not pointed_thing.type == "node" then + if pointed_thing.type ~= "node" then return itemstack end From e86d0dff9466c1efd170fac7ddf86e1b92a3b242 Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Sun, 24 Apr 2022 12:30:16 +0200 Subject: [PATCH 6/6] TNT node drop particles: Only pick string tiles as fallback --- mods/tnt/init.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mods/tnt/init.lua b/mods/tnt/init.lua index 19fe330c..1c4ead33 100644 --- a/mods/tnt/init.lua +++ b/mods/tnt/init.lua @@ -243,9 +243,9 @@ local function add_effects(pos, radius, drops) local def = minetest.registered_nodes[name] if def then node = { name = name } - end - if def and def.tiles and def.tiles[1] then - texture = def.tiles[1] + if def.tiles and type(def.tiles[1]) == "string" then + texture = def.tiles[1] + end end end end