From b8e0f7d4cf91465532cf2d5365f147fb13a3b841 Mon Sep 17 00:00:00 2001 From: Luke aka SwissalpS Date: Tue, 3 Sep 2024 10:25:14 +0200 Subject: [PATCH 1/2] use smallest area at position --- areas.lua | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/areas.lua b/areas.lua index 512736a..5c39b5e 100644 --- a/areas.lua +++ b/areas.lua @@ -9,15 +9,14 @@ end -- protection check local old_is_protected = minetest.is_protected function minetest.is_protected(pos, name) - local area_list = areas:getAreasAtPos(pos) - for id in pairs(area_list) do - local required_priv = priv_areas[id] - - if required_priv and not minetest.check_player_privs(name, required_priv) then + local _, id = areas:getSmallestAreaAtPos(pos) + if id then + local required_priv = priv_areas[id] + if required_priv and not minetest.check_player_privs(name, required_priv) then -- required privililege not met, protected return true - end - end + end + end return old_is_protected(pos, name) end From 25448ccbf16941a90164797efd11e5ddedb1e7b4 Mon Sep 17 00:00:00 2001 From: Luke aka SwissalpS Date: Mon, 16 Sep 2024 09:50:28 +0200 Subject: [PATCH 2/2] be backward compatible --- areas.lua | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/areas.lua b/areas.lua index 5c39b5e..78a24f4 100644 --- a/areas.lua +++ b/areas.lua @@ -9,12 +9,24 @@ end -- protection check local old_is_protected = minetest.is_protected function minetest.is_protected(pos, name) - local _, id = areas:getSmallestAreaAtPos(pos) - if id then - local required_priv = priv_areas[id] - if required_priv and not minetest.check_player_privs(name, required_priv) then - -- required privililege not met, protected - return true + if areas.getSmallestAreaAtPos then + local _, id = areas:getSmallestAreaAtPos(pos) + if id then + local required_priv = priv_areas[id] + if required_priv and not minetest.check_player_privs(name, required_priv) then + -- required privililege not met, protected + return true + end + end + else + local area_list = areas:getAreasAtPos(pos) + for id in pairs(area_list) do + local required_priv = priv_areas[id] + + if required_priv and not minetest.check_player_privs(name, required_priv) then + -- required privililege not met, protected + return true + end end end