Convert glyph_to_cmap from macro to function
Even if nethack is meant to support compilers that do not know about inline functions, this one was frankly too long to be a macro already, and I'm about to make it longer still.
This commit is contained in:
@@ -725,30 +725,7 @@ enum glyph_offsets {
|
||||
&& (glyph) < (GLYPH_CMAP_C_OFF + ((S_goodpos - S_digbeam) + 1)))
|
||||
|
||||
/* final MAXPCHARS is legal array index because of trailing fencepost entry */
|
||||
#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) \
|
||||
: glyph_is_cmap_zap(glyph) \
|
||||
? ((((glyph) - GLYPH_ZAP_OFF) % 4) + S_vbeam) \
|
||||
: MAXPCHARS)
|
||||
int glyph_to_cmap(int glpyh);
|
||||
|
||||
#define glyph_to_swallow(glyph) \
|
||||
(glyph_is_swallow(glyph) ? (((glyph) - GLYPH_SWALLOW_OFF) & 0x7) : 0)
|
||||
|
||||
29
src/glyphs.c
29
src/glyphs.c
@@ -189,6 +189,35 @@ fix_glyphname(char *str)
|
||||
return str;
|
||||
}
|
||||
|
||||
int
|
||||
glyph_to_cmap(int glyph)
|
||||
{
|
||||
if (glyph == GLYPH_CMAP_STONE_OFF)
|
||||
return S_stone;
|
||||
else if (glyph_is_cmap_main(glyph))
|
||||
return (glyph - GLYPH_CMAP_MAIN_OFF) + S_vwall;
|
||||
else if (glyph_is_cmap_mines(glyph))
|
||||
return (glyph - GLYPH_CMAP_MINES_OFF) + S_vwall;
|
||||
else if (glyph_is_cmap_gehennom(glyph))
|
||||
return (glyph - GLYPH_CMAP_GEH_OFF) + S_vwall;
|
||||
else if (glyph_is_cmap_knox(glyph))
|
||||
return (glyph - GLYPH_CMAP_KNOX_OFF) + S_vwall;
|
||||
else if (glyph_is_cmap_sokoban(glyph))
|
||||
return (glyph - GLYPH_CMAP_SOKO_OFF) + S_vwall;
|
||||
else if (glyph_is_cmap_a(glyph))
|
||||
return (glyph - GLYPH_CMAP_A_OFF) + S_ndoor;
|
||||
else if (glyph_is_cmap_altar(glyph))
|
||||
return S_altar;
|
||||
else if (glyph_is_cmap_b(glyph))
|
||||
return (glyph - GLYPH_CMAP_B_OFF) + S_grave;
|
||||
else if (glyph_is_cmap_c(glyph))
|
||||
return (glyph - GLYPH_CMAP_C_OFF) + S_digbeam;
|
||||
else if (glyph_is_cmap_zap(glyph))
|
||||
return ((glyph - GLYPH_ZAP_OFF) % 4) + S_vbeam;
|
||||
else
|
||||
return MAXPCHARS;
|
||||
}
|
||||
|
||||
staticfn int
|
||||
glyph_find_core(const char *id, struct find_struct *findwhat)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user