- Joined
- Jan 9, 2005
- Messages
- 2,126
Disclaimer: I'm terrible at reading code.
TimeUtils has NewTimer() and NewTimerEx(). So far, I've been using NewTimerEx() exclusively since I always have some sort of data attached to it, but I recently tried using NewTimer() for a delayed special effect destruction and it seems to work fine. Does that mean that NewTimer() allocates the timer its own instance? While all timer data from NewTimer() returns 0, the following seems to work without a hitch in single player:
Can anyone shed some light?
TimeUtils has NewTimer() and NewTimerEx(). So far, I've been using NewTimerEx() exclusively since I always have some sort of data attached to it, but I recently tried using NewTimer() for a delayed special effect destruction and it seems to work fine. Does that mean that NewTimer() allocates the timer its own instance? While all timer data from NewTimer() returns 0, the following seems to work without a hitch in single player:
JASS:
library DestroyEffectTimed requires TimerUtils
globals
private effect array Effect
endglobals
function EffectEnd takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer t_id = GetTimerData(t)
call DestroyEffect(Effect[t_id])
call ReleaseTimer(t)
set t = null
endfunction
function DelayedDestroyEffect takes effect vfx, real timeout returns nothing
local timer t = NewTimer()
local integer t_id = GetTimerData(t)
set Effect[t_id] = vfx
call TimerStart(t, timeout, false, function EffectEnd)
set t = null
endfunction
endlibrary
Can anyone shed some light?