From b4db66d76f3a40154958f4606ca35b89844af8fe Mon Sep 17 00:00:00 2001 From: James David Clarke Date: Tue, 2 Jan 2024 17:55:20 +0000 Subject: [PATCH] Fix crash in protected area when user violates area protection --- .luacheckrc | 1 + modules/crafting/materials.lua | 2 -- modules/crafting/shared.lua | 3 --- modules/storage/drive.lua | 10 ++++++---- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index 2ba39e4..607a8d3 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -5,6 +5,7 @@ read_globals = { "dump", "ItemStack", "pipeworks", + "unified_inventory", "PseudoRandom", "stairsplus", "intllib", diff --git a/modules/crafting/materials.lua b/modules/crafting/materials.lua index bb8d968..6da6738 100644 --- a/modules/crafting/materials.lua +++ b/modules/crafting/materials.lua @@ -4,8 +4,6 @@ local me = microexpansion local substitute_basic_materials = microexpansion.settings.simple_craft == true or not minetest.get_modpath("basic_materials") -local gold_wire_recipe = nil - if minetest.get_modpath("mcl_core") then gold_wire_recipe = { { 2, { diff --git a/modules/crafting/shared.lua b/modules/crafting/shared.lua index b6a5167..9f114bc 100644 --- a/modules/crafting/shared.lua +++ b/modules/crafting/shared.lua @@ -4,9 +4,6 @@ local me = microexpansion -- custom items that are used by multiple devices -local steel_infused_obsidian_ingot_recipe = nil -local machine_casing_recipe = nil - if minetest.get_modpath("mcl_core") then steel_infused_obsidian_ingot_recipe = { { 2, { diff --git a/modules/storage/drive.lua b/modules/storage/drive.lua index 4ba6e8f..f5b2fb1 100644 --- a/modules/storage/drive.lua +++ b/modules/storage/drive.lua @@ -349,13 +349,14 @@ microexpansion.register_node("drive", { me.send_event(pos,"disconnect") end, allow_metadata_inventory_put = function(pos, _, _, stack, player) + local name = player:get_player_name() local network = me.get_connected_network(pos) if network then if network:get_access_level(player) < access_level.interact then return 0 end - elseif minetest.is_protected(pos, player) then - minetest.record_protection_violation(pos, player) + elseif minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) return 0 end if minetest.get_item_group(stack:get_name(), "microexpansion_cell") == 0 then @@ -384,14 +385,15 @@ microexpansion.register_node("drive", { me.send_event(pos,"items",{net=network}) end, allow_metadata_inventory_take = function(pos,_,_,stack, player) --args: pos, listname, index, stack, player + local name = player:get_player_name() local network = me.get_connected_network(pos) if network then write_drive_cells(pos,network) if network:get_access_level(player) < access_level.interact then return 0 end - elseif minetest.is_protected(pos, player) then - minetest.record_protection_violation(pos, player) + elseif minetest.is_protected(pos, name) then + minetest.record_protection_violation(pos, name) return 0 end return stack:get_count()