Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
I am really confused with leaks. So do I need to create variable for last created unit gorup and then clean it. Or i can just use it with no variables and with not leaks.(same questions for unit)
The GUI-version "Unit - Create Unit" stores the created unit(s) inside bj_lastCreatedGroup, but it does not leak: it re-uses the unit group variable (it does not create one).
"Last created unit" is a unit variable, so that doesn't leak.
@defskull: Yes. "Pick every unit..." translates to ForGroupBJ(). ForGroupBJ() checks if bj_wantDestroyGroup after it calls the ForGroup() function and will destroy the group if you want it to.
JASS:
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
Yes, this leaks.
You're actually using 2 unit groups: Random units from (group) and (group) itself.
Even though you're only picking 1 unit, Warcraft will always put it in a newly created unit group.
You should destroy both groups (this also means that "set bj_wantDestroyGroup" doesn't work for both of them: you should store at least 1 group in a variable, like you did).
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.