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

Function role_menu_extra

src/role.c:1815–1960  ·  view source on GitHub ↗

add a "pick alignment first"-type entry to the specified menu */

Source from the content-addressed store, hash-verified

1813
1814/* add a "pick alignment first"-type entry to the specified menu */
1815void
1816role_menu_extra(int which, winid where, boolean preselect)
1817{
1818 static NEARDATA const char RS_menu_let[] = {
1819 '=', /* name */
1820 '?', /* role */
1821 '/', /* race */
1822 '\"', /* gender */
1823 '[', /* alignment */
1824 };
1825 anything any;
1826 char buf[BUFSZ];
1827 const char *what = 0, *constrainer = 0, *forcedvalue = 0;
1828 int f = 0, r, c, gend, a, i, allowmask;
1829 int clr = NO_COLOR;
1830
1831 r = flags.initrole;
1832 c = flags.initrace;
1833 switch (which) {
1834 case RS_NAME:
1835 what = "name";
1836 break;
1837 case RS_ROLE:
1838 what = "role";
1839 f = r;
1840 for (i = 0; i < SIZE(roles) - 1; ++i)
1841 if (i != f && !gr.rfilter.roles[i])
1842 break;
1843 if (i == SIZE(roles) - 1) {
1844 constrainer = "filter";
1845 forcedvalue = "role";
1846 }
1847 break;
1848 case RS_RACE:
1849 what = "race";
1850 f = flags.initrace;
1851 c = ROLE_NONE; /* override player's setting */
1852 if (r >= 0) {
1853 allowmask = roles[r].allow & ROLE_RACEMASK;
1854 if (allowmask == MH_HUMAN)
1855 c = 0; /* races[human] */
1856 if (c >= 0) {
1857 constrainer = "role";
1858 forcedvalue = races[c].noun;
1859 } else if (f >= 0 && ((allowmask & ~gr.rfilter.mask)
1860 == races[f].selfmask)) {
1861 /* if there is only one race choice available due to user
1862 options disallowing others, race menu entry is disabled */
1863 constrainer = "filter";
1864 forcedvalue = "race";
1865 }
1866 }
1867 break;
1868 case RS_GENDER:
1869 what = "gender";
1870 f = flags.initgend;
1871 gend = ROLE_NONE;
1872 if (r >= 0) {

Callers 1

genl_player_setupFunction · 0.85

Calls 4

add_menu_strFunction · 0.85
add_menuFunction · 0.85
gotrolefilterFunction · 0.85
impossibleFunction · 0.70

Tested by

no test coverage detected