summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-11-07 07:54:12 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-11-07 08:13:18 +0100
commit66bf04b8445e54594ffa1cf1569f176244951da1 (patch)
treee2c5aeba26f326d628f5c89946ec7d0ed2b8fd06
parent77a32300cdd4026a1c763ad984480d379bda1d66 (diff)
downloadcrawl-ref-66bf04b8445e54594ffa1cf1569f176244951da1.tar.gz
crawl-ref-66bf04b8445e54594ffa1cf1569f176244951da1.zip
Fix moves.target getting out of sync with ray in targetting.
This was causing ASSERTs in tiles (BR 2886295). Also, beams weren't getting drawn when mouse-targetting. Now tracking ray target separately from moves.target. Also some slight cleanup. More needed.
-rw-r--r--crawl-ref/source/directn.cc53
1 files changed, 17 insertions, 36 deletions
diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc
index 45a6a3d843..87cda945c4 100644
--- a/crawl-ref/source/directn.cc
+++ b/crawl-ref/source/directn.cc
@@ -1044,8 +1044,10 @@ void direction(dist& moves, targetting_type restricts,
int dir = 0;
bool show_beam = Options.show_beam && !just_looking && needs_path;
- bool have_beam = false;
- ray_def ray;
+
+ ray_def ray; // The possibly filled in beam.
+ bool have_beam = false; // Whether it is filled in.
+ coord_def beam_target; // What target is was chosen for.
coord_def objfind_pos, monsfind_pos;
@@ -1055,7 +1057,10 @@ void direction(dist& moves, targetting_type restricts,
// If we show the beam on startup, we have to initialise it.
if (show_beam)
+ {
have_beam = find_ray(you.pos(), moves.target, ray);
+ beam_target = moves.target;
+ }
bool skip_iter = false;
bool found_autotarget = false;
@@ -1141,22 +1146,14 @@ void direction(dist& moves, targetting_type restricts,
if (skip_iter)
{
if (restricts == DIR_TARGET_OBJECT)
- {
key_command = CMD_TARGET_OBJ_CYCLE_FORWARD;
- }
else if (found_autotarget)
- {
key_command = CMD_NO_CMD;
- }
else
- {
key_command = CMD_TARGET_CYCLE_FORWARD; // Find closest target.
- }
}
else
- {
key_command = beh->get_command();
- }
#ifdef USE_TILE
// If a mouse command, update location to mouse position.
@@ -1173,26 +1170,10 @@ void direction(dist& moves, targetting_type restricts,
moves.target = gc;
if (key_command == CMD_TARGET_MOUSE_SELECT)
- {
key_command = CMD_TARGET_SELECT;
-// Do we really need this? (jpeg)
-// Looks like the redrawing routine already handles it.
-#if 0
- if (needs_path && range > 0)
- {
- ray_def raycopy = ray;
- int l = 0;
- while (raycopy.pos() != moves.target && range > l++)
- raycopy.advance();
- moves.target = raycopy.pos();
- }
-#endif
- }
}
else
- {
key_command = CMD_NO_CMD;
- }
}
else
moved_with_keys = true;
@@ -1326,6 +1307,7 @@ void direction(dist& moves, targetting_type restricts,
show_beam = true;
have_beam = find_ray(you.pos(), moves.target, ray,
opc_solid, bds_default, show_beam);
+ beam_target = moves.target;
need_beam_redraw = true;
break;
#endif
@@ -1346,6 +1328,7 @@ void direction(dist& moves, targetting_type restricts,
}
have_beam = find_ray(you.pos(), moves.target, ray);
+ beam_target = moves.target;
show_beam = true;
need_beam_redraw = true;
}
@@ -1683,16 +1666,13 @@ void direction(dist& moves, targetting_type restricts,
moves.target = old_target;
}
- bool have_moved = false;
- if (old_target != moves.target)
- {
- have_moved = true;
+ bool have_moved = (old_target != moves.target);
- if (show_beam)
- {
- have_beam = find_ray(you.pos(), moves.target, ray);
- need_beam_redraw = true;
- }
+ if (beam_target != moves.target && show_beam)
+ {
+ have_beam = find_ray(you.pos(), moves.target, ray);
+ beam_target = moves.target;
+ need_beam_redraw = true;
}
if (have_moved || force_redraw)
@@ -1722,7 +1702,8 @@ void direction(dist& moves, targetting_type restricts,
// your square or the target square.
// Out-of-range cells get grey '*'s instead.
ray_def raycopy = ray; // temporary copy to work with
- while (raycopy.pos() != moves.target)
+ // XXX: should have moves.target == beam_target, but don't.
+ while (raycopy.pos() != beam_target)
{
if (raycopy.pos() != you.pos())
{