• 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!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Unit Group Memory Leak Problem

Status
Not open for further replies.
Level 3
Joined
Aug 11, 2007
Messages
36
  • TheSelect
    • Events
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units of type Circle of Power) and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
      • Custom script: set bj_wantDestroyGroup = true
See, this is how I have it now. I had it backwards before which resulted in the whole iteration never working. Now, it works the first time, but not the second.

So, what's the right way to do it? Cause I only found a mention of this years ago and can't remember.

Thanks in advance.
 
Level 14
Joined
Mar 4, 2009
Messages
1,156
  • TheSelect
    • Events
    • Conditions
    • Actions
      • Unit Group - Pick every unit i:mwahaha:n (Units of type Circle of Power) and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
      • Custom script: set bj_wantDestroyGroup = true
See, this is how I have it now. I had it backwards before which resulted in the whole iteration never working. Now, it works the first time, but not the second.

So, what's the right way to do it? Cause I only found a mention of this years ago and can't remember.

Thanks in advance.

You need to set variable for your unit group

set=YourUnitGroup
Pick every units in YourUnitGroup and do actions
-remove picked unit
Custom script: call DestroyGroup(udg_YourUnitGroup)
 
Level 14
Joined
Mar 4, 2009
Messages
1,156
just do it on my way it will be good i saw many people doing it like that
set YourUnitGroup=units owned by player 1(red).....
Pick every units rom YourUnitGroup and do actions....
costom script DestroyGroup(udg_YourUnitGroup)
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
His way destroys all the groups in the trigger which get created after the trigger ends.
No it doesn't. Check out the code if you don't believe me.

--

bj_wantDestroyGroup is handy in GUI simply because it's a little shorter and allows you to not screw with variables when you don't need them.

just do it on my way it will be good i saw many people doing it like that
Lots of people doing something doesn't make it smart.
 
Level 5
Joined
Sep 8, 2004
Messages
98
Can someone say how it should be done and is my way good or wrong?

These are both the correct solution:

The custom script should be before the action...

set=YourUnitGroup
Pick every units in YourUnitGroup and do actions
-remove picked unit
Custom script: call DestroyGroup(udg_YourUnitGroup)

Basically, the bj_wantDestroyGroup is checked every time a GUI "Pick every units in ..." function runs, and if it is true, it destroys the group, and sets it to false again. If it is false, it leaves the group alone.

I believe setting it to a variable, and then destroying it yourself makes your code more readable, however.
 
Level 21
Joined
Aug 9, 2006
Messages
2,384
Purple, you are all wrong, the bj_wantDestroyGroup will destroy ALL the groups in the WHOLE trigger after completing the execution of the trigger, I tested it, and I hate people like you which think they know everything, beside that my sources are jassvault and others..

YOU should explain what something does before you give the suggestion to other people, if he uses this in combination with 2 groups in 1 trigger which 1 of those should be saved and the other deleted and he forgets to set it false it will bug the hell out of the trigger.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Purple, you are all wrong, the bj_wantDestroyGroup will destroy ALL the groups in the WHOLE trigger after completing the execution of the trigger, I tested it, and I hate people like you which think they know everything, beside that my sources are jassvault and others..

YOU should explain what something does before you give the suggestion to other people, if he uses this in combination with 2 groups in 1 trigger which 1 of those should be saved and the other deleted and he forgets to set it false it will bug the hell out of the trigger.
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

Go away.
 
Status
Not open for further replies.
Top