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

Function is_vision_block

plugins/reveal.cpp:169–191  ·  view source on GitHub ↗

identify blocks that have tiles within the box that contains the unit's 26 tile radius vision cylinder

Source from the content-addressed store, hash-verified

167// identify blocks that have tiles within the box that contains the unit's
168// 26 tile radius vision cylinder
169static bool is_vision_block(const df::coord & upos, const df::coord & bpos, int offset = 0) {
170 const int radius = 27 + offset;
171
172 int ux1, ux2, uy1, uy2;
173 ux1 = upos.x - radius;
174 ux2 = upos.x + radius;
175 uy1 = upos.y - radius;
176 uy2 = upos.y + radius;
177
178 int bx1, bx2, by1, by2;
179 bx1 = bpos.x;
180 bx2 = bpos.x + 15;
181 by1 = bpos.y;
182 by2 = bpos.y + 15;
183
184 int clip_x1, clip_x2, clip_y1, clip_y2;
185 clip_x1 = std::max(ux1, bx1);
186 clip_y1 = std::max(uy1, by1);
187 clip_x2 = std::min(ux2, bx2);
188 clip_y2 = std::min(uy2, by2);
189
190 return clip_x1 <= clip_x2 && clip_y1 <= clip_y2;
191}
192
193static void do_reveal_adventure(color_ostream &out, bool no_hell, bool incremental = false) {
194 df::coord pos;

Callers 2

do_reveal_adventureFunction · 0.85
unrevealFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected