Thread: PowerupSentinel
View Single Post
Old 10-30-2009, 03:06 PM   #10
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,898

Submissions (37)

Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)

Hero Contest #3 - 2nd Place

Default

hmnn this is what jasshelper generates, not sure which one is the least readable...

Collapse JASS:
/*
*  PowerupSentinel
*  ------------
*    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 caused memory leaks but - worse -
* it also makes areas of your map where a lot of tomes have been used lag a lot.
*
*/

library PowerupSentinel initializer onInit 
    private keyword tic
    private keyword queue
    private keyword qn
    private keyword onInit
    globals
    private timer tic
    endglobals
    globals
    private item  array queue
    endglobals
    globals
    private integer qn=0
    endglobals
            private function anon__1 takes nothing returns nothing
                local integer i=0
                set 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 anon__0 takes nothing returns boolean
            set queue[qn]=GetManipulatedItem()
            set qn=qn+1
            call TimerStart(tic,0.0,false,function anon__1)
            return false
        endfunction
    private function onInit takes nothing returns nothing
        local trigger t=CreateTrigger()
        set tic=CreateTimer()
        call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_PICKUP_ITEM)
        call TriggerAddCondition(t,function anon__0)
    endfunction
endlibrary
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote