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

Function role_selection_prolog

src/role.c:1725–1812  ·  view source on GitHub ↗

show current settings for name, role, race, gender, and alignment in the specified window */

Source from the content-addressed store, hash-verified

1723/* show current settings for name, role, race, gender, and alignment
1724 in the specified window */
1725void
1726role_selection_prolog(int which, winid where)
1727{
1728 static const char NEARDATA choosing[] = " choosing now",
1729 not_yet[] = " not yet specified",
1730 rand_choice[] = " random";
1731 char buf[BUFSZ];
1732 int r, c, gend, a, allowmask;
1733
1734 r = flags.initrole;
1735 c = flags.initrace;
1736 gend = flags.initgend;
1737 a = flags.initalign;
1738 if (r >= 0) {
1739 assert(IndexOkT(r, roles));
1740 allowmask = roles[r].allow;
1741 if ((allowmask & ROLE_RACEMASK) == MH_HUMAN)
1742 c = 0; /* races[human] */
1743 else if (IndexOkT(c, races)
1744 && !(allowmask & ROLE_RACEMASK & races[c].allow))
1745 c = ROLE_RANDOM;
1746 if ((allowmask & ROLE_GENDMASK) == ROLE_MALE)
1747 gend = 0; /* role forces male (hypothetical) */
1748 else if ((allowmask & ROLE_GENDMASK) == ROLE_FEMALE)
1749 gend = 1; /* role forces female (valkyrie) */
1750 if ((allowmask & ROLE_ALIGNMASK) == AM_LAWFUL)
1751 a = 0; /* aligns[lawful] */
1752 else if ((allowmask & ROLE_ALIGNMASK) == AM_NEUTRAL)
1753 a = 1; /* aligns[neutral] */
1754 else if ((allowmask & ROLE_ALIGNMASK) == AM_CHAOTIC)
1755 a = 2; /* aligns[chaotic] */
1756 }
1757 if (c >= 0) {
1758 assert(IndexOkT(c, races));
1759 allowmask = races[c].allow;
1760 if ((allowmask & ROLE_ALIGNMASK) == AM_LAWFUL)
1761 a = 0; /* aligns[lawful] */
1762 else if ((allowmask & ROLE_ALIGNMASK) == AM_NEUTRAL)
1763 a = 1; /* aligns[neutral] */
1764 else if ((allowmask & ROLE_ALIGNMASK) == AM_CHAOTIC)
1765 a = 2; /* aligns[chaotic] */
1766 /* [c never forces gender] */
1767 }
1768 /* [g and a don't constrain anything sufficiently
1769 to narrow something done to a single choice] */
1770
1771 Sprintf(buf, "%12s ", "name:");
1772 Strcat(buf, (which == RS_NAME) ? choosing
1773 : !*svp.plname ? not_yet : svp.plname);
1774 putstr(where, 0, buf);
1775 Sprintf(buf, "%12s ", "role:");
1776 assert(which == RS_ROLE || r == ROLE_NONE || r == ROLE_RANDOM
1777 || IndexOkT(r, roles));
1778 Strcat(buf, (which == RS_ROLE) ? choosing
1779 : (r == ROLE_NONE) ? not_yet
1780 : (r == ROLE_RANDOM) ? rand_choice
1781 : roles[r].name.m);
1782 if (r >= 0 && roles[r].name.f) {

Callers

nothing calls this directly

Calls 1

eosFunction · 0.85

Tested by

no test coverage detected