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

Started by
5 comments, last by Bregma 11 years, 5 months ago
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!
Advertisement

I want to make sure the player can't edit the save file.

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.

Stephen M. Webb
Professional Free Software Developer


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.


Yes, how would I do that? That is what I am looking for. I want to add serialization in it though.
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.
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.

I open sourced my C++/iOS OpenGL 2D RPG engine :-)



See my blog: (Tutorials and GameDev)


[size=2]http://howtomakeitin....wordpress.com/

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 %AppData%\Local ;
2) In Linux you have the user's home and you can create a hidden folder.
3) In a more crossplatform manner, you can use Boost Filesystem library

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.
Programming is an art. Game programming is a masterpiece!

[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.

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 istream can read what the ostream writes.

Stephen M. Webb
Professional Free Software Developer

This topic is closed to new replies.

Advertisement