HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Destroy Timer Issues?

10-10-2006, 04:26 PM#1
Rising_Dusk
Collapse JASS:
function EndTimer takes nothing returns nothing
    local integer i = H2I(GetExpiredTimer())
    local unit u = udg_SomeUnit
    
    call PauseTimer(I2Timer(i))
    call DestroyTimer(I2Timer(i))

    //**************************************************************************
    //** This is where I have questions.
    //** If I pause/destroy this timer before doing the following calls, will
    //** the thread have a chance to end prematurely and not unpause/uninvul the unit?
    //**
    call SetUnitInvulnerable(u, false)
    call PauseUnit(u, false)
    
    set u = null
endfunction

function StartTimer takes nothing returns nothing
    local unit u = udg_SomeUnit
    
    call PauseUnit(u, true)
    call SetUnitInvulnerable(u, true)
    call TimerStart(CreateTimer(), 1.0, false, function EndTimer)
    
    set u = null
endfunction

The question is shown in comments in the above jass script.
But basically, I'm asking if Pausing/Destroying timers in their callback can cause the thread to end prematurely?
10-10-2006, 04:38 PM#2
blu_da_noob
Have you tried debug messages to test?
10-10-2006, 04:38 PM#3
Vexorian
I doubt PauseTimer does, but the other day DestroyTimer seemed to have a chance it should be easier to just recycle timers though
10-10-2006, 04:40 PM#4
Rising_Dusk
Quote:
Have you tried debug messages to test?
That's a good idea, however I cannot do so right away.
I'll run a test on it later tonight.

Still though, I was destroying the timer in tons of spells before other calls in AotZ.
So if this is an issue, then maybe I've located the cause for the multitude of bugs in AotZ.
We'll see.
10-10-2006, 05:46 PM#5
emjlr3
ive been wondering this myself for a while

what is this recycle timers of which you speak?

im looking in the hydra spell, and i am trying to figure out how it works

basically just looks like you only pause timers, and never destroy them unless there are 8191 still alive, then you destroy it

what is the purpose of this, I just thought any timer bugs were caused by setting they're locals to null
10-10-2006, 06:50 PM#6
Chuckle_Brother
In my experience, destroying the timer is fine, even in its callback, of course I never really made any wildly complicated spells, so who knows what I am missing.

@Emj - It seems the bugs are much more...robust than that. Seems handles can become corrupted in several ways.
10-10-2006, 06:54 PM#7
Vexorian
Quote:
Originally Posted by emjlr3
ive been wondering this myself for a while

what is this recycle timers of which you speak?

im looking in the hydra spell, and i am trying to figure out how it works

basically just looks like you only pause timers, and never destroy them unless there are 8191 still alive, then you destroy it

what is the purpose of this, I just thought any timer bugs were caused by setting they're locals to null
well it is a way to not have leaks and still fix the issue, also it seems that getting the timer from stack is faster than CreateTimer although I doubt if it is true when the extra call is involved
10-11-2006, 07:44 AM#8
DotA_DR
I guess, Within Timer/Enum/Filter/Condition's call not applicable operation which can interrupt execition flow. (ex: TriggerSleepAction, IssueOrder and other action with gameplay object)