diff options
author | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-10 23:18:30 -0800 |
---|---|---|
committer | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-10 23:20:10 -0800 |
commit | 25e42bedb537cfcf27d837d59df48e42e93f2bd4 (patch) | |
tree | 9088ff06a80c6008f573d0de538f244200c212f6 | |
parent | a7ae274043d1829aedc5b9eb66235d720343e5bc (diff) | |
download | crawl-ref-25e42bedb537cfcf27d837d59df48e42e93f2bd4.tar.gz crawl-ref-25e42bedb537cfcf27d837d59df48e42e93f2bd4.zip |
Corpse names for unusally named monsters
Fix corpse names (and zombie names) for monsters which are named with
name_adjective, name_suffix or name_replace.
-rw-r--r-- | crawl-ref/source/itemname.cc | 24 | ||||
-rw-r--r-- | crawl-ref/source/itemname.h | 6 | ||||
-rw-r--r-- | crawl-ref/source/monstuff.cc | 5 | ||||
-rw-r--r-- | crawl-ref/source/spells3.cc | 8 |
4 files changed, 36 insertions, 7 deletions
diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc index 16adb7a234..5de5f16256 100644 --- a/crawl-ref/source/itemname.cc +++ b/crawl-ref/source/itemname.cc @@ -1637,9 +1637,14 @@ std::string item_def::name_aux(description_level_type desc, if (food_is_rotten(*this) && !dbname) buff << "rotting "; - const std::string _name = get_corpse_name(*this); + unsigned long name_type; + + const std::string _name = get_corpse_name(*this, &name_type); const bool shaped = starts_with(_name, "shaped "); + if (!_name.empty() && name_type == MF_NAME_ADJECTIVE) + buff << _name << " "; + if (!dbname && !starts_with(_name, "the ")) { buff << mons_type_name(it_plus, DESC_PLAIN) << ' '; @@ -1655,8 +1660,13 @@ std::string item_def::name_aux(description_level_type desc, else buff << "corpse bug"; - if (!_name.empty() && !shaped) - buff << " of " << _name; + if (!_name.empty() && !shaped && name_type != MF_NAME_ADJECTIVE) + { + if (name_type == MF_NAME_SUFFIX) + buff << " " << _name; + else + buff << " of " << _name; + } break; } @@ -3065,12 +3075,18 @@ bool is_named_corpse(const item_def &corpse) return (corpse.props.exists(CORPSE_NAME_KEY)); } -std::string get_corpse_name(const item_def &corpse) +std::string get_corpse_name(const item_def &corpse, unsigned long *name_type) { ASSERT(corpse.base_type == OBJ_CORPSES); if (!corpse.props.exists(CORPSE_NAME_KEY)) return (""); + if (name_type != NULL) + { + *name_type + = (unsigned long) corpse.props[CORPSE_NAME_TYPE_KEY].get_long(); + } + return (corpse.props[CORPSE_NAME_KEY].get_string()); } diff --git a/crawl-ref/source/itemname.h b/crawl-ref/source/itemname.h index 731c7b7443..271bf2d340 100644 --- a/crawl-ref/source/itemname.h +++ b/crawl-ref/source/itemname.h @@ -10,7 +10,8 @@ #include "externs.h" -#define CORPSE_NAME_KEY "corpse_name_key" +#define CORPSE_NAME_KEY "corpse_name_key" +#define CORPSE_NAME_TYPE_KEY "corpse_name_type_key" struct item_types_pair { @@ -126,6 +127,7 @@ std::vector<std::string> item_name_list_for_glyph(unsigned glyph); const char* wand_type_name(int wandtype); bool is_named_corpse(const item_def &corpse); -std::string get_corpse_name(const item_def &corpse); +std::string get_corpse_name(const item_def &corpse, + unsigned long *name_type = NULL); #endif diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 201d374041..6c849a2ba6 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -333,11 +333,16 @@ monster_type fill_out_corpse(const monsters* monster, item_def& corpse, corpse.colour = monster->colour; if (!monster->mname.empty()) + { corpse.props[CORPSE_NAME_KEY] = monster->mname; + corpse.props[CORPSE_NAME_TYPE_KEY] + = (long) (monster->flags & MF_NAME_MASK); + } else if (mons_is_unique(monster->type)) { corpse.props[CORPSE_NAME_KEY] = mons_type_name(monster->type, DESC_PLAIN); + corpse.props[CORPSE_NAME_TYPE_KEY] = (long) 0; } return (corpse_class); diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index f235c04520..97b2cb04d0 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -984,7 +984,13 @@ static bool _raise_remains(const coord_def &pos, int corps, beh_type beha, const int monnum = item.orig_monnum - 1; if (is_named_corpse(item)) - name_zombie(&menv[monster], monnum, get_corpse_name(item)); + { + unsigned long name_type; + std::string name = get_corpse_name(item, &name_type); + + if (name_type == 0 || name_type == MF_NAME_REPLACE) + name_zombie(&menv[monster], monnum, name); + } equip_undead(pos, corps, monster, monnum); |