summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/map/Makefile.in2
-rw-r--r--src/map/battle.c15
-rw-r--r--src/map/battle.h2
-rw-r--r--src/map/map.c17
-rw-r--r--src/map/map.h12
-rw-r--r--src/map/path.c175
-rw-r--r--src/map/skill.c5
-rw-r--r--src/map/unit.c45
-rw-r--r--src/map/unit.h4
-rw-r--r--vcproj-6/map-server_sql.dsp4
-rw-r--r--vcproj-6/map-server_txt.dsp4
-rw-r--r--vcproj-7.1/map-server_sql.vcproj3
-rw-r--r--vcproj-7.1/map-server_txt.vcproj3
-rw-r--r--vcproj-8/map-server_sql.vcproj4
-rw-r--r--vcproj-8/map-server_txt.vcproj4
15 files changed, 147 insertions, 152 deletions
diff --git a/src/map/Makefile.in b/src/map/Makefile.in
index 355086127..4276b976a 100644
--- a/src/map/Makefile.in
+++ b/src/map/Makefile.in
@@ -21,7 +21,7 @@ MAP_OBJ = map.o chrif.o clif.o pc.o status.o npc.o \
MAP_TXT_OBJ = $(MAP_OBJ:%=obj_txt/%)
MAP_SQL_OBJ = $(MAP_OBJ:%=obj_sql/%)
MAP_H = map.h chrif.h clif.h pc.h status.h npc.h \
- chat.h itemdb.h mob.h script.h \
+ chat.h itemdb.h mob.h script.h path.h \
storage.h skill.h atcommand.h charcommand.h battle.h \
intif.h trade.h party.h vending.h guild.h pet.h \
log.h mail.h date.h irc.h unit.h mercenary.h
diff --git a/src/map/battle.c b/src/map/battle.c
index f9dbb636e..142db46db 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -11,6 +11,7 @@
#include "../common/utils.h"
#include "map.h"
+#include "path.h"
#include "pc.h"
#include "status.h"
#include "skill.h"
@@ -3274,25 +3275,25 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
/*==========================================
* 射程判定
*------------------------------------------*/
-int battle_check_range(struct block_list *src,struct block_list *bl,int range)
+bool battle_check_range(struct block_list *src,struct block_list *bl,int range)
{
- nullpo_retr(0, src);
- nullpo_retr(0, bl);
+ nullpo_retr(false, src);
+ nullpo_retr(false, bl);
if(src->m != bl->m) // 違うマップ
- return 0;
+ return false;
if(src->type == BL_HOM && battle_config.hom_setting&0x2)
range = battle_config.area_size + 1; //WTF, way to go Aegis and your awesome bugs.
if (!check_distance_bl(src, bl, range))
- return 0;
+ return false;
if(distance_bl(src, bl) < 2) //No need for path checking.
- return 1;
+ return true;
// ?瘧Q物判定
- return path_search_long(NULL,src->m,src->x,src->y,bl->x,bl->y);
+ return path_search_long(NULL,src->m,src->x,src->y,bl->x,bl->y,CELL_CHKWALL);
}
static const struct _battle_data {
diff --git a/src/map/battle.h b/src/map/battle.h
index a46592308..1b12dbd03 100644
--- a/src/map/battle.h
+++ b/src/map/battle.h
@@ -86,7 +86,7 @@ int battle_getcurrentskill(struct block_list *bl);
int battle_check_undead(int race,int element);
int battle_check_target(struct block_list *src, struct block_list *target,int flag);
-int battle_check_range(struct block_list *src,struct block_list *bl,int range);
+bool battle_check_range(struct block_list *src,struct block_list *bl,int range);
void battle_consume_ammo(struct map_session_data* sd, int skill, int lv);
// 設定
diff --git a/src/map/map.c b/src/map/map.c
index 26a8931e6..e3c5aacbe 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -14,6 +14,7 @@
#include "../common/utils.h"
#include "map.h"
+#include "path.h"
#include "chrif.h"
#include "clif.h"
#include "intif.h"
@@ -690,7 +691,7 @@ int map_foreachinshootrange(int (*func)(struct block_list*,va_list),struct block
#ifdef CIRCULAR_AREA
&& check_distance_bl(center, bl, range)
#endif
- && path_search_long(NULL,center->m,center->x,center->y,bl->x,bl->y)
+ && path_search_long(NULL,center->m,center->x,center->y,bl->x,bl->y,CELL_CHKWALL)
&& bl_list_count<BL_LIST_MAX)
bl_list[bl_list_count++]=bl;
}
@@ -707,7 +708,7 @@ int map_foreachinshootrange(int (*func)(struct block_list*,va_list),struct block
#ifdef CIRCULAR_AREA
&& check_distance_bl(center, bl, range)
#endif
- && path_search_long(NULL,center->m,center->x,center->y,bl->x,bl->y)
+ && path_search_long(NULL,center->m,center->x,center->y,bl->x,bl->y,CELL_CHKWALL)
&& bl_list_count<BL_LIST_MAX)
bl_list[bl_list_count++]=bl;
}
@@ -1123,7 +1124,7 @@ int map_foreachinpath(int (*func)(struct block_list*,va_list),int m,int x0,int y
if (k < 0 || k > len_limit) //Since more skills use this, check for ending point as well.
continue;
- if (k > magnitude2 && !path_search_long(NULL,m,x0,y0,xi,yi))
+ if (k > magnitude2 && !path_search_long(NULL,m,x0,y0,xi,yi,CELL_CHKWALL))
continue; //Targets beyond the initial ending point need the wall check.
//All these shifts are to increase the precision of the intersection point and distance considering how it's
@@ -1158,7 +1159,7 @@ int map_foreachinpath(int (*func)(struct block_list*,va_list),int m,int x0,int y
if (k < 0 || k > len_limit)
continue;
- if (k > magnitude2 && !path_search_long(NULL,m,x0,y0,xi,yi))
+ if (k > magnitude2 && !path_search_long(NULL,m,x0,y0,xi,yi,CELL_CHKWALL))
continue; //Targets beyond the initial ending point need the wall check.
k = (k<<4)/magnitude2; //k will be between 1~16 instead of 0~1
@@ -2194,7 +2195,6 @@ uint8 map_calc_dir(struct block_list* src, int x, int y)
*------------------------------------------*/
int map_random_dir(struct block_list *bl, short *x, short *y)
{
- struct walkpath_data wpd;
short xi = *x-bl->x;
short yi = *y-bl->y;
short i=0, j;
@@ -2210,10 +2210,9 @@ int map_random_dir(struct block_list *bl, short *x, short *y)
xi = bl->x + segment*dirx[j];
segment = (short)sqrt(dist2 - segment*segment); //The complement of the previously picked segment
yi = bl->y + segment*diry[j];
- } while ((
- map_getcell(bl->m,xi,yi,CELL_CHKNOPASS) ||
- path_search_real(&wpd,bl->m,bl->x,bl->y,xi,yi,1,CELL_CHKNOREACH) == -1)
- && (++i)<100);
+ } while (
+ (map_getcell(bl->m,xi,yi,CELL_CHKNOPASS) || !path_search(NULL,bl->m,bl->x,bl->y,xi,yi,1,CELL_CHKNOREACH))
+ && (++i)<100 );
if (i < 100) {
*x = xi;
diff --git a/src/map/map.h b/src/map/map.h
index 7aa99d219..6d06bc599 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -236,7 +236,7 @@ struct block_list {
};
struct walkpath_data {
- unsigned char path_len,path_pos,path_half;
+ unsigned char path_len,path_pos;
unsigned char path[MAX_WALKPATH];
};
struct shootpath_data {
@@ -1344,16 +1344,6 @@ int map_check_dir(int s_dir,int t_dir);
unsigned char map_calc_dir( struct block_list *src,int x,int y);
int map_random_dir(struct block_list *bl, short *x, short *y); // [Skotlex]
-// path.cより
-int path_search_real(struct walkpath_data *wpd,int m,int x0,int y0,int x1,int y1,int flag,cell_t flag2);
-#define path_search(wpd,m,x0,y0,x1,y1,flag) path_search_real(wpd,m,x0,y0,x1,y1,flag,CELL_CHKNOPASS)
-#define path_search2(wpd,m,x0,y0,x1,y1,flag) path_search_real(wpd,m,x0,y0,x1,y1,flag,CELL_CHKWALL)
-
-bool path_search_long_real(struct shootpath_data *spd,int m,int x0,int y0,int x1,int y1,cell_t flag);
-#define path_search_long(spd,m,x0,y0,x1,y1) path_search_long_real(spd,m,x0,y0,x1,y1,CELL_CHKWALL)
-
-int path_blownpos(int m,int x0,int y0,int dx,int dy,int count);
-
// distance related functions [Skotlex]
#define check_distance_bl(bl1, bl2, distance) check_distance((bl1)->x - (bl2)->x, (bl1)->y - (bl2)->y, distance)
#define check_distance_blxy(bl, x1, y1, distance) check_distance((bl)->x-(x1), (bl)->y-(y1), distance)
diff --git a/src/map/path.c b/src/map/path.c
index 3d4b99fc9..52dcd0ac8 100644
--- a/src/map/path.c
+++ b/src/map/path.c
@@ -7,14 +7,13 @@
#include "../common/malloc.h"
#include "map.h"
#include "battle.h"
+#include "path.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-//#define PATH_STANDALONETEST
-
#define MAX_HEAP 150
struct tmp_path { short x,y,dist,before,cost,flag;};
@@ -226,18 +225,22 @@ int path_blownpos(int m,int x0,int y0,int dx,int dy,int count)
x0+=dx;
y0+=dy;
}
- return (x0<<16)|y0;
+ return (x0<<16)|y0; //TODO: use 'struct point' here instead?
}
/*==========================================
* is ranged attack from (x0,y0) to (x1,y1) possible?
*------------------------------------------*/
-bool path_search_long_real(struct shootpath_data *spd,int m,int x0,int y0,int x1,int y1,cell_t flag)
+bool path_search_long(struct shootpath_data *spd,int m,int x0,int y0,int x1,int y1,cell_t cell)
{
int dx, dy;
int wx = 0, wy = 0;
int weight;
struct map_data *md;
+ struct shootpath_data s_spd;
+
+ if( spd == NULL )
+ spd = &s_spd; // use dummy output variable
if (!map[m].gat)
return false;
@@ -251,43 +254,41 @@ bool path_search_long_real(struct shootpath_data *spd,int m,int x0,int y0,int x1
}
dy = (y1 - y0);
- if (spd) {
- spd->rx = spd->ry = 0;
- spd->len = 1;
- spd->x[0] = x0;
- spd->y[0] = y0;
- }
+ spd->rx = spd->ry = 0;
+ spd->len = 1;
+ spd->x[0] = x0;
+ spd->y[0] = y0;
- if (map_getcellp(md,x1,y1,flag))
+ if (map_getcellp(md,x1,y1,cell))
return false;
if (dx > abs(dy)) {
weight = dx;
- if (spd)
- spd->ry=1;
+ spd->ry = 1;
} else {
weight = abs(y1 - y0);
- if (spd)
- spd->rx=1;
+ spd->rx = 1;
}
- while (x0 != x1 || y0 != y1) {
- if (map_getcellp(md,x0,y0,flag))
+ while (x0 != x1 || y0 != y1)
+ {
+ if (map_getcellp(md,x0,y0,cell))
return false;
wx += dx;
wy += dy;
if (wx >= weight) {
wx -= weight;
- x0 ++;
+ x0++;
}
if (wy >= weight) {
wy -= weight;
- y0 ++;
+ y0++;
} else if (wy < 0) {
wy += weight;
- y0 --;
+ y0--;
}
- if (spd && spd->len<MAX_WALKPATH) {
+ if( spd->len<MAX_WALKPATH )
+ {
spd->x[spd->len] = x0;
spd->y[spd->len] = y0;
spd->len++;
@@ -299,39 +300,48 @@ bool path_search_long_real(struct shootpath_data *spd,int m,int x0,int y0,int x1
/*==========================================
* path search (x0,y0)->(x1,y1)
+ * wpd: path info will be written here
* flag: &1 = easy path search only
+ * cell: type of obstruction to check for
*------------------------------------------*/
-int path_search_real(struct walkpath_data *wpd,int m,int x0,int y0,int x1,int y1,int flag,cell_t flag2)
+bool path_search(struct walkpath_data *wpd,int m,int x0,int y0,int x1,int y1,int flag,cell_t cell)
{
int heap[MAX_HEAP+1];
struct tmp_path tp[MAX_WALKPATH*MAX_WALKPATH];
- register int i,x,y,dx,dy;
+ register int i,j,len,x,y,dx,dy;
int rp,xs,ys;
struct map_data *md;
+ struct walkpath_data s_wpd;
- nullpo_retr(0, wpd);
+ if( wpd == NULL )
+ wpd = &s_wpd; // use dummy output variable
if( !map[m].gat )
- return -1;
+ return false;
md = &map[m];
+
#ifdef CELL_NOSTACK
//Do not check starting cell as that would get you stuck.
if( x0 < 0 || x0 >= md->xs || y0 < 0 || y0 >= md->ys )
#else
- if( x0 < 0 || x0 >= md->xs || y0 < 0 || y0 >= md->ys /*|| map_getcellp(md,x0,y0,flag2)*/ )
+ if( x0 < 0 || x0 >= md->xs || y0 < 0 || y0 >= md->ys /*|| map_getcellp(md,x0,y0,cell)*/ )
#endif
- return -1;
- if( x1 < 0 || x1 >= md->xs || y1 < 0 || y1 >= md->ys || map_getcellp(md,x1,y1,flag2) )
- return -1;
+ return false;
+ if( x1 < 0 || x1 >= md->xs || y1 < 0 || y1 >= md->ys || map_getcellp(md,x1,y1,cell) )
+ return false;
// calculate (sgn(x1-x0), sgn(y1-y0))
dx = ((dx = x1-x0)) ? ((dx<0) ? -1 : 1) : 0;
dy = ((dy = y1-y0)) ? ((dy<0) ? -1 : 1) : 0;
// try finding direct path to target
- for( x = x0, y = y0, i = 0; i < ARRAYLENGTH(wpd->path); )
+ x = x0;
+ y = y0;
+ i = 0;
+ while( i < ARRAYLENGTH(wpd->path) )
{
- wpd->path[i++] = walk_choices[-dy + 1][dx + 1];
+ wpd->path[i] = walk_choices[-dy + 1][dx + 1];
+ i++;
x += dx;
y += dy;
@@ -339,9 +349,9 @@ int path_search_real(struct walkpath_data *wpd,int m,int x0,int y0,int x1,int y1
if( x == x1 ) dx = 0;
if( y == y1 ) dy = 0;
- if( !dx && !dy )
+ if( dx == 0 && dy == 0 )
break; // success
- if( map_getcellp(md,x,y,flag2) )
+ if( map_getcellp(md,x,y,cell) )
break; // obstacle = failure
}
@@ -349,12 +359,11 @@ int path_search_real(struct walkpath_data *wpd,int m,int x0,int y0,int x1,int y1
{ //easy path successful.
wpd->path_len = i;
wpd->path_pos = 0;
- wpd->path_half = 0;
- return 0;
+ return true;
}
if( flag&1 )
- return -1;
+ return false;
memset(tp,0,sizeof(tp));
@@ -369,94 +378,78 @@ int path_search_real(struct walkpath_data *wpd,int m,int x0,int y0,int x1,int y1
push_heap_path(heap,tp,calc_index(x0,y0));
xs = md->xs-1; // あらかじめ1減算しておく
ys = md->ys-1;
- while(1){
+
+ while(1)
+ {
int e=0,f=0,dist,cost,dc[4]={0,0,0,0};
if(heap[0]==0)
- return -1;
+ return false;
rp = pop_heap_path(heap,tp);
x = tp[rp].x;
y = tp[rp].y;
dist = tp[rp].dist + 10;
cost = tp[rp].cost;
- if(x==x1 && y==y1) break;
+
+ if(x==x1 && y==y1)
+ break;
// dc[0] : y++ の時のコスト増分
// dc[1] : x-- の時のコスト増分
// dc[2] : y-- の時のコスト増分
// dc[3] : x++ の時のコスト増分
- if(y < ys && !map_getcellp(md,x ,y+1,flag2)) {
+ if(y < ys && !map_getcellp(md,x ,y+1,cell)) {
f |= 1; dc[0] = (y >= y1 ? 20 : 0);
e+=add_path(heap,tp,x ,y+1,dist,rp,cost+dc[0]); // (x, y+1)
}
- if(x > 0 && !map_getcellp(md,x-1,y ,flag2)) {
+ if(x > 0 && !map_getcellp(md,x-1,y ,cell)) {
f |= 2; dc[1] = (x <= x1 ? 20 : 0);
e+=add_path(heap,tp,x-1,y ,dist,rp,cost+dc[1]); // (x-1, y )
}
- if(y > 0 && !map_getcellp(md,x ,y-1,flag2)) {
+ if(y > 0 && !map_getcellp(md,x ,y-1,cell)) {
f |= 4; dc[2] = (y <= y1 ? 20 : 0);
e+=add_path(heap,tp,x ,y-1,dist,rp,cost+dc[2]); // (x , y-1)
}
- if(x < xs && !map_getcellp(md,x+1,y ,flag2)) {
+ if(x < xs && !map_getcellp(md,x+1,y ,cell)) {
f |= 8; dc[3] = (x >= x1 ? 20 : 0);
e+=add_path(heap,tp,x+1,y ,dist,rp,cost+dc[3]); // (x+1, y )
}
- if( (f & (2+1)) == (2+1) && !map_getcellp(md,x-1,y+1,flag2))
+ if( (f & (2+1)) == (2+1) && !map_getcellp(md,x-1,y+1,cell))
e+=add_path(heap,tp,x-1,y+1,dist+4,rp,cost+dc[1]+dc[0]-6); // (x-1, y+1)
- if( (f & (2+4)) == (2+4) && !map_getcellp(md,x-1,y-1,flag2))
+ if( (f & (2+4)) == (2+4) && !map_getcellp(md,x-1,y-1,cell))
e+=add_path(heap,tp,x-1,y-1,dist+4,rp,cost+dc[1]+dc[2]-6); // (x-1, y-1)
- if( (f & (8+4)) == (8+4) && !map_getcellp(md,x+1,y-1,flag2))
+ if( (f & (8+4)) == (8+4) && !map_getcellp(md,x+1,y-1,cell))
e+=add_path(heap,tp,x+1,y-1,dist+4,rp,cost+dc[3]+dc[2]-6); // (x+1, y-1)
- if( (f & (8+1)) == (8+1) && !map_getcellp(md,x+1,y+1,flag2))
+ if( (f & (8+1)) == (8+1) && !map_getcellp(md,x+1,y+1,cell))
e+=add_path(heap,tp,x+1,y+1,dist+4,rp,cost+dc[3]+dc[0]-6); // (x+1, y+1)
tp[rp].flag=1;
if(e || heap[0]>=MAX_HEAP-5)
- return -1;
+ return false;
}
- if(x==x1 && y==y1) {
- int len,j;
-
- for(len=0,i=rp;len<100 && i!=calc_index(x0,y0);i=tp[i].before,len++);
- if(len==100 || len>=sizeof(wpd->path))
- return -1;
- wpd->path_len=len;
- wpd->path_pos=0;
- wpd->path_half=0;
- for(i=rp,j=len-1;j>=0;i=tp[i].before,j--) {
- int dx = tp[i].x - tp[tp[i].before].x;
- int dy = tp[i].y - tp[tp[i].before].y;
- int dir;
- if( dx == 0 ) {
- dir = (dy > 0 ? 0 : 4);
- } else if( dx > 0 ) {
- dir = (dy == 0 ? 6 : (dy < 0 ? 5 : 7) );
- } else {
- dir = (dy == 0 ? 2 : (dy > 0 ? 1 : 3) );
- }
- wpd->path[j] = dir;
- }
-#if 0
- // test
- {
- int dirx[8]={0,-1,-1,-1,0,1,1,1};
- int diry[8]={1,1,0,-1,-1,-1,0,1};
- x = x0; y = y0;
- for(i = 0; i < wpd->path_len; i++) {
- x += dirx[ wpd->path[i] ];
- y += diry[ wpd->path[i] ];
- if( map_getcellp(md,x,y,flag2) ) {
- printf("path_search_real: cannot move(%d, %d)\n", x, y);
- return -1;
- }
- }
- if( x != x1 || y != y1 ) {
- printf("path_search_real: dest position is wrong. ok:(%d, %d) ng:(%d,%d)\n", x1, y1, x, y);
- return -1;
- }
+
+ if( !(x==x1 && y==y1) ) // will never happen...
+ return false;
+
+ for(len=0,i=rp;len<100 && i!=calc_index(x0,y0);i=tp[i].before,len++);
+ if(len==100 || len>=sizeof(wpd->path))
+ return false;
+
+ wpd->path_len = len;
+ wpd->path_pos = 0;
+ for(i=rp,j=len-1;j>=0;i=tp[i].before,j--) {
+ int dx = tp[i].x - tp[tp[i].before].x;
+ int dy = tp[i].y - tp[tp[i].before].y;
+ int dir;
+ if( dx == 0 ) {
+ dir = (dy > 0 ? 0 : 4);
+ } else if( dx > 0 ) {
+ dir = (dy == 0 ? 6 : (dy < 0 ? 5 : 7) );
+ } else {
+ dir = (dy == 0 ? 2 : (dy > 0 ? 1 : 3) );
}
-#endif
- return 0;
+ wpd->path[j] = dir;
}
- return -1;
+
+ return true;
}
diff --git a/src/map/skill.c b/src/map/skill.c
index f3709e93a..a54ff032a 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -12,6 +12,7 @@
#include "skill.h"
#include "map.h"
+#include "path.h"
#include "clif.h"
#include "pc.h"
#include "status.h"
@@ -2331,7 +2332,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, int
case KN_CHARGEATK:
{
- bool path = path_search_long(NULL, src->m, src->x, src->y, bl->x, bl->y);
+ bool path = path_search_long(NULL, src->m, src->x, src->y, bl->x, bl->y,CELL_CHKWALL);
unsigned int dist = distance_bl(src, bl);
unsigned int dir = map_calc_dir(bl, src->x, src->y);
@@ -6407,7 +6408,7 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, short skilli
if(alive && map_getcell(src->m,ux,uy,CELL_CHKWALL))
alive = 0;
- if(alive && battle_config.skill_wall_check && !path_search_long(NULL,src->m,ux,uy,x,y))
+ if( alive && battle_config.skill_wall_check && !path_search_long(NULL,src->m,ux,uy,x,y,CELL_CHKWALL) )
alive = 0; //no path between cell and center of casting.
if(alive && skillid == WZ_ICEWALL) {
diff --git a/src/map/unit.c b/src/map/unit.c
index a101a5160..6e0eed53c 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -8,6 +8,7 @@
#include "../common/malloc.h"
#include "unit.h"
#include "map.h"
+#include "path.h"
#include "pc.h"
#include "mob.h"
#include "pet.h"
@@ -58,7 +59,7 @@ int unit_walktoxy_sub(struct block_list *bl)
ud = unit_bl2ud(bl);
if(ud == NULL) return 0;
- if(path_search(&wpd,bl->m,bl->x,bl->y,ud->to_x,ud->to_y,ud->state.walk_easy))
+ if( !path_search(&wpd,bl->m,bl->x,bl->y,ud->to_x,ud->to_y,ud->state.walk_easy,CELL_CHKNOPASS) )
return 0;
memcpy(&ud->walkpath,&wpd,sizeof(wpd));
@@ -472,7 +473,6 @@ int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool
uint8 dir;
struct unit_data *ud = NULL;
struct map_session_data *sd = NULL;
- struct walkpath_data wpd;
nullpo_retr(0, bl);
if( BL_CAST( BL_PC, bl, sd ) ) {
@@ -485,8 +485,8 @@ int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool
unit_stop_walking(bl,1);
unit_stop_attack(bl);
- if(checkpath && (map_getcell(bl->m,dst_x,dst_y, CELL_CHKNOPASS) || path_search_real(&wpd,bl->m,bl->x,bl->y,dst_x,dst_y,easy, CELL_CHKNOREACH)))
- return 0;
+ if( checkpath && (map_getcell(bl->m,dst_x,dst_y,CELL_CHKNOPASS) || !path_search(NULL,bl->m,bl->x,bl->y,dst_x,dst_y,easy,CELL_CHKNOREACH)) )
+ return 0; // unreachable
dir = map_calc_dir(bl, dst_x,dst_y);
ud->dir = dir;
@@ -513,7 +513,7 @@ int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool
{ //Check if pet needs to be teleported. [Skotlex]
int flag = 0;
struct block_list* bl = &sd->pd->bl;
- if (!checkpath && path_search(&wpd,bl->m,bl->x,bl->y,dst_x,dst_y,0))
+ if( !checkpath && !path_search(NULL,bl->m,bl->x,bl->y,dst_x,dst_y,0,CELL_CHKNOPASS) )
flag = 1;
else if (!check_distance_bl(&sd->bl, bl, AREA_SIZE)) //Too far, teleport.
flag = 2;
@@ -1273,46 +1273,35 @@ int unit_cancel_combo(struct block_list *bl)
/*==========================================
*
*------------------------------------------*/
-int unit_can_reach_pos(struct block_list *bl,int x,int y, int easy)
+bool unit_can_reach_pos(struct block_list *bl,int x,int y, int easy)
{
- struct walkpath_data wpd;
-
- nullpo_retr(0, bl);
+ nullpo_retr(false, bl);
if( bl->x==x && bl->y==y ) // 同じマス
- return 1;
+ return true;
- // 障害物判定
- wpd.path_len=0;
- wpd.path_pos=0;
- wpd.path_half=0;
- return (path_search_real(&wpd,bl->m,bl->x,bl->y,x,y,easy,CELL_CHKNOREACH)!=-1);
+ return path_search(NULL,bl->m,bl->x,bl->y,x,y,easy,CELL_CHKNOREACH);
}
/*==========================================
*
*------------------------------------------*/
-int unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range, int easy, short *x, short *y)
+bool unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range, int easy, short *x, short *y)
{
- struct walkpath_data wpd;
int i;
short dx,dy;
- nullpo_retr(0, bl);
- nullpo_retr(0, tbl);
+ nullpo_retr(false, bl);
+ nullpo_retr(false, tbl);
if( bl->m != tbl->m)
- return 0;
+ return false;
if( bl->x==tbl->x && bl->y==tbl->y )
- return 1;
+ return true;
if(range>0 && !check_distance_bl(bl, tbl, range))
- return 0;
+ return false;
- wpd.path_len=0;
- wpd.path_pos=0;
- wpd.path_half=0;
-
// It judges whether it can adjoin or not.
dx=tbl->x - bl->x;
dy=tbl->y - bl->y;
@@ -1322,14 +1311,14 @@ int unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range, i
if (map_getcell(tbl->m,tbl->x-dx,tbl->y-dy,CELL_CHKNOPASS))
{ //Look for a suitable cell to place in.
for(i=0;i<9 && map_getcell(tbl->m,tbl->x-dirx[i],tbl->y-diry[i],CELL_CHKNOPASS);i++);
- if (i==9) return 0; //No valid cells.
+ if (i==9) return false; //No valid cells.
dx = dirx[i];
dy = diry[i];
}
if (x) *x = tbl->x-dx;
if (y) *y = tbl->y-dy;
- return (path_search_real(&wpd,bl->m,bl->x,bl->y,tbl->x-dx,tbl->y-dy,easy,CELL_CHKNOREACH)!=-1);
+ return path_search(NULL,bl->m,bl->x,bl->y,tbl->x-dx,tbl->y-dy,easy,CELL_CHKNOREACH);
}
diff --git a/src/map/unit.h b/src/map/unit.h
index 6c6124f5c..2c569607d 100644
--- a/src/map/unit.h
+++ b/src/map/unit.h
@@ -34,8 +34,8 @@ int unit_setdir(struct block_list *bl,unsigned char dir);
uint8 unit_getdir(struct block_list *bl);
// そこまで歩行でたどり着けるかの判定
-int unit_can_reach_pos(struct block_list *bl,int x,int y,int easy);
-int unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range, int easy, short *x, short *y);
+bool unit_can_reach_pos(struct block_list *bl,int x,int y,int easy);
+bool unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range, int easy, short *x, short *y);
// 攻撃関連
int unit_stop_attack(struct block_list *bl);
diff --git a/vcproj-6/map-server_sql.dsp b/vcproj-6/map-server_sql.dsp
index f18eda8c6..a80ded6f1 100644
--- a/vcproj-6/map-server_sql.dsp
+++ b/vcproj-6/map-server_sql.dsp
@@ -351,6 +351,10 @@ SOURCE=..\src\map\path.c
# End Source File
# Begin Source File
+SOURCE=..\src\map\path.h
+# End Source File
+# Begin Source File
+
SOURCE=..\src\map\pc.c
# End Source File
# Begin Source File
diff --git a/vcproj-6/map-server_txt.dsp b/vcproj-6/map-server_txt.dsp
index 9cf688678..2f56c5a62 100644
--- a/vcproj-6/map-server_txt.dsp
+++ b/vcproj-6/map-server_txt.dsp
@@ -379,6 +379,10 @@ SOURCE=..\src\map\party.h
# End Source File
# Begin Source File
+SOURCE=..\src\map\path.h
+# End Source File
+# Begin Source File
+
SOURCE=..\src\map\pc.h
# End Source File
# Begin Source File
diff --git a/vcproj-7.1/map-server_sql.vcproj b/vcproj-7.1/map-server_sql.vcproj
index ff3662304..7b6329f0d 100644
--- a/vcproj-7.1/map-server_sql.vcproj
+++ b/vcproj-7.1/map-server_sql.vcproj
@@ -259,6 +259,9 @@
RelativePath="..\src\map\path.c">
</File>
<File
+ RelativePath="..\src\map\path.h">
+ </File>
+ <File
RelativePath="..\src\map\pc.c">
</File>
<File
diff --git a/vcproj-7.1/map-server_txt.vcproj b/vcproj-7.1/map-server_txt.vcproj
index c4220e0aa..899268ebd 100644
--- a/vcproj-7.1/map-server_txt.vcproj
+++ b/vcproj-7.1/map-server_txt.vcproj
@@ -259,6 +259,9 @@
RelativePath="..\src\map\path.c">
</File>
<File
+ RelativePath="..\src\map\path.h">
+ </File>
+ <File
RelativePath="..\src\map\pc.c">
</File>
<File
diff --git a/vcproj-8/map-server_sql.vcproj b/vcproj-8/map-server_sql.vcproj
index 913422ea2..d1cd17c8c 100644
--- a/vcproj-8/map-server_sql.vcproj
+++ b/vcproj-8/map-server_sql.vcproj
@@ -509,6 +509,10 @@
>
</File>
<File
+ RelativePath="..\src\map\path.h"
+ >
+ </File>
+ <File
RelativePath="..\src\map\pc.c"
>
</File>
diff --git a/vcproj-8/map-server_txt.vcproj b/vcproj-8/map-server_txt.vcproj
index 57e557e1f..24069e35c 100644
--- a/vcproj-8/map-server_txt.vcproj
+++ b/vcproj-8/map-server_txt.vcproj
@@ -357,6 +357,10 @@
>
</File>
<File
+ RelativePath="..\src\map\path.h"
+ >
+ </File>
+ <File
RelativePath="..\src\map\pc.c"
>
</File>