From: PatR Date: Sun, 21 May 2017 05:55:08 +0000 (-0700) Subject: dumplog of map X-Git-Tag: NetHack-3.6.1_RC01~491 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ead698fd029255581a89aa86b4b9f157d2d6db7a;p=nethack dumplog of map When writing the known portion of the current level's map into dumplog, discard any blank rows at the top (there will already be one blank line separating it from the text that precedes) and keep at most one blank row at the bottom (sometimes there won't be any). --- diff --git a/include/extern.h b/include/extern.h index e8e15e701..cabdb51b0 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 extern.h $NHDT-Date: 1494107197 2017/05/06 21:46:37 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.587 $ */ +/* NetHack 3.6 extern.h $NHDT-Date: 1495346095 2017/05/21 05:54:55 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.588 $ */ /* Copyright (c) Steve Creps, 1988. */ /* NetHack may be freely redistributed. See license for details. */ @@ -270,7 +270,9 @@ E void NDECL(warnreveal); E int FDECL(dosearch0, (int)); E int NDECL(dosearch); E void NDECL(sokoban_detect); +#ifdef DUMPLOG E void NDECL(dump_map); +#endif E void FDECL(reveal_terrain, (int, int)); /* ### dig.c ### */ diff --git a/src/detect.c b/src/detect.c index def22469e..86e3159bf 100644 --- a/src/detect.c +++ b/src/detect.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 detect.c $NHDT-Date: 1491705573 2017/04/09 02:39:33 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.76 $ */ +/* NetHack 3.6 detect.c $NHDT-Date: 1495346103 2017/05/21 05:55:03 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.77 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1799,15 +1799,28 @@ int default_glyph, which_subset; return glyph; } +#ifdef DUMPLOG void dump_map() { - int x, y, glyph; + int x, y, glyph, skippedrows; int subset = TER_MAP | TER_TRP | TER_OBJ | TER_MON; int default_glyph = cmap_to_glyph(level.flags.arboreal ? S_tree : S_stone); char buf[BUFSZ]; + boolean blankrow, toprow; + /* + * Squeeze out excess vertial space when dumping the map. + * If there are any blank map rows at the top, suppress them + * (our caller has already printed a separator). If there is + * more than one blank map row at the bottom, keep just one. + * Any blank rows within the middle of the map are kept. + * Note: putstr() with winid==0 is for dumplog. + */ + skippedrows = 0; + toprow = TRUE; for (y = 0; y < ROWNO; y++) { + blankrow = TRUE; /* assume blank until we discover otherwise */ for (x = 1; x < COLNO; x++) { int ch, color; unsigned special; @@ -1815,12 +1828,27 @@ dump_map() glyph = reveal_terrain_getglyph(x,y, FALSE, u.uswallow, default_glyph, subset); (void) mapglyph(glyph, &ch, &color, &special, x, y); - buf[x-1] = ch; + buf[x - 1] = ch; + if (ch != ' ') + blankrow = FALSE; + } + if (!blankrow) { + buf[x - 2] = '\0'; + if (toprow) { + skippedrows = 0; + toprow = FALSE; + } + for (x = 0; x < skippedrows; x++) + putstr(0, 0, ""); + putstr(0, 0, buf); /* map row #y */ + } else { + ++skippedrows; } - buf[x-2] = '\0'; - putstr(0,0, buf); } + if (skippedrows) + putstr(0, 0, ""); } +#endif /* DUMPLOG */ /* idea from crawl; show known portion of map without any monsters, objects, or traps occluding the view of the underlying terrain */