From 0adf2c9dd91d2f49931fc242545b1e4cd7f5119b Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Fri, 16 Oct 2009 23:30:11 +0200 Subject: 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. --- crawl-ref/source/directn.cc | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) (limited to 'crawl-ref/source/directn.cc') 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; -- cgit v1.2.3-54-g00ecf