Handle Counter
A sure fire way to determine whether you're map is leaking handles.
Simply copy the JASS script into a trigger named HandleCounter, configure the options, and enjoy!
Credits to Cohadar for first interesting me in this concept.
A sure fire way to determine whether you're map is leaking handles.
Simply copy the JASS script into a trigger named HandleCounter, configure the options, and enjoy!
Credits to Cohadar for first interesting me in this concept.
JASS:
scope HandleCounter
globals
//=====Config. Options=====\\
private constant string Title = "Handle Counter" // Title of your leaderboard
private constant string HandlesTitle = "Handles" // Text to display in handle count row
private constant string SecondsTitle = "Time (sec.)" // Text to display in time row
private constant real Timeout = 1. // Interval to update at ( I recommend a whole number, or your time elapsed displayed could bug)
private constant player DisplayTo = Player(0) // What player to display the leaderboard to
private constant player Row1 = Player(0) // The time text will be displayed in this players color
private constant player Row2 = Player(1) // The handle count text will be displayed in this players color
private constant boolean Single_Only = true // Whether to display the Handle Counter leaderboard in single player only
//=====No Touching Past This Point!!!!=====\\
private trigger Trigger = CreateTrigger()
private leaderboard Lead = null
private integer Seconds = 0
private location L = null
endglobals
private function H2I takes handle h returns integer
return h
return 0
endfunction
private function HandleCounter_Conditions takes nothing returns boolean
return not Single_Only or bj_isSinglePlayer
endfunction
private function Update takes nothing returns nothing
set Seconds = Seconds + Timeout
call LeaderboardSetItemValue(Lead,0,Seconds)
set L = Location(5.,5.)
call LeaderboardSetItemValue(Lead,1,H2I(L)-0x100000)
call RemoveLocation(L)
endfunction
private function HandleCounter_Actions takes nothing returns nothing
call DestroyTrigger(Trigger)
set Trigger = CreateTrigger()
call TriggerRegisterTimerEvent(Trigger,Timeout,true)
call TriggerAddAction(Trigger,function Update)
set Lead = CreateLeaderboard()
call LeaderboardSetLabel(Lead, Title)
call PlayerSetLeaderboard(DisplayTo,Lead)
call LeaderboardDisplay(Lead,true)
call LeaderboardAddItem(Lead,SecondsTitle,Seconds,Row1)
call LeaderboardAddItem(Lead,HandlesTitle,0,Row2)
call LeaderboardSetSizeByItemCount(Lead,2)
endfunction
//===========================================================================
public function InitTrig takes nothing returns nothing
call TriggerRegisterTimerEvent(Trigger,.001,false)
call TriggerAddCondition(Trigger,Condition(function HandleCounter_Conditions))
call TriggerAddAction( Trigger, function HandleCounter_Actions )
endfunction
endscope