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

Function str2race

src/role.c:812–841  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

810}
811
812int
813str2race(const char *str)
814{
815 int i, len;
816
817 /* Is str valid? */
818 if (!str || !str[0])
819 return ROLE_NONE;
820
821 /* Match as much of str as is provided */
822 len = Strlen(str);
823 for (i = 0; races[i].noun; i++) {
824 /* Does it match the noun? */
825 if (!strncmpi(str, races[i].noun, len))
826 return i;
827 /* check adjective too */
828 if (races[i].adj && !strncmpi(str, races[i].adj, len))
829 return i;
830 /* Or the filecode? */
831 if (!strcmpi(str, races[i].filecode))
832 return i;
833 }
834
835 if ((len == 1 && (*str == '*' || *str == '@'))
836 || !strncmpi(str, randomstr, len))
837 return ROLE_RANDOM;
838
839 /* Couldn't find anything appropriate */
840 return ROLE_NONE;
841}
842
843boolean
844validgend(int rolenum, int racenum, int gendnum)

Callers 10

process_optionsFunction · 0.85
process_optionsFunction · 0.85
early_optionsFunction · 0.85
process_optionsFunction · 0.85
process_optionsFunction · 0.85
optfn_raceFunction · 0.85
score_wantedFunction · 0.85
setrolefilterFunction · 0.85
plnamesuffixFunction · 0.85
process_optionsFunction · 0.85

Calls 1

strncmpiFunction · 0.70

Tested by

no test coverage detected