show_glyph() impossible

After glyph expansion a while back, a few 'if's had tests of
|  else if ((offset = (foo - bar)))
which should be
|  else if ((offset = (foo - bar)) >= 0)
Only used if show_glyph() has been passed invalid map coordinates
so never seen.
This commit is contained in:
PatR
2023-01-02 23:40:06 -08:00
parent c91f142bdb
commit 18fa85c681
+13 -12
View File
@@ -1684,16 +1684,18 @@ show_glyph(coordxy x, coordxy y, int glyph)
* This assumes an ordering of the offsets. See display.h for * This assumes an ordering of the offsets. See display.h for
* the definition. * the definition.
*/ */
if (glyph < 0 || glyph >= MAX_GLYPH) {
if ((offset = (glyph - GLYPH_NOTHING_OFF)) >= 0) { /* invalid location and also invalid glyph */
text = "invalid";
} else if ((offset = (glyph - GLYPH_NOTHING_OFF)) >= 0) {
text = "nothing"; text = "nothing";
} else if ((offset = (glyph - GLYPH_UNEXPLORED_OFF)) >= 0) { } else if ((offset = (glyph - GLYPH_UNEXPLORED_OFF)) >= 0) {
text = "unexplored"; text = "unexplored";
} else if ((offset = (glyph - GLYPH_STATUE_FEM_PILETOP_OFF))) { } else if ((offset = (glyph - GLYPH_STATUE_FEM_PILETOP_OFF)) >= 0) {
text = "statue of a female monster at top of a pile"; text = "statue of a female monster at top of a pile";
} else if ((offset = (glyph - GLYPH_STATUE_MALE_PILETOP_OFF))) { } else if ((offset = (glyph - GLYPH_STATUE_MALE_PILETOP_OFF)) >= 0) {
text = "statue of a male monster at top of a pile"; text = "statue of a male monster at top of a pile";
} else if ((offset = (glyph - GLYPH_BODY_PILETOP_OFF))) { } else if ((offset = (glyph - GLYPH_BODY_PILETOP_OFF)) >= 0) {
text = "body at top of a pile"; text = "body at top of a pile";
} else if ((offset = (glyph - GLYPH_OBJ_PILETOP_OFF))) { } else if ((offset = (glyph - GLYPH_OBJ_PILETOP_OFF))) {
text = "object at top of a pile"; text = "object at top of a pile";
@@ -1765,14 +1767,13 @@ show_glyph(coordxy x, coordxy y, int glyph)
} else if ((offset = (glyph - GLYPH_MON_MALE_OFF)) >= 0) { } else if ((offset = (glyph - GLYPH_MON_MALE_OFF)) >= 0) {
text = "male monster"; text = "male monster";
} }
impossible("show_glyph: bad pos %d %d with glyph %d [%s %d].", x, y, impossible("show_glyph: bad pos <%d,%d> with glyph %d [%s %d].",
glyph, text, offset); x, y, glyph, text, offset);
return; return;
} } else if (glyph < 0 || glyph >= MAX_GLYPH) {
/* valid location but invalid glyph */
if (glyph >= MAX_GLYPH) { impossible("show_glyph: bad glyph %d [max %d] at <%d,%d>.",
impossible("show_glyph: bad glyph %d [max %d] at (%d,%d).", glyph, glyph, MAX_GLYPH, x, y);
MAX_GLYPH, x, y);
return; return;
} }
#ifndef UNBUFFERED_GLYPHINFO #ifndef UNBUFFERED_GLYPHINFO