summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mapmark.cc
diff options
context:
space:
mode:
authorpauldubois <pauldubois@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-20 21:58:18 +0000
committerpauldubois <pauldubois@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-20 21:58:18 +0000
commit9cc4ae67d7aba85a9eee26bb6e390ecd2e30da77 (patch)
treeb615526b7a5a739df6cbee1331c7f493baaded33 /crawl-ref/source/mapmark.cc
parentbe9f773b92d011e6cb8a1bdfa72ae323807b8468 (diff)
downloadcrawl-ref-9cc4ae67d7aba85a9eee26bb6e390ecd2e30da77.tar.gz
crawl-ref-9cc4ae67d7aba85a9eee26bb6e390ecd2e30da77.zip
A little bit of savegame code cleanup; and a small format change to make
life easier (or rather, possible) for dump_savegame. Should not break saves (let me know if they do). - Fixed dump_savegame bug reading TAG_LEVEL. Handle lua map_markers (by skipping over them) -- requires format change and minor version bump. - Consolidated YOU_MINOR_VERSION, LEVEL_MINOR_VERSION, GHOST_MINOR_VERSION into a single TAG_MINOR_VERSION, because otherwise versions can't be passed into data structures being deserialized (because they may be contained in both you and ghost, for example). - Clean out old code that pretends to restore other major versions, and some duplicate code that pretends level loading and general tagged file loading are different. (Left ghosts alone because they really do do something different, slightly) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4420 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/mapmark.cc')
-rw-r--r--crawl-ref/source/mapmark.cc30
1 files changed, 27 insertions, 3 deletions
diff --git a/crawl-ref/source/mapmark.cc b/crawl-ref/source/mapmark.cc
index 5c7a008d49..3ecbe9afd1 100644
--- a/crawl-ref/source/mapmark.cc
+++ b/crawl-ref/source/mapmark.cc
@@ -733,22 +733,46 @@ void map_markers::clear()
markers.clear();
}
+static const long MARKERS_COOKY = 0x17742C32;
void map_markers::write(writer &outf) const
{
- // how many markers
+ marshallLong(outf, MARKERS_COOKY);
+
+ std::vector<unsigned char> buf;
+
marshallShort(outf, markers.size());
for (dgn_marker_map::const_iterator i = markers.begin();
i != markers.end(); ++i)
{
- i->second->write(outf);
+ buf.clear();
+ writer tmp_outf(&buf);
+ i->second->write(tmp_outf);
+
+ // Write the marker data, prefixed by a size
+ marshallLong(outf, buf.size());
+ outf.write(&buf[0], buf.size());
}
}
-void map_markers::read(reader &inf)
+void map_markers::read(reader &inf, int minorVersion)
{
clear();
+
+ if (minorVersion >= TAG_MINOR_MAPMARK)
+ {
+ const long cooky = unmarshallLong(inf);
+ ASSERT(cooky == MARKERS_COOKY);
+ }
+
const int nmarkers = unmarshallShort(inf);
for (int i = 0; i < nmarkers; ++i)
+ {
+ // used by tools
+ if (minorVersion >= TAG_MINOR_MAPMARK)
+ unmarshallLong(inf);
if (map_marker *mark = map_marker::read_marker(inf))
+ {
add(mark);
+ }
+ }
}