From 8fe02be5ae2a9b1560fd5f1a0aeaf2b48cce0f33 Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Fri, 15 Jul 2022 19:53:47 -0400 Subject: [PATCH] Fix: getpos cmap vs typ/glyph confusion 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 | 10 ++++------ src/mkroom.c | 1 + 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/do_name.c b/src/do_name.c index 4de715afa..a6309edf4 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -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] diff --git a/src/mkroom.c b/src/mkroom.c index 94d4e3776..abdeeef13 100644 --- a/src/mkroom.c +++ b/src/mkroom.c @@ -942,6 +942,7 @@ cmap_to_type(int sym) typ = TREE; break; case S_room: + case S_darkroom: typ = ROOM; break; case S_corr: -- 2.50.1