wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Resources > Code Resources > Systems
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 10-06-2007, 08:35 PM   #16
PipeDream
Moderator
 
PipeDream's Avatar


Code Moderator
 
Join Date: Feb 2006
Posts: 1,405

Submissions (6)

PipeDream is a glorious beacon of light (463)PipeDream is a glorious beacon of light (463)PipeDream is a glorious beacon of light (463)PipeDream is a glorious beacon of light (463)

Default

Updated, thanks again for the bug report.
__________________
PipeDream is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 07-22-2008, 10:52 AM   #17
Magentix
User
 
Join Date: Mar 2007
Posts: 70

Magentix is on a distinguished road (16)

Default

Quote:
- You'll probably want to mess with the hash and obfuscation functions so that people can't use this stock system map to cheat. One thing that would make things very annoying is to save a random number at map start, then call SetRandomSeed(23), then let your initialization run that doesn't need to vary, then set hash/obfuscation parameters with GetRandomInt. Finally restore the random number you saved. This will force people to figure out those parameters. Remember though that the best you can do is help honest users remain honest.

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 :/
Magentix is offline   Reply With Quote
Old 07-22-2008, 11:22 PM   #18
Ammorth
I blink, therefore I am.
 
Ammorth's Avatar
 
Join Date: Sep 2006
Posts: 1,812

Submissions (10)

Ammorth is a glorious beacon of light (461)Ammorth is a glorious beacon of light (461)Ammorth is a glorious beacon of light (461)Ammorth is a glorious beacon of light (461)

Default

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.
Ammorth is offline   Reply With Quote
Old 07-23-2008, 04:03 PM   #19
Magentix
User
 
Join Date: Mar 2007
Posts: 70

Magentix is on a distinguished road (16)

Default

Thanks, but I was more referring to (and interested in) SetRandomSeed(23) actually :)
Magentix is offline   Reply With Quote
Old 07-23-2008, 10:50 PM   #20
Ammorth
I blink, therefore I am.
 
Ammorth's Avatar
 
Join Date: Sep 2006
Posts: 1,812

Submissions (10)

Ammorth is a glorious beacon of light (461)Ammorth is a glorious beacon of light (461)Ammorth is a glorious beacon of light (461)Ammorth is a glorious beacon of light (461)

Default

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.
__________________
Ammorth is offline   Reply With Quote
Old 07-24-2008, 10:34 AM   #21
Magentix
User
 
Join Date: Mar 2007
Posts: 70

Magentix is on a distinguished road (16)

Default

Quote:
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.

I like... 50% understand what you're trying to say, but how would this go into coding?

Quote:
One thing that would make things very annoying is to save a random number at map start, then call SetRandomSeed(23), then let your initialization run that doesn't need to vary, then set hash/obfuscation parameters with GetRandomInt. Finally restore the random number you saved. This will force people to figure out those parameters.

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.
Magentix is offline   Reply With Quote
Old 07-24-2008, 11:28 PM   #22
Ammorth
I blink, therefore I am.
 
Ammorth's Avatar
 
Join Date: Sep 2006
Posts: 1,812

Submissions (10)

Ammorth is a glorious beacon of light (461)Ammorth is a glorious beacon of light (461)Ammorth is a glorious beacon of light (461)Ammorth is a glorious beacon of light (461)

Default

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 no matter when you call GetRandomSeed(56), the next 10 numbers after it will be the same. This is true for the next 100, next 1000, basically any amount of numbers you need.

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:

Expand 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.
__________________
Ammorth is offline   Reply With Quote
Old 07-25-2008, 01:39 PM   #23
Magentix
User
 
Join Date: Mar 2007
Posts: 70

Magentix is on a distinguished road (16)

Default

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.
Magentix is offline   Reply With Quote
Old 08-13-2009, 10:21 AM   #24
Arkan.
User
 
Arkan.'s Avatar
 
Join Date: Jun 2007
Posts: 6

Arkan. has little to show at this moment (0)

Default

Code:
method Clean takes nothing returns boolean
This function will no longer compile in 1.24 with JassHelpers "return bug fix". Any advice on how to fix it would be really helpfull.

EDIT: nvm solved it, used a local boolean variable fixed it.
__________________
Check out Dark Invasion, an avant-garde ORPG

Last edited by Arkan. : 08-17-2009 at 09:51 AM.
Arkan. is offline   Reply With Quote
Old 10-31-2009, 10:20 PM   #25
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,729

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

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.
__________________
Rising_Dusk is offline   Reply With Quote
Old 12-10-2009, 05:42 PM   #26
Hodge-Podge
User
 
Hodge-Podge's Avatar
 
Join Date: Dec 2009
Posts: 5

Hodge-Podge has little to show at this moment (8)

Default

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 its one of the better ones out there
__________________
Hodge-Podge is offline   Reply With Quote
Old 12-10-2009, 10:53 PM   #27
Fledermaus
default string
 
Fledermaus's Avatar
 
Join Date: May 2006
Posts: 705

Submissions (1)

Fledermaus is a jewel in the rough (194)Fledermaus is a jewel in the rough (194)Fledermaus is a jewel in the rough (194)

Send a message via MSN to Fledermaus
Default

Quote:
Originally Posted by Documentation
Savecode_player_charset: These are the characters that will be considered in hashing a name. You probably want to add everything that is valid on bnet. It's ok if player has a name which contains a character this string doesn't, but if you later add that character, his codes will break.
Fledermaus is offline   Reply With Quote
Old 12-27-2009, 08:34 PM   #28
nome
User
 
nome's Avatar
 
Join Date: May 2008
Posts: 17

nome has little to show at this moment (0)

Default

hi man i just downloaded the savecode.w3x and i got a crash before it can begin to load the map...

any ideaS?
nome
nome is offline   Reply With Quote
Old 12-27-2009, 08:52 PM   #29
Joker
User
 
Joker's Avatar
 
Join Date: Sep 2006
Posts: 687

Joker will become famous soon enough (32)Joker will become famous soon enough (32)

Default

this resource is pretty outdated. Probably doesn't work with new patches.
Joker is offline   Reply With Quote
Old 12-28-2009, 12:40 PM   #30
exilus4
User
 
Join Date: Sep 2009
Posts: 3

exilus4 has little to show at this moment (0)

Default

acutly how to active the save or load system(srry my english is bad)
exilus4 is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 10:03 PM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services