HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Why do you always use InitGameCache twice?

05-02-2007, 06:05 PM#1
Danat
Hi, I'm new to Jass and when I analyse some of your code examples I always see something like this:
Code:
call FlushGameCache(InitGameCache("GC"))
set udg_GC=InitGameCache("GC")
My question is: Why do you initialize game cache and then instantly flush it? What's the point of it? :)
Why not simply initialize it once?
05-02-2007, 06:44 PM#2
Vexorian
If your map was multiplayer guaranteed that wouldn't be an issue.

But we also might use test map for quick tests so it is better to do that.

Why? The problem is that When a gamecache is saved the game somehow thinks it is a good idea to save ALL GAMECACHES . Even these ones we use for spell and system storage rather than for saving stuff in disk for the player.

Then if one of these dummy gamecaches is saved it will be automatically loaded by InitGameCache.

So it is better than when initializing it you Flush it (aka clear it)

But then Flush also discards the gamecache handle, so you have to call InitGameCache again. (this time it 'll be empty)
05-02-2007, 07:09 PM#3
Danat
OK I got it. Thank you.
There is one more thing i want to ask:
Code:
set gcOne = InitGameCache("GC")
set gcTwo = InitGameCache("GC")
will gcOne and gcTwo point to the same object or InitGameCache allocates a new memory block for each call even if the cache name is the same?