summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-04 10:53:02 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-04 10:53:02 +0000
commitc81fce9280be5aa5fdfb47bc4df74f4984150dda (patch)
tree741e5624ab0ff2c306b22a0ca5699665c8215ffc
parent8725f4c04bb0f541c07aed190e3c031d978f73a5 (diff)
downloadcrawl-ref-c81fce9280be5aa5fdfb47bc4df74f4984150dda.tar.gz
crawl-ref-c81fce9280be5aa5fdfb47bc4df74f4984150dda.zip
Merge trunk 1528 (fix for travel cache corruption) into 0.2 branch.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.2@1529 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/travel.cc19
-rw-r--r--crawl-ref/source/travel.h3
2 files changed, 16 insertions, 6 deletions
diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc
index 082ad2c784..2cc5d71c2b 100644
--- a/crawl-ref/source/travel.cc
+++ b/crawl-ref/source/travel.cc
@@ -2927,9 +2927,9 @@ void LevelInfo::load(FILE *file)
travel_hell_entry = si.destination;
}
+ stair_distances.clear();
if (stair_count)
{
- stair_distances.clear();
stair_distances.reserve(stair_count * stair_count);
for (int i = stair_count * stair_count - 1; i >= 0; --i)
stair_distances.push_back( readShort(file) );
@@ -3145,10 +3145,18 @@ void TravelCache::save(FILE *file) const
writeByte(file, TC_MAJOR_VERSION);
writeByte(file, TC_MINOR_VERSION);
- // How many levels do we have?
- writeShort(file, levels.size());
+ int level_count = 0;
+ for (travel_levels_map::const_iterator i = levels.begin();
+ i != levels.end(); ++i)
+ {
+ if (i->first.level_type == LEVEL_DUNGEON)
+ ++level_count;
+ }
+
+ // Write level count:
+ writeShort(file, level_count);
- // Save all the levels we have
+ // Save all the LEVEL_DUNGEON levels we have
std::map<level_id, LevelInfo>::const_iterator i =
levels.begin();
for ( ; i != levels.end(); ++i)
@@ -3174,7 +3182,8 @@ void TravelCache::load(FILE *file)
// Check version. If not compatible, we just ignore the file altogether.
unsigned char major = readByte(file),
minor = readByte(file);
- if (major != TC_MAJOR_VERSION || minor != TC_MINOR_VERSION) return ;
+ if (major != TC_MAJOR_VERSION || minor != TC_MINOR_VERSION)
+ return ;
int level_count = readShort(file);
for (int i = 0; i < level_count; ++i)
diff --git a/crawl-ref/source/travel.h b/crawl-ref/source/travel.h
index eb8f1abd13..dc1821fca8 100644
--- a/crawl-ref/source/travel.h
+++ b/crawl-ref/source/travel.h
@@ -435,7 +435,8 @@ private:
void fixup_levels();
private:
- std::map<level_id, LevelInfo> levels;
+ typedef std::map<level_id, LevelInfo> travel_levels_map;
+ travel_levels_map levels;
level_pos waypoints[TRAVEL_WAYPOINT_COUNT];
};