MCPcopy Create free account
hub / github.com/NetHack/NetHack / vision_reset

Function vision_reset

src/vision.c:210–265  ·  view source on GitHub ↗

* vision_reset() * * This must be called *after* the levl[][] structure is set with the new * level and the level monsters and objects are in place. */

Source from the content-addressed store, hash-verified

208 * level and the level monsters and objects are in place.
209 */
210void
211vision_reset(void)
212{
213 int y;
214 int x, i, dig_left, block;
215 struct rm *lev;
216
217 /* Start out with cs0 as our current array */
218 gv.viz_array = cs_rows0;
219 gv.viz_rmin = cs_rmin0;
220 gv.viz_rmax = cs_rmax0;
221
222 (void) memset((genericptr_t) could_see, 0, sizeof(could_see));
223
224 /* Reset the pointers and clear so that we have a "full" dungeon. */
225 (void) memset((genericptr_t) viz_clear, 0, sizeof(viz_clear));
226
227 /* Dig the level */
228 for (y = 0; y < ROWNO; y++) {
229 dig_left = 0;
230 block = TRUE; /* location (0,y) is always stone; it's !isok() */
231 lev = &levl[1][y];
232 for (x = 1; x < COLNO; x++, lev += ROWNO)
233 if (block != (IS_OBSTRUCTED(lev->typ) || does_block(x, y, lev))) {
234 if (block) {
235 for (i = dig_left; i < x; i++) {
236 left_ptrs[y][i] = dig_left;
237 right_ptrs[y][i] = x - 1;
238 }
239 } else {
240 i = dig_left;
241 if (dig_left)
242 dig_left--; /* point at first blocked point */
243 for (; i < x; i++) {
244 left_ptrs[y][i] = dig_left;
245 right_ptrs[y][i] = x;
246 viz_clear[y][i] = 1;
247 }
248 }
249 dig_left = x;
250 block = !block;
251 }
252 /* handle right boundary; almost identical for blocked/unblocked */
253 i = dig_left;
254 if (!block && dig_left)
255 dig_left--; /* point at first blocked point */
256 for (; i < COLNO; i++) {
257 left_ptrs[y][i] = dig_left;
258 right_ptrs[y][i] = (COLNO - 1);
259 viz_clear[y][i] = !block;
260 }
261 }
262
263 iflags.vision_inited = TRUE; /* vision is ready */
264 gv.vision_full_recalc = 1; /* we want to run vision_recalc() */
265}
266
267/*

Callers 5

newgameFunction · 0.85
goto_levelFunction · 0.85
dorecoverFunction · 0.85
flip_levelFunction · 0.85
makemap_prepostFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected