summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/stash.cc
diff options
context:
space:
mode:
authorNeil Moore <neil@s-z.org>2012-07-06 20:30:51 -0400
committerNeil Moore <neil@s-z.org>2012-07-06 21:49:03 -0400
commit51a2f406346d6c5f295618cf0563e21c00cca7be (patch)
tree7062f3f3aeeda50db8dfc39505086ee824949d72 /crawl-ref/source/stash.cc
parent81afa9b3e9ed1e5d4886dc3a9c635366a62afcae (diff)
downloadcrawl-ref-51a2f406346d6c5f295618cf0563e21c00cca7be.tar.gz
crawl-ref-51a2f406346d6c5f295618cf0563e21c00cca7be.zip
Use correct feature name in stashes.
We were looking up the feature description for the item's (x,y) position... on the current level. The problem was introduced by commit 84529d6, but portals had the same problem before then (which is why Ctrl-F trove never worked). Now we also store the feature's description in the stash. For old saves, we use the default description for that type of feature (ignoring overrides) until we next update the stash. Floor and other uninteresting features are stored as the empty string. Fixes #5880.
Diffstat (limited to 'crawl-ref/source/stash.cc')
-rw-r--r--crawl-ref/source/stash.cc20
1 files changed, 16 insertions, 4 deletions
diff --git a/crawl-ref/source/stash.cc b/crawl-ref/source/stash.cc
index c822917ec9..fc592d3349 100644
--- a/crawl-ref/source/stash.cc
+++ b/crawl-ref/source/stash.cc
@@ -282,6 +282,11 @@ void Stash::update()
feat = DNGN_FLOOR, trap = TRAP_UNASSIGNED;
}
+ if (feat == DNGN_FLOOR)
+ feat_desc = "";
+ else
+ feat_desc = feature_description_at(coord_def(x, y), false);
+
// If this is your position, you know what's on this square
if (p == you.pos())
{
@@ -554,10 +559,7 @@ std::string Stash::description() const
std::string Stash::feature_description() const
{
- if (feat == DNGN_FLOOR)
- return "";
-
- return (::feature_description_at(coord_def(x, y), false));
+ return feat_desc;
}
bool Stash::matches_search(const std::string &prefix,
@@ -747,6 +749,8 @@ void Stash::save(writer& outf) const
marshallByte(outf, feat);
marshallByte(outf, trap);
+ marshallString(outf, feat_desc);
+
// Note: Enabled save value is inverted logic, so that it defaults to true
marshallByte(outf, ((verified ? 1 : 0) | (!enabled ? 2 : 0)
| (is_stack ? 4 : 0)));
@@ -770,6 +774,14 @@ void Stash::load(reader& inf)
#if TAG_MAJOR_VERSION == 33
if (trap == TRAP_AXED)
trap = TRAP_SPEAR;
+
+ if (inf.getMinorVersion() < TAG_MINOR_STASH_FEATDESC)
+ {
+ feat_desc = (is_boring_feature(feat)
+ ? "" : ::feature_description(feat, trap));
+ }
+ else
+ feat_desc = unmarshallString(inf);
#endif
uint8_t flags = unmarshallUByte(inf);