MCPcopy Create free account
hub / github.com/NetHack/NetHack / wiz_display_macros

Function wiz_display_macros

src/wizcmds.c:1704–1778  ·  view source on GitHub ↗

the #wizdispmacros command * Verify that some display macros are returning sane values */

Source from the content-addressed store, hash-verified

1702/* the #wizdispmacros command
1703 * Verify that some display macros are returning sane values */
1704int
1705wiz_display_macros(void)
1706{
1707 static const char display_issues[] = "Display macro issues:";
1708 char buf[BUFSZ];
1709 winid win;
1710 int glyph, test, trouble = 0, no_glyph = NO_GLYPH, max_glyph = MAX_GLYPH;
1711
1712 win = create_nhwindow(NHW_TEXT);
1713
1714 for (glyph = 0; glyph < MAX_GLYPH; ++glyph) {
1715 /* glyph_is_cmap / glyph_to_cmap() */
1716 if (glyph_is_cmap(glyph)) {
1717 test = glyph_to_cmap(glyph);
1718 /* check for MAX_GLYPH return */
1719 if (test == no_glyph) {
1720 if (!trouble++)
1721 putstr(win, 0, display_issues);
1722 Sprintf(buf, "glyph_is_cmap() / glyph_to_cmap(glyph=%d)"
1723 " sync failure, returned NO_GLYPH (%d)",
1724 glyph, test);
1725 putstr(win, 0, buf);
1726 }
1727 if (glyph_is_cmap_zap(glyph)
1728 && !(test >= S_vbeam && test <= S_rslant)) {
1729 if (!trouble++)
1730 putstr(win, 0, display_issues);
1731 Sprintf(buf,
1732 "glyph_is_cmap_zap(glyph=%d) returned non-zap cmap %d",
1733 glyph, test);
1734 putstr(win, 0, buf);
1735 }
1736 /* check against defsyms array subscripts */
1737 if (!IndexOk(test, defsyms)) {
1738 if (!trouble++)
1739 putstr(win, 0, display_issues);
1740 Sprintf(buf, "glyph_to_cmap(glyph=%d) returns %d"
1741 " exceeds defsyms[%d] bounds (MAX_GLYPH = %d)",
1742 glyph, test, SIZE(defsyms), max_glyph);
1743 putstr(win, 0, buf);
1744 }
1745 }
1746 /* glyph_is_monster / glyph_to_mon */
1747 if (glyph_is_monster(glyph)) {
1748 test = glyph_to_mon(glyph);
1749 /* check against mons array subscripts */
1750 if (test < 0 || test >= NUMMONS) {
1751 if (!trouble++)
1752 putstr(win, 0, display_issues);
1753 Sprintf(buf, "glyph_to_mon(glyph=%d) returns %d"
1754 " exceeds mons[%d] bounds",
1755 glyph, test, NUMMONS);
1756 putstr(win, 0, buf);
1757 }
1758 }
1759 /* glyph_is_object / glyph_to_obj */
1760 if (glyph_is_object(glyph)) {
1761 test = glyph_to_obj(glyph);

Callers

nothing calls this directly

Calls 1

glyph_to_cmapFunction · 0.85

Tested by

no test coverage detected