| 90 | static auto DEFAULT_PRE_BLOCK_FN = [](df::map_block *block){return block->flags.bits.has_aquifer;}; |
| 91 | |
| 92 | static void for_block(int minz, int maxz, const df::coord & pos1, const df::coord & pos2, |
| 93 | std::function<void(const df::coord &)> pos_fn, |
| 94 | std::function<bool(df::map_block *)> pre_block_fn = DEFAULT_PRE_BLOCK_FN) |
| 95 | { |
| 96 | for (auto block : world->map.map_blocks) { |
| 97 | const df::coord & bpos = block->map_pos; |
| 98 | if (maxz < bpos.z || minz > bpos.z || |
| 99 | bpos.x > pos2.x || bpos.x + 15 < pos1.x || |
| 100 | bpos.y > pos2.y || bpos.y + 15 < pos1.y) |
| 101 | { |
| 102 | continue; |
| 103 | } |
| 104 | |
| 105 | if (!pre_block_fn(block)) |
| 106 | continue; |
| 107 | |
| 108 | for (int xoff = 0; xoff <= 15; ++xoff) { |
| 109 | for (int yoff = 0; yoff <= 15; ++yoff) { |
| 110 | df::coord pos = bpos + df::coord(xoff, yoff, 0); |
| 111 | if (pos.x >= pos1.x && pos.x <= pos2.x && pos.y >= pos1.y && pos.y <= pos2.y) |
| 112 | pos_fn(pos); |
| 113 | } |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | static int get_max_ground_z(color_ostream &out, const df::coord &pos1, const df::coord &pos2) |
| 119 | { |
no outgoing calls
no test coverage detected