summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/stash.cc
diff options
context:
space:
mode:
authorNeil Moore <neil@s-z.org>2014-06-07 02:05:57 -0400
committerNeil Moore <neil@s-z.org>2014-06-07 02:15:58 -0400
commit8698f31d8830b63d549ef9e7bf480e10e670f1eb (patch)
treed65ab7f579c1102338cc95340b286f517caf614f /crawl-ref/source/stash.cc
parentcdf1dfce163e53efcafa8efde3c3620d1b73208d (diff)
downloadcrawl-ref-8698f31d8830b63d549ef9e7bf480e10e670f1eb.tar.gz
crawl-ref-8698f31d8830b63d549ef9e7bf480e10e670f1eb.zip
Show visible changes to status of stack toppers.
If two corpses were sitting on a visible square, ctrl-x would never show the rotting of the visible top corpse; and the stash tracker itself would show it as "rotten by now" even though we can actually see the corpse rotting. This also affects recharging rods since the previous commit. Now if the seen item and the remembered top item are "the same" but not identical (because of rotting, recharging, etc.), we update the stash anyway.
Diffstat (limited to 'crawl-ref/source/stash.cc')
-rw-r--r--crawl-ref/source/stash.cc21
1 files changed, 15 insertions, 6 deletions
diff --git a/crawl-ref/source/stash.cc b/crawl-ref/source/stash.cc
index 210c897b36..661b5ac2a7 100644
--- a/crawl-ref/source/stash.cc
+++ b/crawl-ref/source/stash.cc
@@ -183,14 +183,14 @@ Stash::Stash(int xp, int yp) : enabled(true), items()
update();
}
-bool Stash::are_items_same(const item_def &a, const item_def &b)
+bool Stash::are_items_same(const item_def &a, const item_def &b, bool exact)
{
const bool same = a.base_type == b.base_type
&& a.sub_type == b.sub_type
// Ignore Gozag's gold flag, and rod charges.
- && (a.plus == b.plus || a.base_type == OBJ_GOLD
- || a.base_type == OBJ_RODS)
- && (a.plus2 == b.plus2 || a.base_type == OBJ_RODS)
+ && (a.plus == b.plus || a.base_type == OBJ_GOLD && !exact
+ || a.base_type == OBJ_RODS && !exact)
+ && (a.plus2 == b.plus2 || a.base_type == OBJ_RODS && !exact)
&& a.special == b.special
&& a.colour == b.colour
&& a.flags == b.flags
@@ -198,7 +198,7 @@ bool Stash::are_items_same(const item_def &a, const item_def &b)
// Account for rotting meat when comparing items.
return same
- || (a.base_type == b.base_type
+ || (!exact && a.base_type == b.base_type
&& (a.base_type == OBJ_CORPSES
|| (a.base_type == OBJ_FOOD && a.sub_type == FOOD_CHUNK
&& b.sub_type == FOOD_CHUNK))
@@ -357,7 +357,16 @@ void Stash::update()
// the top item matches what we remember.
const item_def &first = items[0];
// Compare these items
- if (!are_items_same(first, item))
+ if (are_items_same(first, item))
+ {
+ // Replace the item to reflect seen recharging, rotting, etc.
+ if (!are_items_same(first, item, true))
+ {
+ items.erase(items.begin());
+ add_item(item, true);
+ }
+ }
+ else
{
// See if 'item' matches any of the items we have. If it does,
// we'll just make that the first item and leave 'verified'