Skip to content

Commit

Permalink
use smallest area at given position
Browse files Browse the repository at this point in the history
Evaluate protection based on smallest area as that is what
most users seem to expect to be happening.
  • Loading branch information
SwissalpS committed Sep 3, 2024
1 parent 5c5292e commit 8e0b0f9
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions areas.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,16 @@ 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 xp_area = xp_areas[id]

if xp_area then
local xp = xp_redo.get_xp(name)
if xp_area.min and xp < xp_area.min then
return true
elseif xp_area.max and xp > xp_area.max then
return true
end
end
end
local _, id = areas:getSmallestAreaAtPos(pos)
local xp_area = id and xp_areas[id]
if xp_area then
local xp = xp_redo.get_xp(name)
if xp_area.min and xp < xp_area.min then
return true
elseif xp_area.max and xp > xp_area.max then
return true
end
end

return old_is_protected(pos, name)
end
Expand Down

0 comments on commit 8e0b0f9

Please sign in to comment.