• 🏆 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!

Cache won't retain some data

Status
Not open for further replies.
Level 23
Joined
Apr 3, 2018
Messages
460
I'm having an issue with game caches.
Some of the data I put in it is not retained.

BUT, this only happens with some of the stored data. Some keys work fine, but others don't.
Is there an article on what exactly am I supposed to do to have all my data saved in the cache?

the hell.jpg

Code:
StoreInteger(udg_cache, crea_name[i], name, 1)
BJDebugMsg("saved "+I2S(GetStoredInteger(udg_cache, crea_name[i], name)))
SaveGameCache(udg_cache)

TriggerSleepAction(3.)
BJDebugMsg("3sec later, the value is "+I2S(GetStoredInteger(udg_cache, crea_name[i], name)))

ReloadGameCachesFromDisk()
TriggerSleepAction(3.)

BJDebugMsg("3sec after reloading the cache "+I2S(GetStoredInteger(udg_cache, crea_name[i], name)))

crea_name here is "Ghouls" and name is "Ghoul frenzy". I'm trying to make a talent system with unlockable talents. The integer for marking unlocked talents won't save.
but StoreString(udg_cache, "Ghouls", "SelectedTalent", "Ghoul frenzy") for saving which of the unlocked talents is selected works just fine.
So some of the keys work but others don't and it's super annoying.
 
Last edited:
Level 12
Joined
Feb 22, 2010
Messages
1,115
I don't understand what your screenshot supposed to show. Do you know what ReloadGameCachesFromDisk does? As far as I know, it tries to load game caches for the map you are currently playing, if it does not find any already saved game caches, it creates new ones. No wonder you see "0" at the end because I don't see any save action inbetween.
 
Level 23
Joined
Apr 3, 2018
Messages
460
Yeah there's no need for ReloadGameCachesFromDisk.

The "reload caches from disk" function is only used here to check if stuff was saved on disk or not, to show in the post that stuff doesn't get saved.

- the values get stored in cache and can be retrieved from it during the game just fine
- but the moment I close the map or if I use "reload from disk" to emulate that, it turns out that some values went missing, even though I used "Save Game Cache"
- the whole purpose of the cache is to have that data available next time I run the map!

Most of my data gets saved just fine, but some of it doesn't for some reason, and I suspect it has something to do with the way StringHash works. So I'm asking, how do I save all of my stuff instead of only a random half of it? Is there a rule for choosing the hash keys?
 
Last edited:
Level 23
Joined
Apr 3, 2018
Messages
460
Code:
        string talentkey = "1"//name
        StoreInteger(udg_cache, crea_name[i], talentkey, 1)
        BJDebugMsg("saved "+I2S(GetStoredInteger(udg_cache, crea_name[i], talentkey)))
        SaveGameCache(udg_cache)
        TriggerSleepAction(3.)
        BJDebugMsg("3sec later, the value is "+I2S(GetStoredInteger(udg_cache, crea_name[i], talentkey)))
        ReloadGameCachesFromDisk()
        TriggerSleepAction(3.)
        BJDebugMsg("3sec after reloading the cache "+I2S(GetStoredInteger(udg_cache, crea_name[i], talentkey)))

Only thing that changed is that the second hash key is now just "1" instead of "Ghoul frenzy".
For some reason this now works - the debug gives 1 in the end instead of 0.
Could it be that it can't take long keys?
 
Status
Not open for further replies.
Top