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

Method updateBuildings

library/modules/Buildings.cpp:1479–1511  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1477}
1478
1479void Buildings::updateBuildings(color_ostream&, void* ptr)
1480{
1481 int32_t id = (int32_t)(intptr_t)ptr;
1482 auto building = df::building::find(id);
1483
1484 if (building)
1485 {
1486 bool is_civzone = !building->isSettingOccupancy();
1487 if (!corner1.count(id) && !is_civzone)
1488 cacheBuilding(building);
1489 }
1490 else if (corner1.count(id))
1491 {
1492 // existing building: destroy it
1493 // note that civzones are lazy-destroyed in findCivzonesAt() and are
1494 // not handled here
1495 df::coord p1 = corner1[id];
1496 df::coord p2 = corner2[id];
1497
1498 for ( int32_t x = p1.x; x <= p2.x; x++ ) {
1499 for ( int32_t y = p1.y; y <= p2.y; y++ ) {
1500 df::coord pt(x,y,p1.z);
1501
1502 auto cur = locationToBuilding.find(pt);
1503 if (cur != locationToBuilding.end() && cur->second == id)
1504 locationToBuilding.erase(cur);
1505 }
1506 }
1507
1508 corner1.erase(id);
1509 corner2.erase(id);
1510 }
1511}
1512
1513static std::map<df::building_type, std::vector<std::string>> room_quality_names = {
1514 {df::building_type::Bed, {

Callers

nothing calls this directly

Calls 6

cacheBuildingFunction · 0.85
findFunction · 0.50
countMethod · 0.45
findMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected