From 9bcc2e717c3a1d37590ff462fd49f6571c0dcf23 Mon Sep 17 00:00:00 2001 From: Hugues Ross Date: Sat, 13 Jun 2020 16:33:41 -0400 Subject: [PATCH] Various fixes --- items.lua | 4 ++-- map_api.lua | 9 ++++++--- scanner.lua | 8 +++++--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/items.lua b/items.lua index eb0a768..26444e0 100644 --- a/items.lua +++ b/items.lua @@ -413,10 +413,10 @@ local function copy_map_item(stack) local new_id = maps.create(src.x, src.z, src.w, src.h, false, src.detail, src.scale); local dest = maps.get(new_id); for k,v in pairs(src.fill) do - dest.fill[k] = v; + dest.fill[k] = table.copy(v); end for k,v in pairs(src.markers) do - dest.markers[k] = v; + dest.markers[k] = table.copy(v); end copy_meta:set_int("cartographer:map_id", new_id); diff --git a/map_api.lua b/map_api.lua index f58399c..c6fd035 100644 --- a/map_api.lua +++ b/map_api.lua @@ -19,7 +19,6 @@ function Map.resize(self, w, h) if w >= self.w and h >= self.h then self.w = w; self.h = h; - -- FIXME: Is this really correct? Seems questionable. end end @@ -32,8 +31,12 @@ end -- h: The height, in map coordinates function Map.fill_area(self, x, z, w, h) for i = math.max(x, 0),math.min(x + w - 1, self.w),1 do + if not self.fill[i] then + self.fill[i] = {}; + end + for j = math.max(z, 0),math.min(z + h - 1, self.h),1 do - self.fill[i + (j * self.w)] = self.detail; + self.fill[i][j] = self.detail; end end end @@ -112,7 +115,7 @@ end -- x: The x position, in map coordinates -- z: The z position, in map coordinates function Map.is_filled(self, x, z) - return self.fill[(x - self.x) + ((z - self.z) * self.w)] ~= nil; + return self.fill[x - self.x] and self.fill[x - self.x][z - self.z]; end -- The Map API diff --git a/scanner.lua b/scanner.lua index f1524ce..9c75a5f 100644 --- a/scanner.lua +++ b/scanner.lua @@ -238,9 +238,7 @@ end -- -- flush: Flush the entire scan queue, scanning all queued regions function scanner.scan_regions(flush) - local len = #scan_queue; - - if len == 0 then + if #scan_queue == 0 then return; end @@ -250,6 +248,10 @@ function scanner.scan_regions(flush) end else for _=1,settings.backup_scan_count do + if #scan_queue == 0 then + break; + end + scan_internal(); end end