diff options
author | Adam Borowski <kilobyte@angband.pl> | 2013-11-04 19:37:43 +0100 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2013-11-05 05:14:17 +0100 |
commit | 75e84aa610c300a6f83b442f4afb78f50a13fcc6 (patch) | |
tree | 609b95a766e47f9f7838c26ba66dec2938070936 /crawl-ref/source/coord-circle.cc | |
parent | 5114b4b827b5b56b3f5e6a204c682c3ac77ad755 (diff) | |
download | crawl-ref-75e84aa610c300a6f83b442f4afb78f50a13fcc6.tar.gz crawl-ref-75e84aa610c300a6f83b442f4afb78f50a13fcc6.zip |
Eradicate C_SQUARE/SH_SQUARE.
circle_def can now be replaced by just a center + radius instead of a
complex object.
Diffstat (limited to 'crawl-ref/source/coord-circle.cc')
-rw-r--r-- | crawl-ref/source/coord-circle.cc | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/crawl-ref/source/coord-circle.cc b/crawl-ref/source/coord-circle.cc index c4ed7025e2..72cf2b389f 100644 --- a/crawl-ref/source/coord-circle.cc +++ b/crawl-ref/source/coord-circle.cc @@ -35,7 +35,7 @@ circle_def::circle_def() circle_def::circle_def(const coord_def& origin_, const circle_def& bds) : los_radius(bds.los_radius), check_bounds(true), - shape(bds.shape), origin(origin_), + origin(origin_), radius(bds.radius), radius_sq(bds.radius_sq) { // Set up bounding box. @@ -59,22 +59,15 @@ void circle_def::init(int param, circle_type ctype) { switch (ctype) { - case C_SQUARE: - shape = SH_SQUARE; - radius = param; - break; case C_CIRCLE: - shape = SH_CIRCLE; radius_sq = param; radius = isqrt_ceil(radius_sq); break; case C_ROUND: - shape = SH_CIRCLE; radius = param; radius_sq = radius * radius + 1; break; case C_POINTY: - shape = SH_CIRCLE; radius = param; radius_sq = radius * radius; } @@ -108,16 +101,7 @@ bool circle_def::contains(const coord_def &p) const { if (!bbox.contains(p)) return false; - switch (shape) - { - case SH_SQUARE: - return ((p - origin).rdist() <= radius); - case SH_CIRCLE: - { - int r_sq = los_radius ? get_los_radius_sq() : radius_sq; - return ((p - origin).abs() <= r_sq); - } - default: - return false; - } + + int r_sq = los_radius ? get_los_radius_sq() : radius_sq; + return ((p - origin).abs() <= r_sq); } |