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

Method forBlock

library/modules/Maps.cpp:209–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207}
208
209void cuboid::forBlock(std::function<bool(df::map_block *, cuboid)> fn, bool ensure_block) const
210{
211 auto c = *this; // Create a copy to modify.
212 if (!c.clampMap().isValid()) // No intersection.
213 return;
214
215 // Process z, y, then x.
216 for (int16_t x = (c.x_min >> 4) << 4; x <= c.x_max; x += 16)
217 for (int16_t y = (c.y_min >> 4) << 4; y <= c.y_max; y += 16)
218 for (int16_t z = c.z_max; z >= c.z_min; z--)
219 {
220 auto *block = ensure_block ? Maps::ensureTileBlock(x, y, z) : Maps::getTileBlock(x, y, z);
221 if (!block) // Skip unallocated block.
222 continue;
223 else if (!fn(block, cuboid(block).clamp(c)))
224 return; // Break iterator.
225 }
226}
227
228/*
229 * The Maps module

Callers 3

setAreaAquiferMethod · 0.80
removeAreaAquiferMethod · 0.80
regrass_cuboidFunction · 0.80

Calls 6

ensureTileBlockFunction · 0.85
getTileBlockFunction · 0.85
cuboidClass · 0.85
clampMapMethod · 0.80
clampMethod · 0.80
isValidMethod · 0.45

Tested by

no test coverage detected