HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Gamecache

01-03-2009, 06:58 AM#1
fX_
What is it? How does it work? How is it manipulated?

All I know about it is that it can store stuff.
EDIT: also, Bonus TFT Campaign about Rexxar
01-03-2009, 07:20 AM#2
Archmage Owenalacaster
The gamecache was first mentioned in the Book of Genesis. The Lord God Almighty stored a boolean value using call StoreBoolean( Creation, "Universe", "DoesExist", true ).

But seriously (and in nontechnical terms), it stores values. You can retrieve those values with the correct key. You need to flush the values before assigning a new one to the same position (I think). It can store just about anything.
01-03-2009, 07:35 AM#3
Vestras
I think these days you are best placed if you don't know what it is.
01-03-2009, 07:39 AM#4
chobibo
The gamecache is a save file used for the passing of a value, unit and others, from a map to another by storing data to your hard disk, AFAIK, you can only save the gamecache file for single player campaigns only, but that doesn't mean you can't use it on multiplayer maps. You can store data to it by using string keys and mission keys; by also using those keys, you can retrieve your data.

How does it work for multiplayer maps? Apparently, the gamecache writes its data to your computers primary memory (RAM) first, caching it there until you decide to save it to your hard disk. This means that you can access data from your gamecache while your map is still being played.

Quote:
I think these days you are best placed if you don't know what it is.
I disagree, what if he's making a campaign? gamecache was intended for campaigns anyways.
01-03-2009, 08:18 AM#5
fX_
You say it is intended for campaigns... but, apparently, it's being used to multiplayer maps too. So it is also used for storage, here? What are the advantages of using it and how is it used?
01-03-2009, 09:23 AM#6
Bobo_The_Kodo
If you're not using it for a campaign, you're better off not knowing. It was an OLD/OUTDATED/BUGGY method of storage used in multiplayer maps that generally resulted in what are known as "chaos bugs", which are random bugs that happen with the map code as the result of doing one of many random (some times unknown) things in conjunction with gamecache
01-03-2009, 09:26 AM#7
Jazradel
It's used because you can store data using the handle of a unit as a key.
H2I(unit) will return an integer unique to a unit, which you can then use as a gamecache key/store in a gamecache.
It was also used because you could store a lot of data globally and only have to declare only global variable.

Katana's handle vars (probably still on wc3jass) are the original usage. Vex's Table is the latest implementation.
01-03-2009, 12:36 PM#8
chobibo
Hey fx_
Quote:
Originally Posted by fx_
You say it is intended for campaigns... but, apparently, it's being used to multiplayer maps too.

Quote:
Originally Posted by chobibo_post#4
but that doesn't mean you can't use it on multiplayer maps

I did say that it can be used for multiplayer maps didn't I?

Quote:
Originally Posted by Bobo_The_Kodo
It was an OLD/OUTDATED/BUGGY method of storage used in multiplayer maps that generally resulted in what are known as "chaos bugs", which are random bugs that happen with the map code as the result of doing one of many random (some times unknown) things in conjunction with gamecache

Gamecache didn't cause the bugs, it was the return bug, specifically the IntegerToHandle typecasts.
Collapse JASS:
function I2H takes integer i returns handle
     return i
     return null
endfunction

Vexorian's Table uses gamecache, I think he wouldn't have used it if the bugs were caused by gamecache itself.
01-03-2009, 08:23 PM#9
Bobo_The_Kodo
Well that was required for using it to directly store handles, that is why Table only store integers
01-03-2009, 08:37 PM#10
chobibo
You're referring to Kattana's Local Handle Vars, not gamecache, the only handles supported by gamecache are units, of course, this is assuming that you won't exploit the return bug on gamecache. Anyways, I just wanted to clear that gamecache isn't bugged, it's just slow but it works as intended. Also because of structs, we can use gamecache safely since the preprocessor deals with instantiating the objects we use in our code, thus removing the need to typecast.
01-03-2009, 09:51 PM#11
Karawasa
Though this has little relevance for almost all maps, the gamecache serves one purpose that is infinitely useful for mine. It allows for the real time collection of multiplayer game data for use in a league.
01-03-2009, 11:06 PM#12
Anitarf
Quote:
Originally Posted by Bobo_The_Kodo
If you're not using it for a campaign, you're better off not knowing. It was an OLD/OUTDATED/BUGGY method of storage used in multiplayer maps that generally resulted in what are known as "chaos bugs", which are random bugs that happen with the map code as the result of doing one of many random (some times unknown) things in conjunction with gamecache
This statement is so 2007.

Gamecache is basically some sort of hash table object where you can store data (integers, reals, strings, even units) by associating it with two keys (which can be any string) and you can save the gamecache object itself to the hard drive and also load it from there (but only in single player). It is very useful as a data structure; it's kinda slow but it has very few limitations, the two string keys offer much more possibilities than for example the 0-8191 index limit in arrays.
01-03-2009, 11:27 PM#13
Rising_Dusk
AotZ is awesome for its chaos bugs. It has all sorts of problems, dynamic triggers, I2H, and a motley of other proven-to-be-awful techniques used all over the place. As far as I'm aware, AotZ is the only map with the proper errors lined up to cause natives to fail and timers to randomly stop and stuff.

Anyways, though, that is a result of poor coding more than anything else. Cache in itself is a very safe thing.
01-04-2009, 04:13 AM#14
fX_
Why is it slow and how can this be fixed?
01-04-2009, 04:36 AM#15
DioD
Fixing cache problems fast and easy...

Thread in russian

We must keep at least one reference to timer, or you will get 2 or more timers with same handle.

Collapse JASS:
call HandleDelay(SomeHandleLocal)
set SomeHandleLocal = null

Collapse JASS:
function HandleDelay takes handle Handle returns nothing
    set GlobalCounterInteger = GlobalCounterInteger + 1

    if GlobalCounterInteger == 8000 then
    set GlobalCounterInteger = 1
    endif

    set HandleStorage[GlobalCounterInteger] = Handle
    call ExecuteFunc("HandleCleanUp")
endfunction

function HandleCleanUp takes nothing returns nothing
    local integer ID = GlobalCounterInteger
    call TriggerSleepAction(0.00)
    set HandleStorage[ID] = null
endfunction


Same code for "unknown delay" removal.

Collapse JASS:
function HandleLOG takes handle Handle returns nothing
    set GlobalCounterInteger = GlobalCounterInteger + 1

    if GlobalCounterInteger == 8000 then
    set GlobalCounterInteger = 1
    endif

    set HandleStorage[GlobalCounterInteger] = Handle
    call StoreInteger(EngineCacheGlobal,H2S(Handle),"RecycleID",GlobalCounterInteger)
endfunction

function HandleRecycle takes handle Handle returns nothing
    set HandleStorage[GetStoredInteger(EngineCacheGlobal,H2S(Handle),"RecycleID")] = null
endfunction

Dont remember such code poster here.