| 207 | } |
| 208 | |
| 209 | void 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 |
no test coverage detected