figure out what type of monster a user-supplied string is specifying; return a pointer to whatever is past the monster name--necessary if caller wants to strip off the name and it matches one of the alternate names rather the canonical mons[].mname */
| 890 | caller wants to strip off the name and it matches one of the alternate |
| 891 | names rather the canonical mons[].mname */ |
| 892 | int |
| 893 | name_to_monplus( |
| 894 | const char *in_str, |
| 895 | const char **remainder_p, |
| 896 | int *gender_name_var) |
| 897 | { |
| 898 | /* Be careful. We must check the entire string in case it was |
| 899 | * something such as "ettin zombie corpse". The calling routine |
| 900 | * doesn't know about the "corpse" until the monster name has |
| 901 | * already been taken off the front, so we have to be able to |
| 902 | * read the name with extraneous stuff such as "corpse" stuck on |
| 903 | * the end. |
| 904 | * This causes a problem for names which prefix other names such |
| 905 | * as "ettin" on "ettin zombie". In this case we want the _longest_ |
| 906 | * name which exists. |
| 907 | * This also permits plurals created by adding suffixes such as 's' |
| 908 | * or 'es'. Other plurals must still be handled explicitly. |
| 909 | */ |
| 910 | int i; |
| 911 | int mntmp = NON_PM; |
| 912 | char *s, *str, *term; |
| 913 | char buf[BUFSZ]; |
| 914 | int len, mgend, matchgend = -1; |
| 915 | size_t slen; |
| 916 | boolean exact_match = FALSE; |
| 917 | |
| 918 | if (remainder_p) |
| 919 | *remainder_p = (const char *) 0; |
| 920 | |
| 921 | str = strcpy(buf, in_str); |
| 922 | |
| 923 | if (!strncmp(str, "a ", 2)) |
| 924 | str += 2; |
| 925 | else if (!strncmp(str, "an ", 3)) |
| 926 | str += 3; |
| 927 | else if (!strncmp(str, "the ", 4)) |
| 928 | str += 4; |
| 929 | |
| 930 | slen = strlen(str); |
| 931 | term = str + slen; |
| 932 | |
| 933 | if ((s = strstri(str, "vortices")) != 0) |
| 934 | Strcpy(s + 4, "ex"); |
| 935 | /* be careful with "ies"; "priest", "zombies" */ |
| 936 | else if (slen > 3 && !strcmpi(term - 3, "ies") |
| 937 | && (slen < 7 || strcmpi(term - 7, "zombies"))) |
| 938 | Strcpy(term - 3, "y"); |
| 939 | /* luckily no monster names end in fe or ve with ves plurals */ |
| 940 | else if (slen > 3 && !strcmpi(term - 3, "ves")) |
| 941 | Strcpy(term - 3, "f"); |
| 942 | |
| 943 | slen = strlen(str); /* length possibly needs recomputing */ |
| 944 | |
| 945 | { |
| 946 | static const struct alt_spl names[] = { |
| 947 | /* Alternate spellings */ |
| 948 | { "grey dragon", PM_GRAY_DRAGON, NEUTRAL }, |
| 949 | { "baby grey dragon", PM_BABY_GRAY_DRAGON, NEUTRAL }, |
no test coverage detected