diff options
author | Wushin <pasekei@gmail.com> | 2015-09-19 22:21:16 -0500 |
---|---|---|
committer | Wushin <pasekei@gmail.com> | 2015-09-19 22:21:16 -0500 |
commit | ce49c4725855137624d854ece6513bd52f5d6122 (patch) | |
tree | 1760c3f9e93c5d01fefa392a738076535a6c2b63 /src | |
parent | 05b13aab2a018f8a5a519a2f154fd2de123439ec (diff) | |
parent | 3332fd62bda83d7e1f4e09bab2f61babf97a0fc1 (diff) | |
download | tmwa-ce49c4725855137624d854ece6513bd52f5d6122.tar.gz tmwa-ce49c4725855137624d854ece6513bd52f5d6122.tar.bz2 tmwa-ce49c4725855137624d854ece6513bd52f5d6122.tar.xz tmwa-ce49c4725855137624d854ece6513bd52f5d6122.zip |
Merge pull request #148 from wushin/pc-attack-path-problem
Declaring abs for dx & dy caused latter equation to always be positive
Diffstat (limited to 'src')
-rw-r--r-- | src/map/battle.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/map/battle.cpp b/src/map/battle.cpp index 5b63acc..589568b 100644 --- a/src/map/battle.cpp +++ b/src/map/battle.cpp @@ -2129,16 +2129,18 @@ int battle_check_range(dumb_ptr<block_list> src, dumb_ptr<block_list> bl, int range) { - int dx, dy; + int dx, dy, rangex, rangey; struct walkpath_data wpd; int arange; nullpo_retz(src); nullpo_retz(bl); - dx = abs(bl->bl_x - src->bl_x); - dy = abs(bl->bl_y - src->bl_y); - arange = ((dx > dy) ? dx : dy); + dx = (bl->bl_x - src->bl_x); + dy = (bl->bl_y - src->bl_y); + rangex = abs(dx); + rangey = abs(dy); + arange = ((rangex > rangey) ? rangex : rangey); if (src->bl_m != bl->bl_m) // 違うマップ return 0; |