MCPcopy Index your code
hub / github.com/NetHack/NetHack / str2role

Function str2role

src/role.c:746–775  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

744}
745
746int
747str2role(const char *str)
748{
749 int i, len;
750
751 /* Is str valid? */
752 if (!str || !str[0])
753 return ROLE_NONE;
754
755 /* Match as much of str as is provided */
756 len = Strlen(str);
757 for (i = 0; roles[i].name.m; i++) {
758 /* Does it match the male name? */
759 if (!strncmpi(str, roles[i].name.m, len))
760 return i;
761 /* Or the female name? */
762 if (roles[i].name.f && !strncmpi(str, roles[i].name.f, len))
763 return i;
764 /* Or the filecode? */
765 if (!strcmpi(str, roles[i].filecode))
766 return i;
767 }
768
769 if ((len == 1 && (*str == '*' || *str == '@'))
770 || !strncmpi(str, randomstr, len))
771 return ROLE_RANDOM;
772
773 /* Couldn't find anything appropriate */
774 return ROLE_NONE;
775}
776
777boolean
778validrace(int rolenum, int racenum)

Callers 14

process_optionsFunction · 0.85
process_optionsFunction · 0.85
early_optionsFunction · 0.85
process_optionsFunction · 0.85
process_optionsFunction · 0.85
optfn_roleFunction · 0.85
readentryFunction · 0.85
score_wantedFunction · 0.85
setrolefilterFunction · 0.85
plnamesuffixFunction · 0.85
role_initFunction · 0.85
cnf_line_ROLEFunction · 0.85

Calls 1

strncmpiFunction · 0.70

Tested by

no test coverage detected