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

Save/Load Alternatives

Status
Not open for further replies.
Level 22
Joined
Jul 25, 2009
Messages
3,091
I'm working on a major release, with a whole slew of new features implemented into warcraft 3, but it currently has an archaic save/load system based on typing -save, writing down a code on screen and typing -load (your numbers here) to load the code in a future match. I'm aware Nestharus found a way to create a codeless save/load. Anyway, help me out here.

I only want to save 2 integers with arrays (each array for a player),
Games_Played[]
and Player_Experience[], player_experience's value could get up to 500,000 max, but I could make the ceiling a lot lower if this was a problem (I don't see why the value would effect speed).

I'm not a coder, so I need help with this. I just want to save/load 2 integers with arrays using the most lightweight, convenient process available.

Here's the map thread by the way ::: http://www.hiveworkshop.com/forums/map-development-202/black-winter-243396/
 
Well, you need to realize that your code is going to increase with the hash. You'll definitely want a hash. Depending on what encryption you use, it may or may not increase. AES-128 will keep it at a minimal of 128 bits. If you go with MD5, you have another 128 bits. 1 full integer is 32 bits (talking using all of it), so minimally you are going to have 256 bit codes. If you go with Knuth for your hash, it'll be much smaller because Knuth is tiny.

You probably want version control as well. Version control doesn't add much. You should always have version control, even if you think you don't need it. If you ever, in the future, want to change your code, no version control = reset, lol, so you want it.

