From a713efe0510a49ced7ee28e3b5817a22733dfa7e Mon Sep 17 00:00:00 2001 From: sfan5 Date: Sat, 20 Apr 2024 12:51:05 +0200 Subject: [PATCH] Fix wand tool causing pos1/pos2 aliasing fixes #245 --- worldedit/cuboid.lua | 2 ++ worldedit_commands/wand.lua | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/worldedit/cuboid.lua b/worldedit/cuboid.lua index f9a647f..e8160ae 100644 --- a/worldedit/cuboid.lua +++ b/worldedit/cuboid.lua @@ -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 diff --git a/worldedit_commands/wand.lua b/worldedit_commands/wand.lua index b3fdcef..4952187 100644 --- a/worldedit_commands/wand.lua +++ b/worldedit_commands/wand.lua @@ -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