|
|
#16 |
|
Moderator
Code Moderator
Join Date: Feb 2006
Posts: 1,405
![]() ![]() ![]()
|
Updated, thanks again for the bug report.
__________________ |
|
|
|
| Sponsored Links - Login to hide this ad! |
|
|
|
|
#17 | |
|
User
Join Date: Mar 2007
Posts: 70
|
Quote:
Could you please elaborate on this? I'm trying to combine several ways of making a save/load code as hacker-unfriendly as possible. This method could be one of them if only I understood it fully :/ |
|
|
|
|
|
|
#18 |
|
I blink, therefore I am.
Join Date: Sep 2006
Posts: 1,812
![]() ![]() ![]()
|
The hash is an algorithm that generates a number based on the "number" being saved. The hash can be any sort of mathematical operations with any numbers you want, but you should incorporate the saving number so that the hash is unique. The hash is also 1-way, so you don't have to worry about going backwards. The hash is calculated on both save and load and is compared. If the hash is the same, the code must be valid (no changes to the characters). More info about hashes can be found at wikipedia.
__________________The reason you would want to make a custom hash is so that player's can't take this version here and use it to decode the save-codes your map generates. Creating a custom hash should change the code significantly that looking at this code won't help. Last edited by Ammorth : 07-22-2008 at 11:23 PM. |
|
|
|
|
|
#19 |
|
User
Join Date: Mar 2007
Posts: 70
|
Thanks, but I was more referring to (and interested in) SetRandomSeed(23) actually :)
|
|
|
|
|
|
#20 |
|
I blink, therefore I am.
Join Date: Sep 2006
Posts: 1,812
![]() ![]() ![]()
|
The game uses random seeds to generate random numbers. http://en.wikipedia.org/wiki/Random_seed With the same random seed, you can generate the same random numbers every time. So, if you incorporate a random seed and GetRandomInt/Real then you can add complexity to your hash, as the person decoding needs to know the seed being used to receive the same hash.
__________________The reason why you get a random number first is that you will get a random seed after the save-code and players won't find themselves random-ing the same numbers after a save. |
|
|
|
|
|
#21 | ||
|
User
Join Date: Mar 2007
Posts: 70
|
Quote:
I like... 50% understand what you're trying to say, but how would this go into coding? Quote:
This I understand (I guess...): - So at map start (0.0 time or init?) I save a GetRandomInt(x,y) with the save/load system itself - Then I call SetRandomSeed(z) before I initialize the rest of my map - I use a GetRandomInt/GetRandomReal instead of the numbers in my hash code This I don't get: - But why the f.. do I have to save and restore a random number? - And if I save a number first and then change the hash, won't that make me unable to restore it? - Why would it "force people to find out those parameters"? Thanks for the help so far, but I really need to understand this fully before I can safely use/adjust it in a map... (If you could write out a library or something, showing a full example, I'd really apreciate it.) Last edited by Magentix : 07-24-2008 at 10:36 AM. |
||
|
|
|
|
|
#22 |
|
I blink, therefore I am.
Join Date: Sep 2006
Posts: 1,812
![]() ![]() ![]()
|
Nothing should be done at map init with the save system. It should all happen during the saving/loading.
__________________The reason why we save a random number before setting the random seed is so that after we are done with the hashing, we can set the number generator back to random numbers. If you were to do SetRandomSeed(GetRandomInt(0, MaxInt)) you would end up having the same random numbers occuring after every save. For example. Lets say you need 10 numbers between 0 and 100 at random. Lets pretend we use random seed 56. Every time you call SetRandomSeed(56) the next 10 random numbers will be: Code:
35 18 72 89 44 06 29 48 92 31 So after the 10 random numbers, the same number would keep coming up for the SetRandomSeed(GetRandomInt(0, MaxInt)) as the 11th random number of seed 56 will always be the same. Since we know all the numbers will come out the same after setting a seed, we can safely generate the same random numbers, as long as we know the seed from which the numbers were generated from. This is how we can increase the complexity of the hash. I wrote a save-system similar to PipeDream's system here. Below the the hash part of the code: JASS:As you can see, we only modify the random seed during the hash, and then revert it back instantly. MAX_INT is the maximum value an integer can be before causing problems (it overflows to a negative number). It is (2^31) - 1 or 2147483647 After a hash is created, it is saved into the save code. When the player loads a code, you can load the hash out and then rehash the save-code. If the hashes are the same, the code must be legit and then it is parsed. |
|
|
|
|
|
#23 |
|
User
Join Date: Mar 2007
Posts: 70
|
Thanks, now I understand what the idea is.
So suppose I did this at init: - I save a random number SeedInt to a global - I SetRandomSeed(someNumber) - I set some globals named HASHInt1, HASHInt2, etc with GetRandomInt - I SetRandomSeed(SeedInt) Then, in my hash code I wouldn't use numbers, but HASHInt1, HASHInt2, etc. That would always make my hash the same every time the map loads and yet more difficult for hackers to decode, right? (Is that what PipeDream meant?) Last edited by Magentix : 07-25-2008 at 01:40 PM. |
|
|
|
|
|
#24 |
|
User
Join Date: Jun 2007
Posts: 6
|
Code:
method Clean takes nothing returns boolean EDIT: nvm solved it, used a local boolean variable fixed it. Last edited by Arkan. : 08-17-2009 at 09:51 AM. |
|
|
|
|
|
#25 |
|
Obscurity, the Art
|
I think this might possibly have the worst documentation ever of anything I've ever tried to use. It uses a library that isn't approved and has no documentation, it should be using the Log library in the script database, it should have like a billion more comments, it should have an actual example in the testmap...
__________________I mean, really. |
|
|
|
|
|
#26 |
|
User
Join Date: Dec 2009
Posts: 5
|
I play on a server where A-Z, a-z, 1-0, and Chars: ~!@#$%^&*()_+|}{":?></.,';\][=-` are all acceptable. Also haveing all chars acceptable in your save code system, would allow for LANers to save. My bnet name is Hodge-Podge, and my LAN name is }{odge-Podge, so it would be cool to have that capability =P, but anyways. Really nice system
__________________ |
|
|
|
|
|
#27 | |
|
default string
|
Quote:
|
|
|
|
|
|
|
#28 |
|
User
Join Date: May 2008
Posts: 17
|
hi man i just downloaded the savecode.w3x and i got a crash before it can begin to load the map...
any ideaS? nome |
|
|
|
|
|
#29 |
|
User
Join Date: Sep 2006
Posts: 687
![]()
|
this resource is pretty outdated. Probably doesn't work with new patches.
|
|
|
|
|
|
#30 |
|
User
Join Date: Sep 2009
Posts: 3
|
acutly how to active the save or load system(srry my english is bad)
|
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
|
|
Donate |