Demo Map Simple Save Demo

Nestharus

o-o
Reaction score
84
Save/Load With Snippets

This is a pack of resources that makes creating a high quality save/load system easy. It includes systems, snippets, tutorials, and demonstrations.

Requirements

vJASS


General Resources Included


Save/Load Resources Included


The Encyclopedia of Catalogs

Items

General Item Catalog
Hero Specific Item Catalog
Hero Specific Item Catalog with Slotted Items (chestplate item chest slot, boots item feet slot)
Item Catalogs Across Versions
Hero Specific Item Catalog with Slotted Items Across Versions
Dynamic Version Specific Hero Specific Level Specific Slotted Item Catalog
Heroes

Hero Catalog


Detailed Save/Load System Demonstrations

Simple Save/Load
Backwards Compatible Save/Load Codes


Tutorials

Saving An Inventory
Saving A Hero Specific Inventory
Saving A Slotted Inventory
Saving Item Charges
Saving Hero
Saving Multiple Units
Saving Versioned Catalogs
The Importance of the First Value
Smartly Saving Gold For RPG
Ways To Protect Code
The Architecture of Saving
The Architecture of Versioned Saving
Saving Infinite Unique Units
Saving Player Resources
Conditional Saving
Designing More Complex Catalogs
Pros/Cons of displaying code version vs having code version inside of code
Saving Partial Slotted Inventories of multiple sections
 

Attachments

  • Demo Map.w3x
    159.6 KB · Views: 509
  • Save and Load With Snippets.w3x
    166.2 KB · Views: 534

Laiev

Hey Listen!!
Reaction score
188
LOL

the most fast thread at Resources at TheHelper.

at least post the trigger lol :thup:
 

Nestharus

o-o
Reaction score
84
Added SaveXP and put string length checking into -load since you should always do string length checking.


Again, remember that this is just a demonstration and has in it a variety of useful snippets for save/load =).


The demo trigger is meant to show you good save/load practices ; P.
 

Nestharus

o-o
Reaction score
84
Added 5 detailed sample catalogs


General Items
Hero Specific Items
Hero Specific Items with Slots (chest -> chest slot, boots -> boots slot)
Item Catalogs Across Versions (adding new items to the map in a new release?)
Hero Specific Items with Slots Across Versions


And believe me, backwards compatibility has never been easier!


Sample of loading an item from the Hero Specific Items with Slots Across Versions Catalog
[ljass]local integer itemTypeId = Items.version[heroTypeId][Items.TYPE].raw(stack.pop(Items.version[heroTypeId][Items.TYPE].count))[/ljass]
 

Nestharus

o-o
Reaction score
84
Updated with more stuff ; O.


2 save/load demonstrations now and more details on stuff and yea, = D
 

Nestharus

o-o
Reaction score
84
Added information for how to save different things as well as how to architect backwards compatible save/load codes dealing with both code versions and a new concept I introduce called architecture versions.



This is the ultimate resource for save/load and is just jam packed with resources from demonstrations to tutorials to scripts.
 

Nestharus

o-o
Reaction score
84
Added
Saving Infinite Unique Units
Saving Player Resources
Conditional Saving

And a discussion on designing more complex catalogs


The two examples in the discussion are these
-Version Specific Hero Specific Level Specific Slotted Item Catalog
-Dynamic Item Catalogs Generated Based On Hero Inventory (ultimate compression)

However, the two catalogs (especially the second) are so complex that I don't really want to code them ; P.
 

Nestharus

o-o
Reaction score
84
Fixes:

InitSave
LoadInventory
LoadItemCharges
Catalog


Additions:

AVL Tree
Pros/Cons of displaying code version vs having code version inside of code
Saving Partial Slotted Inventories of multiple sections
Dynamic Version Specific Hero Specific Level Specific Slotted Item Catalog
 

tooltiperror

Super Moderator
Reaction score
231
Let's play the resource moderating game!

I'm going to throw this at you: Why approve any of these resources when Encoder already does this fine? The casual user should use Encoder, and anyone more advanced will be making something redundant by using this.
 

Nestharus

o-o
Reaction score
84
Actually, it's easier to use this than Encoder and you'll get the same results. It's also possible to use this for more advanced save/load.


Also, these resources are all submitted solo (most of them). The thing the map primarily contains is a pack of tutorials and demonstrations using those resources. The resources are only also included in the pack as they are needed to run the demos ; P.


The casual user should not use Encoder. Simple save/load is easier with this. Complex save/load is easier with this. Encoder is harder to use, can't do as much, and has more overhead. It loses on all fronts.


The only save/load system that is easier to use than these snippets is AceHart's. However, AceHart's simplicity is 1 less argument than what this has (this is just about as simple).


My stance is that all save/load systems be gy'd for snippets ; ). That ofc includes Encoder.


Now, to show you what I mean by ease of use

Snippets
[ljass]call stack.push(value, maxValue)[/ljass]

AceHart's
JASS:

set Save[1]=value
set SaveCount=1



The extra thing in the snippets is the maxValue arg.



It is easier and simpler to use these snippets than all save/load systems excluding AceHart's.


It is also possible to easily create things like a SaveInventory function.


Also keep in mind that the advanced techniques I've used in the most advanced item catalog are 100% impossible to pull off with Encoder.


People that were afraid of Encoder have begun using this as well. People that didn't understand Encoder at all understand this just fine and very easily (although people who know nothing about what a stack is do struggle at the start since they don't seem to read my notes or tutorials).


