Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix regression in checkFreeTiles #5270

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/include/modules/Buildings.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ DFHACK_EXPORT bool getCorrectSize(df::coord2d &size, df::coord2d &center,
* Checks if the tiles are free to be built upon.
*/
DFHACK_EXPORT bool checkFreeTiles(df::coord pos, df::coord2d size,
df::building *bld,
df::building *bld = nullptr,
bool create_ext = false,
bool allow_occupied = false,
bool allow_wall = false,
Expand Down
15 changes: 6 additions & 9 deletions library/modules/Buildings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,10 +735,7 @@ bool Buildings::checkFreeTiles(df::coord pos, df::coord2d size,
bool allow_wall,
bool allow_flow)
{
CHECK_NULL_POINTER(bld);

bool found_any = false;
auto & room = bld->room;

for (int dx = 0; dx < size.x; dx++)
{
Expand All @@ -748,9 +745,9 @@ bool Buildings::checkFreeTiles(df::coord pos, df::coord2d size,
df::building_extents_type *etile = NULL;

// Exclude using extents
if (room.extents)
if (bld && bld->room.extents)
{
etile = getExtentTile(room, tile);
etile = getExtentTile(bld->room, tile);
if (!etile || !*etile)
continue;
}
Expand Down Expand Up @@ -784,13 +781,13 @@ bool Buildings::checkFreeTiles(df::coord pos, df::coord2d size,
found_any = true;
else
{
if (!create_ext)
if (!bld || !create_ext)
return false;

if (!room.extents)
if (!bld->room.extents)
{
init_extents(room, pos, size);
etile = getExtentTile(room, tile);
init_extents(bld->room, pos, size);
etile = getExtentTile(bld->room, tile);
}

if (!etile)
Expand Down
Loading