Keep in mind that for codeless save/load to work, players must run a bat file that will be written to their machine when first starting up the File IO system. This adds the burden of players having to run a .bat file and restarting wc3 in order to load codes from your map (maybe you don't have to restart wc3, not sure, would have to test editing the registry value while wc3 is running) (they can play through your map and save etc, then when they done, restart wc3). This isn't a major issue, they only ever have to run the bat file one time and then they are good forever, but whatever, keep that in mind.


Now if you go with simple encryption (won't increase your code size) and a small knuth checksum, then you are probably looking at 4 integers saved (need a CRC too), which will probably be small enough to run through the current Network library without killing everybody, haha.

I don't have time to update it to use the new method, sorry =\. If I could update it, it could be used for a lot more data =). You can always write your own Network library using the new method and just integrate it in with the rest of the system. Up to you.


As such, you have 4 options

1. use BigInt + Knuth + CRC + Scrambler (AES not written for BigInt yet) (old, but ok for codes that aren't codeless, AES is smarter choice than Scrambler)
2. use BitInt + CRC + MD5 + AES (new, but longer codes, not good unless codeless)
3. use codeless save/load + BitInt + BigInt (need both) + CRC + Knuth + Scrambler (will require some tinkering) (Network is meh)
4. write Network library (most of new code is already provided) and integrate it with codeless save/load, then do BitInt + CRC + MD5 + AES (very good)

Actually, I may spend some time to write the Network library this weekend, we'll see. My schedule is pretty dern packed. I'd love to update BooleanExpression to use a different data structure, which will remove the need for the rebuild process. I guess Network and BooleanExpression will be at the top of my list, although AttackIndexer and Lua updates are pretty important too (get Lua to run on a machine with bad wc3 installation).
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Or you can write your own which is nowhere near a complex as Nestharus's but still good enough that no one cares.

Easiest is bit-aligned fields with simple checksum stuff and some simple shift encryption. Not secure but good enough to stop anyone who is not actively trying to cheat (who will just hack your save triggers anyway so even the most secure code is then cracked with the same effort).
 
Level 22
Joined
Jul 25, 2009
Messages
3,091
This is all so god damn over my head hahaha.

I don't think I'll be writing any network libraries lol.

Encryption isn't a big deal, if people feel such an inherent need to cheat then they'll find a way, I just want to eliminate the easy ways, like going into singleplayer and farming with "whosyourdaddy"

With a network you would still have to run a .bat file to initialize right? That obviously wouldn't effect this part of it?

And I'm a huge nooby when it comes to coding, so it's pretty obvious if I get into the codeless side of this I'll need someone to do it for me or at the very least hold my hand through it.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,219
Ok so I did a quick save/load with file I/O should be somewhat simple for you to modify it. I only save/load the experience right here, but adding games played should be simple.
  • GUI Save
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Custom script: local File file
      • Set mapName = testMap
      • Set file = exp
      • Set player = Player 1 (Red)
      • Set playerID = (Player number of player)
      • Set playerExperience[playerID] = 10000
      • Custom script: set file = File.open(udg_mapName, udg_file, File.Flag.WRITE)
      • Custom script: if GetLocalPlayer() == udg_player then
      • Custom script: call file.write(I2S(udg_playerExperience[udg_playerID]))
      • Game - Display to (All players) the text: saved!
      • Custom script: endif
      • Custom script: call file.close()
  • GUI Load
    • Events
      • Player - Player 1 (Red) types a chat message containing load as An exact match
    • Conditions
    • Actions
      • Custom script: local File file
      • Set mapName = testMap
      • Set file = exp
      • Set player = (Triggering player)
      • Set playerID = (Player number of player)
      • Custom script: set file = File.open(udg_mapName, udg_file, File.Flag.READ)
      • Custom script: if GetLocalPlayer() == udg_player then
      • Custom script: set udg_playerExperience[udg_playerID] = S2I(file.read())
      • Game - Display to (All players) the text: (String(playerExperience[playerID]))
      • Custom script: endif
      • Custom script: call file.close()
 

Attachments

  • File IO.w3x
    21 KB · Views: 108
Last edited:
Level 22
Joined
Jul 25, 2009
Messages
3,091
Ok so I did a quick save/load with file I/O should be somewhat simple for you to modify it. I only save/load the experience right here, but adding games played should be simple.
  • GUI Save
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Custom script: local File file
      • Set mapName = testMap
      • Set file = exp
      • Set player = Player 1 (Red)
      • Set playerID = (Player number of player)
      • Set playerExperience[playerID] = 10000
      • Custom script: set file = File.open(udg_mapName, udg_file, File.Flag.WRITE)
      • Custom script: if GetLocalPlayer() == udg_player then
      • Custom script: call file.write(I2S(udg_playerExperience[udg_playerID]))
      • Game - Display to (All players) the text: saved!
      • Custom script: endif
      • Custom script: call file.close()
  • GUI Load
    • Events
      • Player - Player 1 (Red) types a chat message containing load as An exact match
    • Conditions
    • Actions
      • Custom script: local File file
      • Set mapName = testMap
      • Set file = exp
      • Set player = (Triggering player)
      • Set playerID = (Player number of player)
      • Custom script: set file = File.open(udg_mapName, udg_file, File.Flag.READ)
      • Custom script: if GetLocalPlayer() == udg_player then
      • Custom script: set udg_playerExperience[udg_playerID] = S2I(file.read())
      • Game - Display to (All players) the text: (String(playerExperience[playerID]))
      • Custom script: endif
      • Custom script: call file.close()

This is just saving the code to a file in a folder and referencing it in game whenever you type save, right?
 
Do iiiittttttt.

Also huge thanks. I don't have time to implement this right now, but I'm sure when I do there'll be questions. Again thanks a ton for this bit.

There's a huge interactive save/load tutorial already written that covers practically everything = ). Look in my sig under My Resources. Download the map and then "play it"
 
Oh so your system will only work in single player?

Only one machine has the file. When you read it, only one player has the data. Network is a way to share that data witj everyone else in the game. Current Network is garbage, which is why codeless save/load hasn't taken off. Someone came up with a much faster way, ForceUIKey and ability events, but gotta make a lib for it using his research. As such, unless you have VERY little data, codeless save/load isn't possible. Gotta update Network library.
 
Level 22
Joined
Jul 25, 2009
Messages
3,091
Only one machine has the file. When you read it, only one player has the data. Network is a way to share that data witj everyone else in the game. Current Network is garbage, which is why codeless save/load hasn't taken off. Someone came up with a much faster way, ForceUIKey and ability events, but gotta make a lib for it using his research. As such, unless you have VERY little data, codeless save/load isn't possible. Gotta update Network library.

How little data?

And what's a lib?
 
A lib is short for library, which is just a resource. Network is a library.

As for how little data, I think up to 128 bits might be ok, maybe even a little bit more. This'll allow you to use Knuth + AES-128, but not MD5. I don't think 256 bits will work. You'll know whether it's ok or not = P. Just start a game with 12 players and see if the game is frozen for awhile or not, lol. If it is, too much data. If not, you're good.

If you have too much data with AES, move down to Scrambler.

You're going to have to mix/match vJASS resources here.
 
Status
Not open for further replies.
Top