]> granicus.if.org Git - nethack/commitdiff
#terrain (trunk only)
authornethack.rankin <nethack.rankin>
Sat, 1 Apr 2006 05:48:55 +0000 (05:48 +0000)
committernethack.rankin <nethack.rankin>
Sat, 1 Apr 2006 05:48:55 +0000 (05:48 +0000)
     I've been using this for a while; it is occasionally handy.  #terrain
is a new wizard mode command which brings up a text display where the map
topology is revealed, similar to the obscure #wmode command but showing
different information.  Also, #wmode has been tweaked a little so as to
actually overlay the tty-mode map exactly, rather than being off by one
line and one column.  (That shouldn't really matter for other windowing
schemes where the map and a text rendition of it aren't very likely to
have a given location be displayed at the exact same screen position.)

     The line of formatted flags info below the terrain display probably
belongs in a separate debugging command altogether where it wouldn't have
to be displayed in such a terse fashion.

dat/wizhelp
doc/fixes35.0
src/cmd.c

index 6b38bc8ad8c07990207de428561a6627c22411dc..5a7252028959184888b54c60082d7af7898167fb 100644 (file)
@@ -17,6 +17,7 @@ Debug-Mode Quick Reference:
 #polyself == polymorph self
 #seenv == show seen vectors
 #stats == show memory statistics
+#terrain == show map topology
 #timeout == look at timeout queue
 #vision == show vision array
 #wmode == show wall modes
index 6e7fc3c8656a8ceb0a70926d5d0e1c39d3e7139a..faaaba32d5f08088ae1140e39bdd3ddb85c429f4 100644 (file)
@@ -192,6 +192,7 @@ display spell retention information in the spell menu
 tame ghouls can eat old eggs
 new effect for reading a scroll of light while confused
 allow digging an adjacent pit with wand of digging while trapped in a pit
+#terrain command for debug mode
 
 
 Platform- and/or Interface-Specific New Features
