properly detect valid tiles for civzones

develop
Myk Taylor 2020-08-15 17:24:12 -07:00
parent f2b0f012c9
commit ae872e812f
2 changed files with 10 additions and 4 deletions

@ -141,7 +141,9 @@ DFHACK_EXPORT bool getCorrectSize(df::coord2d &size, df::coord2d &center,
*/
DFHACK_EXPORT bool checkFreeTiles(df::coord pos, df::coord2d size,
df::building_extents *ext = NULL,
bool create_ext = false, bool allow_occupied = false);
bool create_ext = false,
bool allow_occupied = false,
bool is_civzone = false);
/**
* Returns the number of tiles included by the extent, or defval.

@ -574,7 +574,9 @@ bool Buildings::getCorrectSize(df::coord2d &size, df::coord2d &center,
bool Buildings::checkFreeTiles(df::coord pos, df::coord2d size,
df::building_extents *ext,
bool create_ext, bool allow_occupied)
bool create_ext,
bool allow_occupied,
bool is_civzone)
{
bool found_any = false;
@ -609,7 +611,7 @@ bool Buildings::checkFreeTiles(df::coord pos, df::coord2d size,
else
{
auto tile = block->tiletype[btile.x][btile.y];
if (!HighPassable(tile))
if (!is_civzone && !HighPassable(tile))
allowed = false;
}
@ -659,7 +661,9 @@ static bool checkBuildingTiles(df::building *bld, bool can_change)
return Buildings::checkFreeTiles(psize.first, psize.second, &bld->room,
can_change && bld->isExtentShaped(),
!bld->isSettingOccupancy());
!bld->isSettingOccupancy(),
bld->getType() ==
df::building_type::Civzone);
}
int Buildings::countExtentTiles(df::building_extents *ext, int defval)