I've got some leaky code here, in functions that I use in a few places in my map.
I'm not sure how to plug the leaks though. Some kind of handle wrapper? Or is there a simpler way I've missed?
I'm not sure how to plug the leaks though. Some kind of handle wrapper? Or is there a simpler way I've missed?
JASS:
library filters
globals
group enumGrp = CreateGroup()
endglobals
function TrueFilter takes nothing returns boolean
return true
endfunction
function Get_unit_in_square takes real x, real y returns unit
local unit u
call GroupEnumUnitsInRange(enumGrp, x, y, 200, Filter(function TrueFilter))
set u = FirstOfGroup(enumGrp)
call GroupClear(enumGrp)
return u
// leeeeeeeeeeeeeeeak
endfunction
function get_random_unit_of_player takes integer playerID returns unit
local unit u
call GroupEnumUnitsOfPlayer(enumGrp, Player(playerID), null)
set u = GroupPickRandomUnit(enumGrp)
call GroupClear(enumGrp)
return u //leeeeak
endfunction
function get_random_unit_of_type takes integer unitid, integer playerNum returns unit
local unit u
set bj_groupEnumTypeId = unitid
call GroupEnumUnitsOfPlayer(enumGrp, Player(playerNum), filterGetUnitsOfPlayerAndTypeId)
set u = GroupPickRandomUnit(enumGrp)
call GroupClear(enumGrp)
return u //leeeeeak
endfunction
endlibrary