diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/map/unit.c | 23 |
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; } |