summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwushin <pasekei@gmail.com>2015-09-19 21:22:53 -0500
committerwushin <pasekei@gmail.com>2015-09-19 21:22:53 -0500
commit3332fd62bda83d7e1f4e09bab2f61babf97a0fc1 (patch)
tree1760c3f9e93c5d01fefa392a738076535a6c2b63
parent05b13aab2a018f8a5a519a2f154fd2de123439ec (diff)
downloadtmwa-3332fd62bda83d7e1f4e09bab2f61babf97a0fc1.tar.gz
tmwa-3332fd62bda83d7e1f4e09bab2f61babf97a0fc1.tar.bz2
tmwa-3332fd62bda83d7e1f4e09bab2f61babf97a0fc1.tar.xz
tmwa-3332fd62bda83d7e1f4e09bab2f61babf97a0fc1.zip
Declaring abs for dx & dy caused latter equation to always be positive
-rw-r--r--src/map/battle.cpp10
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;