diff options
Diffstat (limited to 'src/map/map.c')
-rw-r--r-- | src/map/map.c | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/src/map/map.c b/src/map/map.c index 2c1495f32..e5574eaf7 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -397,6 +397,7 @@ int map_moveblock(struct block_list *bl, int x1, int y1, int64 tick) { * Counts specified number of objects on given cell. * flag: * 0x1 - only count standing units + * 0x2 - don't count invinsible units * TODO: merge with bl_getall_area *------------------------------------------*/ int map_count_oncell(int16 m, int16 x, int16 y, int type, int flag) { @@ -410,29 +411,41 @@ int map_count_oncell(int16 m, int16 x, int16 y, int type, int flag) { bx = x/BLOCK_SIZE; by = y/BLOCK_SIZE; - if (type&~BL_MOB) - for( bl = map->list[m].block[bx+by*map->list[m].bxs] ; bl != NULL ; bl = bl->next ) - if(bl->x == x && bl->y == y && bl->type&type) { - if(flag&1) { + if (type&~BL_MOB) { + for (bl = map->list[m].block[bx+by*map->list[m].bxs]; bl != NULL; bl = bl->next) { + if (bl->x == x && bl->y == y && bl->type&type) { + if (flag&0x2) { + struct status_change *sc = status->get_sc(bl); + if (sc && (sc->option&OPTION_INVISIBLE)) + continue; + } + if (flag&0x1) { struct unit_data *ud = unit->bl2ud(bl); - if(!ud || ud->walktimer == INVALID_TIMER) - count++; - } else { - count++; + if (ud && ud->walktimer != INVALID_TIMER) + continue; } + count++; } + } + } - if (type&BL_MOB) - for( bl = map->list[m].block_mob[bx+by*map->list[m].bxs] ; bl != NULL ; bl = bl->next ) - if(bl->x == x && bl->y == y) { - if(flag&1) { + if (type&BL_MOB) { + for (bl = map->list[m].block_mob[bx+by*map->list[m].bxs]; bl != NULL; bl = bl->next) { + if (bl->x == x && bl->y == y) { + if (flag&0x2) { + struct status_change *sc = status->get_sc(bl); + if (sc && (sc->option&OPTION_INVISIBLE)) + continue; + } + if (flag&0x1) { struct unit_data *ud = unit->bl2ud(bl); - if(!ud || ud->walktimer == INVALID_TIMER) - count++; - } else { - count++; + if (ud && ud->walktimer != INVALID_TIMER) + continue; } + count++; } + } + } return count; } @@ -5484,7 +5497,7 @@ void map_helpscreen(bool do_exit) ShowInfo(" scripts passed through --load-script.\n"); ShowInfo(" --load-script <file> Loads an additional script (can be repeated).\n"); ShowInfo(" --load-plugin <name> Loads an additional plugin (can be repeated).\n"); - HPM->arg_help();/* display help for commands implemented thru HPM */ + HPM->arg_help(); /* display help for commands implemented through HPM */ if( do_exit ) exit(EXIT_SUCCESS); } |