summaryrefslogtreecommitdiff
path: root/src/map/map.c
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-12-22 13:00:48 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-12-22 13:00:48 +0000
commitebf1cd085c9f4061318f99f9ab19b63148d19819 (patch)
tree876e3d2c2bc05cbce67604eaa734a741410fb3bf /src/map/map.c
parent5f857bae116433a2a0fd38b8c3539352c5453f7a (diff)
downloadhercules-ebf1cd085c9f4061318f99f9ab19b63148d19819.tar.gz
hercules-ebf1cd085c9f4061318f99f9ab19b63148d19819.tar.bz2
hercules-ebf1cd085c9f4061318f99f9ab19b63148d19819.tar.xz
hercules-ebf1cd085c9f4061318f99f9ab19b63148d19819.zip
Path code cleaning...
* Added map/path.h, moved path-related function headers to path.h. * Removed the macroed _real() path functions. * Modified some functions to use boolean return values instead of 1/0 or 0/-1. * Modified path_search_long() to allow a NULL output pointer (in which case a temporary local buffer will be used instead). * Removed an unused ->path_half member variable from struct walkpath_data. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11958 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/map.c')
-rw-r--r--src/map/map.c17
1 files changed, 8 insertions, 9 deletions
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;