Well, I just made another trigger with use of structs, but I feel I'm not that good at it, so I was just wondering if someone could give me some advice if there is something wrong that I could improve with my code. Just to learn a little bit more.
Also, I would like to do some random questions like if I have to destroy the timers, I mean, do they leak?
And can I use the same data name for more than 1 struct? For example, can I have
JASS:
struct WkUp
integer i
endstruct
function WakeUp takes nothing returns nothing
local WkUp data = GetCSData(GetExpiredTimer())
local timer t = GetExpiredTimer()
local integer i = data.i
call PauseUnit( udg_Survivor[i], false )
call UnitRemoveAbility( udg_Survivor[i], 'A011' )
//unleak
set t = null
call data.destroy()
endfunction
function Trig_ESC_Actions takes nothing returns nothing
local integer i = GetPlayerId(GetTriggerPlayer())+1
local timer t = CreateTimer()
local WkUp data = WkUp.create()
if ( GetUnitAbilityLevel( udg_Survivor[i], 'A011' ) > 0 ) then
//struct data
set data.i = i
call SetCSData(t, data)
call DisplayTextToPlayer(Player(i-1), 0, 0, "Trying to wake up, please wait some seconds while you wake up from your dreams")
call TimerStart( t, 10, false, function WakeUp )
else
call data.destroy()
endif
//unleak
set t = null
endfunction
Also, I would like to do some random questions like if I have to destroy the timers, I mean, do they leak?
And can I use the same data name for more than 1 struct? For example, can I have
WkUp
data and Ress data
without getting errors like the Double Free or something like that?