I'm having trouble with using Destroy group and remove Rect etc in reawltion to a ForGroupBJ function. Basically the triggers look like this.
function func1 takes nothing returns nothing
local unit u = GetEnumUnit()
local integer i = GetUnitUserData(u)
local location l = GetUnitLoc(u)
call Something to do with u,i and l.
call RemoveLocation(l)
set l = null
set u = null
set i = 0
endfunction
function actions takes nothing returns nothing
local rect r = GetPlayableMapRect()
local group g = GetEnumUnitsInRect(r) //Or something like that.
call ForGroupBJ(g, (function func1))
call DestroyGroup(g)
set g = null
call RemoveRect(r)
set r = null
endfunction
function InitTrig...
(Periodic (0.01))
endfunction
Now it works fine if I don't remove location or rects or groups, but just use nulls, but I don't know the effect on memory. But if I put all the Removes and Destroys in, then the trigger completely stuffs up, as if I was removing and Destroying before calling the function. But that shouldn't happen should it?
Rect and Group should only be Removed after the whole ForGroupBJ has finished, and I thought ForGroupBJ was some kind of loop, that executed func1 for every picked unit, so that even if I removed the location at the end, it would recreate it at the beginning of the next loop for the next unit.
Could someone tell me why this is not so? I want to clean up the memory leaks of my map.
function func1 takes nothing returns nothing
local unit u = GetEnumUnit()
local integer i = GetUnitUserData(u)
local location l = GetUnitLoc(u)
call Something to do with u,i and l.
call RemoveLocation(l)
set l = null
set u = null
set i = 0
endfunction
function actions takes nothing returns nothing
local rect r = GetPlayableMapRect()
local group g = GetEnumUnitsInRect(r) //Or something like that.
call ForGroupBJ(g, (function func1))
call DestroyGroup(g)
set g = null
call RemoveRect(r)
set r = null
endfunction
function InitTrig...
(Periodic (0.01))
endfunction
Now it works fine if I don't remove location or rects or groups, but just use nulls, but I don't know the effect on memory. But if I put all the Removes and Destroys in, then the trigger completely stuffs up, as if I was removing and Destroying before calling the function. But that shouldn't happen should it?
Rect and Group should only be Removed after the whole ForGroupBJ has finished, and I thought ForGroupBJ was some kind of loop, that executed func1 for every picked unit, so that even if I removed the location at the end, it would recreate it at the beginning of the next loop for the next unit.
Could someone tell me why this is not so? I want to clean up the memory leaks of my map.