summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-10-27 03:40:45 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-10-27 03:50:56 +0100
commit69cd15f050cdef9f4f82bd4d9ff2f54dd37c87d1 (patch)
tree58a660decbe74f768eb2211a9604487d5b55de7c /crawl-ref
parentc9b7a93349b9215c94dd48f4e51023f4047cd820 (diff)
downloadcrawl-ref-69cd15f050cdef9f4f82bd4d9ff2f54dd37c87d1.tar.gz
crawl-ref-69cd15f050cdef9f4f82bd4d9ff2f54dd37c87d1.zip
Move exclusion marshalling code to exclude.cc.
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/exclude.cc40
-rw-r--r--crawl-ref/source/exclude.h5
-rw-r--r--crawl-ref/source/travel.cc32
3 files changed, 47 insertions, 30 deletions
diff --git a/crawl-ref/source/exclude.cc b/crawl-ref/source/exclude.cc
index 077487b1b1..4aae129c68 100644
--- a/crawl-ref/source/exclude.cc
+++ b/crawl-ref/source/exclude.cc
@@ -10,6 +10,7 @@
#include "mon-util.h"
#include "overmap.h"
#include "stuff.h"
+#include "tags.h"
#include "terrain.h"
#include "travel.h"
#include "tutorial.h"
@@ -363,3 +364,42 @@ std::string get_exclusion_desc()
", and ", ", "));
}
+
+void marshallExcludes(writer& outf, const exclvec& excludes)
+{
+ marshallShort(outf, excludes.size());
+ if (excludes.size())
+ {
+ for (int i = 0, count = excludes.size(); i < count; ++i)
+ {
+ marshallCoord(outf, excludes[i].pos);
+ marshallShort(outf, excludes[i].radius);
+ marshallBoolean(outf, excludes[i].autoex);
+ marshallShort(outf, excludes[i].mon);
+ // XXX: marshall travel_exclude::vault?
+ }
+ }
+}
+
+void unmarshallExcludes(reader& inf, char minorVersion, exclvec &excludes)
+{
+ excludes.clear();
+ int nexcludes = unmarshallShort(inf);
+ if (nexcludes)
+ {
+ for (int i = 0; i < nexcludes; ++i)
+ {
+ coord_def c;
+ unmarshallCoord(inf, c);
+ const int radius = unmarshallShort(inf);
+ bool autoexcl = false;
+ monster_type mon = MONS_NO_MONSTER;
+ if (minorVersion >= TAG_ANNOTATE_EXCL)
+ {
+ autoexcl = unmarshallBoolean(inf);
+ mon = static_cast<monster_type>(unmarshallShort(inf));
+ }
+ excludes.push_back(travel_exclude(c, radius, autoexcl, mon));
+ }
+ }
+}
diff --git a/crawl-ref/source/exclude.h b/crawl-ref/source/exclude.h
index 1a39d82f53..eb1630a1f2 100644
--- a/crawl-ref/source/exclude.h
+++ b/crawl-ref/source/exclude.h
@@ -44,5 +44,10 @@ extern exclvec curr_excludes; // in travel.cc
bool is_excluded(const coord_def &p, const exclvec &exc = curr_excludes);
+class writer;
+class reader;
+void marshallExcludes(writer& outf, const exclvec& excludes);
+void unmarshallExcludes(reader& inf, char minorVersion, exclvec& excludes);
+
#endif
diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc
index 14eb85f72d..079b4a877d 100644
--- a/crawl-ref/source/travel.cc
+++ b/crawl-ref/source/travel.cc
@@ -3314,17 +3314,7 @@ void LevelInfo::save(writer& outf) const
}
}
- marshallShort(outf, excludes.size());
- if (excludes.size())
- {
- for (int i = 0, count = excludes.size(); i < count; ++i)
- {
- marshallCoord(outf, excludes[i].pos);
- marshallShort(outf, excludes[i].radius);
- marshallBoolean(outf, excludes[i].autoex);
- marshallShort(outf, excludes[i].mon);
- }
- }
+ marshallExcludes(outf, excludes);
}
void LevelInfo::load(reader& inf, char minorVersion)
@@ -3354,25 +3344,7 @@ void LevelInfo::load(reader& inf, char minorVersion)
stair_distances.push_back( unmarshallShort(inf) );
}
- excludes.clear();
- int nexcludes = unmarshallShort(inf);
- if (nexcludes)
- {
- for (int i = 0; i < nexcludes; ++i)
- {
- coord_def c;
- unmarshallCoord(inf, c);
- const int radius = unmarshallShort(inf);
- bool autoexcl = false;
- monster_type mon = MONS_NO_MONSTER;
- if (minorVersion >= TAG_ANNOTATE_EXCL)
- {
- autoexcl = unmarshallBoolean(inf);
- mon = static_cast<monster_type>(unmarshallShort(inf));
- }
- excludes.push_back(travel_exclude(c, radius, autoexcl, mon));
- }
- }
+ unmarshallExcludes(inf, minorVersion, excludes);
}
void LevelInfo::fixup()