| 222 | } |
| 223 | |
| 224 | static void add_zone_to_all_buildings(df::building* zone_as_building) |
| 225 | { |
| 226 | if (zone_as_building->getType() != df::building_type::Civzone) |
| 227 | return; |
| 228 | |
| 229 | auto zone = strict_virtual_cast<df::building_civzonest>(zone_as_building); |
| 230 | |
| 231 | if (zone == nullptr) |
| 232 | return; |
| 233 | |
| 234 | for (auto bld : world->buildings.other.IN_PLAY) |
| 235 | { |
| 236 | if (zone->z != bld->z) |
| 237 | continue; |
| 238 | |
| 239 | if (!is_suitable_building_for_zoning(bld)) |
| 240 | continue; |
| 241 | |
| 242 | int32_t cx = bld->centerx; |
| 243 | int32_t cy = bld->centery; |
| 244 | |
| 245 | df::coord2d coord(cx, cy); |
| 246 | |
| 247 | //can a zone without extents exist? |
| 248 | if (zone->room.extents && zone->isExtentShaped()) |
| 249 | { |
| 250 | auto etile = getExtentTile(zone->room, coord); |
| 251 | if (!etile || !*etile) |
| 252 | continue; |
| 253 | |
| 254 | add_building_to_zone(bld, zone); |
| 255 | } |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | static void remove_building_from_zone(df::building* bld, df::building_civzonest* zone) { |
| 260 | vector_erase_at(zone->contained_buildings, linear_index(zone->contained_buildings, bld)); |
no test coverage detected