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

Method removeAreaAquifer

library/modules/Maps.cpp:1487–1524  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1485}
1486
1487int Maps::removeAreaAquifer(df::coord pos1, df::coord pos2, std::function<bool(df::coord, df::map_block *)> filter) {
1488 int totalAffectedCount = 0;
1489 cuboid bounds(pos1, pos2);
1490
1491 // Loop through the affected blocks
1492 bounds.forBlock([&](df::map_block *block, cuboid intersect) {
1493 int blockAffectedCount = 0;
1494 int aquiferCount = 0;
1495 cuboid block_bounds(block);
1496
1497 // Loop through all tiles in the block
1498 block_bounds.forCoord([&](df::coord pos) {
1499 auto &des = block->designation[pos.x&15][pos.y&15];
1500 if (des.bits.water_table) {
1501 if (intersect.containsPos(pos) && filter(pos, block)) {
1502 blockAffectedCount++;
1503 des.bits.water_table = false;
1504 block->occupancy[pos.x&15][pos.y&15].bits.heavy_aquifer = false;
1505 }
1506 else
1507 aquiferCount++;
1508 }
1509
1510 return true; // Keep iterating tiles
1511 });
1512
1513 // If none of the block's tiles are now aquifers, update the block
1514 if (aquiferCount == 0) {
1515 block->flags.bits.has_aquifer = false;
1516 block->flags.bits.check_aquifer = false;
1517 }
1518 totalAffectedCount += blockAffectedCount;
1519
1520 return true; // Keep iterating blocks
1521 });
1522
1523 return totalAffectedCount;
1524}

Callers

nothing calls this directly

Calls 4

filterFunction · 0.85
forBlockMethod · 0.80
forCoordMethod · 0.80
containsPosMethod · 0.45

Tested by

no test coverage detected