Tom Jones
N/A
- Reaction score
- 437
I think Blizzard has fixed the bug with passing null as argument, because I can't get this to leak no matter how hard I try:
Or maybe I'm simply performing the test wrong.
JASS:
scope TestFilters initializer Init
globals
private constant string COMMAND = "-test "
private constant integer LENGTH = StringLength(COMMAND)
private constant integer DEDUCT = 0x100000
private group G = CreateGroup()
private timer T = CreateTimer()
private real RANGE
private rect AREA
private boolexpr FILTER
private integer HANDLES = 0
endglobals
private function H2I takes handle h returns integer
/*return h
return 0*/
return GetHandleId(h)
endfunction
private function HandleCount takes nothing returns integer
set T = CreateTimer()
set HANDLES = IMaxBJ(H2I(T)-DEDUCT,HANDLES)
call DestroyTimer(T)
return HANDLES
endfunction
private function True takes nothing returns boolean
return true
endfunction
private function Actions takes nothing returns nothing
local string s = GetEventPlayerChatString()
local integer i = StringLength(s)
local string key = StringCase(SubString(s,LENGTH,i),false)
if S2I(key) == 1 or key == "a" then
call GroupEnumUnitsInRange(G,0,0,RANGE,Condition(function True))
call GroupEnumUnitsInRect(G,AREA,Condition(function True))
call GroupEnumUnitsOfPlayer(G,Player(0),Condition(function True))
elseif S2I(key) == 2 or key == "b" then
call GroupEnumUnitsInRange(G,0,0,RANGE,FILTER)
call GroupEnumUnitsInRect(G,AREA,FILTER)
call GroupEnumUnitsOfPlayer(G,Player(0),FILTER)
elseif S2I(key) == 3 or key == "c" then
call GroupEnumUnitsInRange(G,0,0,RANGE,null)
call GroupEnumUnitsInRect(G,AREA,null)
call GroupEnumUnitsOfPlayer(G,Player(0),null)
else
call BJDebugMsg("Bad input: "+key)
return
endif
call BJDebugMsg("\n###################\n#Test "+key+".\n#HandleCount: "+I2S(HandleCount()))
endfunction
private function Init takes nothing returns nothing
local trigger trig = CreateTrigger()
set FILTER = Condition(function True)
set RANGE = GetRectMaxX(bj_mapInitialPlayableArea)-GetRectMinX(bj_mapInitialPlayableArea)
set AREA = Rect(GetRectMinX(bj_mapInitialPlayableArea),GetRectMinY(bj_mapInitialPlayableArea),GetRectMaxX(bj_mapInitialPlayableArea),GetRectMaxX(bj_mapInitialPlayableArea))
call TriggerRegisterPlayerChatEvent(trig,Player(0),COMMAND,false)
call TriggerAddAction(trig,function Actions)
endfunction
endscope
Or maybe I'm simply performing the test wrong.