summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/map/map.c260
-rw-r--r--src/map/map.h21
-rw-r--r--src/map/script.c16
-rw-r--r--src/map/unit.c6
4 files changed, 100 insertions, 203 deletions
diff --git a/src/map/map.c b/src/map/map.c
index c57f76987..0a7bd952d 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -310,7 +310,6 @@ int map_addblock_sub (struct block_list *bl, int flag)
bl->prev = &bl_head;
if (bl->next) bl->next->prev = bl;
map[m].block_mob[pos] = bl;
- map[m].block_mob_count[pos]++;
} else {
if (bl->type == BL_PC && flag)
{
@@ -331,7 +330,6 @@ int map_addblock_sub (struct block_list *bl, int flag)
bl->prev = &bl_head;
if (bl->next) bl->next->prev = bl;
map[m].block[pos] = bl;
- map[m].block_count[pos]++;
}
#ifdef CELL_NOSTACK
@@ -376,12 +374,8 @@ int map_delblock_sub (struct block_list *bl, int flag)
// リストの頭なので、map[]のblock_listを更新する
if (bl->type == BL_MOB) {
map[bl->m].block_mob[b] = bl->next;
- if ((map[bl->m].block_mob_count[b]--) < 0)
- map[bl->m].block_mob_count[b] = 0;
} else {
map[bl->m].block[b] = bl->next;
- if((map[bl->m].block_count[b]--) < 0)
- map[bl->m].block_count[b] = 0;
}
} else {
bl->prev->next = bl->next;
@@ -458,41 +452,12 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick)
}
/*==========================================
- * 周?のPC人?を?える (unused)
- *------------------------------------------*/
-int map_countnearpc (int m, int x, int y)
-{
- int bx, by, c = 0;
- struct block_list *bl=NULL;
-
- if (map[m].users == 0)
- return 0;
- for (by = y/BLOCK_SIZE-AREA_SIZE/BLOCK_SIZE-1; by<=y/BLOCK_SIZE+AREA_SIZE/BLOCK_SIZE+1; by++) {
- if (by < 0 || by >= map[m].bys)
- continue;
- for (bx = x/BLOCK_SIZE-AREA_SIZE/BLOCK_SIZE-1; bx <= x/BLOCK_SIZE+AREA_SIZE/BLOCK_SIZE+1; bx++) {
- if (bx < 0 || bx >= map[m].bxs)
- continue;
- bl = map[m].block[bx+by*map[m].bxs];
- while(bl) {
- if (bl->type == BL_PC)
- c++;
- bl = bl->next;
- }
- }
- }
-
- return c;
-}
-
-/*==========================================
* Counts specified number of objects on given cell.
*------------------------------------------*/
int map_count_oncell(int m, int x, int y, int type)
{
int bx,by;
- struct block_list *bl=NULL;
- int i,c;
+ struct block_list *bl;
int count = 0;
if (x < 0 || y < 0 || (x >= map[m].xs) || (y >= map[m].ys))
@@ -502,20 +467,15 @@ int map_count_oncell(int m, int x, int y, int type)
by = y/BLOCK_SIZE;
if (type&~BL_MOB)
- {
- bl = map[m].block[bx+by*map[m].bxs];
- c = map[m].block_count[bx+by*map[m].bxs];
- for(i=0;i<c && bl;i++,bl=bl->next)
- if(bl->x == x && bl->y == y && bl->type&type) count++;
- }
+ for( bl = map[m].block[bx+by*map[m].bxs] ; bl != NULL ; bl = bl->next )
+ if(bl->x == x && bl->y == y && bl->type&type)
+ count++;
if (type&BL_MOB)
- {
- bl = map[m].block_mob[bx+by*map[m].bxs];
- c = map[m].block_mob_count[bx+by*map[m].bxs];
- for(i=0;i<c && bl;i++,bl=bl->next)
- if(bl->x == x && bl->y == y) count++;
- }
+ for( bl = map[m].block_mob[bx+by*map[m].bxs] ; bl != NULL ; bl = bl->next )
+ if(bl->x == x && bl->y == y)
+ count++;
+
return count;
}
/*
@@ -525,23 +485,21 @@ struct skill_unit *map_find_skill_unit_oncell(struct block_list *target,int x,in
{
int m,bx,by;
struct block_list *bl;
- int i,c;
struct skill_unit *unit;
m = target->m;
if (x < 0 || y < 0 || (x >= map[m].xs) || (y >= map[m].ys))
return NULL;
+
bx = x/BLOCK_SIZE;
by = y/BLOCK_SIZE;
- bl = map[m].block[bx+by*map[m].bxs];
- c = map[m].block_count[bx+by*map[m].bxs];
- for(i=0;i<c && bl;i++,bl=bl->next){
+ for( bl = map[m].block[bx+by*map[m].bxs] ; bl != NULL ; bl = bl->next )
+ {
if (bl->x != x || bl->y != y || bl->type != BL_SKILL)
continue;
unit = (struct skill_unit *) bl;
- if (unit==out_unit || !unit->alive ||
- !unit->group || unit->group->skill_id!=skill_id)
+ if (unit==out_unit || !unit->alive || !unit->group || unit->group->skill_id!=skill_id)
continue;
if (battle_check_target(&unit->bl,target,unit->group->target_flag)>0)
return unit;
@@ -557,8 +515,8 @@ int map_foreachinrange(int (*func)(struct block_list*,va_list), struct block_lis
va_list ap;
int bx,by,m;
int returnCount =0; //total sum of returned values of func() [Skotlex]
- struct block_list *bl=NULL;
- int blockcount=bl_list_count,i,c;
+ struct block_list *bl;
+ int blockcount=bl_list_count,i;
int x0,x1,y0,y1;
va_start(ap,type);
@@ -570,11 +528,10 @@ int map_foreachinrange(int (*func)(struct block_list*,va_list), struct block_lis
if (type&~BL_MOB)
for (by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++) {
- for(bx=x0/BLOCK_SIZE;bx<=x1/BLOCK_SIZE;bx++){
- bl = map[m].block[bx+by*map[m].bxs];
- c = map[m].block_count[bx+by*map[m].bxs];
- for(i=0;i<c && bl;i++,bl=bl->next){
- if(bl && bl->type&type
+ for(bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++) {
+ for( bl = map[m].block[bx+by*map[m].bxs] ; bl != NULL ; bl = bl->next )
+ {
+ if( bl->type&type
&& bl->x>=x0 && bl->x<=x1 && bl->y>=y0 && bl->y<=y1
#ifdef CIRCULAR_AREA
&& check_distance_bl(center, bl, range)
@@ -587,11 +544,9 @@ int map_foreachinrange(int (*func)(struct block_list*,va_list), struct block_lis
if(type&BL_MOB)
for(by=y0/BLOCK_SIZE;by<=y1/BLOCK_SIZE;by++){
for(bx=x0/BLOCK_SIZE;bx<=x1/BLOCK_SIZE;bx++){
- bl = map[m].block_mob[bx+by*map[m].bxs];
- c = map[m].block_mob_count[bx+by*map[m].bxs];
- for(i=0;i<c && bl;i++,bl=bl->next){
- if(bl
- && bl->x>=x0 && bl->x<=x1 && bl->y>=y0 && bl->y<=y1
+ for( bl = map[m].block_mob[bx+by*map[m].bxs] ; bl != NULL ; bl = bl->next )
+ {
+ if( bl->x>=x0 && bl->x<=x1 && bl->y>=y0 && bl->y<=y1
#ifdef CIRCULAR_AREA
&& check_distance_bl(center, bl, range)
#endif
@@ -625,12 +580,14 @@ int map_foreachinshootrange(int (*func)(struct block_list*,va_list),struct block
va_list ap;
int bx,by,m;
int returnCount =0; //total sum of returned values of func() [Skotlex]
- struct block_list *bl=NULL;
- int blockcount=bl_list_count,i,c;
+ struct block_list *bl;
+ int blockcount=bl_list_count,i;
int x0,x1,y0,y1;
+
m = center->m;
if (m < 0)
return 0;
+
va_start(ap,type);
x0 = max(center->x-range, 0);
@@ -639,12 +596,11 @@ int map_foreachinshootrange(int (*func)(struct block_list*,va_list),struct block
y1 = min(center->y+range, map[m].ys-1);
if (type&~BL_MOB)
- for (by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++) {
- for(bx=x0/BLOCK_SIZE;bx<=x1/BLOCK_SIZE;bx++){
- bl = map[m].block[bx+by*map[m].bxs];
- c = map[m].block_count[bx+by*map[m].bxs];
- for(i=0;i<c && bl;i++,bl=bl->next){
- if(bl && bl->type&type
+ for(by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++) {
+ for(bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++) {
+ for( bl = map[m].block[bx+by*map[m].bxs] ; bl != NULL ; bl = bl->next )
+ {
+ if( bl->type&type
&& bl->x>=x0 && bl->x<=x1 && bl->y>=y0 && bl->y<=y1
#ifdef CIRCULAR_AREA
&& check_distance_bl(center, bl, range)
@@ -658,11 +614,9 @@ int map_foreachinshootrange(int (*func)(struct block_list*,va_list),struct block
if(type&BL_MOB)
for(by=y0/BLOCK_SIZE;by<=y1/BLOCK_SIZE;by++){
for(bx=x0/BLOCK_SIZE;bx<=x1/BLOCK_SIZE;bx++){
- bl = map[m].block_mob[bx+by*map[m].bxs];
- c = map[m].block_mob_count[bx+by*map[m].bxs];
- for(i=0;i<c && bl;i++,bl=bl->next){
- if(bl
- && bl->x>=x0 && bl->x<=x1 && bl->y>=y0 && bl->y<=y1
+ for( bl = map[m].block_mob[bx+by*map[m].bxs] ; bl != NULL ; bl = bl->next )
+ {
+ if( bl->x>=x0 && bl->x<=x1 && bl->y>=y0 && bl->y<=y1
#ifdef CIRCULAR_AREA
&& check_distance_bl(center, bl, range)
#endif
@@ -699,8 +653,8 @@ int map_foreachinarea(int (*func)(struct block_list*,va_list), int m, int x0, in
va_list ap;
int bx,by;
int returnCount =0; //total sum of returned values of func() [Skotlex]
- struct block_list *bl=NULL;
- int blockcount=bl_list_count,i,c;
+ struct block_list *bl;
+ int blockcount=bl_list_count,i;
if (m < 0)
return 0;
@@ -723,27 +677,18 @@ int map_foreachinarea(int (*func)(struct block_list*,va_list), int m, int x0, in
if (y1 >= map[m].ys) y1 = map[m].ys-1;
if (type&~BL_MOB)
- for (by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++) {
- for(bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++) {
- bl = map[m].block[bx+by*map[m].bxs];
- c = map[m].block_count[bx+by*map[m].bxs];
- for(i=0;i<c && bl;i++,bl=bl->next){
- if(bl && bl->type&type && bl->x>=x0 && bl->x<=x1 && bl->y>=y0 && bl->y<=y1 && bl_list_count<BL_LIST_MAX)
+ for(by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++)
+ for(bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++)
+ for( bl = map[m].block[bx+by*map[m].bxs] ; bl != NULL ; bl = bl->next )
+ if(bl->type&type && bl->x>=x0 && bl->x<=x1 && bl->y>=y0 && bl->y<=y1 && bl_list_count<BL_LIST_MAX)
bl_list[bl_list_count++]=bl;
- }
- }
- }
+
if(type&BL_MOB)
- for(by=y0/BLOCK_SIZE;by<=y1/BLOCK_SIZE;by++){
- for(bx=x0/BLOCK_SIZE;bx<=x1/BLOCK_SIZE;bx++){
- bl = map[m].block_mob[bx+by*map[m].bxs];
- c = map[m].block_mob_count[bx+by*map[m].bxs];
- for(i=0;i<c && bl;i++,bl=bl->next){
- if(bl && bl->x>=x0 && bl->x<=x1 && bl->y>=y0 && bl->y<=y1 && bl_list_count<BL_LIST_MAX)
+ for(by=y0/BLOCK_SIZE;by<=y1/BLOCK_SIZE;by++)
+ for(bx=x0/BLOCK_SIZE;bx<=x1/BLOCK_SIZE;bx++)
+ for( bl = map[m].block_mob[bx+by*map[m].bxs] ; bl != NULL ; bl = bl->next )
+ if(bl->x>=x0 && bl->x<=x1 && bl->y>=y0 && bl->y<=y1 && bl_list_count<BL_LIST_MAX)
bl_list[bl_list_count++]=bl;
- }
- }
- }
if(bl_list_count>=BL_LIST_MAX)
ShowWarning("map_foreachinarea: block count too many!\n");
@@ -772,9 +717,9 @@ int map_foreachinmovearea(int (*func)(struct block_list*,va_list), struct block_
{
int bx,by,m;
int returnCount =0; //total sum of returned values of func() [Skotlex]
- struct block_list *bl=NULL;
+ struct block_list *bl;
va_list ap;
- int blockcount=bl_list_count,i,c;
+ int blockcount=bl_list_count,i;
int x0, x1, y0, y1;
if (!range) return 0;
@@ -819,9 +764,8 @@ int map_foreachinmovearea(int (*func)(struct block_list*,va_list), struct block_
for(by=y0/BLOCK_SIZE;by<=y1/BLOCK_SIZE;by++){
for(bx=x0/BLOCK_SIZE;bx<=x1/BLOCK_SIZE;bx++){
if (type&~BL_MOB) {
- bl = map[m].block[bx+by*map[m].bxs];
- c = map[m].block_count[bx+by*map[m].bxs];
- for(i=0;i<c && bl;i++,bl=bl->next){
+ for( bl = map[m].block[bx+by*map[m].bxs] ; bl != NULL ; bl = bl->next )
+ {
if(bl->type&type &&
bl->x>=x0 && bl->x<=x1 &&
bl->y>=y0 && bl->y<=y1 &&
@@ -830,9 +774,8 @@ int map_foreachinmovearea(int (*func)(struct block_list*,va_list), struct block_
}
}
if (type&BL_MOB) {
- bl = map[m].block_mob[bx+by*map[m].bxs];
- c = map[m].block_mob_count[bx+by*map[m].bxs];
- for(i=0;i<c && bl;i++,bl=bl->next){
+ for( bl = map[m].block_mob[bx+by*map[m].bxs] ; bl != NULL ; bl = bl->next )
+ {
if(bl->x>=x0 && bl->x<=x1 &&
bl->y>=y0 && bl->y<=y1 &&
bl_list_count<BL_LIST_MAX)
@@ -850,14 +793,12 @@ int map_foreachinmovearea(int (*func)(struct block_list*,va_list), struct block_
for(by=y0/BLOCK_SIZE;by<=y1/BLOCK_SIZE;by++){
for(bx=x0/BLOCK_SIZE;bx<=x1/BLOCK_SIZE;bx++){
if (type & ~BL_MOB) {
- bl = map[m].block[bx+by*map[m].bxs];
- c = map[m].block_count[bx+by*map[m].bxs];
- for(i=0;i<c && bl;i++,bl=bl->next){
- if(!(bl->type&type &&
+ for( bl = map[m].block[bx+by*map[m].bxs] ; bl != NULL ; bl = bl->next )
+ {
+ if( bl->type&type &&
bl->x>=x0 && bl->x<=x1 &&
bl->y>=y0 && bl->y<=y1 &&
- bl_list_count<BL_LIST_MAX))
- continue;
+ bl_list_count<BL_LIST_MAX )
if((dx>0 && bl->x<x0+dx) ||
(dx<0 && bl->x>x1+dx) ||
(dy>0 && bl->y<y0+dy) ||
@@ -866,19 +807,16 @@ int map_foreachinmovearea(int (*func)(struct block_list*,va_list), struct block_
}
}
if (type & BL_MOB) {
- bl = map[m].block_mob[bx+by*map[m].bxs];
- c = map[m].block_mob_count[bx+by*map[m].bxs];
- for(i=0;i<c && bl;i++,bl=bl->next){
- if(!(
- bl->x>=x0 && bl->x<=x1 &&
+ for( bl = map[m].block_mob[bx+by*map[m].bxs] ; bl != NULL ; bl = bl->next )
+ {
+ if( bl->x>=x0 && bl->x<=x1 &&
bl->y>=y0 && bl->y<=y1 &&
- bl_list_count<BL_LIST_MAX))
- continue;
+ bl_list_count<BL_LIST_MAX)
if((dx>0 && bl->x<x0+dx) ||
(dx<0 && bl->x>x1+dx) ||
(dy>0 && bl->y<y0+dy) ||
(dy<0 && bl->y>y1+dy))
- bl_list[bl_list_count++]=bl;
+ bl_list[bl_list_count++]=bl;
}
}
}
@@ -910,9 +848,9 @@ int map_foreachincell(int (*func)(struct block_list*,va_list), int m, int x, int
{
int bx,by;
int returnCount =0; //total sum of returned values of func() [Skotlex]
- struct block_list *bl=NULL;
+ struct block_list *bl;
va_list ap;
- int blockcount=bl_list_count,i,c;
+ int blockcount=bl_list_count,i;
if (x < 0 || y < 0 || x >= map[m].xs || y >= map[m].ys) return 0;
@@ -922,26 +860,14 @@ int map_foreachincell(int (*func)(struct block_list*,va_list), int m, int x, int
bx=x/BLOCK_SIZE;
if(type&~BL_MOB)
- {
- bl = map[m].block[bx+by*map[m].bxs];
- c = map[m].block_count[bx+by*map[m].bxs];
- for(i=0;i<c && bl;i++,bl=bl->next)
- {
- if(bl && bl->type&type && bl->x==x && bl->y==y && bl_list_count<BL_LIST_MAX)
+ for( bl = map[m].block[bx+by*map[m].bxs] ; bl != NULL ; bl = bl->next )
+ if(bl->type&type && bl->x==x && bl->y==y && bl_list_count<BL_LIST_MAX)
bl_list[bl_list_count++]=bl;
- }
- }
if(type&BL_MOB)
- {
- bl = map[m].block_mob[bx+by*map[m].bxs];
- c = map[m].block_mob_count[bx+by*map[m].bxs];
- for(i=0;i<c && bl;i++,bl=bl->next)
- {
- if(bl && bl->x==x && bl->y==y && bl_list_count<BL_LIST_MAX)
+ for( bl = map[m].block_mob[bx+by*map[m].bxs] ; bl != NULL ; bl = bl->next )
+ if(bl->x==x && bl->y==y && bl_list_count<BL_LIST_MAX)
bl_list[bl_list_count++]=bl;
- }
- }
if(bl_list_count>=BL_LIST_MAX)
ShowWarning("map_foreachincell: block count too many!\n");
@@ -1002,7 +928,7 @@ int map_foreachinpath(int (*func)(struct block_list*,va_list),int m,int x0,int y
va_list ap;
int i, blockcount = bl_list_count;
struct block_list *bl;
- int c, bx, by;
+ int bx, by;
//method specific variables
int magnitude2, len_limit; //The square of the magnitude
int k, xi, yi, xu, yu;
@@ -1070,10 +996,9 @@ int map_foreachinpath(int (*func)(struct block_list*,va_list),int m,int x0,int y
if (type & ~BL_MOB)
for (by = my0 / BLOCK_SIZE; by <= my1 / BLOCK_SIZE; by++) {
for(bx=mx0/BLOCK_SIZE;bx<=mx1/BLOCK_SIZE;bx++){
- bl = map[m].block[bx+by*map[m].bxs];
- c = map[m].block_count[bx+by*map[m].bxs];
- for(i=0;i<c && bl;i++,bl=bl->next){
- if(bl && bl->prev && bl->type&type && bl_list_count<BL_LIST_MAX)
+ for( bl = map[m].block[bx+by*map[m].bxs] ; bl != NULL ; bl = bl->next )
+ {
+ if(bl->prev && bl->type&type && bl_list_count<BL_LIST_MAX)
{
xi = bl->x;
yi = bl->y;
@@ -1103,13 +1028,13 @@ int map_foreachinpath(int (*func)(struct block_list*,va_list),int m,int x0,int y
}
}
}
+
if(type&BL_MOB)
for(by=my0/BLOCK_SIZE;by<=my1/BLOCK_SIZE;by++){
for(bx=mx0/BLOCK_SIZE;bx<=mx1/BLOCK_SIZE;bx++){
- bl = map[m].block_mob[bx+by*map[m].bxs];
- c = map[m].block_mob_count[bx+by*map[m].bxs];
- for(i=0;i<c && bl;i++,bl=bl->next){
- if(bl && bl->prev && bl_list_count<BL_LIST_MAX)
+ for( bl = map[m].block_mob[bx+by*map[m].bxs] ; bl != NULL ; bl = bl->next )
+ {
+ if(bl->prev && bl_list_count<BL_LIST_MAX)
{
xi = bl->x;
yi = bl->y;
@@ -1159,38 +1084,25 @@ int map_foreachinmap(int (*func)(struct block_list*,va_list), int m, int type,..
{
int b, bsize;
int returnCount =0; //total sum of returned values of func() [Skotlex]
- struct block_list *bl=NULL;
+ struct block_list *bl;
va_list ap;
- int blockcount=bl_list_count,i,c;
+ int blockcount=bl_list_count,i;
va_start(ap,type);
bsize = map[m].bxs * map[m].bys;
+
if(type&~BL_MOB)
- {
- for(b=0;b<bsize;b++){
- bl = map[m].block[b];
- c = map[m].block_count[b];
- for(i=0;i<c && bl;i++,bl=bl->next)
- {
- if(bl && bl->type&type && bl_list_count<BL_LIST_MAX)
+ for(b=0;b<bsize;b++)
+ for( bl = map[m].block[b] ; bl != NULL ; bl = bl->next )
+ if(bl->type&type && bl_list_count<BL_LIST_MAX)
bl_list[bl_list_count++]=bl;
- }
- }
- }
if(type&BL_MOB)
- {
- for(b=0;b<bsize;b++){
- bl = map[m].block_mob[b];
- c = map[m].block_mob_count[b];
- for(i=0;i<c && bl;i++,bl=bl->next)
- {
- if(bl && bl_list_count<BL_LIST_MAX)
+ for(b=0;b<bsize;b++)
+ for( bl = map[m].block_mob[b] ; bl != NULL ; bl = bl->next )
+ if(bl_list_count<BL_LIST_MAX)
bl_list[bl_list_count++]=bl;
- }
- }
- }
if(bl_list_count>=BL_LIST_MAX)
ShowWarning("map_foreachinmap: block count too many!\n");
@@ -1830,7 +1742,7 @@ struct map_session_data * map_nick2sd(const char *nick)
*------------------------------------------*/
struct block_list * map_id2bl(int id)
{
- struct block_list *bl=NULL;
+ struct block_list *bl;
if(id >= 0 && id < ARRAYLENGTH(objects))
bl = objects[id];
else
@@ -2612,10 +2524,6 @@ int map_readallmaps (void)
size = map[i].bxs * map[i].bys * sizeof(struct block_list*);
map[i].block = (struct block_list**)aCalloc(size, 1);
map[i].block_mob = (struct block_list**)aCalloc(size, 1);
-
- size = map[i].bxs * map[i].bys * sizeof(int);
- map[i].block_count = (int*)aCallocA(size, 1);
- map[i].block_mob_count = (int*)aCallocA(size, 1);
}
if( !enable_grf )
@@ -3093,8 +3001,6 @@ void do_final(void)
#endif
if(map[i].block) aFree(map[i].block);
if(map[i].block_mob) aFree(map[i].block_mob);
- if(map[i].block_count) aFree(map[i].block_count);
- if(map[i].block_mob_count) aFree(map[i].block_mob_count);
if(battle_config.dynamic_mobs) { //Dynamic mobs flag by [random]
for (j=0; j<MAX_MOB_LIST_PER_MAP; j++)
if (map[i].moblist[j]) aFree(map[i].moblist[j]);
diff --git a/src/map/map.h b/src/map/map.h
index 562c8b063..611b19f42 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -171,18 +171,17 @@ enum {
#define map_flag_gvg2(m) (map[m].flag.gvg || map[m].flag.gvg_castle)
//This stackable implementation does not means a BL can be more than one type at a time, but it's
-//meant to make it easier to check for multiple types at a time on invocations such as
-// map_foreach* calls [Skotlex]
+//meant to make it easier to check for multiple types at a time on invocations such as map_foreach* calls [Skotlex]
enum bl_type {
- BL_NUL = 0x000,
- BL_PC = 0x001,
- BL_MOB = 0x002,
- BL_PET = 0x004,
- BL_HOM = 0x008,
- BL_ITEM = 0x010,
+ BL_NUL = 0x000,
+ BL_PC = 0x001,
+ BL_MOB = 0x002,
+ BL_PET = 0x004,
+ BL_HOM = 0x008,
+ BL_ITEM = 0x010,
BL_SKILL = 0x020,
- BL_NPC = 0x040,
- BL_CHAT = 0x080,
+ BL_NPC = 0x040,
+ BL_CHAT = 0x080,
};
//For common mapforeach calls. Since pets cannot be affected, they aren't included here yet.
@@ -1025,7 +1024,6 @@ struct map_data {
#endif
struct block_list **block;
struct block_list **block_mob;
- int *block_count,*block_mob_count;
int m;
short xs,ys; // map dimensions (in cells)
short bxs,bys; // map dimensions (in blocks)
@@ -1289,7 +1287,6 @@ int map_foreachinmovearea(int (*func)(struct block_list*,va_list), struct block_
int map_foreachincell(int (*func)(struct block_list*,va_list), int m, int x, int y, int type, ...);
int map_foreachinpath(int (*func)(struct block_list*,va_list), int m, int x0, int y0, int x1, int y1, int range, int length, int type, ...);
int map_foreachinmap(int (*func)(struct block_list*,va_list), int m, int type, ...);
-int map_countnearpc(int,int,int);
//block関連に追加
int map_count_oncell(int m,int x,int y,int type);
struct skill_unit *map_find_skill_unit_oncell(struct block_list *,int x,int y,int skill_id,struct skill_unit *);
diff --git a/src/map/script.c b/src/map/script.c
index 8b7135e40..a52bf0323 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -10705,8 +10705,8 @@ BUILDIN_FUNC(jump_zero)
BUILDIN_FUNC(getmapmobs)
{
const char *str=NULL;
- int m=-1,bx,by,i;
- int count=0,c;
+ int m=-1,bx,by;
+ int count=0;
struct block_list *bl;
str=script_getstr(st,2);
@@ -10727,16 +10727,12 @@ BUILDIN_FUNC(getmapmobs)
return 0;
}
- for(by=0;by<=(map[m].ys-1)/BLOCK_SIZE;by++){
- for(bx=0;bx<=(map[m].xs-1)/BLOCK_SIZE;bx++){
- bl = map[m].block_mob[bx+by*map[m].bxs];
- c = map[m].block_mob_count[bx+by*map[m].bxs];
- for(i=0;i<c && bl;i++,bl=bl->next){
+ for(by=0;by<=(map[m].ys-1)/BLOCK_SIZE;by++)
+ for(bx=0;bx<=(map[m].xs-1)/BLOCK_SIZE;bx++)
+ for( bl = map[m].block_mob[bx+by*map[m].bxs] ; bl != NULL ; bl = bl->next )
if(bl->x>=0 && bl->x<=map[m].xs-1 && bl->y>=0 && bl->y<=map[m].ys-1)
count++;
- }
- }
- }
+
script_pushint(st,count);
return 0;
}
diff --git a/src/map/unit.c b/src/map/unit.c
index 6e0eed53c..c8ae55bc3 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -149,8 +149,7 @@ static int unit_walktoxy_timer(int tid,unsigned int tick,int id,int data)
// バシリカ判定
- map_foreachinmovearea(clif_outsight, bl, AREA_SIZE,
- dx, dy, sd?BL_ALL:BL_PC, bl);
+ map_foreachinmovearea(clif_outsight, bl, AREA_SIZE, dx, dy, sd?BL_ALL:BL_PC, bl);
x += dx;
y += dy;
@@ -161,8 +160,7 @@ static int unit_walktoxy_timer(int tid,unsigned int tick,int id,int data)
return 0; //map_moveblock has altered the object beyond what we expected (moved/warped it)
ud->walktimer = 1;
- map_foreachinmovearea(clif_insight, bl, AREA_SIZE,
- -dx, -dy, sd?BL_ALL:BL_PC, bl);
+ map_foreachinmovearea(clif_insight, bl, AREA_SIZE, -dx, -dy, sd?BL_ALL:BL_PC, bl);
ud->walktimer = -1;
if(sd) {