Merge remote-tracking branch 'myk002/myk_force_extents' into develop + add extra changelog note

Conflicts:
	docs/changelog.txt
develop
lethosor 2021-07-05 15:50:02 -04:00
commit f33db33c8f
No known key found for this signature in database
GPG Key ID: 76A269552F4F58C1
2 changed files with 24 additions and 9 deletions

@ -35,6 +35,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## Fixes
- Fixed an issue where scrollable text in Lua-based screens could prevent other widgets from scrolling
- Fixed an issue preventing some external scripts from creating zones and other abstract buildings (see note about room definitions under "Internals")
- `buildingplan`: fixed an issue where planned constructions designated with DF's sizing keys (``umkh``) would sometimes be larger than requested
- `buildingplan`: fixed an issue preventing other plugins like `automaterial` from planning constructions if the "enable all" buildingplan setting was turned on
- `command-prompt`: fixed issues where overlays created by running certain commands (e.g. `gui/liquids`, `gui/teleport`) would not update the parent screen correctly
@ -81,6 +82,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
- DFHack unit tests must now match any output expected to be printed via ``dfhack.printerr()``
- Fortress mode is now supported for unit tests (allowing tests that require a fortress map to be loaded) - note that these tests are skipped by continuous integration for now, pending a suitable test fortress
- Unit tests can now use ``delay_until(predicate_fn, timeout_frames)`` to delay until a condition is met
- Room definitions and extents are now created for abstract buildings so callers don't have to initialize the room structure themselves
# 0.47.05-r1

@ -587,6 +587,18 @@ bool Buildings::getCorrectSize(df::coord2d &size, df::coord2d &center,
}
}
static void init_extents(df::building_extents *ext, const df::coord &pos,
const df::coord2d &size)
{
ext->extents = new df::building_extents_type[size.x*size.y];
ext->x = pos.x;
ext->y = pos.y;
ext->width = size.x;
ext->height = size.y;
memset(ext->extents, 1, size.x*size.y);
}
bool Buildings::checkFreeTiles(df::coord pos, df::coord2d size,
df::building_extents *ext,
bool create_ext,
@ -640,13 +652,7 @@ bool Buildings::checkFreeTiles(df::coord pos, df::coord2d size,
if (!ext->extents)
{
ext->extents = new df::building_extents_type[size.x*size.y];
ext->x = pos.x;
ext->y = pos.y;
ext->width = size.x;
ext->height = size.y;
memset(ext->extents, 1, size.x*size.y);
init_extents(ext, pos, size);
etile = getExtentTile(*ext, tile);
}
@ -670,10 +676,17 @@ std::pair<df::coord,df::coord2d> Buildings::getSize(df::building *bld)
return std::pair<df::coord,df::coord2d>(pos, df::coord2d(bld->x2+1,bld->y2+1) - pos);
}
static bool checkBuildingTiles(df::building *bld, bool can_change)
static bool checkBuildingTiles(df::building *bld, bool can_change,
bool force_extents = false)
{
auto psize = Buildings::getSize(bld);
if (force_extents && !bld->room.extents)
{
// populate the room structure if it's not set already
init_extents(&bld->room, psize.first, psize.second);
}
return Buildings::checkFreeTiles(psize.first, psize.second, &bld->room,
can_change && bld->isExtentShaped(),
!bld->isSettingOccupancy(),
@ -978,7 +991,7 @@ bool Buildings::constructAbstract(df::building *bld)
CHECK_INVALID_ARGUMENT(bld->id == -1);
CHECK_INVALID_ARGUMENT(!bld->isActual());
if (!checkBuildingTiles(bld, false))
if (!checkBuildingTiles(bld, true, true))
return false;
switch (bld->getType())