diff options
author | Vsevolod Kozlov <zaba@thorium.homeunix.org> | 2009-12-27 19:00:10 +0300 |
---|---|---|
committer | Vsevolod Kozlov <zaba@thorium.homeunix.org> | 2009-12-27 19:00:10 +0300 |
commit | 507c3523d54cd2c15185f06f8be1f1ea353497d8 (patch) | |
tree | 2cea6119f61c8c03c9333537d554685d9ebe71d2 /crawl-ref/source | |
parent | 76b76949fb3f6fe4c1e735f0b1d9ef72ae4a6a68 (diff) | |
download | crawl-ref-507c3523d54cd2c15185f06f8be1f1ea353497d8.tar.gz crawl-ref-507c3523d54cd2c15185f06f8be1f1ea353497d8.zip |
Make item_is_critical a method of item_def.
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/externs.h | 3 | ||||
-rw-r--r-- | crawl-ref/source/itemprop.cc | 15 | ||||
-rw-r--r-- | crawl-ref/source/itemprop.h | 3 | ||||
-rw-r--r-- | crawl-ref/source/items.cc | 15 | ||||
-rw-r--r-- | crawl-ref/source/terrain.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/xom.cc | 2 |
6 files changed, 20 insertions, 20 deletions
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index c3eb240a16..cf2b98d8d0 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -533,6 +533,9 @@ public: bool is_valid() const; + // Returns true if this item should be preserved as far as possible. + bool is_critical() const; + private: std::string name_aux(description_level_type desc, bool terse, bool ident, diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc index 720dfff844..ee8e022c63 100644 --- a/crawl-ref/source/itemprop.cc +++ b/crawl-ref/source/itemprop.cc @@ -567,21 +567,6 @@ bool item_ident( const item_def &item, unsigned long flags ) return ((item.flags & flags) == flags); } -// The Orb of Zot and unique runes are considered critical. -bool item_is_critical(const item_def &item) -{ - if (!item.is_valid()) - return (false); - - if (item.base_type == OBJ_ORBS) - return (true); - - return (item.base_type == OBJ_MISCELLANY - && item.sub_type == MISC_RUNE_OF_ZOT - && item.plus != RUNE_DEMONIC - && item.plus != RUNE_ABYSSAL); -} - // Is item something that no one would usually bother enchanting? bool item_is_mundane(const item_def &item) { diff --git a/crawl-ref/source/itemprop.h b/crawl-ref/source/itemprop.h index a8f1eceabd..3a38fdb35b 100644 --- a/crawl-ref/source/itemprop.h +++ b/crawl-ref/source/itemprop.h @@ -14,9 +14,6 @@ struct bolt; void init_properties(void); -// Returns true if this item should be preserved as far as possible. -bool item_is_critical(const item_def &item); - // Returns true if this item should not normally be enchanted. bool item_is_mundane(const item_def &item); diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index a3418761d4..fa2b57fdea 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -2919,6 +2919,21 @@ bool item_def::is_valid() const return (base_type != OBJ_UNASSIGNED && quantity > 0); } +// The Orb of Zot and unique runes are considered critical. +bool item_def::is_critical() const +{ + if (!is_valid()) + return (false); + + if (base_type == OBJ_ORBS) + return (true); + + return (base_type == OBJ_MISCELLANY + && sub_type == MISC_RUNE_OF_ZOT + && plus != RUNE_DEMONIC + && plus != RUNE_ABYSSAL); +} + static void _rune_from_specs(const char* _specs, item_def &item) { char specs[80]; diff --git a/crawl-ref/source/terrain.cc b/crawl-ref/source/terrain.cc index 05b3033e8e..9b2fe96deb 100644 --- a/crawl-ref/source/terrain.cc +++ b/crawl-ref/source/terrain.cc @@ -664,7 +664,7 @@ static void _dgn_check_terrain_items(const coord_def &pos, bool preserve_items) item = mitm[item].link; // Game-critical item. - if (preserve_items || item_is_critical(mitm[curr])) + if (preserve_items || mitm[curr].is_critical()) _dgn_shift_item(pos, mitm[curr]); else { diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc index a2c7a4d227..4f01f1145a 100644 --- a/crawl-ref/source/xom.cc +++ b/crawl-ref/source/xom.cc @@ -2308,7 +2308,7 @@ static void _xom_zero_miscast() { const item_def &item(you.inv[i]); if (item.is_valid() && !item_is_equipped(item) - && !item_is_critical(item)) + && !item.is_critical()) { inv_items.push_back(i); } |