summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/ray.cc
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-11-03 12:34:02 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-11-03 15:27:26 +0100
commit8e5e988616936c039e56e60796624d582f5499c0 (patch)
tree708fe408a6db85d742a4159fc1815765d15cc9d1 /crawl-ref/source/ray.cc
parent339ded6179de8c98dd895da4229f5693b2a95795 (diff)
downloadcrawl-ref-8e5e988616936c039e56e60796624d582f5499c0.tar.gz
crawl-ref-8e5e988616936c039e56e60796624d582f5499c0.zip
ray_def::bounce now guarantees it leaves the ray in a clear tile.
Diffstat (limited to 'crawl-ref/source/ray.cc')
-rw-r--r--crawl-ref/source/ray.cc19
1 files changed, 7 insertions, 12 deletions
diff --git a/crawl-ref/source/ray.cc b/crawl-ref/source/ray.cc
index 6d7049b4ab..b76db73562 100644
--- a/crawl-ref/source/ray.cc
+++ b/crawl-ref/source/ray.cc
@@ -217,11 +217,11 @@ static geom::line _choose_reflect_line(bool rx, bool ry, bool rxy)
void ray_def::bounce(const reflect_grid &rg)
{
-#ifdef DEBUG_REFLECTION
- mprf(MSGCH_DIAGNOSTICS, "mirroring ray: (%f,%f) + t*(%f,%f)",
- r.start.x, r.start.y, r.dir.x, r.dir.y);
-#endif
ASSERT(_valid());
+ ASSERT(!rg(rg_o)); // The cell we bounce from is not solid.
+#ifdef DEBUG
+ const coord_def old_pos = pos();
+#endif
if (on_corner)
{
@@ -269,10 +269,6 @@ void ray_def::bounce(const reflect_grid &rg)
// One of the three neighbours on this side must be bouncy.
ASSERT(rx || ry || rxy);
-#ifdef DEBUG_REFLECTION
- mprf(MSGCH_DIAGNOSTICS, "bouncy cells: rx=%d, ry=%d, rxy=%d", rx, ry, rxy);
-#endif
-
// Now go through the cases separately.
if (rx && ry && !rxy)
{
@@ -307,16 +303,15 @@ void ray_def::bounce(const reflect_grid &rg)
if (!in_diamond(rmirr.start))
on_corner = _advance_from_non_diamond(&rmirr);
}
+
// Mirror back.
rtrans = _mirror(rmirr, side);
// Translate back.
r.start = rtrans.start + p;
r.dir = rtrans.dir;
-#ifdef DEBUG_REFLECTION
- mprf(MSGCH_DIAGNOSTICS, "mirrored ray: (%f,%f) + t*(%f,%f)",
- r.start.x, r.start.y, r.dir.x, r.dir.y);
-#endif
+
ASSERT(_valid());
+ ASSERT(rg(pos() - old_pos));
}
void ray_def::regress()