diff options
author | Robert Vollmert <rvollmert@gmx.net> | 2009-10-11 19:03:45 +0200 |
---|---|---|
committer | Robert Vollmert <rvollmert@gmx.net> | 2009-10-11 21:30:30 +0200 |
commit | 38d50b4e0df9c9baab31313c1d1db2b678a72a3a (patch) | |
tree | 7a48f2066fe4b1ba46fdfa39bb7895cf72acf80a /crawl-ref/source/ray.h | |
parent | 4783b4ed0e228b3de642d71c6554ffcf60ab7858 (diff) | |
download | crawl-ref-38d50b4e0df9c9baab31313c1d1db2b678a72a3a.tar.gz crawl-ref-38d50b4e0df9c9baab31313c1d1db2b678a72a3a.zip |
Make advance direction and quadrants explicit as enums.
Diffstat (limited to 'crawl-ref/source/ray.h')
-rw-r--r-- | crawl-ref/source/ray.h | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/crawl-ref/source/ray.h b/crawl-ref/source/ray.h index 201a92edf1..c55ff1390e 100644 --- a/crawl-ref/source/ray.h +++ b/crawl-ref/source/ray.h @@ -7,8 +7,22 @@ #ifndef RAY_H #define RAY_H -int shoot_ray(double accx, double accy, const double slope, - int maxrange, int xpos[], int ypos[]); +// quadrant +enum quad_type +{ + QUAD_SE = 0, + QUAD_SW = 1, + QUAD_NW = 2, + QUAD_NE = 3 +}; + +// direction of advance: +enum adv_type +{ + ADV_X = 0, // changed x + ADV_Y = 1, // changed y + ADV_XY = 2 // changed x and y (diagonal) +}; struct ray_def { @@ -16,19 +30,19 @@ public: double accx; double accy; double slope; - int quadrant; // 0 down-right, 1 down-left, 2 up-left, 3 up-right + quad_type quadrant; int fullray_idx; // for cycling: where did we come from? public: ray_def(double accx = 0.0, double accy = 0.0, double slope = 0.0, - int quadrant = 0, int fullray_idx = -1); + quad_type quadrant = QUAD_SE, int fullray_idx = -1); int x() const; int y() const; coord_def pos() const; - // returns the direction taken (0,1,2) - int advance(bool shorten = false, const coord_def *p = NULL); - int advance_through(const coord_def &point); + // returns the direction taken + adv_type advance(bool shorten = false, const coord_def *p = NULL); + adv_type advance_through(const coord_def &point); void advance_and_bounce(); void regress(); @@ -40,9 +54,9 @@ public: void set_degrees(double deg); private: - int raw_advance_0(); + adv_type raw_advance_0(); void flip(); - int raw_advance(); + adv_type raw_advance(); double reflect(bool x, double oldc, double newc) const; void set_reflect_point(const double oldx, const double oldy, bool blocked_x, bool blocked_y); |