summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mapdef.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-11-25 23:36:07 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-11-25 23:36:07 +0000
commit83b1c7b2cc01d46d8f904b102681e85c044710a0 (patch)
tree9d76a04ce3d820458e18b87c7283f4f68b4f2fa4 /crawl-ref/source/mapdef.cc
parent527fdaf6347eeec4683c418593c1977ab77c5007 (diff)
downloadcrawl-ref-83b1c7b2cc01d46d8f904b102681e85c044710a0.tar.gz
crawl-ref-83b1c7b2cc01d46d8f904b102681e85c044710a0.zip
Place external loot chamber for ziggurat levels with jellies.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7625 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/mapdef.cc')
-rw-r--r--crawl-ref/source/mapdef.cc53
1 files changed, 49 insertions, 4 deletions
diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc
index 8cbe27c026..57302d789f 100644
--- a/crawl-ref/source/mapdef.cc
+++ b/crawl-ref/source/mapdef.cc
@@ -1663,17 +1663,62 @@ coord_def map_def::float_random_place() const
random_range(minvborder, GYM - minvborder - map.height()));
}
+point_vector map_def::anchor_points() const
+{
+ point_vector points;
+ for (int y = 0, cheight = map.height(); y < cheight; ++y)
+ for (int x = 0, cwidth = map.width(); x < cwidth; ++x)
+ if (map.glyph(x, y) == '@')
+ points.push_back(coord_def(x, y));
+ return (points);
+}
+
+coord_def map_def::float_aligned_place() const
+{
+ const point_vector our_anchors = anchor_points();
+ const coord_def fail(-1, -1);
+
+#ifdef DEBUG_DIAGNOSTICS
+ mprf(MSGCH_DIAGNOSTICS,
+ "Aligning floating vault with %lu points vs %lu reference points",
+ our_anchors.size(), map_anchor_points.size());
+#endif
+
+ // Mismatch in the number of points we have to align, bail.
+ if (our_anchors.size() != map_anchor_points.size())
+ return (fail);
+
+ // Align first point of both vectors, then check that the others match.
+ const coord_def pos = map_anchor_points[0] - our_anchors[0];
+
+ for (int i = 1, psize = map_anchor_points.size(); i < psize; ++i)
+ if (pos + our_anchors[i] != map_anchor_points[i])
+ return (fail);
+
+ // Looking good, check bounds.
+ if (!map_bounds(pos) || !map_bounds(pos + size() - 1))
+ return (fail);
+
+ // Go us!
+ return (pos);
+}
+
coord_def map_def::float_place()
{
ASSERT(orient == MAP_FLOAT);
coord_def pos(-1, -1);
- if (coinflip())
- pos = float_dock();
+ if (!map_anchor_points.empty())
+ pos = float_aligned_place();
+ else
+ {
+ if (coinflip())
+ pos = float_dock();
- if (pos.x == -1)
- pos = float_random_place();
+ if (pos.x == -1)
+ pos = float_random_place();
+ }
return (pos);
}