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

Function ok_align

src/role.c:1171–1204  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1169/* is alignnum compatible with any rolenum/racenum/gendnum constraints? */
1170/* alignment and gender are not comparable (and also not constrainable) */
1171boolean
1172ok_align(int rolenum, int racenum, int gendnum UNUSED, int alignnum)
1173{
1174 int i;
1175 short allow;
1176
1177 if (alignnum >= 0 && alignnum < ROLE_ALIGNS) {
1178 if (gr.rfilter.mask & aligns[alignnum].allow)
1179 return FALSE;
1180 allow = aligns[alignnum].allow;
1181 if (IndexOkT(rolenum, roles)
1182 && !(allow & roles[rolenum].allow & ROLE_ALIGNMASK))
1183 return FALSE;
1184 if (IndexOkT(racenum, races)
1185 && !(allow & races[racenum].allow & ROLE_ALIGNMASK))
1186 return FALSE;
1187 return TRUE;
1188 } else {
1189 /* random; check whether any selection is possible */
1190 for (i = 0; i < ROLE_ALIGNS; i++) {
1191 if (gr.rfilter.mask & aligns[i].allow)
1192 continue;
1193 allow = aligns[i].allow;
1194 if (IndexOkT(rolenum, roles)
1195 && !(allow & roles[rolenum].allow & ROLE_ALIGNMASK))
1196 continue;
1197 if (IndexOkT(racenum, races)
1198 && !(allow & races[racenum].allow & ROLE_ALIGNMASK))
1199 continue;
1200 return TRUE;
1201 }
1202 return FALSE;
1203 }
1204}
1205
1206/* Pick a random alignment subject to any rolenum/racenum/gendnum constraints;
1207 alignment and gender 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_alignFunction · 0.85
root_plselection_promptFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected