From 33995bc6ecf5b497f4e6b84b72fb476acf203af7 Mon Sep 17 00:00:00 2001 From: FaceDeer Date: Sun, 7 Jan 2018 13:38:25 -0700 Subject: attempt to recover from failure to write to map There have been reports of large, distant-from-player Digtrons apparently failing to completely write their layouts to the map, resulting in an inconsistency. This adds an attempt to brute-force a solution. When a map write fails it will be retried until it succeeds, or until 1 second elapses (at which point the write is aborted in a hopefully somewhat clean manner). --- util_execute_cycle.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'util_execute_cycle.lua') diff --git a/util_execute_cycle.lua b/util_execute_cycle.lua index 3997395..b294aa2 100644 --- a/util_execute_cycle.lua +++ b/util_execute_cycle.lua @@ -283,7 +283,9 @@ digtron.execute_dig_cycle = function(pos, clicker) --move the array layout:move_layout_image(dir) - layout:write_layout_image(clicker) + if not layout:write_layout_image(clicker) then + return pos, "unrecoverable write_layout_image error", 1 + end local oldpos = {x=pos.x, y=pos.y, z=pos.z} pos = vector.add(pos, dir) meta = minetest.get_meta(pos) @@ -412,7 +414,10 @@ digtron.execute_move_cycle = function(pos, clicker) minetest.sound_play("truck", {gain=1.0, pos=pos}) --move the array - layout:write_layout_image(clicker) + if not layout:write_layout_image(clicker) then + return pos, "unrecoverable write_layout_image error", 1 + end + pos = vector.add(pos, dir) if move_player then clicker:moveto(vector.add(clicker:getpos(), dir), true) @@ -520,7 +525,9 @@ digtron.execute_downward_dig_cycle = function(pos, clicker) --move the array layout:move_layout_image(digtron.facedir_to_down_dir(facing)) - layout:write_layout_image(clicker) + if not layout:write_layout_image(clicker) then + return pos, "unrecoverable write_layout_image error", 1 + end local oldpos = {x=pos.x, y=pos.y, z=pos.z} pos = vector.add(pos, dir) meta = minetest.get_meta(pos) -- cgit v1.2.3