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

Function for_block

plugins/aquifer.cpp:92–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90static auto DEFAULT_PRE_BLOCK_FN = [](df::map_block *block){return block->flags.bits.has_aquifer;};
91
92static 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
118static int get_max_ground_z(color_ostream &out, const df::coord &pos1, const df::coord &pos2)
119{

Callers 3

get_max_ground_zFunction · 0.85
get_max_aq_zFunction · 0.85
aquifer_listFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected