/// Executes 'func' for each guild member on the same map and in range (0:whole map)
int guild_foreachinmap(int (*func)(struct block_list*,va_list),int map,int guildid,...)
{
struct guild *g = NULL;
int i,m;
struct block_list *list[MAX_GUILD];
int blockcount=0;
int total = 0; //Return value.
if( (g = guild_search(guildid)) == NULL )
return 0;
if((m = map_mapindex2mapid(map)) == NULL)
return 0;
if( g )
{
for(i=0;i<MAX_GUILD;i++)
{
struct map_session_data *psd = g->member[i].sd;
if(!psd) continue;
if(psd->bl.m!=m || !psd->bl.prev)
continue;
list[blockcount++]=&psd->bl;
}
}
else return 0;
map_freeblock_lock();
for(i=0;i<blockcount;i++)
{
va_list ap;
va_start(ap, guildid);
total += func(list[i], ap);
va_end(ap);
}
map_freeblock_unlock();
return total;
}