HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Fatal error with simple function?

07-28-2006, 09:58 PM#1
The)TideHunter(
Ok, i made a function that pauses gametime for a certain amount of time, then when its finished it changes it to another time.
Here it is:

Collapse JASS:
function CF_SetCustomTime_Expire takes nothing returns nothing
    local timer t = GetExpiredTimer()
    call SetTimeOfDay(CF_GetAttachedReal(t, "CF_SetCustomTime_EndTime"))
    call SetTimeOfDayScale(1.)
    call CF_DestroyTimer(t)
endfunction

function CF_SetCustomTime takes real StartTime, real Duration, real FinishTime returns nothing
    local timer t = CreateTimer()
    call SetTimeOfDay(StartTime)
    call SetTimeOfDayScale(0.)
    call CF_AttachReal(FinishTime, "CF_SetCustomTime_EndTime", t)
    call TimerStart(t, Duration, false, function CF_FreezeTimeOfDay)
endfunction

Its gets the chrash after the duration has ended, so when it runs CF_SetCustomTime_Expire, can anybody see a problem with it?
All the CF functions work ok btw. Just incase their might be problems, i attached the 1s i used.

Collapse JASS:
function CF_RemoveAttachments takes handle KeyHandle returns nothing
    call FlushStoredMission(CF_GC(), CF_H2S(KeyHandle))
endfunction

function CF_DestroyTimer takes timer whichTimer returns nothing
    call PauseTimer(whichTimer)
    call CF_RemoveAttachments(whichTimer)
    call DestroyTimer(whichTimer)
endfunction

function CF_AttachReal takes real whichReal, string label, handle KeyHandle returns nothing
    local integer i = CF_H2I(KeyHandle)
    if(i != 0) then
        call StoreReal(CF_GC(), label, I2S(i), whichReal)
    else
        call FlushStoredMission(CF_GC(), label)
    endif
endfunction

function CF_GetAttachedReal takes handle KeyHandle, string label returns real
    return GetStoredReal(CF_GC(), label, CF_H2S(KeyHandle))
endfunction

function CF_H2S takes handle H returns string
    return I2S(CF_H2I(H))
endfunction

Thanks in advance.

EDIT: Added GetAttached
EDIT2: Noticed H2S, added.
07-28-2006, 10:05 PM#2
Captain Griffen
You haven't shown us the GetAttached function, but:

Collapse JASS:
call StoreReal(CF_GC(), label, I2S(i), whichReal)

Shouldn't it be I2S(i), then label?
07-28-2006, 11:32 PM#3
The)TideHunter(
I switched all my Store and Attach functions around so the handle uses the mission slot.
It all works well, the CF functions are working the way they are surposed too, but i dont understand how this could cause a fatal error.

EDIT: Note, CnP is evil! do not trust it, especially with a bad memory like me -.-
I noticed the TimerStart, the function is takes, that is not part of that module, its a completly different function!
Im so annoyed at myself.
Sorry for all this.