summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/act-iter.h
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2013-10-31 08:16:07 +0100
committerAdam Borowski <kilobyte@angband.pl>2013-10-31 16:57:54 +0100
commita57962fa1975ecc27863c2f847fa2a1c4484f7fa (patch)
tree7e5055301b3554b4598be94b52b65633fea156dc /crawl-ref/source/act-iter.h
parentb5aec581b1ad18e6eefb77947e822c089f778d6f (diff)
downloadcrawl-ref-a57962fa1975ecc27863c2f847fa2a1c4484f7fa.tar.gz
crawl-ref-a57962fa1975ecc27863c2f847fa2a1c4484f7fa.zip
monster_near_iterator
Does the "in view" part of functionality of monster_iterator, is simpler, allows using los models other than LOS_DEFAULT, and gets rid of a lot of uses of get_los(). The code is nearly identical as actor_near_iterator, but the old delegation used more code than either of those. Still, perhaps templating could work? This commit also fixes a buttload of ignoring invis / see invis / sense invis (ie, visible_to()) and act-through-glass bugs.
Diffstat (limited to 'crawl-ref/source/act-iter.h')
-rw-r--r--crawl-ref/source/act-iter.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/crawl-ref/source/act-iter.h b/crawl-ref/source/act-iter.h
index dc70e66ea5..58db3eab7c 100644
--- a/crawl-ref/source/act-iter.h
+++ b/crawl-ref/source/act-iter.h
@@ -28,4 +28,26 @@ protected:
void advance();
};
+class monster_near_iterator
+{
+public:
+ monster_near_iterator(coord_def c, los_type los = LOS_DEFAULT);
+ monster_near_iterator(const actor* a, los_type los = LOS_DEFAULT);
+
+ operator bool() const;
+ monster* operator*() const;
+ monster* operator->() const;
+ monster_near_iterator& operator++();
+ monster_near_iterator operator++(int);
+
+protected:
+ const coord_def center;
+ los_type _los;
+ const actor* viewer;
+ int i;
+
+ bool valid(const monster* a) const;
+ void advance();
+};
+
#endif