diff options
author | Robert Vollmert <rvollmert@gmx.net> | 2009-10-30 15:59:29 +0100 |
---|---|---|
committer | Robert Vollmert <rvollmert@gmx.net> | 2009-10-30 21:32:06 +0100 |
commit | c72f09adfa6f776ff5cabd0b8e4b4e0a2e752703 (patch) | |
tree | 4d8df78d7c26029a1849bb20caf13b98756d0196 /crawl-ref/source/coordit.h | |
parent | 764ee1d67a579678d69aa690e92e263fee2b02e3 (diff) | |
download | crawl-ref-c72f09adfa6f776ff5cabd0b8e4b4e0a2e752703.tar.gz crawl-ref-c72f09adfa6f776ff5cabd0b8e4b4e0a2e752703.zip |
Splitting up stuff.cc.
New: colour.cc, coord.cc, coordit.cc, random.cc, rng.cc.
Diffstat (limited to 'crawl-ref/source/coordit.h')
-rw-r--r-- | crawl-ref/source/coordit.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/crawl-ref/source/coordit.h b/crawl-ref/source/coordit.h new file mode 100644 index 0000000000..b7323bbef8 --- /dev/null +++ b/crawl-ref/source/coordit.h @@ -0,0 +1,62 @@ +#ifndef COORDIT_H +#define COORDIT_H + +#include "player.h" + +class rectangle_iterator : + public std::iterator<std::forward_iterator_tag, coord_def> +{ +public: + rectangle_iterator( const coord_def& corner1, const coord_def& corner2 ); + explicit rectangle_iterator( int x_border_dist, int y_border_dist = -1 ); + operator bool() const; + coord_def operator *() const; + const coord_def* operator->() const; + + rectangle_iterator& operator ++ (); + rectangle_iterator operator ++ (int); +private: + coord_def current, topleft, bottomright; +}; + +class radius_iterator : public std::iterator<std::bidirectional_iterator_tag, + coord_def> +{ +public: + radius_iterator( const coord_def& center, int radius, + bool roguelike_metric = true, + bool require_los = true, + bool exclude_center = false, + const env_show_grid* losgrid = NULL ); + bool done() const; + void reset(); + operator bool() const { return !done(); } + coord_def operator *() const; + const coord_def* operator->() const; + + const radius_iterator& operator ++ (); + const radius_iterator& operator -- (); + radius_iterator operator ++ (int); + radius_iterator operator -- (int); +private: + void step(); + void step_back(); + bool on_valid_square() const; + + coord_def location, center; + int radius; + bool roguelike_metric, require_los, exclude_center; + const env_show_grid* losgrid; + bool iter_done; +}; + +class adjacent_iterator : public radius_iterator +{ +public: + explicit adjacent_iterator( const coord_def& pos = you.pos(), + bool _exclude_center = true ) : + radius_iterator(pos, 1, true, false, _exclude_center) {} +}; + +#endif + |