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

Function vision_recalc

src/vision.c:511–857  ·  view source on GitHub ↗

* vision_recalc() * * Do all of the heavy vision work. Recalculate all locations that could * possibly be seen by the hero --- if the location were lit, etc. Note * which locations are actually seen because of lighting. Then add to * this all locations that be seen by hero due to night vision and x-ray * vision. Finally, compare with what the hero was able to see previously. * Update th

Source from the content-addressed store, hash-verified

509 * + Just before bubbles are moved. [movebubbles()]
510 */
511void
512vision_recalc(int control)
513{
514 extern const seenV seenv_matrix[3][3]; /* from display.c */
515 static coordxy colbump[COLNO + 1]; /* cols to bump sv */
516 seenV **temp_array; /* points to the old vision array */
517 seenV **next_array; /* points to the new vision array */
518 seenV *next_row; /* row pointer for the new array */
519 seenV *old_row; /* row pointer for the old array */
520 coordxy *next_rmin; /* min pointer for the new array */
521 coordxy *next_rmax; /* max pointer for the new array */
522 const coordxy *ranges; /* circle ranges -- used for xray & night vision */
523 int row = 0; /* row counter (outer loop) */
524 int start, stop; /* inner loop starting/stopping index */
525 int dx, dy; /* one step from a lit door or lit wall (see below) */
526 int col; /* inner loop counter */
527 struct rm *lev; /* pointer to current pos */
528 struct rm *flev; /* pointer to position in "front" of current pos */
529 const seenV *sv; /* ptr to seen angle bits */
530 int oldseenv; /* previous seenv value */
531
532 gv.vision_full_recalc = 0; /* reset flag */
533 if (gi.in_mklev || program_state.in_getlev || !iflags.vision_inited)
534 return;
535
536 /*
537 * Either the light sources have been taken care of, or we must
538 * recalculate them here.
539 */
540
541 /* Get the unused could see, row min, and row max arrays. */
542 get_unused_cs(&next_array, &next_rmin, &next_rmax);
543
544 /* You see nothing, nothing can see you --- if swallowed or refreshing. */
545 if (u.uswallow || control == 2) {
546 /* do nothing -- get_unused_cs() nulls out the new work area */
547 ;
548 } else if (Blind) {
549 /*
550 * Calculate the could_see array even when blind so that monsters
551 * can see you, even if you can't see them. Note that the current
552 * setup allows:
553 *
554 * + Monsters to see with the "new" vision, even on the rogue
555 * level.
556 * + Monsters can see you even when you're in a pit.
557 */
558 view_from(u.uy, u.ux, next_array, next_rmin, next_rmax, 0,
559 (void (*)(coordxy, coordxy, genericptr_t)) 0,
560 (genericptr_t) 0);
561
562 /*
563 * Our own version of the update loop below. We know we can't see
564 * anything, so we only need to update positions we used to be able
565 * to see.
566 */
567 temp_array = gv.viz_array; /* set gv.viz_array so newsym() will work */
568 gv.viz_array = next_array;

Callers 15

optfn_booleanFunction · 0.85
allmain.cFile · 0.85
maybe_do_tutorialFunction · 0.85
toggle_blindnessFunction · 0.85
show_transient_lightFunction · 0.85
transient_light_cleanupFunction · 0.85
teledsFunction · 0.85
do_clear_areaFunction · 0.85
goto_levelFunction · 0.85
vplineFunction · 0.85
domove_coreFunction · 0.85
unearth_youFunction · 0.85

Calls 9

get_unused_csFunction · 0.85
view_fromFunction · 0.85
newsymFunction · 0.85
rogue_visionFunction · 0.85
isokFunction · 0.85
is_poolFunction · 0.85
do_light_sourcesFunction · 0.85
new_angleFunction · 0.85
notice_all_monsFunction · 0.85

Tested by

no test coverage detected