diff options
author | Robert Vollmert <rvollmert@gmx.net> | 2009-10-16 23:30:11 +0200 |
---|---|---|
committer | Robert Vollmert <rvollmert@gmx.net> | 2009-10-16 23:49:51 +0200 |
commit | 0adf2c9dd91d2f49931fc242545b1e4cd7f5119b (patch) | |
tree | 136e0d0d210b358f072973742d9c6852ae112ef0 /crawl-ref/source/directn.cc | |
parent | 1feac7b0b1cef1cea1ab107f0cce26e3a94e84b7 (diff) | |
download | crawl-ref-0adf2c9dd91d2f49931fc242545b1e4cd7f5119b.tar.gz crawl-ref-0adf2c9dd91d2f49931fc242545b1e4cd7f5119b.zip |
Some find_ray related cleanup.
Introduce a function exists_ray when the ray is not actually needed.
Also factor out part of _blocked_ray from directn.cc to ray_blocker.
Diffstat (limited to 'crawl-ref/source/directn.cc')
-rw-r--r-- | crawl-ref/source/directn.cc | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index 15d3ebd572..45aaacbdcb 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -960,26 +960,17 @@ bool _dist_ok(const dist& moves, int range, targ_mode_type mode, return (true); } -// XXX: fold this into generalized find_ray. +// Assuming the target is in view, is line-of-fire +// blocked, and by what? static bool _blocked_ray(const coord_def &where, dungeon_feature_type* feat = NULL) { - ray_def ray; - if (!find_ray(you.pos(), where, ray)) - fallback_ray(you.pos(), where, ray); - ray.advance_through(where); - - while (ray.pos() != where) - { - if (grd(ray.pos()) <= DNGN_MINMOVE) - { - if (feat != NULL) - *feat = grd(ray.pos()); - return (true); - } - ray.advance_through(where); - } - return (false); + if (exists_ray(you.pos(), where)) + return (false); + if (feat == NULL) + return (true); + *feat = ray_blocker(you.pos(), where); + return (true); } void direction(dist& moves, targetting_type restricts, @@ -1316,7 +1307,8 @@ void direction(dist& moves, targetting_type restricts, #ifdef WIZARD case CMD_TARGET_CYCLE_BEAM: show_beam = true; - have_beam = find_ray(you.pos(), moves.target, ray, show_beam); + have_beam = find_ray(you.pos(), moves.target, ray, + opc_solid, bds_default, show_beam); need_beam_redraw = true; break; #endif @@ -3353,6 +3345,7 @@ std::string get_monster_equipment_desc(const monsters *mon, bool full_desc, return desc; } +// Describe a cell, guaranteed to be in view. static void _describe_cell(const coord_def& where, bool in_range) { bool mimic_item = false; |