summaryrefslogtreecommitdiff
path: root/src/map/unit.c
diff options
context:
space:
mode:
authorskyleo <skyleo@skyleo.de>2019-10-03 19:09:16 +0200
committerHaru <haru@dotalux.com>2020-03-08 20:56:27 +0100
commitf4039d8b2c28b06b160fa44e27908856646633a7 (patch)
tree7dbfa0a4fd9c5a1bcd35c8015c5912164fb67d36 /src/map/unit.c
parent0ca593266e3d7f78eb4648ffe7bad7a7db9b6490 (diff)
downloadhercules-f4039d8b2c28b06b160fa44e27908856646633a7.tar.gz
hercules-f4039d8b2c28b06b160fa44e27908856646633a7.tar.bz2
hercules-f4039d8b2c28b06b160fa44e27908856646633a7.tar.xz
hercules-f4039d8b2c28b06b160fa44e27908856646633a7.zip
Rename reused var appropriately in unit->walktoxy_sub
Diffstat (limited to 'src/map/unit.c')
-rw-r--r--src/map/unit.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/map/unit.c b/src/map/unit.c
index 12d53df13..d6eb6c30f 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -123,7 +123,6 @@ static struct unit_data *unit_bl2ud2(struct block_list *bl)
*/
static int unit_walktoxy_sub(struct block_list *bl)
{
- int i;
nullpo_retr(2, bl);
struct unit_data *ud = unit->bl2ud(bl);
if (ud == NULL)
@@ -147,9 +146,9 @@ static int unit_walktoxy_sub(struct block_list *bl)
//Generally speaking, the walk path is already to an adjacent tile
//so we only need to shorten the path if the range is greater than 1.
- //Trim the last part of the path to account for range,
- //but always move at least one cell when requested to move.
- for (i = (ud->chaserange*10)-10; i > 0 && ud->walkpath.path_len>1;) {
+ // Trim the last part of the path to account for range,
+ // but always move at least one cell when requested to move.
+ for (int i = ud->chaserange * 10 - 10; i > 0 && ud->walkpath.path_len > 1;) {
uint8 dir;
ud->walkpath.path_len--;
dir = ud->walkpath.path[ud->walkpath.path_len];
@@ -171,14 +170,16 @@ static int unit_walktoxy_sub(struct block_list *bl)
}
clif->move(ud);
- if(ud->walkpath.path_pos>=ud->walkpath.path_len)
- i = -1;
- else if(ud->walkpath.path[ud->walkpath.path_pos]&1)
- i = status->get_speed(bl)*MOVE_DIAGONAL_COST/MOVE_COST;
+ int timer_delay;
+ if (ud->walkpath.path_pos >= ud->walkpath.path_len)
+ timer_delay = -1;
+ else if ((ud->walkpath.path[ud->walkpath.path_pos] & 1) != 0)
+ timer_delay = status->get_speed(bl) * MOVE_DIAGONAL_COST / MOVE_COST;
else
- i = status->get_speed(bl);
- if( i > 0)
- ud->walktimer = timer->add(timer->gettick()+i,unit->walktoxy_timer,bl->id,i);
+ timer_delay = status->get_speed(bl);
+
+ if (timer_delay > 0)
+ ud->walktimer = timer->add(timer->gettick() + timer_delay, unit->walktoxy_timer, bl->id, 0); //TODO: check if unit->walktoxy_timer uses any intptr data
return 1;
}