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

Function ok_gend

src/role.c:1106–1139  ·  view source on GitHub ↗

is gendnum compatible with any rolenum/racenum/alignnum constraints? */ gender and alignment are not comparable (and also not constrainable) */

Source from the content-addressed store, hash-verified

1104/* is gendnum compatible with any rolenum/racenum/alignnum constraints? */
1105/* gender and alignment are not comparable (and also not constrainable) */
1106boolean
1107ok_gend(int rolenum, int racenum, int gendnum, int alignnum UNUSED)
1108{
1109 int i;
1110 short allow;
1111
1112 if (gendnum >= 0 && gendnum < ROLE_GENDERS) {
1113 if (gr.rfilter.mask & genders[gendnum].allow)
1114 return FALSE;
1115 allow = genders[gendnum].allow;
1116 if (IndexOkT(rolenum, roles)
1117 && !(allow & roles[rolenum].allow & ROLE_GENDMASK))
1118 return FALSE;
1119 if (IndexOkT(racenum, races)
1120 && !(allow & races[racenum].allow & ROLE_GENDMASK))
1121 return FALSE;
1122 return TRUE;
1123 } else {
1124 /* random; check whether any selection is possible */
1125 for (i = 0; i < ROLE_GENDERS; i++) {
1126 if (gr.rfilter.mask & genders[i].allow)
1127 continue;
1128 allow = genders[i].allow;
1129 if (IndexOkT(rolenum, roles)
1130 && !(allow & roles[rolenum].allow & ROLE_GENDMASK))
1131 continue;
1132 if (IndexOkT(racenum, races)
1133 && !(allow & races[racenum].allow & ROLE_GENDMASK))
1134 continue;
1135 return TRUE;
1136 }
1137 return FALSE;
1138 }
1139}
1140
1141/* pick a random gender subject to any rolenum/racenum/alignnum constraints */
1142/* gender and alignment are not comparable (and also not constrainable) */

Callers 15

PlayerSelectorDlgProcFunction · 0.85
plselAdjustSelectionsFunction · 0.85
plselFinalSelectionFunction · 0.85
plselRandomizeFunction · 0.85
curses_choose_characterFunction · 0.85
winmisc.cFile · 0.85
amii_player_selectionFunction · 0.85
randrole_filteredFunction · 0.85
pick_roleFunction · 0.85
pick_gendFunction · 0.85
genl_player_setupFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected