-/* NetHack 3.6 display.c $NHDT-Date: 1554045810 2019/03/31 15:23:30 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.99 $ */
+/* NetHack 3.6 display.c $NHDT-Date: 1556835736 2019/05/02 22:22:16 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.101 $ */
/* Copyright (c) Dean Luick, with acknowledgements to Kevin Darcy */
/* and Dave Cohrs, 1990. */
/* NetHack may be freely redistributed. See license for details. */
* background
*
* If the location is out of sight, display in order:
- * sensed monsters (telepathy)
+ * sensed monsters (via telepathy or persistent detection)
+ * warning (partly-sensed monster shown as an abstraction)
* memory
*
+ * "Remembered, unseen monster" is handled like an object rather
+ * than a monster, and stays displayed whether or not it is in sight.
+ * It is removed when a visible or sensed or warned-of monster gets
+ * shown at its location or when searching or fighting reveals that
+ * no monster is there.
*
*
* Here is a list of the major routines in this file to be used externally:
if (!level.flags.hero_memory)
return;
- if ((trap = t_at(x, y)) != 0 && trap->tseen && !covers_traps(x, y))
+ if ((trap = t_at(x, y)) != 0 && trap->tseen && !covers_traps(x, y)) {
map_trap(trap, 0);
- else if (levl[x][y].seenv) {
+ } else if (levl[x][y].seenv) {
struct rm *lev = &levl[x][y];
map_background(x, y, 0);
if (!lev->waslit && lev->glyph == cmap_to_glyph(S_room)
&& lev->typ == ROOM)
lev->glyph = cmap_to_glyph(S_stone);
- } else
+ } else {
levl[x][y].glyph = cmap_to_glyph(S_stone); /* default val */
+ }
}
/*
*
* Internal to display.c, this is a #define for speed.
*/
-#define _map_location(x, y, show) \
+#define _map_location(x, y, show) \
{ \
register struct obj *obj; \
register struct trap *trap; \
}
}
- /* If the mimic is unsuccessfully mimicing something, display the monster.
- */
+ /* If mimic is unsuccessfully mimicing something, display the monster. */
if (!mon_mimic || sensed) {
int num;
} else if (sightflags == DETECTED) {
if (worm_tail)
num = detected_monnum_to_glyph(
- what_mon(PM_LONG_WORM_TAIL, rn2_on_display_rng));
+ what_mon(PM_LONG_WORM_TAIL, rn2_on_display_rng));
else
num = detected_mon_to_glyph(mon, rn2_on_display_rng);
} else {
if (worm_tail)
num = monnum_to_glyph(
- what_mon(PM_LONG_WORM_TAIL, rn2_on_display_rng));
+ what_mon(PM_LONG_WORM_TAIL, rn2_on_display_rng));
else
num = mon_to_glyph(mon, rn2_on_display_rng);
}
* floor symbol.
*
* Similarly, if the hero digs a hole in a wall or feels a
- * location
- * that used to contain an unseen monster. In these cases,
- * there's no reason to assume anything was underneath, so
- * just show the appropriate floor symbol. If something was
+ * location that used to contain an unseen monster. In these
+ * cases, there's no reason to assume anything was underneath,
+ * so just show the appropriate floor symbol. If something was
* embedded in the wall, the glyph will probably already
* reflect that. Don't change the symbol in this case.
*
else
goto show_mem;
} else {
- show_mem:
+ show_mem:
show_glyph(x, y, lev->glyph);
}
}
* but explode() wants to delay].
*
* Call:
- * (DISP_BEAM, glyph) open, initialize glyph
- * (DISP_FLASH, glyph) open, initialize glyph
- * (DISP_ALWAYS, glyph) open, initialize glyph
- * (DISP_CHANGE, glyph) change glyph
- * (DISP_END, 0) close & clean up (second argument doesn't
- * matter)
- * (DISP_FREEMEM, 0) only used to prevent memory leak during
- * exit)
+ * (DISP_BEAM, glyph) open, initialize glyph
+ * (DISP_FLASH, glyph) open, initialize glyph
+ * (DISP_ALWAYS, glyph) open, initialize glyph
+ * (DISP_CHANGE, glyph) change glyph
+ * (DISP_END, 0) close & clean up (2nd argument doesn't matter)
+ * (DISP_FREEMEM, 0) only used to prevent memory leak during exit)
* (x, y) display the glyph at the location
*
- * DISP_BEAM - Display the given glyph at each location, but do not erase
- * any until the close call.
- * DISP_TETHER- Display a tether glyph at each location, and the tethered
- * object at the farthest location, but do not erase any
- * until the return trip or close.
- * DISP_FLASH - Display the given glyph at each location, but erase the
- * previous location's glyph.
- * DISP_ALWAYS- Like DISP_FLASH, but vision is not taken into account.
+ * DISP_BEAM - Display the given glyph at each location, but do not erase
+ * any until the close call.
+ * DISP_TETHER - Display a tether glyph at each location, and the tethered
+ * object at the farthest location, but do not erase any
+ * until the return trip or close.
+ * DISP_FLASH - Display the given glyph at each location, but erase the
+ * previous location's glyph.
+ * DISP_ALWAYS - Like DISP_FLASH, but vision is not taken into account.
*/
#define TMP_AT_MAX_GLYPHS (COLNO * 2)
if (!tglyph)
tmp = &tgfirst;
else /* nested effect; we need dynamic memory */
- tmp = (struct tmp_glyph *) alloc(sizeof(struct tmp_glyph));
+ tmp = (struct tmp_glyph *) alloc(sizeof *tmp);
tmp->prev = tglyph;
tglyph = tmp;
tglyph->sidx = 0;
/* Prevent infinite loops on errors:
* flush_screen->print_glyph->impossible->pline->flush_screen
*/
- static boolean flushing = 0;
- static boolean delay_flushing = 0;
+ static int flushing = 0;
+ static int delay_flushing = 0;
register int x, y;
if (cursor_on_u == -1)
for (y = 0; y < ROWNO; y++) {
register gbuf_entry *gptr = &gbuf[y][x = gbuf_start[y]];
+
for (; x <= gbuf_stop[y]; gptr++, x++)
if (gptr->new) {
print_glyph(WIN_MAP, x, y, gptr->glyph, get_bk_glyph(x, y));
struct rm *lev = &levl[x][y];
if (iflags.use_background_glyph && lev->seenv != 0
- && gbuf[y][x].glyph != cmap_to_glyph(S_stone)) {
+ && gbuf[y][x].glyph != cmap_to_glyph(S_stone)) {
switch (lev->typ) {
case SCORR:
case STONE:
return bkglyph;
}
-/* -------------------------------------------------------------------------
- */
-/* Wall Angle --------------------------------------------------------------
- */
+/* ------------------------------------------------------------------------ */
+/* Wall Angle ------------------------------------------------------------- */
#ifdef WA_VERBOSE
int x, y, which;
{
int type;
+
if (!isok(x, y))
return which;
type = levl[x][y].typ;
{
int wmode, is_1, is_2, is_3;
+#ifndef WA_VERBOSE
+ /* non-verbose more_than_one() doesn't use these */
nhUse(x0);
nhUse(y0);
+#endif
is_1 = check_pos(x1, y1, WM_T_LONG);
is_2 = check_pos(x2, y2, WM_T_BL);
#endif /* WA_VERBOSE */
}
-/* -------------------------------------------------------------------------
- */
+/* ------------------------------------------------------------------------ */
/* This matrix is used here and in vision.c. */
unsigned char seenv_matrix[3][3] = { { SV2, SV1, SV0 },
{ SV3, SVALL, SV7 },
lev->seenv &= ~seenv_matrix[dy + 1][dx + 1];
}
-/* -------------------------------------------------------------------------
- */
+/* ------------------------------------------------------------------------ */
/* T wall types, one for each row in wall_matrix[][]. */
#define T_d 0
goto do_twall;
case TDWALL:
row = wall_matrix[T_d];
- do_twall:
+ do_twall:
switch (lev->wall_info & WM_MASK) {
case 0:
if (seenv == SV4) {
break;
case WM_T_BL:
#if 0 /* older method, fixed */
- if (only(seenv, SV4|SV5)) {
+ if (only(seenv, SV4 | SV5)) {
col = T_tlcorn;
- } else if ((seenv & (SV0|SV1|SV2))
- && only(seenv, SV0|SV1|SV2|SV6|SV7)) {
+ } else if ((seenv & (SV0 | SV1 | SV2))
+ && only(seenv, SV0 | SV1 | SV2 | SV6 | SV7)) {
col = T_hwall;
} else if ((seenv & SV3)
- || ((seenv & (SV0|SV1|SV2)) && (seenv & (SV4|SV5)))) {
+ || ((seenv & (SV0 | SV1 | SV2))
+ && (seenv & (SV4 | SV5)))) {
col = T_tdwall;
} else {
if (seenv != SV6)
break;
case WM_T_BR:
#if 0 /* older method, fixed */
- if (only(seenv, SV5|SV6)) {
+ if (only(seenv, SV5 | SV6)) {
col = T_trcorn;
- } else if ((seenv & (SV0|SV1|SV2))
- && only(seenv, SV0|SV1|SV2|SV3|SV4)) {
+ } else if ((seenv & (SV0 | SV1 | SV2))
+ && only(seenv, SV0 | SV1 | SV2 | SV3 | SV4)) {
col = T_hwall;
} else if ((seenv & SV7)
- || ((seenv & (SV0|SV1|SV2)) && (seenv & (SV5|SV6)))) {
+ || ((seenv & (SV0 | SV1 | SV2))
+ && (seenv & (SV5 | SV6)))) {
col = T_tdwall;
} else {
if (seenv != SV4)
case SDOOR:
if (lev->horizontal)
goto horiz;
- /* fall through */
+ /*FALLTHRU*/
case VWALL:
switch (lev->wall_info & WM_MASK) {
case 0:
break;
case HWALL:
- horiz:
+ horiz:
switch (lev->wall_info & WM_MASK) {
case 0:
idx = seenv ? S_hwall : S_stone;
goto do_crwall;
case WM_X_BR:
row = cross_matrix[C_br];
- do_crwall:
- if (seenv == SV4)
+ do_crwall:
+ if (seenv == SV4) {
idx = S_stone;
- else {
+ } else {
seenv = seenv & ~SV4; /* strip SV4 */
if (seenv == SV0) {
col = C_brcorn;