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/travel.cc | |
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/travel.cc')
-rw-r--r-- | crawl-ref/source/travel.cc | 21 |
1 files changed, 20 insertions, 1 deletions
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; } |