Thread: PowerupSentinel
View Single Post
Old 10-30-2009, 03:25 PM   #11
D3zmodos
User
 
Join Date: Feb 2009
Posts: 13

D3zmodos has little to show at this moment (8)

Default

I did a quick conversion, for those who dont want to do it themselves and dont like zinc:

Collapse JASS:
library PowerupSentinel initializer onInit
//* ============================================================================
//*  PowerupSentinel by Vexorian
//*  ------------
//*    Placing this library in your map will automatically fix all rune/tome
//* memory leaks in your map.
//*
//*    Powerup items don't get removed automatically by the game, they instead
//*    just leave a small item in the map, this causes memory leaks but - worse -
//*    it also makes areas of your map where a lot of tomes have been used lag.
//*
//* ===========================================================================

globals
    private timer tic
    private item  array queue
    private integer qn=0
endglobals
    
    private function Callback takes nothing returns nothing
        local integer i=0
        loop
            exitwhen ( i >= qn )
            if ( GetWidgetLife(queue[i]) < 0.405 ) then
                call RemoveItem(queue[i])
            endif
            set queue[i]=null
            set i=i + 1
        endloop
        set qn=0
    endfunction
            
    private function CleanCall takes nothing returns boolean
        set queue[qn]=GetManipulatedItem()
        set qn=qn + 1
        call TimerStart(tic, 0.0, false, function Callback)
        return false
    endfunction
        
    private function onInit takes nothing returns nothing
        local trigger t=CreateTrigger()
        local integer i = 0
        set tic=CreateTimer()
        loop
            call TriggerRegisterPlayerUnitEvent(t,Player(i),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
            set i = i + 1
            exitwhen i == bj_MAX_PLAYER_SLOTS
        endloop
        call TriggerAddCondition(t, Condition(function CleanCall))
    endfunction

    endlibrary
D3zmodos is offline   Reply With Quote