diff options
author | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-05-01 21:53:17 +0000 |
---|---|---|
committer | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-05-01 21:53:17 +0000 |
commit | 5d51ba8e8b84af11603b0c9c87b6203618604df0 (patch) | |
tree | 5b5233c7f03a7c2e6665c487f1b7fad6f1230462 /src | |
parent | 2c82c85e3857f9bcf513f4771f393f5f788f7f3f (diff) | |
download | hercules-5d51ba8e8b84af11603b0c9c87b6203618604df0.tar.gz hercules-5d51ba8e8b84af11603b0c9c87b6203618604df0.tar.bz2 hercules-5d51ba8e8b84af11603b0c9c87b6203618604df0.tar.xz hercules-5d51ba8e8b84af11603b0c9c87b6203618604df0.zip |
- Added function map_foreachinshootrange, behaves the same way as map_foreachinrange, but it also performs a "shoot-path" check before invoking the function. Used in the skill subtimer function if skill_wall_check is defined.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@6436 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r-- | src/map/map.c | 74 | ||||
-rw-r--r-- | src/map/map.h | 1 | ||||
-rw-r--r-- | src/map/skill.c | 8 |
3 files changed, 80 insertions, 3 deletions
diff --git a/src/map/map.c b/src/map/map.c index 950eb6e03..87fd292ba 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -673,7 +673,79 @@ int map_foreachinrange(int (*func)(struct block_list*,va_list),struct block_list for(i=0;i<c && bl;i++,bl=bl->next){ if(bl && bl->x>=x0 && bl->x<=x1 && bl->y>=y0 && bl->y<=y1 - && check_distance_bl(center, bl, range) +// && check_distance_bl(center, bl, range) + && bl_list_count<BL_LIST_MAX) + bl_list[bl_list_count++]=bl; + } + } + } + + if(bl_list_count>=BL_LIST_MAX) { + if(battle_config.error_log) + ShowWarning("map_foreachinrange: block count too many!\n"); + } + + map_freeblock_lock(); // メモリからの解放を禁止する + + for(i=blockcount;i<bl_list_count;i++) + if(bl_list[i]->prev) // 有?かどうかチェック + returnCount += func(bl_list[i],ap); + + map_freeblock_unlock(); // 解放を許可する + + va_end(ap); + bl_list_count = blockcount; + return returnCount; //[Skotlex] +} + +/*========================================== + * Same as foreachinrange, but there must be a shoot-able range between center and target to be counted in. [Skotlex] + *------------------------------------------ + */ +int map_foreachinshootrange(int (*func)(struct block_list*,va_list),struct block_list *center, int range,int type,...) { + 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; + int x0,x1,y0,y1; + m = center->m; + if (m < 0) + return 0; + va_start(ap,type); + x0 = center->x-range; + x1 = center->x+range; + y0 = center->y-range; + y1 = center->y+range; + + if (x0 < 0) x0 = 0; + if (y0 < 0) y0 = 0; + if (x1 >= map[m].xs) x1 = map[m].xs-1; + 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 + && path_search_long(NULL,center->m,center->x,center->y,bl->x,bl->y) + && 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 + && path_search_long(NULL,center->m,center->x,center->y,bl->x,bl->y) && bl_list_count<BL_LIST_MAX) bl_list[bl_list_count++]=bl; } diff --git a/src/map/map.h b/src/map/map.h index 105183244..66a242545 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -1254,6 +1254,7 @@ int map_delblock_sub(struct block_list *, int); #define map_delblock(bl) map_delblock_sub(bl,1)
int map_moveblock(struct block_list *, int, int, unsigned int);
int map_foreachinrange(int (*)(struct block_list*,va_list),struct block_list *,int,int,...);
+int map_foreachinshootrange(int (*)(struct block_list*,va_list),struct block_list *,int,int,...);
int map_foreachinarea(int (*)(struct block_list*,va_list),int,int,int,int,int,int,...);
// -- moonsoul (added map_foreachincell)
int map_foreachincell(int (*)(struct block_list*,va_list),int,int,int,int,...);
diff --git a/src/map/skill.c b/src/map/skill.c index 3fb8dfcbb..b09d4927b 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -9639,8 +9639,12 @@ int skill_unit_timer_sub( struct block_list *bl, va_list ap ) /* onplace_timerイベント呼び?oし */
if (unit->range>=0 && group->interval!=-1) {
- map_foreachinrange(skill_unit_timer_sub_onplace, bl, unit->range,
- group->bl_flag,bl,tick);
+ if (battle_config.skill_wall_check)
+ map_foreachinshootrange(skill_unit_timer_sub_onplace, bl, unit->range,
+ group->bl_flag,bl,tick);
+ else
+ map_foreachinrange(skill_unit_timer_sub_onplace, bl, unit->range,
+ group->bl_flag,bl,tick);
if (!unit->alive)
return 0;
}
|