• 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.

[General] Hashtables vs GameCache

Status
Not open for further replies.
Level 15
Joined
Oct 29, 2012
Messages
1,474
Well, it's simple... GameCache is a 'file' saved in your HDD, while Hashtables are not, they are dealt with, in the same level (afaik they are memory binaries or data or something like that, that's why they are faster)

Let's say, both use Child key and Parent Key, they both store information... also GameCache is a very useful to save an exact copy of a hero. And Hashtables are useful for MUI spells as AFAIK are faster than GameCache ( since creating a file depends on many things that may slow down the operations). Hashtable is one-level only use and GameCache can be used in the next level to load information, like Save-Load code.
A Hashtable can be contained into Game-Cache and vice-versa is wrong

They barely work the same since they do similar tasks , for example storing different values like integers and reals and abilities, and like overpassing storing a null value that's senseless ... I don't think they are very different though, I would like if someone gave further explanation too
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Sigh, young people...

GameCache is a 'file' saved in your HDD
Not in multiplayer sessions. Only if the session is started as single player.

Too bad GameCache is single player only... Thanks
Incorrect. Game caches do work in multiplayer. However their persistence function does not.

The similarities between hashtable and gamecache are more than coincidence. Long before Blizzard eventually added hashtable into WC3 there was only gamecache. All the functionality we take for advantage using hashtable was then done using gamecache. In fact gamecache was a lot more flexible than hashtable in this mode of operation as we had a completely unchecked, unsafe typecast exploit to change values between literally any type. We also did not know of string leaks back then.

However, with DotA rising in popularity hackers eventually discovered that JASS code works as a dynamic function pointer internally. As such you could turn WC3 into the ultimate Trojan and make it execute what ever code you want.

As a demonstration map, some annoyed mappers created a map that passed as the lattest version of DotA when viewed from the lobby and was so small it loaded and started instantly. The map then proceeded to delete vast amounts of data from the user's systems. I forget if it was just all their WC3 maps or if it also deleted their Window folder destroying their OS installation. In any case this was a major security exploit that had to be fixed before Blizzard became liable for damages.

So a team was created to patch WC3 and remove the type casting exploit (or at least the ones that worked with code). Although this was easy to do, they had a problem that a lot of maps would no longer function as they depended heavily on type casting for carious systems and data management.

The solution was to take the commonly used game cache data structure and give it type safe wrappers for all commonly used types. Also to minimize string leaks, instead of taking strings for parent and child, hashing them and using those numbers to look up the data, the hashes would be taken as arguments directly. To generate these hashes, the string has function was exposed as a native and also the handle to integer function was created since handles operate inherently as hashes.

Not everything went perfectly well however, when GUI wrappers were made they forgot what a mess GUI was and though that "ability" in JASS was the same as Ability type in GUI. The result is selecting certain wrappers for the hashtables will crash the editor. However this only affects GUI.

To improve safety they also tried to reference count stored handles and prevent the hashtables from being used as type cast sources themselves. The result however was a number of in-game crashes relating to incorrect usage of hashtables that may or may not have been fixed over the years.

The end result was the hashtable data structure which takes the hashtable nature of gamecache and exposes it in a more efficient and usable interface. As such gamecaches have fallen out of common use except for their original purpose, to store persistent single player data.

This is why both gamecache and hashtable have a 255 or 256 instance limit since hashtables were based on gamecache code.
 
Status
Not open for further replies.
Top