diff options
author | Haru <haru@dotalux.com> | 2013-09-28 18:15:23 +0200 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2013-09-29 01:45:34 +0200 |
commit | 5697031dce0f02a55044504077775b909a42982d (patch) | |
tree | aef805d4d5f4eb9bc4da0282e84322369c26ed3b /src/map/party.c | |
parent | fe624087b2495fb258afd9177c6299139a1f914d (diff) | |
download | hercules-5697031dce0f02a55044504077775b909a42982d.tar.gz hercules-5697031dce0f02a55044504077775b909a42982d.tar.bz2 hercules-5697031dce0f02a55044504077775b909a42982d.tar.xz hercules-5697031dce0f02a55044504077775b909a42982d.zip |
Provided argument-list equivalent for several variadic functions
This is necessary for the upcoming HPM hooking system
Diffstat (limited to 'src/map/party.c')
-rw-r--r-- | src/map/party.c | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/src/map/party.c b/src/map/party.c index 29ab5044c..a3fd5019f 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -1031,9 +1031,11 @@ int party_sub_count(struct block_list *bl, va_list ap) return 1; } -/// Executes 'func' for each party member on the same map and in range (0:whole map) -int party_foreachsamemap(int (*func)(struct block_list*,va_list),struct map_session_data *sd,int range,...) -{ +/** + * Arglist-based version of party_foreachsamemap + * @see party_foreachsamemap + */ +int party_vforeachsamemap(int (*func)(struct block_list*,va_list), struct map_session_data *sd, int range, va_list ap) { struct party_data *p; int i; int x0,y0,x1,y1; @@ -1067,10 +1069,10 @@ int party_foreachsamemap(int (*func)(struct block_list*,va_list),struct map_sess map->freeblock_lock(); for(i=0;i<blockcount;i++) { - va_list ap; - va_start(ap, range); - total += func(list[i], ap); - va_end(ap); + va_list ap_copy; + va_copy(ap_copy, ap); + total += func(list[i], ap_copy); + va_end(ap_copy); } map->freeblock_unlock(); @@ -1078,6 +1080,23 @@ int party_foreachsamemap(int (*func)(struct block_list*,va_list),struct map_sess return total; } +/** + * Executes 'func' for each party member on the same map and within a 'range' cells area + * @param func Function to execute + * @param sd Reference character for party, map, area center + * @param range Area size (0 = whole map) + * @param ... Adidtional parameters to pass to func() + * @return Sum of the return values from func() + */ +int party_foreachsamemap(int (*func)(struct block_list*,va_list), struct map_session_data *sd, int range, ...) { + va_list ap; + int ret; + va_start(ap, range); + ret = party->vforeachsamemap(func, sd, range, ap); + va_end(ap); + return ret; +} + /*========================================== * Party Booking in KRO [Spiria] *------------------------------------------*/ @@ -1291,6 +1310,7 @@ void party_defaults(void) { party->booking_update = party_booking_update; party->booking_search = party_booking_search; party->booking_delete = party_booking_delete; + party->vforeachsamemap = party_vforeachsamemap; party->foreachsamemap = party_foreachsamemap; party->send_xy_timer = party_send_xy_timer; party->fill_member = party_fill_member; |