summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mapmark.cc
diff options
context:
space:
mode:
authorRaphael Langella <raphael.langella@gmail.com>2011-08-11 21:27:40 +0200
committerRaphael Langella <raphael.langella@gmail.com>2011-08-11 21:27:40 +0200
commitd647f48844401cb98cc8068c69e0d54116b7203a (patch)
tree549ca1bdb8e2fab61df00b4f0f727057a3d175eb /crawl-ref/source/mapmark.cc
parent4b4b5900429bddd34569ff5adb0a0b71c769be64 (diff)
downloadcrawl-ref-d647f48844401cb98cc8068c69e0d54116b7203a.tar.gz
crawl-ref-d647f48844401cb98cc8068c69e0d54116b7203a.zip
Randomize the destination of hatches and shafts (#3200).
Hatch destination is randomly chosen on level generation and is saved in a map marker, so it's always the same. We don't bother using a marker for shafts since they are single use. Items falling through shafts have no reason to end up on the same coordinates since they can even end up on a different level, so their destination is randomised too.
Diffstat (limited to 'crawl-ref/source/mapmark.cc')
-rw-r--r--crawl-ref/source/mapmark.cc48
1 files changed, 47 insertions, 1 deletions
diff --git a/crawl-ref/source/mapmark.cc b/crawl-ref/source/mapmark.cc
index ab1e1e3844..98aab5b559 100644
--- a/crawl-ref/source/mapmark.cc
+++ b/crawl-ref/source/mapmark.cc
@@ -32,7 +32,8 @@ map_marker::marker_reader map_marker::readers[NUM_MAP_MARKER_TYPES] =
&map_wiz_props_marker::read,
&map_tomb_marker::read,
&map_malign_gateway_marker::read,
- &map_phoenix_marker::read
+ &map_phoenix_marker::read,
+ &map_position_marker::read
};
map_marker::marker_parser map_marker::parsers[NUM_MAP_MARKER_TYPES] =
@@ -709,6 +710,51 @@ std::string map_phoenix_marker::debug_describe() const
return make_stringf("Phoenix marker (%d, %d)", turn_start, turn_stop);
}
+////////////////////////////////////////////////////////////////////////////
+// map_position_marker
+
+map_position_marker::map_position_marker(
+ const coord_def &p,
+ const coord_def _dest)
+ : map_marker(MAT_POSITION, p), dest(_dest)
+{
+}
+
+map_position_marker::map_position_marker(
+ const map_position_marker &other)
+ : map_marker(MAT_POSITION, other.pos), dest(other.dest)
+{
+}
+
+void map_position_marker::write(writer &outf) const
+{
+ this->map_marker::write(outf);
+ marshallCoord(outf, dest);
+}
+
+void map_position_marker::read(reader &inf)
+{
+ map_marker::read(inf);
+ dest = (unmarshallCoord(inf));
+}
+
+map_marker *map_position_marker::clone() const
+{
+ return new map_position_marker(pos, dest);
+}
+
+map_marker *map_position_marker::read(reader &inf, map_marker_type)
+{
+ map_marker *mapf = new map_position_marker();
+ mapf->read(inf);
+ return (mapf);
+}
+
+std::string map_position_marker::debug_describe() const
+{
+ return make_stringf("position (%d,%d)", dest.x, dest.y);
+}
+
//////////////////////////////////////////////////////////////////////////
// Map markers in env.