diff --git a/src/building_floorplan.cpp b/src/building_floorplan.cpp index a779eefa6..b0c3babfb 100644 --- a/src/building_floorplan.cpp +++ b/src/building_floorplan.cpp @@ -2193,7 +2193,15 @@ void building_interior_t::assign_door_conn_rooms(unsigned start_ds_ix) { for (unsigned r = rooms_start; r < rooms_end; ++r) { if (rooms[r].contains_pt(test_pt)) {ds_room_ix = r; break;} } - assert(ds_room_ix >= 0); // adj room must be found + if (ds_room_ix == -1) { // adj room not found + // can only happen with complex floorplan buildings where a wall ends exactly at a doorway so that neither room contains the point + test_pt[!d->dim] = d->d[!d->dim][0]; // choose edge of door rather than center + + for (unsigned r = rooms_start; r < rooms_end; ++r) { + if (rooms[r].contains_pt(test_pt)) {ds_room_ix = r; break;} + } + assert(ds_room_ix >= 0); + } d->conn_room[s] = ds_room_ix; } // for s assert(d->conn_room[0] != d->conn_room[1]); // can't be connected to the same room on both sides