viewing paste Unknown #385 | C

Posted on the | Last edited on
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
/// 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;
}
Viewed 1286 times, submitted by lighta.