From 5dff906b0f5e82630004bd1c27d1fbfe1ac949a1 Mon Sep 17 00:00:00 2001 From: 1F616EMO Date: Fri, 11 Aug 2023 08:29:11 +0800 Subject: [PATCH 1/3] Fix non-diagonal borders water detect --- mods/ctf/ctf_map/map_functions.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mods/ctf/ctf_map/map_functions.lua b/mods/ctf/ctf_map/map_functions.lua index 6bfa79787d..b1df5182ab 100644 --- a/mods/ctf/ctf_map/map_functions.lua +++ b/mods/ctf/ctf_map/map_functions.lua @@ -74,6 +74,7 @@ function ctf_map.remove_barrier(mapmeta, pos2, callback) -- Shave off ~0.1 seconds from the main loop minetest.handle_async(function(d, p1, p2, barrier_nodes, t) + local mod = table.copy(d) local Nx = p2.x - p1.x + 1 local Ny = p2.y - p1.y + 1 local ID_IGNORE = minetest.CONTENT_IGNORE @@ -107,7 +108,7 @@ function ctf_map.remove_barrier(mapmeta, pos2, callback) end end end - d[vi] = replacement_this + mod[vi] = replacement_this done = true break end @@ -115,13 +116,13 @@ function ctf_map.remove_barrier(mapmeta, pos2, callback) -- Avoid changing nodes players placed during async if not done then - d[vi] = ID_IGNORE + mod[vi] = ID_IGNORE end end end end - return d + return mod end, function(d) vm:set_data(d) vm:update_liquids() From ca4359049d406cf1f6a78bdcc7bbb322d854d964 Mon Sep 17 00:00:00 2001 From: 1F616EMO Date: Sat, 12 Aug 2023 08:02:53 +0800 Subject: [PATCH 2/3] Optimize by not copying the table --- mods/ctf/ctf_map/map_functions.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ctf/ctf_map/map_functions.lua b/mods/ctf/ctf_map/map_functions.lua index b1df5182ab..292290fc1a 100644 --- a/mods/ctf/ctf_map/map_functions.lua +++ b/mods/ctf/ctf_map/map_functions.lua @@ -74,7 +74,7 @@ function ctf_map.remove_barrier(mapmeta, pos2, callback) -- Shave off ~0.1 seconds from the main loop minetest.handle_async(function(d, p1, p2, barrier_nodes, t) - local mod = table.copy(d) + local mod = {} local Nx = p2.x - p1.x + 1 local Ny = p2.y - p1.y + 1 local ID_IGNORE = minetest.CONTENT_IGNORE From b7a5b939ec9bea0a45439341b35b470e7857fa09 Mon Sep 17 00:00:00 2001 From: 1F616EMO Date: Sat, 12 Aug 2023 08:07:26 +0800 Subject: [PATCH 3/3] Inline comments --- mods/ctf/ctf_map/map_functions.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ctf/ctf_map/map_functions.lua b/mods/ctf/ctf_map/map_functions.lua index 292290fc1a..778d90d017 100644 --- a/mods/ctf/ctf_map/map_functions.lua +++ b/mods/ctf/ctf_map/map_functions.lua @@ -74,7 +74,7 @@ function ctf_map.remove_barrier(mapmeta, pos2, callback) -- Shave off ~0.1 seconds from the main loop minetest.handle_async(function(d, p1, p2, barrier_nodes, t) - local mod = {} + local mod = {} -- All its contents will be recreated in the loop local Nx = p2.x - p1.x + 1 local Ny = p2.y - p1.y + 1 local ID_IGNORE = minetest.CONTENT_IGNORE