From 257f8dbe00e4327d81c0258d98c018795682f38c Mon Sep 17 00:00:00 2001 From: lethosor Date: Thu, 1 Apr 2021 00:16:54 -0400 Subject: [PATCH] buildingplan: fix size calculation for constructions Planning a 4x2 construction with DF's `umkh` keys (i.e. not automaterial's box-select) would previously produce a 5x3 construction instead, for example. --- docs/changelog.txt | 3 +++ plugins/lua/buildingplan.lua | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index fba342802..3363a6c77 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -33,6 +33,9 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: # Future +## Fixes +- `buildingplan`: fixed an issue where planned constructions designated with DF's sizing keys (``umkh``) would sometimes be larger than requested + ## Lua - ``gui.Painter``: fixed error when calling ``viewport()`` method - `xlsxreader`: Added Lua class wrappers for the xlsxreader plugin API diff --git a/plugins/lua/buildingplan.lua b/plugins/lua/buildingplan.lua index c0e69168a..43122a7da 100644 --- a/plugins/lua/buildingplan.lua +++ b/plugins/lua/buildingplan.lua @@ -103,9 +103,9 @@ function construct_buildings_from_ui_state() if width == 1 and height == 1 and (world.building_width > 1 or world.building_height > 1) then min_x = math.ceil(pos.x - world.building_width/2) - max_x = math.floor(pos.x + world.building_width/2) + max_x = min_x + world.building_width - 1 min_y = math.ceil(pos.y - world.building_height/2) - max_y = math.floor(pos.y + world.building_height/2) + max_y = min_y + world.building_height - 1 end local blds = {} for y=min_y,max_y do for x=min_x,max_x do