summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-09-24 15:32:41 +0300
committerAndrei Karas <akaras@inbox.ru>2015-09-24 15:33:09 +0300
commit7a867315dac6aaf78a4d61ea67174820a4d30c59 (patch)
treed08ace6759528a25ed9e124724309e4d0832dc1b
parentf94190251bc199582d819fefa448b32a662a297a (diff)
downloadhercules-7a867315dac6aaf78a4d61ea67174820a4d30c59.tar.gz
hercules-7a867315dac6aaf78a4d61ea67174820a4d30c59.tar.bz2
hercules-7a867315dac6aaf78a4d61ea67174820a4d30c59.tar.xz
hercules-7a867315dac6aaf78a4d61ea67174820a4d30c59.zip
Add bl parameter to closest_freecell.
-rw-r--r--src/map/map.c10
-rw-r--r--src/map/map.h2
-rw-r--r--src/map/unit.c2
3 files changed, 7 insertions, 7 deletions
diff --git a/src/map/map.c b/src/map/map.c
index cd0f516ed..ddb5ace42 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -1511,7 +1511,7 @@ int map_search_freecell(struct block_list *src, int16 m, int16 *x,int16 *y, int1
* flag:
* 0x1 - only count standing units
*------------------------------------------*/
-bool map_closest_freecell(int16 m, int16 *x, int16 *y, int type, int flag)
+bool map_closest_freecell(int16 m, const struct block_list *bl, int16 *x, int16 *y, int type, int flag)
{
uint8 dir = 6;
int16 tx = *x;
@@ -1530,7 +1530,7 @@ bool map_closest_freecell(int16 m, int16 *x, int16 *y, int type, int flag)
if(dir%2 == 0 && costrange%MOVE_COST == 0) {
tx = *x+dx*(costrange/MOVE_COST);
ty = *y+dy*(costrange/MOVE_COST);
- if (!map->count_oncell(m, tx, ty, type, flag) && map->getcell(m, NULL, tx, ty, CELL_CHKPASS)) {
+ if (!map->count_oncell(m, tx, ty, type, flag) && map->getcell(m, bl, tx, ty, CELL_CHKPASS)) {
*x = tx;
*y = ty;
return true;
@@ -1540,7 +1540,7 @@ bool map_closest_freecell(int16 m, int16 *x, int16 *y, int type, int flag)
else if(dir%2 == 1 && costrange%MOVE_DIAGONAL_COST == 0) {
tx = *x+dx*(costrange/MOVE_DIAGONAL_COST);
ty = *y+dy*(costrange/MOVE_DIAGONAL_COST);
- if (!map->count_oncell(m, tx, ty, type, flag) && map->getcell(m, NULL, tx, ty, CELL_CHKPASS)) {
+ if (!map->count_oncell(m, tx, ty, type, flag) && map->getcell(m, bl, tx, ty, CELL_CHKPASS)) {
*x = tx;
*y = ty;
return true;
@@ -1550,14 +1550,14 @@ bool map_closest_freecell(int16 m, int16 *x, int16 *y, int type, int flag)
else if(dir%2 == 1 && costrange%MOVE_COST == 4) {
tx = *x+dx*((dir%4==3)?(costrange/MOVE_COST):1);
ty = *y+dy*((dir%4==1)?(costrange/MOVE_COST):1);
- if (!map->count_oncell(m, tx, ty, type, flag) && map->getcell(m, NULL, tx, ty, CELL_CHKPASS)) {
+ if (!map->count_oncell(m, tx, ty, type, flag) && map->getcell(m, bl, tx, ty, CELL_CHKPASS)) {
*x = tx;
*y = ty;
return true;
}
tx = *x+dx*((dir%4==1)?(costrange/MOVE_COST):1);
ty = *y+dy*((dir%4==3)?(costrange/MOVE_COST):1);
- if (!map->count_oncell(m, tx, ty, type, flag) && map->getcell(m, NULL, tx, ty, CELL_CHKPASS)) {
+ if (!map->count_oncell(m, tx, ty, type, flag) && map->getcell(m, bl, tx, ty, CELL_CHKPASS)) {
*x = tx;
*y = ty;
return true;
diff --git a/src/map/map.h b/src/map/map.h
index caff2cfc8..dc970a5a3 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -946,7 +946,7 @@ END_ZEROED_BLOCK;
// search and creation
int (*get_new_object_id) (void);
int (*search_freecell) (struct block_list *src, int16 m, int16 *x, int16 *y, int16 rx, int16 ry, int flag);
- bool (*closest_freecell) (int16 m, int16 *x, int16 *y, int type, int flag);
+ bool (*closest_freecell) (int16 m, const struct block_list *bl, int16 *x, int16 *y, int type, int flag);
//
int (*quit) (struct map_session_data *sd);
// npc
diff --git a/src/map/unit.c b/src/map/unit.c
index 2d8776d53..04a8befc2 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -494,7 +494,7 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag)
if( ud == NULL) return 0;
- if (battle_config.check_occupied_cells && (flag&8) && !map->closest_freecell(bl->m, &x, &y, BL_CHAR|BL_NPC, 1)) //This might change x and y
+ if (battle_config.check_occupied_cells && (flag&8) && !map->closest_freecell(bl->m, bl, &x, &y, BL_CHAR|BL_NPC, 1)) //This might change x and y
return 0;
if (!path->search(&wpd, bl, bl->m, bl->x, bl->y, x, y, flag&1, CELL_CHKNOPASS)) // Count walk path cells