One person's code for save/load was 10 lines long (all of his custom code, the saving of the data and the loading of the data). He saved the hero, hero lvl/xp, gold, lumber and inventory.


When I began coding these snippets, I realized that the weakness of all save/load systems was their blueprints (the structure that stores maximum values of each slot in the code). Encoder expanded these blueprints by going to a tree structure (allowing for more complex logic). However, with snippets, there are no blueprints. You code the logic straight into it.



Now are you telling me that save/load systems, which are more complex to use and cumbersome than this, are a better option? The only one that doesn't lose on all fronts is AceHart's, and it barely wins with simplicity (it's win is so trivial that I don't even think you could count that as a win).


The highlight in this map is again not the snippets within it. These snippets (as can be seen by the links) were submitted as actual standalone resources. The highlights in this map are the demonstrations showing how to use those snippets for save/load as well as the tutorials.
 

Nestharus

o-o
Reaction score
84
Major Update-

This update includes a new resource called Buffer as well as a variety of additions/updates to already existing resources.

NumberEncrypter: versioned encryption/decryption
NumberStack: new remaining property
All Save/Load Snippets: New Buffer Loaders
Versioned Save/Load Architecture: Changed to use Buffer (loader structure etc is different)



New features-
Perfect overflow/underflow detection
If a code is out of bounds (too big/too small), it will be detected with 100% accuracy. What this means is that you no longer need version specific checksums to keep the versions separated. If a user attempted to load an older code into a newer version, it'll overflow or underflow.

Overflow/underflow detection is done at the very end of loading (after all data is loaded). What this means is that data now needs to be loaded into a buffer before being created. Load data into buffer, do error check, if pass, read data out of buffer and create.

Automatic version retrieval
A good technique for storing the version into the code was devised. This will almost certainly not increase the code size at all. The limit to this is that you can only have up to a certain number of code versions and that you can't overwrite older versions (100% stuck limit). However, the good news is that the default safe value I have set is 50000 (can easily go up to like 500,000 for most checksums without increasing code size). 50000 is more than enough for any map.

With automatic code version retrieval, -load version, code is no longer possible. It will always be -load code.



Snippets to be written for future versions-
SaveHeroStr
SaveHeroAgi
SaveHeroInt
SaveAbilities
 

Nestharus

o-o
Reaction score
84
Updated

perfect overflow/underflow detection (1 bit cost)
automatic version retrieval without increasing code size

included new save hero stats lib

edit
Update:

Include latest BigInt (2 fixes)
Fixes to Core Load
Fixes to Bounds Checking for special cases

edit
reverted bounds detection, it was working fine ;p
 

Nestharus

o-o
Reaction score
84
Added a new option** for improved CRC. CRC is the out of bounds checking.


The improved CRC takes up more space, but it offers better security. The code size may increase up to 2 characters.
 

Nestharus

o-o
Reaction score
84
Update


Latest BigInt
The BigInt revision improves the speed of base conversion, which drastically reduces the amount of freezing in the encryption/decryption processes. This means that the save/load is faster.​


Latest Base
The update to Base adds a new line that fixes leaks. The base constructor method operator was broken (continued to remake Bases over and over again).​


Updated NumberEncrypter
The NumberEncrypter password thing was broken. The update fixes this by changing two variables in one line.​
 

Dirac

22710180
Reaction score
147
If i wanted to store up a string inside a numberstack, how would that go?

Also, why does number stack asks for a max value? makes no sense to me.

.push 1 -> 1
.push 2 -> 2,1
.push 5 -> 5,2,1

.pop 5,2,1 -> 5
.pop 2,1 -> 2
.pop 1 -> 1

What's the max value for? if i were to store a variable and i really don't know how high it can go, such as ASCII 2 Int conversion, how am i supposed to store it in it?
 

Nestharus

o-o
Reaction score
84
To store multiple numbers into a stack, you have to know the maximums -.-. If you don't want a maximum, pick a max like 2^31.


A NumberStack is a BigInt. It's one huge number with lots of numbers inside of it. It stores each number into a digit, thus it needs to know the size that the digit needs to be in order to store that number. You can't just have a dynamic digit because this isn't a stack, it's a number that is like a stack.


To give you a visual example, you may store 1, 2, and 3 in that order like this
321 (notice that this is the number three hundred and twenty one, not a stack)

If it was like that, each number would have a max value of 9, meaning that they could be stored in base 10 digits.



As for strings, I'd first make a base made up of all of the possible characters you could have in your string. From there, it's easy. Ordinal value = char value and max size = base size - 1 etc.


The only time I've ever seen strings saved into a code is when a player name was saved. If you are doing that for player unique codes, don't do it. That is a really naive and stupid design >.>. The Encryption is already player unique.


Try saving a code in the demo map and then loading it up under a different name. You will see that the code will not work.
 

Dirac

22710180
Reaction score
147
The Encryption is already player unique.
This is what was troubling me. I didn't really read the code because, well, i'm very inexperienced when it comes to save load data.
 

Nestharus

o-o
Reaction score
84
The encryption is based on the player's name and two passwords.


If you don't believe me, try what I said in single player. Save a code in the demo map, then change the name and try loading it. Ofc, you will need to change the name in WE Options (changing the name in-game won't do any good).

edit
Doh... changing the name will mess up one of the encryption thingies (the player unique checksum) if it is done before saving. I shall fix it tonight >: O. Another update for NumberEncryptor ;D. Yea, I totally didn't think about it ^)^. At least I thought about it for Scrambler tho ^^.


edit
Updated NumberEncryptor again. It would have bugged the checksums if players had changed their names. It now loads player names at map init.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top