Various fixes

This commit is contained in:
Hugues Ross 2020-06-13 16:33:41 -04:00
parent 2ea7de7f29
commit 9bcc2e717c
3 changed files with 13 additions and 8 deletions

View File

@ -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);

View File

@ -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

View File

@ -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