Fix SC_WINKCHARM behavior (#6384)
Adds a check to prevent func unit_walktoxy_timer to use DIR_CENTER direction (which has -1 value) on SC_WINKCHARMed mobs. Using this direction may cause dump values when accessing dirx or diry array; Fixed timer mismatchs reported in https://github.com/rathena/rathena/issues/6371#issuecomment-982108186 Fixes #6371 Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
This commit is contained in:
parent
081b5c86bd
commit
a028a74ae5
@ -139,8 +139,14 @@ int unit_walktoxy_sub(struct block_list *bl)
|
||||
i = status_get_speed(bl)*MOVE_DIAGONAL_COST/MOVE_COST;
|
||||
else
|
||||
i = status_get_speed(bl);
|
||||
if( i > 0)
|
||||
if( i > 0 ){
|
||||
if( ud->walktimer != INVALID_TIMER ){
|
||||
delete_timer( ud->walktimer, unit_walktoxy_timer );
|
||||
ud->walktimer = INVALID_TIMER;
|
||||
}
|
||||
ud->walktimer = add_timer(gettick()+i,unit_walktoxy_timer,bl->id,i);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -388,13 +394,12 @@ static TIMER_FUNC(unit_walktoxy_timer)
|
||||
if(ud->walkpath.path_pos>=ud->walkpath.path_len)
|
||||
return 0;
|
||||
|
||||
if(ud->walkpath.path[ud->walkpath.path_pos]>=DIR_MAX)
|
||||
return 1;
|
||||
|
||||
int x = bl->x;
|
||||
int y = bl->y;
|
||||
|
||||
enum directions dir = ud->walkpath.path[ud->walkpath.path_pos];
|
||||
|
||||
if( dir <= DIR_CENTER || dir >= DIR_MAX ){
|
||||
return 0;
|
||||
}
|
||||
|
||||
ud->dir = dir;
|
||||
|
||||
int dx = dirx[dir];
|
||||
@ -420,6 +425,9 @@ static TIMER_FUNC(unit_walktoxy_timer)
|
||||
case BL_NPC: nd = BL_CAST(BL_NPC, bl); break;
|
||||
}
|
||||
|
||||
int x = bl->x;
|
||||
int y = bl->y;
|
||||
|
||||
//Monsters will walk into an icewall from the west and south if they already started walking
|
||||
if(map_getcell(bl->m,x+dx,y+dy,CELL_CHKNOPASS)
|
||||
&& (icewall_walk_block == 0 || dx < 0 || dy < 0 || !map_getcell(bl->m,x+dx,y+dy,CELL_CHKICEWALL)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user