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

Function pick_race

src/role.c:1080–1102  ·  view source on GitHub ↗

Pick a random race subject to any rolenum/gendnum/alignnum constraints. If pickhow == PICK_RIGID a race is returned only if there is a single possibility. */

Source from the content-addressed store, hash-verified

1078 If pickhow == PICK_RIGID a race is returned only if there is
1079 a single possibility. */
1080int
1081pick_race(int rolenum, int gendnum, int alignnum, int pickhow)
1082{
1083 int i;
1084 int races_ok = 0;
1085
1086 for (i = 0; i < SIZE(races) - 1; i++) {
1087 if (ok_race(rolenum, i, gendnum, alignnum))
1088 races_ok++;
1089 }
1090 if (races_ok == 0 || (races_ok > 1 && pickhow == PICK_RIGID))
1091 return ROLE_NONE;
1092 races_ok = rn2(races_ok);
1093 for (i = 0; i < SIZE(races) - 1; i++) {
1094 if (ok_race(rolenum, i, gendnum, alignnum)) {
1095 if (races_ok == 0)
1096 return i;
1097 else
1098 races_ok--;
1099 }
1100 }
1101 return ROLE_NONE;
1102}
1103
1104/* is gendnum compatible with any rolenum/racenum/alignnum constraints? */
1105/* gender and alignment are not comparable (and also not constrainable) */

Callers 13

plselAdjustSelectionsFunction · 0.85
mswin_player_selectionFunction · 0.85
curses_choose_characterFunction · 0.85
winmisc.cFile · 0.85
amii_player_selectionFunction · 0.85
rigid_role_checksFunction · 0.85
genl_player_setupFunction · 0.85
gnome_player_selectionFunction · 0.85
Gem_player_selectionFunction · 0.85
plselFinalSelectionFunction · 0.85
mswin_player_selectionFunction · 0.85

Calls 2

ok_raceFunction · 0.85
rn2Function · 0.85

Tested by

no test coverage detected