Knockback now works through cells where there is a diagonal path, but no horizontal+vertical alternative (like two perpendicular icewalls with a gap where they 'join').

Some dead code removal in path.c.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@11991 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
ultramage 2007-12-29 20:12:46 +00:00
parent 88b874c259
commit bad3a0c04e
2 changed files with 26 additions and 56 deletions

View File

@ -3,6 +3,10 @@ Date Added
AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2007/12/29
* Knockback now works through cells where there is a diagonal path, but
no horizontal+vertical (two 90` icewalls with a gap where they 'join')
* Some dead code removal in path.c [ultramage]
2007/12/28
* Fixed a memory leak in memitemdata_to_sql.
* Reverted a bad modification in clif_produceeffect from r11290. [FlavioJS]

View File

@ -144,52 +144,9 @@ static int add_path(int *heap,struct tmp_path *tp,int x,int y,int dist,int befor
return 0;
}
/*==========================================
* is (x,y) passable?
* flag: 0x10000 = ranged attack check
* 0x30000 = stacking check
*------------------------------------------*/
static int can_place(struct map_data *m,int x,int y,int flag)
{
if( map_getcellp(m,x,y,CELL_CHKPASS) )
return 1;
if( (flag&0x10000)&&map_getcellp(m,x,y,CELL_CHKGROUND) )
return 1;
#ifdef CELL_NOSTACK
//Special flag for CELL_NOSTACK systems. Returns true when the given cell is stacked. [Skotlex]
if( (flag&0x30000)&&map_getcellp(m,x,y,CELL_CHKSTACK) )
return 1;
#endif
return 0;
}
/*==========================================
* can you move from (x0,y0) to (x1,y1) in one step?
* (helper function for path_blownpos())
*------------------------------------------*/
static int can_move(struct map_data *m,int x0,int y0,int x1,int y1,int flag)
{
if( x1 < 0 || y1 < 0 || x1 >= m->xs || y1 >= m->ys)
return 0; // out-of-bounds coordinates
if( flag&0x20000 ) //Flag to ignore everything, for use with Taekwon's Jump skill currently. [Skotlex]
return 1;
#ifndef CELL_NOSTACK
//In no-stack mode, do not check current cell.
if( !can_place(m,x0,y0,flag) )
return 0;
#endif
if( !can_place(m,x1,y1,flag) )
return 0;
if( x0 == x1 || y0 == y1 )
return 1;
if( !can_place(m,x0,y1,flag) || !can_place(m,x1,y0,flag) )
return 0;
return 1;
}
/*==========================================
* (x0,y0)©ç(dx,dy)ûŒüÖcountƒZƒª
* Find the closest reachable cell, 'count' cells away from (x0,y0) in direction (dx,dy).
*
*
*------------------------------------------*/
int path_blownpos(int m,int x0,int y0,int dx,int dy,int count)
@ -210,21 +167,30 @@ int path_blownpos(int m,int x0,int y0,int dx,int dy,int count)
dy=(dy>0)?1:((dy<0)?-1:0);
}
while( (count--)>0 && (dx || dy) )
while( count > 0 && (dx != 0 || dy != 0) )
{
if( !can_move(md,x0,y0,x0+dx,y0+dy,0) ){
int fx=(dx!=0 && can_move(md,x0,y0,x0+dx,y0,0));
int fy=(dy!=0 && can_move(md,x0,y0,x0,y0+dy,0));
if( fx && fy ){
if(rand()&1) dx=0;
else dy=0;
if( !map_getcellp(md,x0+dx,y0+dy,CELL_CHKPASS) )
{// attempt partial movement
int fx = ( dx != 0 && map_getcellp(md,x0+dx,y0,CELL_CHKPASS) );
int fy = ( dy != 0 && map_getcellp(md,x0,y0+dy,CELL_CHKPASS) );
if( fx && fy )
{
if(rand()&1)
dx=0;
else
dy=0;
}
if( !fx ) dx=0;
if( !fy ) dy=0;
else if( !fx )
dx=0;
else if( !fy )
dy=0;
}
x0+=dx;
y0+=dy;
x0 += dx;
y0 += dy;
count--;
}
return (x0<<16)|y0; //TODO: use 'struct point' here instead?
}