From: nethack.rankin Date: Mon, 5 Dec 2011 03:17:36 +0000 (+0000) Subject: mimics vs DUNGEON_OVERVIEW (trunk only) X-Git-Tag: MOVE2GIT~145 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=73a934f6f6f3efbebf2f888753c01a75ca541c08;p=nethack mimics vs DUNGEON_OVERVIEW (trunk only) Noticed while looking into whether I could use DUNGEON_OVERVIEW data for something useful, it was recording accurate terrain type for locations covered by mimics who were mimicking furniture (such as stairs or altars). Hero should remember the fake terrain rather than whatever is actually underneath the mimic. No fixes entry; user-contributed DUNGEON_OVERVIEW is post-3.4.3 code. --- diff --git a/include/extern.h b/include/extern.h index 0d7dfdedb..1d35b8bb5 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1282,6 +1282,7 @@ E struct permonst *NDECL(courtmon); E void FDECL(save_rooms, (int)); E void FDECL(rest_rooms, (int)); E struct mkroom *FDECL(search_special, (SCHAR_P)); +E int FDECL(cmap_to_type, (int)); /* ### mon.c ### */ diff --git a/src/display.c b/src/display.c index 68143db75..b48d06833 100644 --- a/src/display.c +++ b/src/display.c @@ -414,9 +414,16 @@ display_monster(x, y, mon, sightflags, worm_tail) * mappearance is currently set to an S_ index value in * makemon.c. */ - register int glyph = cmap_to_glyph(mon->mappearance); + int sym = mon->mappearance, glyph = cmap_to_glyph(sym); + levl[x][y].glyph = glyph; - if (!sensed) show_glyph(x,y, glyph); + if (!sensed) { + show_glyph(x,y, glyph); +#ifdef DUNGEON_OVERVIEW + /* override real topology with mimic's fake one */ + lastseentyp[x][y] = cmap_to_type(sym); +#endif + } break; } diff --git a/src/dungeon.c b/src/dungeon.c index 98dc0e72f..c0907695b 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -5,9 +5,6 @@ #include "hack.h" #include "dgn_file.h" #include "dlb.h" -#ifdef DUNGEON_OVERVIEW -#include "display.h" -#endif /* DUNGEON_OVERVIEW */ #define DUNGEON_FILE "dungeon" @@ -2132,7 +2129,7 @@ recalc_mapseen() } } - /* Update styp with typ if and only if it is in sight or the hero can + /* Update lastseentyp with typ if and only if it is in sight or the hero can * feel it on their current location (i.e. not levitating). This *should* * give the "last known typ" for each dungeon location. (At the very least, * it's a better assumption than determining what the player knows from @@ -2147,17 +2144,20 @@ recalc_mapseen() * Although no current windowing systems (can) do this, this would add the * ability to have non-dungeon glyphs float above the last known dungeon * glyph (i.e. items on fountains). - * - * (vision-related styp update done in loop below) */ if (!Levitation) lastseentyp[u.ux][u.uy] = levl[u.ux][u.uy].typ; for (x = 0; x < COLNO; x++) { for (y = 0; y < ROWNO; y++) { - /* update styp from viz_array */ - if (viz_array[y][x] & IN_SIGHT) - lastseentyp[x][y] = levl[x][y].typ; + if (cansee(x, y)) { + struct monst *mtmp = m_at(x, y); + + lastseentyp[x][y] = + (mtmp && mtmp->m_ap_type == M_AP_FURNITURE && canseemon(mtmp)) ? + cmap_to_type(mtmp->mappearance) : + levl[x][y].typ; + } switch (lastseentyp[x][y]) { /* diff --git a/src/mkroom.c b/src/mkroom.c index fc7607037..67be40e27 100644 --- a/src/mkroom.c +++ b/src/mkroom.c @@ -12,6 +12,7 @@ * courtmon() -- generate a court monster * save_rooms() -- save rooms into file fd * rest_rooms() -- restore rooms from file fd + * cmap_to_type() -- convert S_xxx symbol to XXX topology code */ #include "hack.h" @@ -783,4 +784,59 @@ int fd; subrooms[nsubroom].hx = -1; } +/* convert a display symbol for terrain into topology type; + used for remembered terrain when mimics pose as furniture */ +int +cmap_to_type(sym) +int sym; +{ + int typ = STONE; /* catchall */ + + switch (sym) { + case S_stone: typ = STONE; break; + case S_vwall: typ = VWALL; break; + case S_hwall: typ = HWALL; break; + case S_tlcorn: typ = TLCORNER; break; + case S_trcorn: typ = TRCORNER; break; + case S_blcorn: typ = BLCORNER; break; + case S_brcorn: typ = BRCORNER; break; + case S_crwall: typ = CROSSWALL; break; + case S_tuwall: typ = TUWALL; break; + case S_tdwall: typ = TDWALL; break; + case S_tlwall: typ = TLWALL; break; + case S_trwall: typ = TRWALL; break; + case S_ndoor: /* no door (empty doorway) */ + case S_vodoor: /* open door in vertical wall */ + case S_hodoor: /* open door in horizontal wall */ + case S_vcdoor: /* closed door in vertical wall */ + case S_hcdoor: typ = DOOR; break; + case S_bars: typ = IRONBARS; break; + case S_tree: typ = TREE; break; + case S_room: typ = ROOM; break; + case S_corr: + case S_litcorr: typ = CORR; break; + case S_upstair: + case S_dnstair: typ = STAIRS; break; + case S_upladder: + case S_dnladder: typ = LADDER; break; + case S_altar: typ = ALTAR; break; + case S_grave: typ = GRAVE; break; + case S_throne: typ = THRONE; break; + case S_sink: typ = SINK; break; + case S_fountain: typ = FOUNTAIN; break; + case S_pool: typ = POOL; break; + case S_ice: typ = ICE; break; + case S_lava: typ = LAVAPOOL; break; + case S_vodbridge: /* open drawbridge spanning north/south */ + case S_hodbridge: typ = DRAWBRIDGE_DOWN; break; /* east/west */ + case S_vcdbridge: /* closed drawbridge in vertical wall */ + case S_hcdbridge: typ = DBWALL; break; + case S_air: typ = AIR; break; + case S_cloud: typ = CLOUD; break; + case S_water: typ = WATER; break; + default: break; /* not a cmap symbol? */ + } + return typ; +} + /*mkroom.c*/