diff options
author | gumi <git@gumi.ca> | 2018-11-07 16:14:36 -0500 |
---|---|---|
committer | gumi <git@gumi.ca> | 2018-11-07 16:15:26 -0500 |
commit | f3af2d37a90a83bbec25c15e59c29e0f9802daca (patch) | |
tree | ad869c6a1ed701fe4e42961ec572cfd5b12e63a9 /src/map/script.c | |
parent | b30f62468a5e923bf5d9533adec064ada1716459 (diff) | |
download | hercules-f3af2d37a90a83bbec25c15e59c29e0f9802daca.tar.gz hercules-f3af2d37a90a83bbec25c15e59c29e0f9802daca.tar.bz2 hercules-f3af2d37a90a83bbec25c15e59c29e0f9802daca.tar.xz hercules-f3af2d37a90a83bbec25c15e59c29e0f9802daca.zip |
break the loop in buildin_getunits when the max is reached
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/src/map/script.c b/src/map/script.c index e38aae562..5e900167d 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -11382,7 +11382,7 @@ static int buildin_getunits_sub(struct block_list *bl, va_list ap) (const void *)h64BPTRSIZE(bl->id), ref); (*count)++; - return 0; + return 1; } static int buildin_getunits_sub_pc(struct map_session_data *sd, va_list ap) @@ -11454,18 +11454,10 @@ static BUILDIN(getunits) int16 x2 = script_getnum(st, 8); int16 y2 = script_getnum(st, 9); - // FIXME: map_foreachinarea does NOT stop iterating when the callback - // function returns -1. we still limit the array size, but - // this doesn't break the loop. We need a foreach function - // that behaves like map_foreachiddb, but for areas - map->foreachinarea(buildin_getunits_sub, m, x1, y1, x2, y2, type, + map->forcountinarea(buildin_getunits_sub, m, x1, y1, x2, y2, limit, type, st, sd, id, start, &count, limit, name, ref, type); } else { - // FIXME: map_foreachinmap does NOT stop iterating when the callback - // function returns -1. we still limit the array size, but - // this doesn't break the loop. We need a foreach function - // that behaves like map_foreachiddb, but for maps - map->foreachinmap(buildin_getunits_sub, m, type, + map->forcountinmap(buildin_getunits_sub, m, limit, type, st, sd, id, start, &count, limit, name, ref, type); } } else { |