summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/beam.cc8
-rw-r--r--crawl-ref/source/directn.cc5
-rw-r--r--crawl-ref/source/los.cc16
-rw-r--r--crawl-ref/source/ray.cc41
-rw-r--r--crawl-ref/source/ray.h4
5 files changed, 18 insertions, 56 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index 3a8acbd9ac..96f3f09649 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -1408,7 +1408,7 @@ static void _munge_bounced_bolt(bolt &old_bolt, bolt &new_bolt,
// Don't bounce straight into another wall. Can happen if the beam
// is shot into an inside corner.
ray_def test_ray = temp_ray;
- test_ray.advance(true);
+ test_ray.advance();
if (in_bounds(test_ray.pos()) && !cell_is_solid(test_ray.pos()))
break;
@@ -2112,11 +2112,7 @@ void bolt::do_fire()
// the cell.
draw(pos());
- // A bounce takes away the meaning from the target.
- if (bounces == 0)
- ray.advance_through(target);
- else
- ray.advance(true);
+ ray.advance();
avoid_self = false;
}
diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc
index 7dc912ccba..2de07d8688 100644
--- a/crawl-ref/source/directn.cc
+++ b/crawl-ref/source/directn.cc
@@ -1175,8 +1175,7 @@ void direction(dist& moves, targetting_type restricts,
ray_def raycopy = ray;
int l = 0;
while (raycopy.pos() != moves.target && range > l++)
- raycopy.advance_through(moves.target);
-
+ raycopy.advance();
moves.target = raycopy.pos();
}
#endif
@@ -1731,7 +1730,7 @@ void direction(dist& moves, targetting_type restricts,
bcol | COLFLAG_REVERSE, in_range);
#endif
}
- raycopy.advance_through(moves.target);
+ raycopy.advance();
}
textcolor(LIGHTGREY);
#ifdef USE_TILE
diff --git a/crawl-ref/source/los.cc b/crawl-ref/source/los.cc
index cff3c128be..3a4f9267fd 100644
--- a/crawl-ref/source/los.cc
+++ b/crawl-ref/source/los.cc
@@ -253,7 +253,11 @@ bool _is_better(const cellray& a, const cellray& b)
ASSERT(a.target() == b.target());
// calc_params() has been called.
ASSERT(a.imbalance >= 0 && b.imbalance >= 0);
- if (a.imbalance < b.imbalance)
+ if (a.end < b.end)
+ return (true);
+ else if (a.end > b.end)
+ return (false);
+ else if (a.imbalance < b.imbalance)
return (true);
else if (a.imbalance > b.imbalance)
return (false);
@@ -558,7 +562,7 @@ static int _imbalance(ray_def ray, const coord_def& target)
int diags = 0, straights = 0;
while (ray.pos() != target)
{
- adv_type adv = ray.advance_through(target);
+ adv_type adv = ray.advance();
if (adv == ADV_XY)
{
straights = 0;
@@ -714,14 +718,14 @@ dungeon_feature_type ray_blocker(const coord_def& source,
return (NUM_REAL_FEATURES);
}
- ray.advance(false); // Must not cut corners!
+ ray.advance();
int blocked = 0;
while (ray.pos() != target)
{
blocked += opc_solid(ray.pos());
if (blocked >= OPC_OPAQUE)
return (env.grid(ray.pos()));
- ray.advance(false);
+ ray.advance();
}
ASSERT (false);
return (NUM_REAL_FEATURES);
@@ -760,7 +764,7 @@ int num_feats_between(const coord_def& source, const coord_def& target,
if (exclude_endpoints && ray.pos() == source)
{
- ray.advance(true);
+ ray.advance();
max_dist--;
}
@@ -785,7 +789,7 @@ int num_feats_between(const coord_def& source, const coord_def& target,
if (reached_target)
break;
- ray.advance(true);
+ ray.advance();
}
return (count);
diff --git a/crawl-ref/source/ray.cc b/crawl-ref/source/ray.cc
index fc88b57712..5635aaf161 100644
--- a/crawl-ref/source/ray.cc
+++ b/crawl-ref/source/ray.cc
@@ -84,7 +84,7 @@ void ray_def::advance_and_bounce()
{
int oldx = x(), oldy = y();
const double oldaccx = accx, oldaccy = accy;
- adv_type rc = advance(false);
+ adv_type rc = advance();
int newx = x(), newy = y();
ASSERT(feat_is_solid(grd[newx][newy]));
@@ -161,45 +161,10 @@ void ray_def::set_degrees(double deg)
void ray_def::regress()
{
quadx = -quadx; quady= -quady;
- advance(false);
+ advance();
quadx = -quadx; quady= -quady;
}
-adv_type ray_def::advance_through(const coord_def &target)
-{
- return (advance(true, &target));
-}
-
-adv_type ray_def::advance(bool shortest_possible, const coord_def *target)
-{
- if (!shortest_possible)
- return (raw_advance());
-
- // If we want to minimise the number of moves on the ray, look one
- // step ahead and see if we can get a diagonal.
-
- const coord_def old = pos();
- const adv_type ret = raw_advance();
-
- if (ret == ADV_XY || (target && pos() == *target))
- return (ret);
-
- const double maccx = accx, maccy = accy;
- if (raw_advance() != ADV_XY)
- {
- const coord_def second = pos();
- // If we can convert to a diagonal, do so.
- if ((second - old).abs() == 2)
- return (ADV_XY);
- }
-
- // No diagonal, so roll back.
- accx = maccx;
- accy = maccy;
-
- return (ret);
-}
-
// Advance a ray in the positive quadrant.
// note that slope must be nonnegative!
// returns 0 if the advance was in x, 1 if it was in y, 2 if it was
@@ -276,7 +241,7 @@ void ray_def::flip()
accy = 0.5 + quady * (accy - 0.5);
}
-adv_type ray_def::raw_advance()
+adv_type ray_def::advance()
{
adv_type rc;
flip();
diff --git a/crawl-ref/source/ray.h b/crawl-ref/source/ray.h
index aa4570426e..a720dc4885 100644
--- a/crawl-ref/source/ray.h
+++ b/crawl-ref/source/ray.h
@@ -35,8 +35,7 @@ public:
coord_def pos() const;
// returns the direction taken
- adv_type advance(bool shorten = false, const coord_def *p = NULL);
- adv_type advance_through(const coord_def &point);
+ adv_type advance();
void advance_and_bounce();
void regress();
@@ -48,7 +47,6 @@ public:
protected:
adv_type raw_advance_pos();
void flip();
- adv_type raw_advance();
double reflect(bool x, double oldc, double newc) const;
void set_reflect_point(const double oldx, const double oldy,
bool blocked_x, bool blocked_y);