From 52346c8248552a295ecbbd7899f8507148f3d149 Mon Sep 17 00:00:00 2001 From: Doktor L Date: Mon, 2 Sep 2024 00:07:20 +0200 Subject: [PATCH] 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? --- include/display.h | 2 ++ src/glyphs.c | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/display.h b/include/display.h index 89bf29b6c..eb8eebfb8 100644 --- a/include/display.h +++ b/include/display.h @@ -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) diff --git a/src/glyphs.c b/src/glyphs.c index 021889190..e378b594e 100644 --- a/src/glyphs.c +++ b/src/glyphs.c @@ -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]);