diff options
author | Adam Borowski <kilobyte@angband.pl> | 2011-11-13 05:06:50 +0100 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2011-11-13 13:09:27 +0100 |
commit | d4ec7f300b6086c5a3a6b80eb006e7a11098db53 (patch) | |
tree | 9db1058e7df6dc45986e7f61a2c642d0e0fef260 /crawl-ref/source/dgn-shoals.cc | |
parent | d3257a5d2d64c1e7316d4c89696c4c3c0679b9bb (diff) | |
download | crawl-ref-d4ec7f300b6086c5a3a6b80eb006e7a11098db53.tar.gz crawl-ref-d4ec7f300b6086c5a3a6b80eb006e7a11098db53.zip |
Replace a bunch of floating-point sqrt()s by integer ones.
Diffstat (limited to 'crawl-ref/source/dgn-shoals.cc')
-rw-r--r-- | crawl-ref/source/dgn-shoals.cc | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/crawl-ref/source/dgn-shoals.cc b/crawl-ref/source/dgn-shoals.cc index 4547ae05c6..0db024798e 100644 --- a/crawl-ref/source/dgn-shoals.cc +++ b/crawl-ref/source/dgn-shoals.cc @@ -969,17 +969,11 @@ static int _shoals_tide_at(coord_def pos, int base_tide) if (!tide_caller) return base_tide; - // try to avoid the costly sqrt() call - const int rl_distance = grid_distance(pos, tide_caller_pos); - if (rl_distance > TIDE_CALL_RADIUS) + pos -= tide_caller->pos(); + if (pos.abs() > sqr(TIDE_CALL_RADIUS) + 1) return base_tide; - const int distance = - static_cast<int>(sqrt((float)(pos - tide_caller->pos()).abs())); - if (distance > TIDE_CALL_RADIUS) - return base_tide; - - return (base_tide + std::max(0, tide_called_peak - distance * 3)); + return (base_tide + std::max(0, tide_called_peak - pos.range() * 3)); } static std::vector<coord_def> _shoals_extra_tide_seeds() |