• 💀 Happy Halloween! 💀 It's time to vote for the best terrain! Check out the entries to Hive's HD Terrain Contest #2 - Vampire Folklore.❗️Poll closes on November 14, 2023. 🔗Click here to cast your vote!
  • 🏆 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!
  • 🏆 HD Level Design Contest #1 is OPEN! Contestants must create a maze with at least one entry point, and at least one exit point. The map should be made in HD mode, and should not be openable in SD. Only custom models from Hive's HD model and texture sections are allowed. The only exceptions are DNC models and omnilights. This is mainly a visual and design oriented contest, not technical. The UI and video walkthrough rules are there to give everyone an equal shot at victory by standardizing how viewers see the terrain. 🔗Click here to enter!

[JASS] vJass Question

Status
Not open for further replies.
Level 5
Joined
Aug 16, 2007
Messages
149
Hi, I want to make a save/load system for my campaign and theres a lot of data to store. It would take multiple game caches (I want 5 save slots) and be very slow while loading the data. This might put people off my campaign. I was wondering if it is possible to store my saves in a struct, store the struct in a game cache then retrieve the data later with minimum lag while saving and loading. If anyone knows will you please tell me if it is possible and if so how?
 
Level 6
Joined
Jun 30, 2006
Messages
230
Well... when USING data, a struct is by far more efficient. However, for permanently saving data you will have to store it in a gamecache anyways. Calling that data from the gamecache may be faster if it is in a struct, but I honestly don't know. I'd expect it only to be slightly faster if faster at all. Data is data, no matter how you refer to it, so setting it in a struct and then storing it in the cache will eliminate all but 1 call to the game cache for each save/load.

The answer is: why don't you try both ways and find out?
 
Level 5
Joined
Aug 16, 2007
Messages
149
Eleandor, the reason I can't do it with subfolders is I have LOADS to save. Probably more than the available 255 slots for each save slot...
The Answer is: why don't you try both ways and find out?
I suppose that may be the only way of doing it... but i'm not at the point where i can test it yet. I'm making the save/load system before i've made most of the rest of the campaign!
I don't know much about save/load codes, but what I do know is that structs are faster since you only have to attach one thing that holds many things (just explaining to Eleandor)........right?
I think i agree with silvenon on that one
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
I don't know much about save/load codes, but what I do know is that structs are faster since you only have to attach one thing that holds many things (just explaining to Eleandor)........right?

Sure it's faster in-game, but if you want to store something like that on your disk, you'll have to split it up in each individual field anyway, so...

Now what exactly are you trying to save that you need more than 256 slots?
 
Level 5
Joined
Aug 16, 2007
Messages
149
the x,y,owner and type of every unit, x,y and of every destructible(or destructable)and each player's resources (custom resources, more than just gold+lumber and yes, i need to store computer's resources as well) the campaign is based on Rome:Total War so I also need to store the units inside each unit (which is actually a unitgroup, but needs to be displayed as a unit) and i also need to store buildings and units inside the cities... basically, theres a hell of a lot to store!
 
Last edited:
Level 21
Joined
Aug 21, 2005
Messages
3,699
If you want to store a complete map (and it appears you're trying to), use the following 2 actions:

Game - Save game as SaveFile.w3z and change level to Maps\MapName.w3x (Skip scores)
Game - Save game as SaveFile.w3z and load LoadFile.w3z (Skip scores)

Whenever you're about to leave the map, use 1 of the 2 actions depending on whether you are going to visit the next map for the first time, or if you already visitted the map before...

If you need more help on this, tell me if you want to save 1 map or multiple maps.
 
Level 5
Joined
Aug 16, 2007
Messages
149
thats a point... i know how to use those functions but i didn't think of it before... but I still need to save the units to be used in the battle to carry through into the battle. That would require lots of slots... but +rep for reminding me how to use SaveGame and LoadGame
 
Last edited:
Level 5
Joined
Aug 16, 2007
Messages
149
Not necessarily. I need to store upgrades (probably a bitstream, booleans stored in an integer), unittype, number for each squad. Thats 3 values. 255/3 = 85. So if i have say 50 squads per side, it would go over the maximum: (50+50)*3 = 300. In fact, any number of squads in total over 85 would cause an error. But I suppose I could just limit the number of squads per side...
 
Last edited:
You should use string data, as in, saving one unit like this in string:
Unit Life + Unit Mana + Unit Type + so on, all in one string variable, like storing THIS into gamecache: 1550(HP);300(MP);hfoo;
To get a 'hfoo' from string you will have to use pools from vex' cscache, converting string to integer in such way.
This way you would need only one slot per unit, and you would need to make functions in that map as well, to read unit life (Function that takes everything before the first ";"(, function that reads mana (Everything from first ";" to second ";") and so on. I think you get the point. You can do same with upgrades, like saving "1;5;4;3;8;65" , having Upgrade ids (for example upgrade #1 takes value before first ";" to first ";", second one takes value from first ";" to second ";").
 
Level 5
Joined
Aug 16, 2007
Messages
149
ye I suppose that would be a good way of doing it, but I'm not really that sure about using strings since people say they leak... wouldn't it be easier to use a struct like my original question was?
 
Level 5
Joined
Aug 16, 2007
Messages
149
Now I think about it, I suppose you're right. I'll use strings. +rep for your help.

EDIT:
HappyTauren you just inspired me to make a String Array system! It would be like vJass Dynamic Arrays except there would be no limit to how many of them could be created at one time and they would be a single variable(technically) so would be storable in Game Caches and usable as parameters! After it's made I'm going to alter it to use in my campaign for my
 
Last edited:
Status
Not open for further replies.
Top