Add swallow and explosion glyphs to glyph_to_cmap

This makes custom S_sw_tc etc. from Enhanced1 symset actually work,
yielding nice smooth outlines for swallowers and explosions. Or so I
think, I have only tested the former because when playing locally,
explosions disappear so fast I cannot see them.

While looking at where else glyph_to_swallow was used, I noticed that
parse_id subtracted S_sw_tl from glyph_to_swallow, even though it
returns 0 to 7. This looks like it would cause out-of-bounds access and
perhaps a segfault when trying to customise glyphs for individual
monster swallow glyphs (or whatever it is parse_id is used for), but
I haven't tried to confirm nor change this because who would ever do
such thing?
This commit is contained in:
Doktor L
2024-09-02 00:07:20 +02:00
parent ede71dd1ac
commit 52346c8248
2 changed files with 7 additions and 2 deletions

View File

@@ -729,6 +729,8 @@ int glyph_to_cmap(int glpyh);
#define glyph_to_swallow(glyph) \
(glyph_is_swallow(glyph) ? (((glyph) - GLYPH_SWALLOW_OFF) & 0x7) : 0)
#define glyph_to_explosion(glyph) \
(glyph_is_explosion(glyph) ? (((glyph) - GLYPH_EXPLODE_OFF) % (S_expl_br - S_expl_tl + 1)) : 0)
#define glyph_to_warning(glyph) \
(glyph_is_warning(glyph) ? ((glyph) - GLYPH_WARNING_OFF) : NO_GLYPH)

View File

@@ -214,6 +214,10 @@ glyph_to_cmap(int 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 if (glyph_is_swallow(glyph))
return glyph_to_swallow(glyph) + S_sw_tl;
else if (glyph_is_explosion(glyph))
return glyph_to_explosion(glyph) + S_expl_tl;
else
return MAXPCHARS;
}
@@ -1051,8 +1055,7 @@ parse_id(const char *id, struct find_struct *findwhat)
j = glyph - GLYPH_EXPLODE_OFF;
expl = j / ((S_expl_br - S_expl_tl) + 1);
cmap = (j % ((S_expl_br - S_expl_tl) + 1))
+ S_expl_tl;
cmap = glyph_to_explosion(glyph) + S_expl_tl;
i = cmap - S_expl_tl;
Snprintf(buf[2], sizeof buf[2], "%s ",
expl_type_texts[expl]);