index 88ec8ef122ed629baa6224dc333ce57fe776f8c5..1f6e95bf5c5715dde7a9fb2ad1240c24ac6400ef 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)cmd.c      3.5     2006/02/15      */
+/*     SCCS Id: @(#)cmd.c      3.5     2006/03/31      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -128,6 +128,7 @@ STATIC_PTR int NDECL(wiz_show_vision);
 STATIC_PTR int NDECL(wiz_smell);
 STATIC_PTR int NDECL(wiz_mon_polycontrol);
 STATIC_PTR int NDECL(wiz_show_wmodes);
+STATIC_PTR int NDECL(wiz_map_terrain);
 #if defined(__BORLANDC__) && !defined(_WIN32)
 extern void FDECL(show_borlandc_stats, (winid));
 #endif
@@ -745,8 +746,10 @@ wiz_show_wmodes()
        int x,y;
        char row[COLNO+1];
        struct rm *lev;
+       boolean istty = !strcmp(windowprocs.name, "tty");
 
        win = create_nhwindow(NHW_TEXT);
+       if (istty) putstr(win, 0, "");  /* tty only: blank top line */
        for (y = 0; y < ROWNO; y++) {
            for (x = 0; x < COLNO; x++) {
                lev = &levl[x][y];
@@ -762,9 +765,116 @@ wiz_show_wmodes()
                    row[x] = 'x';
            }
            row[COLNO] = '\0';
+           /* map column 0, levl[0][], is off the left edge of the screen */
+           putstr(win, 0, &row[1]);
+       }
+       display_nhwindow(win, TRUE);
+       destroy_nhwindow(win);
+       return 0;
+}
+
+/* #terrain command */
+STATIC_PTR int
+wiz_map_terrain()
+{
+       winid win;
+       int x, y, terrain;
+       char row[COLNO+1];
+       boolean istty = !strcmp(windowprocs.name, "tty");
+
+       win = create_nhwindow(NHW_TEXT);
+       /* map row 0, levl[][0], is drawn on the second line of tty screen */
+       if (istty) putstr(win, 0, "");  /* tty only: blank top line */
+       for (y = 0; y < ROWNO; y++) {
+           /* map column 0, levl[0][], is off the left edge of the screen;
+              it should always have terrain type "undiggable stone" */
+           for (x = 1; x < COLNO; x++) {
+               terrain = levl[x][y].typ;
+               /* assumes there aren't more than 10+26+26 terrain types */
+               row[x-1] = (char)((terrain == 0 && !may_dig(x, y)) ? '*' :
+                                 (terrain < 10) ? '0' + terrain :
+                                 (terrain < 36) ? 'a' + terrain - 10 :
+                                                  'A' + terrain - 36);
+           }
+           if (levl[0][y].typ != 0 || may_dig(0, y)) row[x++] = '!';
+           row[x] = '\0';
            putstr(win, 0, row);
        }
+
+    {
+       char dsc[BUFSZ];
+       s_level *slev = Is_special(&u.uz);
+
+       Sprintf(dsc, "D:%d,L:%d", u.uz.dnum, u.uz.dlevel);
+       /* [dungeon branch features currently omitted] */
+       /* special level features */
+       if (slev) {
+           Sprintf(eos(dsc), " \"%s\"", slev->proto);
+           /* special level flags (note: dungeon.def doesn't set `maze'
+              or `hell' for any specific levels so those never show up) */
+           if (slev->flags.maze_like) Strcat(dsc, " mazelike");
+           if (slev->flags.hellish) Strcat(dsc, " hellish");
+           if (slev->flags.town) Strcat(dsc, " town");
+           if (slev->flags.rogue_like) Strcat(dsc, " roguelike");
+           /* alignment currently omitted to save space */
+       }
+       /* level features */
+       if (level.flags.nfountains) Sprintf(eos(dsc), " %c:%d",
+                                           defsyms[S_fountain].sym,
+                                           (int)level.flags.nfountains);
+#ifdef SINKS
+       if (level.flags.nsinks) Sprintf(eos(dsc), " %c:%d",
+                                       defsyms[S_sink].sym,
+                                       (int)level.flags.nsinks);
+#endif
+       if (level.flags.has_vault)      Strcat(dsc, " vault");
+       if (level.flags.has_shop)       Strcat(dsc, " shop");
+       if (level.flags.has_temple)     Strcat(dsc, " temple");
+       if (level.flags.has_court)      Strcat(dsc, " throne");
+       if (level.flags.has_zoo)        Strcat(dsc, " zoo");
+       if (level.flags.has_morgue)     Strcat(dsc, " morgue");
+       if (level.flags.has_barracks)   Strcat(dsc, " barracks");
+       if (level.flags.has_beehive)    Strcat(dsc, " hive");
+       if (level.flags.has_swamp)      Strcat(dsc, " swamp");
+       /* level flags */
+       if (level.flags.noteleport)     Strcat(dsc, " noTport");
+       if (level.flags.hardfloor)      Strcat(dsc, " noDig");
+       if (level.flags.nommap)         Strcat(dsc, " noMMap");
+       if (!level.flags.hero_memory)   Strcat(dsc, " noMem");
+       if (level.flags.shortsighted)   Strcat(dsc, " shortsight");
+       if (level.flags.graveyard)      Strcat(dsc, " graveyard");
+       if (level.flags.is_maze_lev)    Strcat(dsc, " maze");
+       if (level.flags.is_cavernous_lev) Strcat(dsc, " cave");
+       if (level.flags.arboreal)       Strcat(dsc, " tree");
+       /* non-flag info; probably should include dungeon branching
+          checks (extra stairs and magic portals) here */
+       if (Invocation_lev(&u.uz)) Strcat(dsc, " invoke");
+       if (On_W_tower_level(&u.uz)) Strcat(dsc, " tower");
+       /* append a branch identifier for completeness' sake */
+       if (u.uz.dnum == 0)               Strcat(dsc, " dungeon");
+       else if (u.uz.dnum == mines_dnum) Strcat(dsc, " mines");
+       else if (In_sokoban(&u.uz))       Strcat(dsc, " sokoban");
+       else if (u.uz.dnum == quest_dnum) Strcat(dsc, " quest");
+       else if (Is_knox(&u.uz))          Strcat(dsc, " ludios");
+       else if (u.uz.dnum == 1)          Strcat(dsc, " gehennom");
+       else if (u.uz.dnum == tower_dnum) Strcat(dsc, " vlad");
+       else if (In_endgame(&u.uz))       Strcat(dsc, " endgame");
+       else {
+           /* somebody's added a dungeon branch we're not expecting */
+           const char *brname = dungeons[u.uz.dnum].dname;
+
+           if (!brname || !*brname) brname = "unknown";
+           if (!strncmpi(brname, "the ", 4)) brname += 4;
+           Sprintf(eos(dsc), " %s", brname);
+       }
+       /* limit the line length to map width */
+       if (strlen(dsc) >= COLNO) dsc[COLNO-1] = '\0';  /* truncate */
+       putstr(win, 0, dsc);
+    }
+
        display_nhwindow(win, TRUE);
+       /* TODO? create legend of levl[][].typ codes and allow switching
+          back and forth between it and coded map display */
        destroy_nhwindow(win);
        return 0;
 }
@@ -1607,7 +1717,8 @@ struct ext_func_tab extcmdlist[] = {
        {(char *)0, (char *)0, donull, TRUE},
 #endif
        {(char *)0, (char *)0, donull, TRUE},
-        {(char *)0, (char *)0, donull, TRUE},
+       {(char *)0, (char *)0, donull, TRUE},
+       {(char *)0, (char *)0, donull, TRUE},
        {(char *)0, (char *)0, donull, TRUE},
        {(char *)0, (char *)0, donull, TRUE},
        {(char *)0, (char *)0, donull, TRUE},
@@ -1634,6 +1745,7 @@ static const struct ext_func_tab debug_extcmdlist[] = {
 #endif
        {"seenv", "show seen vectors", wiz_show_seenv, TRUE},
        {"stats", "show memory statistics", wiz_show_stats, TRUE},
+       {"terrain", "show map topology", wiz_map_terrain, TRUE},
        {"timeout", "look at timeout queue", wiz_timeout_queue, TRUE},
        {"vision", "show vision array", wiz_show_vision, TRUE},
        {"wizsmell", "smell monster", wiz_smell, TRUE},