Fix wand tool causing pos1/pos2 aliasing

fixes #245
This commit is contained in:
sfan5 2024-04-20 12:51:05 +02:00
parent 469c3bf70b
commit a713efe051
2 changed files with 4 additions and 2 deletions

View File

@ -64,6 +64,8 @@ worldedit.cuboid_shift = function(name, axis, amount)
return false, "undefined cuboid"
end
assert(not rawequal(pos1, pos2)) -- vectors must not alias
if axis == 'x' then
worldedit.pos1[name].x = pos1.x + amount
worldedit.pos2[name].x = pos2.x + amount

View File

@ -34,7 +34,7 @@ minetest.register_tool(":worldedit:wand", {
local entity = pointed_thing.ref:get_luaentity()
if entity and entity.name == "worldedit:pos2" then
-- set pos1 = pos2
worldedit.pos1[name] = worldedit.pos2[name]
worldedit.pos1[name] = vector.copy(worldedit.pos2[name])
worldedit.mark_pos1(name)
end
end
@ -59,7 +59,7 @@ minetest.register_tool(":worldedit:wand", {
local entity = pointed_thing.ref:get_luaentity()
if entity and entity.name == "worldedit:pos1" then
-- set pos2 = pos1
worldedit.pos2[name] = worldedit.pos1[name]
worldedit.pos2[name] = vector.copy(worldedit.pos1[name])
worldedit.mark_pos2(name)
end
return itemstack -- nothing consumed, nothing changed