From 170c1de4d2bc1b996f11cffdec0fc49cfe71c388 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Tue, 12 Dec 2006 14:32:40 +0000 Subject: 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 --- crawl-ref/source/travel.cc | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'crawl-ref/source/travel.cc') 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_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_name(i, DESC_NOCAP_A), i) ); + add_item(i); es_flags |= ES_ITEM; } -- cgit v1.2.3-54-g00ecf