mt-mods / jumpdrive

Minetest jumpdrive mod

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shared area prot, exact boundary, incorrect "Jump Target is Protected!" error.

dennisjenkins75 opened this issue · comments

As posted to #reports just a few seconds ago:

I am unable to jump my R=1 ship such that the target x,y,z lands on an exact area boundary that hedgehog created, even though he added me as a co-owner. ex: I cannot jump to "6200, 112, 22600" (area_id 13318, 13325). However, I can successfully jump to 6198, 112, 2260, which is inside the exact same area. The area has a pos2.x value of 6200.
When I attempt such a jump, I get a "Jump Target is protected!" error.

Steps to reproduce:

  1. Player 1 creates an area.
  2. Player 1 does an "area add owner" to add player 2 to the same area.
  3. Player 2 attempts to jump an R1 ship to center of area (works).
  4. Player 2 attempts to jump an R1 ship such that the X, Y or Z value is exactly the same as a border value (fails).
  5. Player 2 attempts to jump an R1 ship to (X+1, Y, Z) of the area, also fails (ship collides with the area border).

Did you place the drive yourself? The placer of the jumpdrive gets recorded in the node-metadata and that name is
used for protection checks later if the "real" player can't be found (digiline-operation for example)

Relevant code-piece:

local playername = meta:get_string("owner")
if player ~= nil then
playername = player:get_player_name()
end

This seems to be caused by the way the areas are checked in areas:canInteractInArea()

https://github.com/minetest-mods/areas/blob/4018c0d20450a106b3bda6627894b130595a7cd6/api.lua#L134-L174

local blocking_area = nil

local areas = self:getAreasIntersectingArea(pos1, pos2)
for id, area in pairs(areas) do
	if area.owner == name and
			self:isSubarea(pos1, pos2, id) then
		return true
	end

	if not blocking_area and
			(not allow_open or not area.open) and
			(not name or not self:isAreaOwner(id, name)) then
		blocking_area = id
	end
end
if blocking_area then
	return false, blocking_area
end

For each area it first checks if the region if contained within the area (which it is not), and then checks if the area is owned by someone else (which the original area is).

Therefore it returns false, as the region is not contained within the shared (player 2's) area, and it is blocked by the original (player 1's) area.

I think the fix would be to add a check for sub areas using areas:getChildren(), as areas:isAreaOwner() does not check them.

commented

For more information and earlier discussion about problem:
pandorabox-io/in-game#127
pandorabox-io/pandorabox.io#654

There's issues in both areas mod and jumpdrive mod, first does incomplete checks (and this is kind of documented) and second has kind of messed up non standard protection checks.