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

Function ok_race

src/role.c:1036–1075  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1034
1035/* is racenum compatible with any rolenum/gendnum/alignnum constraints? */
1036boolean
1037ok_race(int rolenum, int racenum, int gendnum, int alignnum)
1038{
1039 int i;
1040 short allow;
1041
1042 if (IndexOkT(racenum, races)) {
1043 if (gr.rfilter.mask & races[racenum].selfmask)
1044 return FALSE;
1045 allow = races[racenum].allow;
1046 if (IndexOkT(rolenum, roles)
1047 && !(allow & roles[rolenum].allow & ROLE_RACEMASK))
1048 return FALSE;
1049 if (gendnum >= 0 && gendnum < ROLE_GENDERS
1050 && !(allow & genders[gendnum].allow & ROLE_GENDMASK))
1051 return FALSE;
1052 if (alignnum >= 0 && alignnum < ROLE_ALIGNS
1053 && !(allow & aligns[alignnum].allow & ROLE_ALIGNMASK))
1054 return FALSE;
1055 return TRUE;
1056 } else {
1057 /* random; check whether any selection is possible */
1058 for (i = 0; i < SIZE(races) - 1; i++) {
1059 if (gr.rfilter.mask & races[i].selfmask)
1060 continue;
1061 allow = races[i].allow;
1062 if (IndexOkT(rolenum, roles)
1063 && !(allow & roles[rolenum].allow & ROLE_RACEMASK))
1064 continue;
1065 if (gendnum >= 0 && gendnum < ROLE_GENDERS
1066 && !(allow & genders[gendnum].allow & ROLE_GENDMASK))
1067 continue;
1068 if (alignnum >= 0 && alignnum < ROLE_ALIGNS
1069 && !(allow & aligns[alignnum].allow & ROLE_ALIGNMASK))
1070 continue;
1071 return TRUE;
1072 }
1073 return FALSE;
1074 }
1075}
1076
1077/* Pick a random race subject to any rolenum/gendnum/alignnum constraints.
1078 If pickhow == PICK_RIGID a race is returned only if there is

Callers 15

PlayerSelectorDlgProcFunction · 0.85
plselAdjustSelectionsFunction · 0.85
plselFinalSelectionFunction · 0.85
plselRandomizeFunction · 0.85
plselDrawItemFunction · 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_raceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected