fix glyph_to_cmap() odd macro results
Some discrepencies between glyph_is_cmap and glyph_to_cmap
arose after b14b830b because the change resulted in
glyph_is_cmap matching on zap beams which weren't accounted
for in the glyph_to_cmap macro. It is unlikely that
glyph_to_cmap will ever be used on such a glyph, but at least
have glyph_to_cmap return a sane value rather than drop through
to the last-resort value (currently NO_GLYPH) which is far
outside the range of the defsyms[] array indices.
This commit is contained in:
@@ -711,27 +711,29 @@ enum glyph_offsets {
|
||||
&& (glyph) < (GLYPH_CMAP_C_OFF + ((S_goodpos - S_digbeam) + 1)))
|
||||
|
||||
#define glyph_to_cmap(glyph) \
|
||||
(((glyph) == GLYPH_CMAP_STONE_OFF) \
|
||||
? S_stone \
|
||||
: glyph_is_cmap_main(glyph) \
|
||||
? (((glyph) - GLYPH_CMAP_MAIN_OFF) + S_vwall) \
|
||||
: glyph_is_cmap_mines(glyph) \
|
||||
? (((glyph) - GLYPH_CMAP_MINES_OFF) + S_vwall) \
|
||||
: glyph_is_cmap_gehennom(glyph) \
|
||||
? (((glyph) - GLYPH_CMAP_GEH_OFF) + S_vwall) \
|
||||
: glyph_is_cmap_knox(glyph) \
|
||||
? (((glyph) - GLYPH_CMAP_KNOX_OFF) + S_vwall) \
|
||||
: glyph_is_cmap_sokoban(glyph) \
|
||||
? (((glyph) - GLYPH_CMAP_SOKO_OFF) + S_vwall) \
|
||||
: glyph_is_cmap_a(glyph) \
|
||||
? (((glyph) - GLYPH_CMAP_A_OFF) + S_ndoor) \
|
||||
: glyph_is_cmap_altar(glyph) \
|
||||
? (S_altar) \
|
||||
: glyph_is_cmap_b(glyph) \
|
||||
? (((glyph) - GLYPH_CMAP_B_OFF) + S_grave) \
|
||||
: glyph_is_cmap_c(glyph) \
|
||||
? (((glyph) - GLYPH_CMAP_C_OFF) + S_digbeam) \
|
||||
: NO_GLYPH)
|
||||
(((glyph) == GLYPH_CMAP_STONE_OFF) \
|
||||
? S_stone \
|
||||
: glyph_is_cmap_main(glyph) \
|
||||
? (((glyph) - GLYPH_CMAP_MAIN_OFF) + S_vwall) \
|
||||
: glyph_is_cmap_mines(glyph) \
|
||||
? (((glyph) - GLYPH_CMAP_MINES_OFF) + S_vwall) \
|
||||
: glyph_is_cmap_gehennom(glyph) \
|
||||
? (((glyph) - GLYPH_CMAP_GEH_OFF) + S_vwall) \
|
||||
: glyph_is_cmap_knox(glyph) \
|
||||
? (((glyph) - GLYPH_CMAP_KNOX_OFF) + S_vwall) \
|
||||
: glyph_is_cmap_sokoban(glyph) \
|
||||
? (((glyph) - GLYPH_CMAP_SOKO_OFF) + S_vwall) \
|
||||
: glyph_is_cmap_a(glyph) \
|
||||
? (((glyph) - GLYPH_CMAP_A_OFF) + S_ndoor) \
|
||||
: glyph_is_cmap_altar(glyph) \
|
||||
? (S_altar) \
|
||||
: glyph_is_cmap_b(glyph) \
|
||||
? (((glyph) - GLYPH_CMAP_B_OFF) + S_grave) \
|
||||
: glyph_is_cmap_c(glyph) \
|
||||
? (((glyph) - GLYPH_CMAP_C_OFF) + S_digbeam) \
|
||||
: glyph_is_cmap_zap(glyph) \
|
||||
? ((((glyph) - GLYPH_ZAP_OFF) % 4) + S_vbeam) \
|
||||
: NO_GLYPH)
|
||||
|
||||
#define glyph_to_swallow(glyph) \
|
||||
(glyph_is_swallow(glyph) ? (((glyph) - GLYPH_SWALLOW_OFF) & 0x7) : 0)
|
||||
|
||||
@@ -4026,6 +4026,13 @@ wiz_display_macros(void)
|
||||
glyph, test);
|
||||
putstr(win, 0, buf);
|
||||
}
|
||||
if (glyph_is_cmap_zap(glyph)
|
||||
&& !(test >= S_vbeam && test <= S_rslant)) {
|
||||
Sprintf(buf,
|
||||
"glyph_is_zap(glyph=%d) returned non-zap cmap %d",
|
||||
glyph, test);
|
||||
putstr(win, 0, buf);
|
||||
}
|
||||
/* check against defsyms array subscripts */
|
||||
if (test < 0 || test >= SIZE(defsyms)) {
|
||||
if (!trouble++)
|
||||
|
||||
Reference in New Issue
Block a user