• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] vJASS Structs, Gamecache help!

Status
Not open for further replies.
Level 12
Joined
Feb 23, 2007
Messages
1,030
I attach a struct to a timer using

JASS:
call SetHandleInt(t,"str",str)

Do I need to

JASS:
call FlushHandleLocals(t)

when I destroy the timer (Probably wouldn't have this problem if I tried a timer recycler...)

JASS:
    call FlushStoredInteger(LocalVars(),I2S(H2I(u)),"str")
    call FlushStoredInteger(LocalVars(),I2S(H2I(t)),"str")

Should I use this instead?
 
Level 12
Joined
Feb 23, 2007
Messages
1,030
Not quite what I meant. I was referring to
JASS:
    call FlushStoredInteger(LocalVars(),I2S(H2I(u)),"str")
    call FlushStoredInteger(LocalVars(),I2S(H2I(t)),"str")

Those are the alternatives I meant. Are they usually better than

JASS:
FlushHandleLocals

for clearing up structs after use?
 
Level 11
Joined
Feb 22, 2006
Messages
752
If you're using some kind of gamecache handle var attaching system, the two things you've posted do the same thing. Under jasshelper's inlining system, I think the first one might even be inlined to the second one...and if that is the case there would literally be no difference except the second method takes longer to type and looks uglier.
 
Level 12
Joined
Feb 23, 2007
Messages
1,030
If you're using some kind of gamecache handle var attaching system, the two things you've posted do the same thing. Under jasshelper's inlining system, I think the first one might even be inlined to the second one...and if that is the case there would literally be no difference except the second method takes longer to type and looks uglier.

JASS:
function LocalVars takes nothing returns gamecache
    return GameCache
endfunction

function SetHandleHandle takes handle subject, string name, handle value returns nothing
    if value==null then
        call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
    else
        call StoreInteger(LocalVars(), I2S(H2I(subject)), name, H2I(value))
    endif
endfunction

function GetHandleHandle takes handle subject, string name returns handle
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction

This is what I'm using (that's not all of it).

I need to remove specific structs from the unit (because I might eventually want to attach more than 1 to it). So I think the second method might be better since it allows me to clean up a specific struct.
 
Use TimerUtils, gamecache is slower. Plus you don't have to develop your own system.

This is how TU looks..

JASS:
function callback takes nothing reeturns nothing
    local yourstruct s = GetTimerData(GetExpiredTimer())
endfunction

function example takes nothing returns nothing
    local yourstruct s = s.create()
    local timer t = NewTimer()
    call SetTimerData(t, s)
    call TimerStart(t, .....)
endfunction
 
Level 11
Joined
Feb 22, 2006
Messages
752
God, why is gamecache such a taboo? You say it and every1 runs away before you finish the last syllable...

Yes, gamecache is slower than array lookups (the only other way to map stuff in JASS without using userdata), but unless you are going to be doing hundreds of lookups with gamecache PER SECOND it doesn't matter.
 
Level 12
Joined
Feb 23, 2007
Messages
1,030
I ran the tests for HSAS, HAIL, ABC and GameCache, it really isn't that much slower.

But I would like to use the fastest, and I already null every handle anyways, so I think HSAS would be better, but I can't get it to work. GameCache works fine though, so I might just stick with it.
 
For attaching to units, just gamecache if you can't use UserData.

Also, don't concern yourself with such minor speed perks as flushing the mission versus flushing a key (assuming there is only one key in the mission), just do whatever feels best to you.

I don't care about speed either, I just use TU because I just randomly picked a Timer attachment system :p
 
Status
Not open for further replies.
Top