From 5697031dce0f02a55044504077775b909a42982d Mon Sep 17 00:00:00 2001 From: Haru Date: Sat, 28 Sep 2013 18:15:23 +0200 Subject: Provided argument-list equivalent for several variadic functions This is necessary for the upcoming HPM hooking system --- src/map/party.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'src/map/party.c') 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;ifreeblock_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; -- cgit v1.2.3-70-g09d2