| 753 | } |
| 754 | |
| 755 | bool Buildings::checkFreeTiles(df::coord pos, df::coord2d size, |
| 756 | df::building *bld, |
| 757 | bool create_ext, |
| 758 | bool allow_occupied, |
| 759 | bool allow_wall, |
| 760 | bool allow_flow) |
| 761 | { |
| 762 | bool found_any = false; |
| 763 | |
| 764 | for (int dx = 0; dx < size.x; dx++) |
| 765 | { |
| 766 | for (int dy = 0; dy < size.y; dy++) |
| 767 | { |
| 768 | df::coord tile = pos + df::coord(dx,dy,0); |
| 769 | df::building_extents_type *etile = NULL; |
| 770 | |
| 771 | // Exclude using extents |
| 772 | if (bld && bld->room.extents) |
| 773 | { |
| 774 | etile = getExtentTile(bld->room, tile); |
| 775 | if (!etile || !*etile) |
| 776 | continue; |
| 777 | } |
| 778 | |
| 779 | // Look up map block |
| 780 | df::map_block *block = Maps::getTileBlock(tile); |
| 781 | if (!block) |
| 782 | return false; |
| 783 | |
| 784 | df::coord2d btile = df::coord2d(tile) & 15; |
| 785 | |
| 786 | bool allowed = true; |
| 787 | |
| 788 | // Check occupancy and tile type |
| 789 | if (!allow_occupied && |
| 790 | block->occupancy[btile.x][btile.y].bits.building) |
| 791 | allowed = false; |
| 792 | else if (!allow_wall) |
| 793 | { |
| 794 | auto &tt = block->tiletype[btile.x][btile.y]; |
| 795 | if (!HighPassable(tt)) |
| 796 | allowed = false; |
| 797 | auto &des = block->designation[btile.x][btile.y]; |
| 798 | if (!allow_flow && (des.bits.flow_size > 1 || |
| 799 | (des.bits.flow_size >= 1 && des.bits.liquid_type == df::tile_liquid::Magma))) |
| 800 | allowed = false; |
| 801 | } |
| 802 | |
| 803 | // Create extents if requested |
| 804 | if (allowed) |
| 805 | found_any = true; |
| 806 | else |
| 807 | { |
| 808 | if (!bld || !create_ext) |
| 809 | return false; |
| 810 | |
| 811 | if (!bld->room.extents) |
| 812 | { |
nothing calls this directly
no test coverage detected