summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mapmark.cc
diff options
context:
space:
mode:
authorpauldubois <pauldubois@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-17 05:54:42 +0000
committerpauldubois <pauldubois@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-17 05:54:42 +0000
commit8ba172496400cc74a2fa7d343d9859339f1a0f5d (patch)
tree09715fca1c835aca87d0da9d629ad5f9e0157e54 /crawl-ref/source/mapmark.cc
parent314a2c0efb7083bc9703b6e2f6ee4e054d000cc1 (diff)
downloadcrawl-ref-8ba172496400cc74a2fa7d343d9859339f1a0f5d.tar.gz
crawl-ref-8ba172496400cc74a2fa7d343d9859339f1a0f5d.zip
Cleanup/refactoring of tags.cc. No functional changes. I've been
running with and without this patch applied for about a week, and none of my saves have broken, so I'm ready to commit it. - Tag system no longer uses one big (shared!) global buffer. This was the original impetus behind the change... - Change every use of tagHeader into reader or writer (touches a lot). - Split tagHeader into two classes: reader and writer. Turns out every place that used tagHeader only cared about reading or writing and not about tags at all. There was nothing left in tagHeader, so it disappeared along with a bunch of grotty special-case code. - Not done: merge the files.cc read/writeThing code with the tags.cc marshall/unmarshallThing code. This patch is big enough already. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3685 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/mapmark.cc')
-rw-r--r--crawl-ref/source/mapmark.cc62
1 files changed, 31 insertions, 31 deletions
diff --git a/crawl-ref/source/mapmark.cc b/crawl-ref/source/mapmark.cc
index 589e4f9082..90a5dadf48 100644
--- a/crawl-ref/source/mapmark.cc
+++ b/crawl-ref/source/mapmark.cc
@@ -50,13 +50,13 @@ void map_marker::activate(bool)
{
}
-void map_marker::write(tagHeader &outf) const
+void map_marker::write(writer &outf) const
{
marshallShort(outf, type);
marshallCoord(outf, pos);
}
-void map_marker::read(tagHeader &inf)
+void map_marker::read(reader &inf)
{
// Don't read type! The type has to be read by someone who knows how
// to look up the unmarshall function.
@@ -73,7 +73,7 @@ std::string map_marker::property(const std::string &pname) const
return ("");
}
-map_marker *map_marker::read_marker(tagHeader &inf)
+map_marker *map_marker::read_marker(reader &inf)
{
const map_marker_type type =
static_cast<map_marker_type>(unmarshallShort(inf));
@@ -110,13 +110,13 @@ map_feature_marker::map_feature_marker(
{
}
-void map_feature_marker::write(tagHeader &outf) const
+void map_feature_marker::write(writer &outf) const
{
this->map_marker::write(outf);
marshallShort(outf, feat);
}
-void map_feature_marker::read(tagHeader &inf)
+void map_feature_marker::read(reader &inf)
{
map_marker::read(inf);
feat = static_cast<dungeon_feature_type>(unmarshallShort(inf));
@@ -127,7 +127,7 @@ map_marker *map_feature_marker::clone() const
return new map_feature_marker(pos, feat);
}
-map_marker *map_feature_marker::read(tagHeader &inf, map_marker_type)
+map_marker *map_feature_marker::read(reader &inf, map_marker_type)
{
map_marker *mapf = new map_feature_marker();
mapf->read(inf);
@@ -231,9 +231,9 @@ bool map_lua_marker::get_table() const
return (lua_istable(dlua, -1));
}
-void map_lua_marker::write(tagHeader &th) const
+void map_lua_marker::write(writer &outf) const
{
- map_marker::write(th);
+ map_marker::write(outf);
lua_stack_cleaner clean(dlua);
bool init = initialised;
@@ -243,7 +243,7 @@ void map_lua_marker::write(tagHeader &th) const
init = false;
}
- marshallByte(th, init);
+ marshallByte(outf, init);
if (!init)
return;
@@ -258,7 +258,7 @@ void map_lua_marker::write(tagHeader &th) const
end(1, false, "lua_marker: couldn't save read function: %s",
reader.error.c_str());
- marshallString(th, reader.compiled_chunk());
+ marshallString(outf, reader.compiled_chunk());
// Okay, saved the reader. Now ask the writer to do its thing.
@@ -266,28 +266,28 @@ void map_lua_marker::write(tagHeader &th) const
get_table();
lua_pushstring(dlua, "write");
lua_pushlightuserdata(dlua, const_cast<map_lua_marker*>(this));
- lua_pushlightuserdata(dlua, &th);
+ lua_pushlightuserdata(dlua, &outf);
if (!dlua.callfn("dlua_marker_method", 4))
end(1, false, "lua_marker::write error: %s", dlua.error.c_str());
}
-void map_lua_marker::read(tagHeader &th)
+void map_lua_marker::read(reader &inf)
{
- map_marker::read(th);
+ map_marker::read(inf);
- if (!(initialised = unmarshallByte(th)))
+ if (!(initialised = unmarshallByte(inf)))
return;
lua_stack_cleaner cln(dlua);
// Read the Lua chunk we saved.
- const std::string compiled = unmarshallString(th, LUA_CHUNK_MAX_SIZE);
+ const std::string compiled = unmarshallString(inf, LUA_CHUNK_MAX_SIZE);
dlua_chunk chunk = dlua_chunk::precompiled(compiled);
if (chunk.load(dlua))
end(1, false, "lua_marker::read error: %s", chunk.error.c_str());
dlua_push_userdata(dlua, this, MAPMARK_METATABLE);
- lua_pushlightuserdata(dlua, &th);
+ lua_pushlightuserdata(dlua, &inf);
if (!dlua.callfn("dlua_marker_read", 3, 1))
end(1, false, "lua_marker::read error: %s", dlua.error.c_str());
@@ -295,10 +295,10 @@ void map_lua_marker::read(tagHeader &th)
check_register_table();
}
-map_marker *map_lua_marker::read(tagHeader &th, map_marker_type)
+map_marker *map_lua_marker::read(reader &inf, map_marker_type)
{
map_marker *marker = new map_lua_marker;
- marker->read(th);
+ marker->read(inf);
return (marker);
}
@@ -412,24 +412,24 @@ map_corruption_marker::map_corruption_marker(const coord_def &p,
{
}
-void map_corruption_marker::write(tagHeader &out) const
+void map_corruption_marker::write(writer &out) const
{
map_marker::write(out);
marshallShort(out, duration);
marshallShort(out, radius);
}
-void map_corruption_marker::read(tagHeader &in)
+void map_corruption_marker::read(reader &in)
{
map_marker::read(in);
duration = unmarshallShort(in);
radius = unmarshallShort(in);
}
-map_marker *map_corruption_marker::read(tagHeader &th, map_marker_type)
+map_marker *map_corruption_marker::read(reader &in, map_marker_type)
{
map_corruption_marker *mc = new map_corruption_marker();
- mc->read(th);
+ mc->read(in);
return (mc);
}
@@ -460,7 +460,7 @@ map_wiz_props_marker::map_wiz_props_marker(
{
}
-void map_wiz_props_marker::write(tagHeader &outf) const
+void map_wiz_props_marker::write(writer &outf) const
{
this->map_marker::write(outf);
marshallShort(outf, properties.size());
@@ -472,7 +472,7 @@ void map_wiz_props_marker::write(tagHeader &outf) const
}
}
-void map_wiz_props_marker::read(tagHeader &inf)
+void map_wiz_props_marker::read(reader &inf)
{
map_marker::read(inf);
@@ -515,7 +515,7 @@ map_marker *map_wiz_props_marker::clone() const
return new map_wiz_props_marker(*this);
}
-map_marker *map_wiz_props_marker::read(tagHeader &inf, map_marker_type)
+map_marker *map_wiz_props_marker::read(reader &inf, map_marker_type)
{
map_marker *mapf = new map_wiz_props_marker();
mapf->read(inf);
@@ -718,22 +718,22 @@ void map_markers::clear()
markers.clear();
}
-void map_markers::write(tagHeader &th) const
+void map_markers::write(writer &outf) const
{
// how many markers
- marshallShort(th, markers.size());
+ marshallShort(outf, markers.size());
for (dgn_marker_map::const_iterator i = markers.begin();
i != markers.end(); ++i)
{
- i->second->write(th);
+ i->second->write(outf);
}
}
-void map_markers::read(tagHeader &th)
+void map_markers::read(reader &inf)
{
clear();
- const int nmarkers = unmarshallShort(th);
+ const int nmarkers = unmarshallShort(inf);
for (int i = 0; i < nmarkers; ++i)
- if (map_marker *mark = map_marker::read_marker(th))
+ if (map_marker *mark = map_marker::read_marker(inf))
add(mark);
}