HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

keyword "constant"

02-02-2008, 06:37 PM#1
chobibo
What is the difference between a timer declared as a constant from a timer declared normally?
constant timer T1 = CreateTimer() and timer T2 = CreateTimer()
OFF-TOPIC: Hey why does this function work and not give errors?
Collapse JASS:
    public function StartTimers takes nothing returns nothing
        call TimerStart(Detector, 2.00, false, function StartTimers)
        call BJDebugMsg("Again?")
    endfunction 
02-02-2008, 09:00 PM#2
Vexorian
One will make the optimizer generate a bugged map script.
02-03-2008, 06:42 AM#3
Pyrogasm
Meaning...?
02-03-2008, 10:56 AM#4
chobibo
which one?
02-03-2008, 01:43 PM#5
Deaod
i think Vex's Optimizer tries to inline constant functions and globals. So if you change a constant global during gametime, your map gets srewed up.
02-03-2008, 01:52 PM#6
Malf
You can't change constant stuff. Hence the prefix constant
02-03-2008, 02:58 PM#7
Vexorian
Collapse JASS:

globals
    constant timer t=CreateTimer()
endglobals

function aa takes nothing returns nothing
    call BJDebugMsg("expire!")
    call TimerStart(t, true, GetRandomReal(1,2), function aa)
endfunction


Becomes (after optimizer):

Collapse JASS:
function aa takes nothing returns nothing
    call BJDebugMsg("expire!")
    call TimerStart(CreateTimer(), true, GetRandomReal(1,2), function aa)
endfunction



Try to run "optimized" aa on your map, have fun...