• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] TimerUtils: do I need to PauseTimer before ReleaseTimer?

Status
Not open for further replies.
Level 11
Joined
Oct 11, 2012
Messages
711
I learned from a tutorial that whenever you destroy a timer by using DestroyTimer, you have to pause the timer first by using PauseTimer to avoid bugs. So if I am using TimerUtils, do I need to pause the timer before using ReleaseTimer() ?

JASS:
call PauseTimer(t)
call DestroyTimer(t)

How about:
JASS:
call PauseTimer(t)
call ReleaseTimer(t)
//Do I need to PauseTimer here? or ReleaseTimer would both pause and destroy it?
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
No..

JASS:
    function ReleaseTimer takes timer t returns nothing
        if(t==null) then
            debug call BJDebugMsg("Warning: attempt to release a null timer")
            return
        endif
        if (tN==ARRAY_SIZE) then
            debug call BJDebugMsg("Warning: Timer stack is full, destroying timer!!")

            //stack is full, the map already has much more troubles than the chance of bug
            call DestroyTimer(t)
        else
            call PauseTimer(t)
            if(GetTimerData(t)==HELD) then
                debug call BJDebugMsg("Warning: ReleaseTimer: Double free!")
                return
            endif
            call SetTimerData(t,HELD)
            set tT[tN]=t
            set tN=tN+1
        endif    
    endfunction
 
Level 11
Joined
Oct 11, 2012
Messages
711
No..

JASS:
    function ReleaseTimer takes timer t returns nothing
        if(t==null) then
            debug call BJDebugMsg("Warning: attempt to release a null timer")
            return
        endif
        if (tN==ARRAY_SIZE) then
            debug call BJDebugMsg("Warning: Timer stack is full, destroying timer!!")

            //stack is full, the map already has much more troubles than the chance of bug
            call DestroyTimer(t)
        else
            call PauseTimer(t)
            if(GetTimerData(t)==HELD) then
                debug call BJDebugMsg("Warning: ReleaseTimer: Double free!")
                return
            endif
            call SetTimerData(t,HELD)
            set tT[tN]=t
            set tN=tN+1
        endif    
    endfunction

Thanks for the answer. I managed to understand this codes but failed coz I am a noob LOL
 
Status
Not open for further replies.
Top