- Joined
- Jun 21, 2012
- Messages
- 431
someone tell me that this wrong in this code pls 

JASS:
library Optimizer32
/*********************************************************************************
*
* Optimizer32
* ___________
* v1.0.0.0
* by Thelordmarshall
*
* Description: Coming soon.
*
* Credits:
* ________
* -
*
* Notes:
* ______
* - All suggestions are welcome
*
* Copyright © 2015.
*********************************************************************************/
struct Timer32
static constant real PERIOD=.031250000
private static timer t32=CreateTimer()
private static integer array list
private static integer array timerList
private static integer size=0
private static integer timerSize=0
private static integer instanceData=0
private trigger t
private integer data
private real duration
private boolean active
private boolean periodic
private triggercondition tc
private static method loop32 takes nothing returns nothing
local integer i=0
local integer c=0
local thistype this
loop
exitwhen(i==timerSize)
set this=timerList[i]
if(.active)then
set instanceData=.data
if(not.periodic)then
set .duration=.duration-PERIOD
if(.duration<=0.)then
call TriggerEvaluate(.t)
call .stop()
endif
else
call TriggerEvaluate(.t)
endif
set c=c+1
endif
set i=i+1
endloop
set timerSize=c
if(c==0)then
//call BJDebugMsg("t32 paused")
call PauseTimer(t32)
endif
endmethod
static method getData takes nothing returns integer
return instanceData
endmethod
static method start takes integer data, real duration, code c returns Timer32
local thistype this=list[0]
if(this==0)then
set this=size+1
set size=this
else
set list[0]=list[this]
endif
if(not.active)then
set .t=CreateTrigger()
set .data=data
set .active=true
set .duration=duration
set .periodic=(.duration==0)
set .tc=TriggerAddCondition(.t,Condition(c))
set timerList[timerSize]=this
set timerSize=timerSize+1
if(timerSize==1)then
call TimerStart(t32,PERIOD,true,function thistype.loop32)
endif
endif
return this
endmethod
method stop takes nothing returns nothing
set list[this]=list[0]
set list[0]=this
set timerList[timerSize]=timerList[0]
set timerList[0]=timerSize
set .active=false
set .periodic=false
call TriggerRemoveCondition(.t,.tc)
call DestroyTrigger(.t)
set .t=null
set .tc=null
endmethod
endstruct
endlibrary
Last edited: