• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

game cache initialization

Status
Not open for further replies.
Level 17
Joined
Apr 27, 2008
Messages
2,455
My question is for the good old game cache usage (not to transfer datas between maps)
I had never really used them but i'm wondering why people always do :

JASS:
call FlushGameCache(InitGameCache("myCache"))
set myCache = InitGameCache("myCache")

Instead of directly :

JASS:
set myCache = InitGameCache("myCache")

For me, it's to avoid datas conflits in the case of a campaign, but if it isn't a campaign that seems 100 % useless.
Ofc that doesn't matter that much, just because it's only one more line, and it's not like you can seriously use game caches dynamically, coz of the hardcoded 256 limit.

For example, this works as expected in a not campaign map (always display "0" and then "1") :

JASS:
scope Test initializer init

    private function init takes nothing returns nothing
        local gamecache gc = InitGameCache("myCache")
        
        call BJDebugMsg(I2S(LoadInteger(gc,"0","0")))
        call StoreInteger(gc,"0","0",1)
        call BJDebugMsg(I2S(LoadInteger(gc,"0","0")))
    endfunction

endscope

I'm 99 % sure it's only for campaigns, but who knows maybe there are some hocus pocus bug to know.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Just to confirm what you said, i've tested and it's profile related (even with 2 differents maps but using the same gamecache string name, the values will be kept for the same profile name).
But while you don't use SaveGameCache you don't have to worry about it. (or maybe there are some other functions i don't know)
 
Status
Not open for further replies.
Top