]> granicus.if.org Git - nethack/commitdiff
Fix: getpos cmap vs typ/glyph confusion
authorMichael Meyer <me@entrez.cc>
Fri, 15 Jul 2022 23:53:47 +0000 (19:53 -0400)
committerPatR <rankin@nethack.org>
Sun, 24 Jul 2022 00:04:12 +0000 (17:04 -0700)
When some parts of getpos were rearranged in 7404597, tests of terrain
types and glyphs were moved to a loop which iterated through the defsyms
array without being updated to handle cmap values instead.  Consequently
they weren't excluding certain terrain types from being 'jumped to' as
intended.  (Though it seems as though they actually worked by chance to
some extent, just because there's some overlap between terrain types and
defsyms in terms of where the 'walls/doors' blocks start and end.)

I also noticed that cmap_to_type was missing S_darkroom (it fell through
to the default case so that the function returned STONE), so I added it.

src/do_name.c
src/mkroom.c

index 4de715afacedfa5d9d11ba1980ae60311e4fe61f..a6309edf48425cac40bfe90ee2c0ffc1b2eb4f2d 100644 (file)
@@ -927,12 +927,10 @@ getpos(coord *ccp, boolean force, const char *goal)
 
                 (void) memset((genericptr_t) matching, 0, sizeof matching);
                 for (sidx = 1; sidx < MAXPCHARS; sidx++) { /* [0] left as 0 */
-                    if (IS_DOOR(sidx) || IS_WALL(sidx)
-                        || sidx == SDOOR || sidx == SCORR
-                        || glyph_to_cmap(k) == S_room
-                        || glyph_to_cmap(k) == S_darkroom
-                        || glyph_to_cmap(k) == S_corr
-                        || glyph_to_cmap(k) == S_litcorr)
+                    /* don't even try to match some terrain: walls, room... */
+                    if (sidx <= S_hcdoor
+                        || sidx == S_room || sidx == S_darkroom
+                        || sidx == S_corr || sidx == S_litcorr)
                         continue;
                     if (c == defsyms[sidx].sym
                         || c == (int) g.showsyms[sidx]
index 94d4e37761de2f649fc4c3a4ac2acba36dd9b9c4..abdeeef13e4b6f3e95f2abc0130e04f7661a063f 100644 (file)
@@ -942,6 +942,7 @@ cmap_to_type(int sym)
         typ = TREE;
         break;
     case S_room:
+    case S_darkroom:
         typ = ROOM;
         break;
     case S_corr: