MCPcopy Create free account
hub / github.com/DFHack/dfhack / add_zone_to_all_buildings

Function add_zone_to_all_buildings

library/modules/Buildings.cpp:224–257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222}
223
224static 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
259static 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));

Callers 2

constructAbstractMethod · 0.85
notifyCivzoneModifiedMethod · 0.85

Calls 4

getExtentTileFunction · 0.85
add_building_to_zoneFunction · 0.85
getTypeMethod · 0.80

Tested by

no test coverage detected