• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[General] interesting idea for version retrieval in save/load

Status
Not open for further replies.
Level 31
Joined
Jul 10, 2007
Messages
6,306
If you are doing versioned save/load, you'll generally be adding 1 to the max checksum with each version.

checksum = version + checksum base

What this means is that when a player loads up the code, one can retrieve the version of the code assuming that they didn't type it in incorrectly

version = current version - (generated checksum - checksum)

generated checksum - checksum would be how many versions back. Subtract that from current version the map is on and you have the version of the code.


Now the only problem with this is that invalid codes for the code version might load up properly in a later version. For example, the player makes 1 typo in the code and then it loads it up in the incorrect version correctly. By dynamically getting the version from the code using the checksum and expected checksum, there are more chances for checksum collisions.


The Knuth Checksum does protect against patterns: n(n+3)%m, but changing an earlier digit means a big change, and I don't know if the knuth would protect well against this across multiple versions.


Anyways, that's my current thought on dynamic version retrieval. Does anyone else have any interesting ideas that could possibly be better protected? My idea would work 100% of the time if the player never entered invalid codes, but that would never be the case.


Also, do you guys think that my idea of dynamic version retrieval is fine as it is? It would mean that you wouldn't need to do this anymore-

-load version, code


You could have versioned codes without storing the version into the code and without displaying it : ).


edit
Actually, you could initially add 1 to the number and at the end make sure that you have exactly 1 left in the stack. If the stack is not 1, then you know that the code was out of bounds.


Why I say to check for 1 and not 0 is because 1 will check for codes that are too small and too large. 0 only checks for codes that are too large. This would actually remove the need for IsStringLengthInRange checking. Of course, to use this method, you would need to inline things like SaveInventory and load up all data before you actually create anything (like creating player hero and adding inventory items). This complicates the overall save/load process, but it does give great code range checking and allows you to do dynamic version retrieval (as versions change, the code will be thrown out of bounds if it somehow works).
 
Level 8
Joined
Apr 26, 2011
Messages
403
what the point of version ? do you mean you want to modify the save/load function in future without disable old saved code ?

I am still new to this system, the one I am working on should support future changed in map's content.

for saving :
origin_code = CreateCode() // create code string base on object you want to save.
encrypted_code = FunctionXoR(origin_code + playername)
security_digit_A = GeneratedChecksum(encrypted_code, salt)
security_digit_B = GeneratedChecksum("security_digit_A+encrypted_code", salt)
Final Code = <security_digit_A>encryted_code<security_digit_A>

for Loading:
break down Final Code : security_digit_A, security_digit_B, encryted_code
security check :
- security_digit_B fail/pass ? //check again (encrypted_code, salt)
- security_digit_A fail/pass ? //check against ("security_digit_A+encrypted_code", salt)
- encryted_code fail pass? //check against player's name

if all 3 of above pass, then you can start generated original code, and tranalate these code to data that saved.

the translate function may change over version, but you don't really need to touch save/load function. (unless you want a dynamic salt which can saved inside the encrypted code)
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
can't do a load retrieval system in vjass. The player has to type in the code. However, you can retrieve it from the computer screen and store it in a file or something so that the player can cnp it.


Now, for the versioning, my idea was flawed. The best idea is to add on a maximum amount of versions (like 1000000) to the max checksum. From here, add version to checksum and compare the expected checksum to the found checksum. The difference betwene them will be the version. This will mean that you can't have different checksums for different versions, however, by adding 1 to the start of the code, you will end up doing bounds checking, which will make like a version 1 code not work as a version 2 code (so long as you add something or remove something moving from version 1 to version 2).

I am still new to this system, the one I am working on should support future changed in map's content.

Just use save/load with snippets. The NumberStack is very low level. The only thing lower is BigInt, and you'd do the exact same thing in BigInt as you would with NumberStack (same operations either way).
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
oh, I already have it designed, but I don't much like the design.

Now, for the versioning, my idea was flawed. The best idea is to add on a maximum amount of versions (like 1000000) to the max checksum. From here, add version to checksum and compare the expected checksum to the found checksum. The difference betwene them will be the version. This will mean that you can't have different checksums for different versions, however, by adding 1 to the start of the code, you will end up doing bounds checking, which will make like a version 1 code not work as a version 2 code (so long as you add something or remove something moving from version 1 to version 2).
 
Status
Not open for further replies.
Top