fix pull request #636 - the("Capitalized Monster")
Function the() wasn't supposed to be used for monsters because many of the ones with capitalized names confuse it, but over time multiple instances of the(mon_nam()) have crept into the code. Instead of ripping those out, modify the() to handle that situation better. Pull request #636 by entrez dealt with this with one extra line of code, but could end up scanning all the names in mons[] repeatedly if the("Capitalized string") gets called a lot. This uses a similar one line fix but calls a whole new routine that scans through mons[] once collecting all the relevant special case names. As a bonus, it does the same for hallucinatory monster names which name_to_mon() couldn't handle. Fixes #626
This commit is contained in:
@@ -1524,6 +1524,9 @@ corpse_xname(
|
||||
to precede capitalized unique monsters (pnames are handled above) */
|
||||
if (the_prefix)
|
||||
Strcat(nambuf, "the ");
|
||||
/* note: over time, various instances of the(mon_name()) have crept
|
||||
into the code, so the() has been modified to deal with capitalized
|
||||
monster names; we could switch to using it below like an() */
|
||||
|
||||
if (!adjective || !*adjective) {
|
||||
/* normal case: newt corpse */
|
||||
@@ -1822,6 +1825,8 @@ the(const char* str)
|
||||
Strcpy(&buf[1], str + 1);
|
||||
return buf;
|
||||
} else if (*str < 'A' || *str > 'Z'
|
||||
/* some capitalized monster names want "the", others don't */
|
||||
|| CapitalMon(str)
|
||||
/* treat named fruit as not a proper name, even if player
|
||||
has assigned a capitalized proper name as his/her fruit */
|
||||
|| fruit_from_name(str, TRUE, (int *) 0)) {
|
||||
|
||||
Reference in New Issue
Block a user