diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2006-12-12 14:32:40 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2006-12-12 14:32:40 +0000 |
commit | 170c1de4d2bc1b996f11cffdec0fc49cfe71c388 (patch) | |
tree | f4edd4036c6cc8711048f0f1baf64c6456ae9add /crawl-ref/source | |
parent | 5e94dac9e3537693dfaa1647c143959d1ce5e069 (diff) | |
download | crawl-ref-170c1de4d2bc1b996f11cffdec0fc49cfe71c388.tar.gz crawl-ref-170c1de4d2bc1b996f11cffdec0fc49cfe71c388.zip |
Try to merge items before reporting explore stop messages.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@620 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/items.cc | 7 | ||||
-rw-r--r-- | crawl-ref/source/items.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/travel.cc | 21 | ||||
-rw-r--r-- | crawl-ref/source/travel.h | 1 |
4 files changed, 27 insertions, 3 deletions
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 9b03065bcd..24df6761d9 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -61,7 +61,6 @@ #include "stash.h" static void autopickup(void); -static bool is_stackable_item( const item_def &item ); static bool invisible_to_player( const item_def& item ); static void item_list_on_square( std::vector<const item_def*>& items, int obj, bool force_squelch = false ); @@ -1280,7 +1279,7 @@ void pickup() } } // end pickup() -static bool is_stackable_item( const item_def &item ) +bool is_stackable_item( const item_def &item ) { if (!is_valid_item( item )) return (false); @@ -1290,6 +1289,7 @@ static bool is_stackable_item( const item_def &item ) || item.base_type == OBJ_SCROLLS || item.base_type == OBJ_POTIONS || item.base_type == OBJ_UNKNOWN_II + || item.base_type == OBJ_GOLD || (item.base_type == OBJ_MISCELLANY && item.sub_type == MISC_RUNE_OF_ZOT)) { @@ -1309,6 +1309,9 @@ bool items_stack( const item_def &item1, const item_def &item2 ) if (item1.base_type != item2.base_type || item1.sub_type != item2.sub_type) return (false); + if (item1.base_type == OBJ_GOLD) + return (true); + // These classes also require pluses and special if (item1.base_type == OBJ_MISSILES || item1.base_type == OBJ_MISCELLANY) // only runes diff --git a/crawl-ref/source/items.h b/crawl-ref/source/items.h index e67dc9d685..459d52b862 100644 --- a/crawl-ref/source/items.h +++ b/crawl-ref/source/items.h @@ -28,6 +28,7 @@ void inc_mitm_item_quantity( int obj, int amount ); void move_item_to_grid( int *const obj, int x, int y ); void move_item_stack_to_grid( int x, int y, int targ_x, int targ_y ); int move_item_to_player( int obj, int quant_got, bool quiet = false ); +bool is_stackable_item( const item_def &item ); bool items_stack( const item_def &item1, const item_def &item2 ); item_def find_item_type(int base_type, std::string name); diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc index 7fb1811965..a895044d7b 100644 --- a/crawl-ref/source/travel.cc +++ b/crawl-ref/source/travel.cc @@ -3393,6 +3393,25 @@ void explore_discoveries::found_feature(const coord_def &pos, int grid) } } +void explore_discoveries::add_item(const item_def &i) +{ + if (is_stackable_item(i)) + { + // Try to find something to stack it with. + for (int j = 0, size = items.size(); j < size; ++j) + { + if (items_stack(i, items[j].thing)) + { + items[j].thing.quantity += i.quantity; + items[j].name = item_name(items[j].thing, DESC_NOCAP_A); + return; + } + } + } + + items.push_back( named_thing<item_def>(item_name(i, DESC_NOCAP_A), i) ); +} + void explore_discoveries::found_item(const coord_def &pos, const item_def &i) { if (you.running == RMODE_EXPLORE_GREEDY) @@ -3405,7 +3424,7 @@ void explore_discoveries::found_item(const coord_def &pos, const item_def &i) return; } - items.push_back( named_thing<item_def>(item_name(i, DESC_NOCAP_A), i) ); + add_item(i); es_flags |= ES_ITEM; } diff --git a/crawl-ref/source/travel.h b/crawl-ref/source/travel.h index a95948df2a..b84d2d0584 100644 --- a/crawl-ref/source/travel.h +++ b/crawl-ref/source/travel.h @@ -222,6 +222,7 @@ public: private: template <class C> void say_any(const C &coll, const char *stub) const; std::string cleaned_feature_description(int feature) const; + void add_item(const item_def &item); private: template <class Z> struct named_thing { |