1 #pragma once
2 
3 enum circle_type
4 {
5     C_CIRCLE,      // circle specified by pre-squared radius
6     C_POINTY,      // circle with square radius r*r
7     C_ROUND,       // circle with square radius r*r+1
8     C_SQUARE,      // square with radius r
9 };
10 
11 class rectangle_iterator;
12 class rect_def
13 {
14     coord_def min;
15     coord_def max;
16 
17 public:
rect_def()18     rect_def() {}
rect_def(const coord_def & min_,const coord_def & max_)19     rect_def(const coord_def &min_, const coord_def &max_)
20         : min(min_), max(max_) {}
21 
22     bool contains(const coord_def& p) const PURE;
23     rect_def intersect(const rect_def& other) const PURE;
24     rectangle_iterator iter() const;
25 };
26 
27 #define RECT_MAP_BOUNDS (rect_def(coord_def(X_BOUND_1, Y_BOUND_1), \
28                                   coord_def(X_BOUND_2, Y_BOUND_2)))
29 
30 /*
31  * Circles of different shapes; see circle_type for these.
32  *
33  * radius/radius_sq don't have meaning when global_los_radius is set.
34  */
35 class circle_def
36 {
37     // Are we tracking global LOS radius?
38     bool global_los_radius;
39 
40     // Check against map bounds for containment?
41     bool check_bounds;
42 
43     coord_def origin;
44 
45     int radius;
46     int radius_sq;
47     rect_def bbox;
48     bool is_square;
49 
50 public:
51     // Circle around (0,0) with radius that tracks global LOS radius.
52     // No bounds checking.
53     circle_def();
54     // Circle around origin with shape of given circle.
55     circle_def(const coord_def &origin_, const circle_def &bds);
56     // Circle around (0,0) of specified shape and size.
57     // No bounds checking.
58     explicit circle_def(int param, circle_type ctype);
59     // Circle around given origin of specified shape and size.
60     circle_def(const coord_def &origin_, int param, circle_type ctype);
61 
62     bool contains(const coord_def &p) const PURE;
63     const rect_def& get_bbox() const PURE;
64     const coord_def& get_center() const PURE;
65 
66 private:
67     void init(int param, circle_type ctype);
68     void init_bbox();
69 };
70