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

Function corpse_xname

src/objnam.c:1823–1920  ·  view source on GitHub ↗

format a corpse name (xname() omits monster type; doname() calls us); eatcorpse() also uses us for death reason when eating tainted glob */

Source from the content-addressed store, hash-verified

1821/* format a corpse name (xname() omits monster type; doname() calls us);
1822 eatcorpse() also uses us for death reason when eating tainted glob */
1823char *
1824corpse_xname(
1825 struct obj *otmp,
1826 const char *adjective,
1827 unsigned cxn_flags) /* bitmask of CXN_xxx values */
1828{
1829 char *nambuf;
1830 int omndx = otmp->corpsenm;
1831 boolean ignore_quan = (cxn_flags & CXN_SINGULAR) != 0,
1832 /* suppress "the" from "the unique monster corpse" */
1833 no_prefix = (cxn_flags & CXN_NO_PFX) != 0,
1834 /* include "the" for "the woodchuck corpse */
1835 the_prefix = (cxn_flags & CXN_PFX_THE) != 0,
1836 /* include "an" for "an ogre corpse */
1837 any_prefix = (cxn_flags & CXN_ARTICLE) != 0,
1838 /* leave off suffix (do_name() appends "corpse" itself) */
1839 omit_corpse = (cxn_flags & CXN_NOCORPSE) != 0,
1840 possessive = FALSE,
1841 glob = (otmp->otyp != CORPSE && otmp->globby);
1842 const char *mnam;
1843
1844 /* some callers [aobjnam()] rely on prefix area that xname() sets aside */
1845 gx.xnamep = nextobuf();
1846 nambuf = gx.xnamep + PREFIX;
1847
1848 if (glob) {
1849 mnam = OBJ_NAME(objects[otmp->otyp]); /* "glob of <monster>" */
1850 } else if (omndx == NON_PM) { /* paranoia */
1851 mnam = "thing";
1852 } else {
1853 mnam = obj_pmname(otmp);
1854 if (the_unique_pm(&mons[omndx]) || type_is_pname(&mons[omndx])) {
1855 mnam = s_suffix(mnam);
1856 possessive = TRUE;
1857 /* don't precede personal name like "Medusa" with an article */
1858 if (type_is_pname(&mons[omndx]))
1859 no_prefix = TRUE;
1860 /* always precede non-personal unique monster name like
1861 "Oracle" with "the" unless explicitly overridden */
1862 else if (the_unique_pm(&mons[omndx]) && !no_prefix)
1863 the_prefix = TRUE;
1864 }
1865 }
1866 if (no_prefix)
1867 the_prefix = any_prefix = FALSE;
1868 else if (the_prefix)
1869 any_prefix = FALSE; /* mutually exclusive */
1870
1871 *nambuf = '\0';
1872 /* can't use the() the way we use an() below because any capitalized
1873 Name causes it to assume a personal name and return Name as-is;
1874 that's usually the behavior wanted, but here we need to force "the"
1875 to precede capitalized unique monsters (pnames are handled above) */
1876 if (the_prefix)
1877 Strcat(nambuf, "the ");
1878 /* note: over time, various instances of the(mon_name()) have crept
1879 into the code, so the() has been modified to deal with capitalized
1880 monster names; we could switch to using it below like an() */

Callers 15

cant_wield_corpseFunction · 0.85
wielding_corpseFunction · 0.85
hmon_hitmon_misc_objFunction · 0.85
theft_petrifiesFunction · 0.85
revive_corpseFunction · 0.85
doname_baseFunction · 0.85
cxnameFunction · 0.85
cxname_singularFunction · 0.85
killer_xnameFunction · 0.85
rot_corpseFunction · 0.85
offer_corpseFunction · 0.85
throw_objFunction · 0.85

Calls 9

nextobufFunction · 0.85
obj_pmnameFunction · 0.85
the_unique_pmFunction · 0.85
s_suffixFunction · 0.85
eosFunction · 0.85
mungspacesFunction · 0.85
digitFunction · 0.85
anFunction · 0.85
releaseobufFunction · 0.85

Tested by

no test coverage detected