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

Function ok_role

src/role.c:970–1009  ·  view source on GitHub ↗

is rolenum compatible with any racenum/gendnum/alignnum constraints? */

Source from the content-addressed store, hash-verified

968
969/* is rolenum compatible with any racenum/gendnum/alignnum constraints? */
970boolean
971ok_role(int rolenum, int racenum, int gendnum, int alignnum)
972{
973 int i;
974 short allow;
975
976 if (IndexOkT(rolenum, roles)) {
977 if (gr.rfilter.roles[rolenum])
978 return FALSE;
979 allow = roles[rolenum].allow;
980 if (IndexOkT(racenum, races)
981 && !(allow & races[racenum].allow & ROLE_RACEMASK))
982 return FALSE;
983 if (gendnum >= 0 && gendnum < ROLE_GENDERS
984 && !(allow & genders[gendnum].allow & ROLE_GENDMASK))
985 return FALSE;
986 if (alignnum >= 0 && alignnum < ROLE_ALIGNS
987 && !(allow & aligns[alignnum].allow & ROLE_ALIGNMASK))
988 return FALSE;
989 return TRUE;
990 } else {
991 /* random; check whether any selection is possible */
992 for (i = 0; i < SIZE(roles) - 1; i++) {
993 if (gr.rfilter.roles[i])
994 continue;
995 allow = roles[i].allow;
996 if (IndexOkT(racenum, races)
997 && !(allow & races[racenum].allow & ROLE_RACEMASK))
998 continue;
999 if (gendnum >= 0 && gendnum < ROLE_GENDERS
1000 && !(allow & genders[gendnum].allow & ROLE_GENDMASK))
1001 continue;
1002 if (alignnum >= 0 && alignnum < ROLE_ALIGNS
1003 && !(allow & aligns[alignnum].allow & ROLE_ALIGNMASK))
1004 continue;
1005 return TRUE;
1006 }
1007 return FALSE;
1008 }
1009}
1010
1011/* pick a random role subject to any racenum/gendnum/alignnum constraints */
1012/* If pickhow == PICK_RIGID a role is returned only if there is */

Callers 15

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
maybe_skip_sepsFunction · 0.85
setup_rolemenuFunction · 0.85
setup_racemenuFunction · 0.85
setup_gendmenuFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected