check whether user-supplied name matches or nearly matches an unnameable monster's name, or is an attempt to delete the monster's name; if so, give alternate reject message for do_mgivenname() */
| 155 | monster's name, or is an attempt to delete the monster's name; if so, give |
| 156 | alternate reject message for do_mgivenname() */ |
| 157 | staticfn boolean |
| 158 | alreadynamed(struct monst *mtmp, char *monnambuf, char *usrbuf) |
| 159 | { |
| 160 | char pronounbuf[10], *p; |
| 161 | |
| 162 | if (!*usrbuf) { /* attempt to erase existing name */ |
| 163 | boolean name_not_title = (has_mgivenname(mtmp) |
| 164 | || type_is_pname(mtmp->data) |
| 165 | || mtmp->isshk); |
| 166 | pline("%s would rather keep %s existing %s.", upstart(monnambuf), |
| 167 | is_rider(mtmp->data) ? "its" : mhis(mtmp), |
| 168 | name_not_title ? "name" : "title"); |
| 169 | return TRUE; |
| 170 | } else if (fuzzymatch(usrbuf, monnambuf, " -_", TRUE) |
| 171 | /* catch trying to name "the Oracle" as "Oracle" */ |
| 172 | || (!strncmpi(monnambuf, "the ", 4) |
| 173 | && fuzzymatch(usrbuf, monnambuf + 4, " -_", TRUE)) |
| 174 | /* catch trying to name "invisible Orcus" as "Orcus" */ |
| 175 | || ((p = strstri(monnambuf, "invisible ")) != 0 |
| 176 | && fuzzymatch(usrbuf, p + 10, " -_", TRUE)) |
| 177 | /* catch trying to name "the priest of Crom" as "Crom" */ |
| 178 | || ((p = strstri(monnambuf, " of ")) != 0 |
| 179 | && fuzzymatch(usrbuf, p + 4, " -_", TRUE))) { |
| 180 | if (is_rider(mtmp->data)) { |
| 181 | /* avoid gendered pronoun for riders */ |
| 182 | pline("%s is already called that.", upstart(monnambuf)); |
| 183 | } else { |
| 184 | pline("%s is already called %s.", |
| 185 | upstart(strcpy(pronounbuf, mhe(mtmp))), monnambuf); |
| 186 | } |
| 187 | return TRUE; |
| 188 | } else if (mtmp->data == &mons[PM_JUIBLEX] |
| 189 | && strstri(monnambuf, "Juiblex") |
| 190 | && !strcmpi(usrbuf, "Jubilex")) { |
| 191 | pline("%s doesn't like being called %s.", upstart(monnambuf), usrbuf); |
| 192 | return TRUE; |
| 193 | } |
| 194 | return FALSE; |
| 195 | } |
| 196 | |
| 197 | /* allow player to assign a name to some chosen monster */ |
| 198 | staticfn void |
no test coverage detected