HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

ForGroupBJ function

10-06-2003, 07:52 PM#1
Starcraftfreak
Taken from blizzard.j:
Code:
function ForGroupBJ takes group whichGroup, code callback returns nothing
    // If the user wants the group destroyed, remember that fact and clear
    // the flag, in case it is used again in the callback.
    local boolean wantDestroy = bj_wantDestroyGroup
    set bj_wantDestroyGroup = false

    call ForGroup(whichGroup, callback)

    // If the user wants the group destroyed, do so now.
    if (wantDestroy) then
        call DestroyGroup(whichGroup)
    endif
endfunction

Can someone tell me what that wantDestroy stuff does? I searched the whole blizzard.j and found no function that sets bj_wantDestroyGroup to true. There are certain group-related functions that read that value and set it to false. Does anyone know why it is there and who sets it (I guess the game does this at certain times)?
10-06-2003, 08:15 PM#2
Magos
I guess it has something to do with "temporary groups", meaning groups not assigned to a variable but used directly in a "pick every unit" action. Those have to be destroyed properly too.
10-06-2003, 08:58 PM#3
Nozdormu
I know it's immature, but that's a pretty damn funny function name.
10-06-2003, 09:36 PM#4
PitzerMike
If it doesn't get set to true it won't do anything, so just forget about it. Maybe something they forgot to remove...
10-07-2003, 07:08 PM#5
Starcraftfreak
Quote:
Originally posted by PitzerMike
If it doesn't get set to true it won't do anything, so just forget about it. Maybe something they forgot to remove...
That may be right. But it doesn't look like this. I think I will post that at Bnet.
I need to know that because if this is nonsense I will set UMSWE to use ForGroup instead of ForGroupBJ (without that crap ForGroupBJ is a function that simply calls ForGroup) to increase speed a little (you won't notice). I will do that optimization for all functions, that are literally the same (I won't remove functionality so the average user won't even notice the changes).
10-07-2003, 10:45 PM#6
Magos
http://www.battle.net/forums/war3/th...nt=1#post68337
10-12-2003, 05:27 PM#7
dataangel
If it's for fixing memory leaks -- does that mean calling ForGroup() causes memory leaks and ForGroupBJ() doesn't? Under what circumstances is a memory leak caused? :P

Basically -- should I use ForGroup() for the speed increase or no? Assuming I have shitloads of unit groups.
10-12-2003, 07:41 PM#8
AIAndy
No, it is just that ForGroup does not destroy the groups it works on (which is usually good). To prevent memory leaks you should always destroy groups after usage.
10-13-2003, 07:23 PM#9
Starcraftfreak
BWood explained it to me. You have to set that BJ global to make that function destroy the group specified in whichGroup. That is only needed if you do stuff like For (Pick all units in rect) and do actions. If you write your trigger in jass it would be more efficient to store that group to a local var and use ForGroup. The speed increase wouldn't be noteable, but you may remeber my reasons that you should use common.j functions whenever possible (this increases the internal trigger termination timeout). You may have noticed that sometimes a trigger/function or loop is not executed to it's end, even if it works fine. When using common.j functions, you can increase the time before the termination.