summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/travel.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-04 10:42:28 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-04 10:42:28 +0000
commit48593ab2d1e735cd337b9d12d5e5d772f737bd8a (patch)
treea20545f5462d2cbb51a9e56daa436e9b28097f82 /crawl-ref/source/travel.cc
parent3f06459851fbce40c0f213afe13ae47034a8e736 (diff)
downloadcrawl-ref-48593ab2d1e735cd337b9d12d5e5d772f737bd8a.tar.gz
crawl-ref-48593ab2d1e735cd337b9d12d5e5d772f737bd8a.zip
[1723695] Fixed unholy (and silly) travel cache corruption bug.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1528 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/travel.cc')
-rw-r--r--crawl-ref/source/travel.cc19
1 files changed, 14 insertions, 5 deletions
diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc
index 939d4e8adc..0bc14a2134 100644
--- a/crawl-ref/source/travel.cc
+++ b/crawl-ref/source/travel.cc
@@ -2993,9 +2993,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) );
@@ -3211,10 +3211,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)
@@ -3240,7 +3248,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)