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

Function randrace

src/role.c:786–810  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

784}
785
786int
787randrace(int rolenum)
788{
789 int i, n = 0;
790
791 /* Count the number of valid races */
792 for (i = 0; races[i].noun; i++)
793 if (roles[rolenum].allow & races[i].allow & ROLE_RACEMASK)
794 n++;
795
796 /* Pick a random race */
797 /* Use a factor of 100 in case of bad random number generators */
798 if (n)
799 n = rn2(n * 100) / 100;
800 for (i = 0; races[i].noun; i++)
801 if (roles[rolenum].allow & races[i].allow & ROLE_RACEMASK) {
802 if (n)
803 n--;
804 else
805 return i;
806 }
807
808 /* This role has no permitted races? */
809 return rn2(SIZE(races) - 1);
810}
811
812int
813str2race(const char *str)

Callers 11

mswin_player_selectionFunction · 0.85
curses_choose_characterFunction · 0.85
amii_player_selectionFunction · 0.85
role_initFunction · 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