Sign in to follow this  
Tuxmascot

How should I begin my venture into the Game Save world?

Recommended Posts

I am writing a text-based RPG game using some OOP and polymorphism. I wanted to add a game save function to it, but I am at a dead end as to how to do this. I don't want to use a basic 'ofstream' function, but I want to make sure the player can't edit the save file. So I was thinking about serialization or something. It also needs to be efficient for performance. I am just intimidated by all the options and I don't know what to pick or use.

Any way to do this?

Thanks!

Share this post


Link to post
Share on other sites
[quote name='Tuxmascot' timestamp='1353016556' post='5001359']
I want to make sure the player can't edit the save file.
[/quote]
The only way you could possibly stop someone from modifying theor own data on their own computer is to save the game to a remote server, and even then you'd need a secure connection. Are you sure it's worth the hassle, given they could still crack your program to bypass that?

Just write your data using the standard formatting streams. You can check and edit the save game files manually that way, if only for verification, and you can let people do what they want with their own data.

Share this post


Link to post
Share on other sites
[quote name='Bregma' timestamp='1353017940' post='5001366']
Just write your data using the standard formatting streams. You can check and edit the save game files manually that way, if only for verification, and you can let people do what they want with their own data.
[/quote]

Yes, how would I do that? That is what I am looking for. I want to add serialization in it though. Edited by Tuxmascot

Share this post


Link to post
Share on other sites
Are you asking, "How do I use file streams" ?
Or are you asking "How do I protect my data" ?

The two are very different questions. The second one assumes a knowledge of the first.

Share this post


Link to post
Share on other sites
just use a sha512 with salt and push your regular stream through it. the results you write on disk. the salt should be hardcoded somewhere.

when somehow then wants to "crack" your program, he would need to get the salt out of the binary. Edited by FlyingDutchman

Share this post


Link to post
Share on other sites
Simple thing to do so that you don't worry much:
Write to your save file as binary, so that the user won't be able to read it directly.

Now, if you want to hide it, you can try saving the file in a user's hidden folder:
1) In Windows you have [url="http://msdn.microsoft.com/en-us/library/windows/desktop/bb762188%28v=vs.85%29.aspx"]%AppData%\Local[/url] ;
2) In Linux you have the [url="http://stackoverflow.com/questions/2910377/get-home-directory-in-linux-c"]user's home[/url] and you can create a hidden [url="http://stackoverflow.com/questions/7430248/how-can-i-create-new-folder-using-c-language"]folder[/url].
3) In a more [url="http://stackoverflow.com/questions/4891006/how-to-create-a-folder-in-the-home-directory"]crossplatform manner[/url], you can use [url="http://www.boost.org/doc/libs/1_43_0/libs/filesystem/doc/index.htm"]Boost Filesystem library[/url]

The references above are all in c++ to give you an idea. I don't know what language you are using, but I am sure other languages will have some libraries ready to deal with the filesystem. Edited by kuramayoko10

Share this post


Link to post
Share on other sites
[quote name='Tuxmascot' timestamp='1353022446' post='5001384']
[quote name='Bregma' timestamp='1353017940' post='5001366']
Just write your data using the standard formatting streams. You can check and edit the save game files manually that way, if only for verification, and you can let people do what they want with their own data.
[/quote]
Yes, how would I do that? That is what I am looking for. I want to add serialization in it though.
[/quote]
I suggest you write a pair of functions [font=courier new,courier,monospace]std::ostream& operator<<(std::ostream&, const Game&)[/font] and [font=courier new,courier,monospace]std::istream& operator>>(std::istream&, Game&)[/font] where Game is you game state you want to save. Make them friends of your [font=courier new,courier,monospace]Game[/font] class. Do this recursively with the members of the [font=courier new,courier,monospace]Game[/font] class. Write unit tests to make sure (a) the output is what you expect and (2) the [i]istream[/i] can read what the [i]ostream[/i] writes.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this