| 01-06-2008, 06:15 AM | #1 |
I'm a little confused as to whether this will leak or not... JASS:set bj_wantDestroyGroup = true set u = GroupPickRandomUnit(GetUnitsInRectMatching(gg_rct_Recycle, Condition(function UnitCriteria))) Should I instead do it this way? -- JASS:set ug = GetUnitsInRectMatching(gg_rct_Recycle, Condition(function UnitCriteria)) set bj_wantDestroyGroup = true set u = GroupPickRandomUnit(ug) set ug = null thanks |
| 01-06-2008, 06:20 AM | #2 |
JASS:GetUnitsInRectMatching(...) JASS:local group g = CreateGroup() local unit u call GroupEnumUnitsInRect(g, gg_rct_Recycle, Filter(function UnitCriteria)) set u = GroupPickRandomUnit(g) call DestroyGroup(g) set g = null *If you didn't catch it, notice the DestroyGroup call, that is very neccessary. |
| 01-06-2008, 06:28 AM | #3 |
Thanks for the reply. Here's where I am confused: GetUnitsInRectMatching says that it returns its group--at which point, it gets sent to Pickrandomunit etc, which destroys the group as part of its action.... is the group that gets returned by GetUnitsInRectMatching a *new* copy of the group created inside the function, or is it the same one, in which case it would get destroyed later. Edit: this is what i mean JASS:function GetUnitsInRectMatching takes rect r, boolexpr filter returns group local group g = CreateGroup() call GroupEnumUnitsInRect(g, r, filter) call DestroyBoolExpr(filter) return g //is this group that is sent to my function a copy of the group g, or is it the actual group g? endfunction Also, I noticed that you didn't destroy the boolean filter like the blizzard function--is that because Filter( ) is different from Condition( )? OK all new version, what do you think? The part in the middle is in a loop in which it must pick a different kind of unit every time. JASS:local group ug = CreateGroup() ... ... call GroupEnumUnitsInRect(ug, gg_rct_Recycle, Filter(function UnitCriteria)) set u = FirstOfGroup(ug) call GroupClear(ug) ... ... call DestroyGroup(ug) set ug = null |
| 01-06-2008, 07:08 AM | #4 |
To answer your first question, it is the same group. To answer your second question(s), Filter( ) is the same as Condition( ) and boolexprs do not leak, therefore do not need to be removed. Lastly, looks all good. Great job. |
| 01-06-2008, 07:10 AM | #5 |
Thanks a bunch for the help |
| 01-06-2008, 07:34 AM | #6 |
Not a problem. |
