Skip to content

Commit 768e3f2

Browse files
authored
Merge pull request #5270 from NicksWorld/fix/checkfreetiles
Fix regression in checkFreeTiles
2 parents 4a5c766 + cfb2cac commit 768e3f2

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

library/include/modules/Buildings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ DFHACK_EXPORT bool getCorrectSize(df::coord2d &size, df::coord2d &center,
111111
* Checks if the tiles are free to be built upon.
112112
*/
113113
DFHACK_EXPORT bool checkFreeTiles(df::coord pos, df::coord2d size,
114-
df::building *bld,
114+
df::building *bld = nullptr,
115115
bool create_ext = false,
116116
bool allow_occupied = false,
117117
bool allow_wall = false,

library/modules/Buildings.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -735,10 +735,7 @@ bool Buildings::checkFreeTiles(df::coord pos, df::coord2d size,
735735
bool allow_wall,
736736
bool allow_flow)
737737
{
738-
CHECK_NULL_POINTER(bld);
739-
740738
bool found_any = false;
741-
auto & room = bld->room;
742739

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

750747
// Exclude using extents
751-
if (room.extents)
748+
if (bld && bld->room.extents)
752749
{
753-
etile = getExtentTile(room, tile);
750+
etile = getExtentTile(bld->room, tile);
754751
if (!etile || !*etile)
755752
continue;
756753
}
@@ -784,13 +781,13 @@ bool Buildings::checkFreeTiles(df::coord pos, df::coord2d size,
784781
found_any = true;
785782
else
786783
{
787-
if (!create_ext)
784+
if (!bld || !create_ext)
788785
return false;
789786

790-
if (!room.extents)
787+
if (!bld->room.extents)
791788
{
792-
init_extents(room, pos, size);
793-
etile = getExtentTile(room, tile);
789+
init_extents(bld->room, pos, size);
790+
etile = getExtentTile(bld->room, tile);
794791
}
795792

796793
if (!etile)

0 commit comments

Comments
 (0)