]> granicus.if.org Git - nethack/commitdiff
mimics vs DUNGEON_OVERVIEW (trunk only)
authornethack.rankin <nethack.rankin>
Mon, 5 Dec 2011 03:17:36 +0000 (03:17 +0000)
committernethack.rankin <nethack.rankin>
Mon, 5 Dec 2011 03:17:36 +0000 (03:17 +0000)
     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.

include/extern.h
src/display.c
src/dungeon.c
src/mkroom.c

index 0d7dfdedb771bf81b7dbfd8fcd3940466b656e22..1d35b8bb5b7ac1a62ecec00acc16e67ee8463154 100644 (file)
@@ -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 ### */
 
index 68143db75618cc07fadff29aa6db20f84c16065d..b48d06833f9703f3399a207dfb0b663618289559 100644 (file)
@@ -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;
            }
 
index 98dc0e72f20c06f95cbb88473319e38d61b65de2..c0907695b5eecc1ce3483dba166ed190a29c608a 100644 (file)
@@ -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]) {
                        /*
index fc7607037b05c1eaff259b2140127bd7ed2c3518..67be40e2756e598851ef2eeb28b1323a1ca10bf9 100644 (file)
@@ -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*/