summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/directn.cc
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-31 12:06:58 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-31 12:06:58 +0000
commit630b860361ef96c367743da0da276f320209e61d (patch)
tree9df771fbddd7421773e83f1772d6cfef2f8518e3 /crawl-ref/source/directn.cc
parentf76a28883b52ad529804c1213b25f0fe42f9fc3e (diff)
downloadcrawl-ref-630b860361ef96c367743da0da276f320209e61d.tar.gz
crawl-ref-630b860361ef96c367743da0da276f320209e61d.zip
Implemented basic range darkening while targeting. Nothing uses this
yet, I believe, because most calls to direction() use the default range (-1). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6739 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/directn.cc')
-rw-r--r--crawl-ref/source/directn.cc37
1 files changed, 37 insertions, 0 deletions
diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc
index dc5240794a..6a5e4897bf 100644
--- a/crawl-ref/source/directn.cc
+++ b/crawl-ref/source/directn.cc
@@ -511,6 +511,42 @@ static int _mlist_letter_to_index(char idx)
}
#endif
+class range_view_annotator
+{
+public:
+ range_view_annotator(int range) {
+ orig_colours.init(-1);
+ if ( range < 0 )
+ return;
+ for ( radius_iterator ri(you.pos(), LOS_RADIUS); ri; ++ri )
+ {
+ if (grid_is_solid(*ri) && grid_distance(you.pos(), *ri) > range)
+ {
+ orig_colours(*ri - you.pos() + coord_def(9,9)) =
+ env.grid_colours( *ri );
+ env.grid_colours(*ri) = DARKGREY;
+ }
+ }
+ viewwindow(true, false);
+ }
+
+ ~range_view_annotator() {
+ coord_def c;
+ for ( c.x = 0; c.x < 19; ++c.x )
+ {
+ for ( c.y = 0; c.y < 19; ++c.y )
+ {
+ const int old_colour = orig_colours(c);
+ if ( old_colour != -1 )
+ env.grid_colours(you.pos()+c-coord_def(9,9)) = old_colour;
+ }
+ }
+ viewwindow(true, false);
+ }
+private:
+ FixedArray<int,19,19> orig_colours;
+};
+
void direction(dist& moves, targeting_type restricts,
targ_mode_type mode, int range, bool just_looking,
bool needs_path, bool may_target_monster,
@@ -560,6 +596,7 @@ void direction(dist& moves, targeting_type restricts,
cursor_control con(!Options.use_fake_cursor);
mouse_control mc(MOUSE_MODE_TARGET);
+ range_view_annotator rva(range);
int dir = 0;
bool show_beam = Options.show_beam && !just_looking && needs_path;