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.
develop
lethosor 2021-04-01 00:16:54 -04:00
parent 8129fdab4e
commit 257f8dbe00
No known key found for this signature in database
GPG Key ID: 76A269552F4F58C1
2 changed files with 5 additions and 2 deletions

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

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