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

Function setup_rolemenu

src/role.c:2853–2902  ·  view source on GitHub ↗

add entries a-Archeologist, b-Barbarian, &c to menu being built in 'win' */

Source from the content-addressed store, hash-verified

2851
2852/* add entries a-Archeologist, b-Barbarian, &c to menu being built in 'win' */
2853staticfn void
2854setup_rolemenu(
2855 winid win,
2856 boolean filtering, /* True => exclude filtered roles;
2857 * False => filter reset */
2858 int race, int gend, int algn) /* all ROLE_NONE for !filtering case */
2859{
2860 anything any;
2861 int i;
2862 boolean role_ok;
2863 char thisch, lastch = '\0', rolenamebuf[50];
2864 int clr = NO_COLOR;
2865
2866 any = cg.zeroany; /* zero out all bits */
2867 for (i = 0; roles[i].name.m; i++) {
2868 /* role can be constrained by any of race, gender, or alignment */
2869 role_ok = (ok_role(i, race, gend, algn)
2870 && ok_race(i, race, gend, algn)
2871 && ok_gend(i, race, gend, algn)
2872 && ok_align(i, race, gend, algn));
2873 if (filtering && !role_ok)
2874 continue;
2875 if (filtering)
2876 any.a_int = i + 1;
2877 else
2878 any.a_string = roles[i].name.m;
2879 thisch = lowc(*roles[i].name.m);
2880 if (thisch == lastch)
2881 thisch = highc(thisch);
2882 Strcpy(rolenamebuf, roles[i].name.m);
2883 if (roles[i].name.f) {
2884 /* role has distinct name for female (C,P) */
2885 if (gend == 1) {
2886 /* female already chosen; replace male name */
2887 Strcpy(rolenamebuf, roles[i].name.f);
2888 } else if (gend < 0) {
2889 /* not chosen yet; append slash+female name */
2890 Strcat(rolenamebuf, "/");
2891 Strcat(rolenamebuf, roles[i].name.f);
2892 }
2893 }
2894 /* !filtering implies reset_role_filtering() where we want to
2895 mark this role as preselected if current filter excludes it */
2896 add_menu(win, &nul_glyphinfo, &any, thisch, 0,
2897 ATR_NONE, clr, an(rolenamebuf),
2898 (!filtering && !role_ok)
2899 ? MENU_ITEMFLAGS_SELECTED : MENU_ITEMFLAGS_NONE);
2900 lastch = thisch;
2901 }
2902}
2903
2904staticfn void
2905setup_racemenu(

Callers 2

genl_player_setupFunction · 0.85
reset_role_filteringFunction · 0.85

Calls 8

ok_roleFunction · 0.85
ok_raceFunction · 0.85
ok_gendFunction · 0.85
ok_alignFunction · 0.85
highcFunction · 0.85
add_menuFunction · 0.85
anFunction · 0.85
lowcFunction · 0.70

Tested by

no test coverage detected