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

Function randgend

src/role.c:852–877  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

850}
851
852int
853randgend(int rolenum, int racenum)
854{
855 int i, n = 0;
856
857 /* Count the number of valid genders */
858 for (i = 0; i < ROLE_GENDERS; i++)
859 if (roles[rolenum].allow & races[racenum].allow & genders[i].allow
860 & ROLE_GENDMASK)
861 n++;
862
863 /* Pick a random gender */
864 if (n)
865 n = rn2(n);
866 for (i = 0; i < ROLE_GENDERS; i++)
867 if (roles[rolenum].allow & races[racenum].allow & genders[i].allow
868 & ROLE_GENDMASK) {
869 if (n)
870 n--;
871 else
872 return i;
873 }
874
875 /* This role/race has no permitted genders? */
876 return rn2(ROLE_GENDERS);
877}
878
879int
880str2gend(const char *str)

Callers 10

mswin_player_selectionFunction · 0.85
curses_choose_characterFunction · 0.85
amii_player_selectionFunction · 0.85
genl_player_setupFunction · 0.85
gnome_player_selectionFunction · 0.85
Gem_player_selectionFunction · 0.85
mswin_player_selectionFunction · 0.85
mac_asknameFunction · 0.85

Calls 1

rn2Function · 0.85

Tested by

no test coverage detected