From 769f5801f3499f525071cd0363ca9e66ef46f2cf Mon Sep 17 00:00:00 2001 From: skyleo Date: Wed, 11 Sep 2019 02:21:31 +0200 Subject: Use *DWord functions for saving x & y into data of unit->delay_walktoxy_timer --- src/map/unit.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/map/unit.c b/src/map/unit.c index 8eb490c34..f5784b405 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -57,6 +57,7 @@ #include "common/showmsg.h" #include "common/socket.h" #include "common/timer.h" +#include "common/utils.h" #include #include @@ -499,7 +500,7 @@ static int unit_walktoxy_timer(int tid, int64 tick, int id, intptr_t data) * @param tid: Timer ID, unused * @param tick: Tick, unused * @param id: ID of block_list to execute the action - * @param data: intptr_t filled with x-coord in highest 16 bits and y-coord in lowest 16 bits + * @param data: uint32 data cast to intptr_t with x-coord in lowest 16 bits and y-coord in highest 16 bits * @return 0: success, 1: failure */ static int unit_delay_walktoxy_timer(int tid, int64 tick, int id, intptr_t data) @@ -507,8 +508,8 @@ static int unit_delay_walktoxy_timer(int tid, int64 tick, int id, intptr_t data) struct block_list *bl = map->id2bl(id); if (bl == NULL || bl->prev == NULL) return 1; - short x = (short) ((data >> 16) & 0xffff); - short y = (short) (data & 0xffff); + short x = (short)GetWord((uint32)data, 0); + short y = (short)GetWord((uint32)data, 1); unit->walktoxy(bl, x, y, 0); return 0; } @@ -548,7 +549,7 @@ static int unit_walktoxy(struct block_list *bl, short x, short y, int flag) if (flag&4 && DIFF_TICK(ud->canmove_tick, timer->gettick()) > 0 && DIFF_TICK(ud->canmove_tick, timer->gettick()) < 2000) { // Delay walking command. [Skotlex] - timer->add(ud->canmove_tick+1, unit->delay_walktoxy_timer, bl->id, (x<<16)|(y&0xFFFF)); + timer->add(ud->canmove_tick + 1, unit->delay_walktoxy_timer, bl->id, (intptr_t)MakeDWord((uint16)x, (uint16)y)); return 1; } -- cgit v1.2.3-60-g2f50