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

Could anyone help explain catalogs?

Status
Not open for further replies.
Someone didn't explain it well enough meaning only really good jass'ers would get it >.>

Point is.... are catalogs similar to something like a database or in gui where u store items to an item array to save it? Someone needs to make a working save/load example/version of it.

This is for Nestharus's stuff since he told me to ask here instead of helping in private msg's which he did try, I need someone whos more suited to being able to explain it better :thumbs_up:

Thanks goes out to anyone who bothers to read this and even more thanks if you respond attempting to help a pro GUI'er like me.
 
Catalogs are excellent for data compression, but they need to be created manually from map to map.

Let's say you have a list of items in your map:
JASS:
'I001'
'I003'
'I00k'
'I1k3'
'I200'
'I00h'
'I00m'
Without any compression at all, that is a lot of data to save. Even if you convert them to their string forms, that is a lot of strings. The number forms will hardly help considering rawcodes are incredibly large numbers.

However, catalogs can relieve this issue. Basically, you'll have an "index" to refer to each ID. Instead of saving the item code, you can save the index in the code. Then when you read the load code, you just refer to the index, load up the item code corresponding to it, and you're good to go. It would be kind of like:
JASS:
set catalog[0] = 'I001'
set catalog[1] = 'I003'
set catalog[2] = 'I00k'
set catalog[3] = 'I1k3'
set catalog[4] = 'I200'
set catalog[5] = 'I00h'
set catalog[6] = 'I00m'
When reading the code, obviously you can just get the id by referring to catalog[index]. You might also want to associate the ID with the rawcode, so that you can figure out which id to use for each item ID:
JASS:
call SaveInteger(hash, 'I001', 0, 0)
call SaveInteger(hash, 'I003', 0, 1)
call SaveInteger(hash, 'I00k', 0, 2)
// etc.
So let's say you have a unit with 6 items 'I003', 'I00k', 'I00h', 'I00m', 'I1k3', 'I200'. As you can see from the catalog, a save code (unencrypted) could look like:
1 - 2 - 5 - 6 - 3 - 4
And you would generate it by loading the index for each ID... e.g. LoadInteger(hash, 'I003', 0).

For more information, you can see Nestharus' save/load tutorial:
http://www.hiveworkshop.com/forums/jass-ai-scripts-tutorials-280/saving-loading-192851/
 
Status
Not open for further replies.
Top