From: PatR Date: Thu, 5 Apr 2018 01:27:13 +0000 (-0700) Subject: DUMPLOG map fix X-Git-Tag: NetHack-3.6.1_RC01~77 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e1552679e250e48a667f1c2b4a223f5e528ed42a;p=nethack DUMPLOG map fix I once changed dump_map() to suppress blank lines as it processed the known portion of current dungeon level so that no blank lines would be shown above the mapped area and at most one would be shown below. Any blank lines within were put back. But the count of the current block of suppressed lines wasn't being zeroed when an internal gap did get put back, so after that every line got spurious blank lines inserted in front of it. I'm surprised that no one seems to have discovered this problem. This fix also changes the dumped map to suppress trailing spaces. In the process, I noticed that the original DUMPLOG code was clobbering column COLNO-1 if that was ever part of known map. buf[x - 2] = '\0' overwrote the final map character in buf[] with the terminator. --- diff --git a/doc/fixes36.1 b/doc/fixes36.1 index 8b53024cd..e95ecb7de 100644 --- a/doc/fixes36.1 +++ b/doc/fixes36.1 @@ -627,6 +627,8 @@ gas spore explosion killing a gas spore which triggers a recursive explosion "You are hit by the gas spore's explosion!" (inner call, followed by) "You are hit by the !" (outer call, possibly repeated for multiple explosions causing multiple levels of recursion) +if multiple bands of blank lines were squeezed out of DUMPLOG's map, spurious + blank lines appeared in the final map output Platform- and/or Interface-Specific Fixes diff --git a/src/detect.c b/src/detect.c index d835bd86d..7a6b6eb47 100644 --- a/src/detect.c +++ b/src/detect.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 detect.c $NHDT-Date: 1519281847 2018/02/22 06:44:07 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.80 $ */ +/* NetHack 3.6 detect.c $NHDT-Date: 1522891623 2018/04/05 01:27:03 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.81 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1802,7 +1802,7 @@ int default_glyph, which_subset; void dump_map() { - int x, y, glyph, skippedrows; + int x, y, glyph, skippedrows, lastnonblank; 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]; @@ -1820,19 +1820,22 @@ dump_map() toprow = TRUE; for (y = 0; y < ROWNO; y++) { blankrow = TRUE; /* assume blank until we discover otherwise */ + lastnonblank = -1; /* buf[] index rather than map's x */ for (x = 1; x < COLNO; x++) { int ch, color; unsigned special; - glyph = reveal_terrain_getglyph(x,y, FALSE, u.uswallow, + glyph = reveal_terrain_getglyph(x, y, FALSE, u.uswallow, default_glyph, subset); (void) mapglyph(glyph, &ch, &color, &special, x, y); buf[x - 1] = ch; - if (ch != ' ') + if (ch != ' ') { blankrow = FALSE; + lastnonblank = x - 1; + } } if (!blankrow) { - buf[x - 2] = '\0'; + buf[lastnonblank + 1] = '\0'; if (toprow) { skippedrows = 0; toprow = FALSE; @@ -1840,6 +1843,7 @@ dump_map() for (x = 0; x < skippedrows; x++) putstr(0, 0, ""); putstr(0, 0, buf); /* map row #y */ + skippedrows = 0; } else { ++skippedrows; }