0
\$\begingroup\$

I'm writing a sandbox-type game and i'm looking for a good way to store game data. I tryed Lua and plain text files, but the have a big minus - player can edit them his self!

So how do I protect data from player? Thank you!

\$\endgroup\$
  • 1
    \$\begingroup\$ Why would you do that anyway? When it's a multiplayer game, anything worth editing should be on the server. When it's a singleplayer game, why do you want to prevent the modding community from adding value to your game? \$\endgroup\$ – Philipp May 4 '16 at 14:35
0
\$\begingroup\$

You can store the game data in a file, and obfuscate the data if you do not want the player to modify the stored values.

This would be done by encrypting your data, and then decrypting it when you load it up in your game. The encrypting / decrypting would be hard coded into your binary.

That being said, if someone wants to get at the game data, there will be attempts at cracking your encryption technique, and publish a hack. You can try to prevent the data from being hacked, but you cannot stop it entirely.

\$\endgroup\$
  • \$\begingroup\$ Thank you! Can you give me an example of encrypting / decrypting, please? \$\endgroup\$ – user64142 May 4 '16 at 14:32
  • 1
    \$\begingroup\$ I am not up to date with C++ so I would not be good to suggest what to use. You should just do a google search on encrypting text, text obfuscating. \$\endgroup\$ – jgallant May 4 '16 at 14:35
  • 1
    \$\begingroup\$ This question is actually a duplicate, see comment in your question above. \$\endgroup\$ – jgallant May 4 '16 at 14:36
0
\$\begingroup\$

You can't.

If your game is a single player game or not connected to the internet, and you don't have them use any kind of DRM that big companies can have (Ubisoft, EA, Blizzard and the like), users will find a way to hack in your data and modify them.

There are ways to obfuscate it, and make their life harder, but ultimately, someone motivated enough will find a way to reverse engineer your data (savegame or assets), make an editor, and change the content of your game.

\$\endgroup\$
  • \$\begingroup\$ But can I make it unreable (inexplicable) for users? That's what I meant. \$\endgroup\$ – user64142 May 4 '16 at 14:30
  • \$\begingroup\$ As I said, you can't. You can only make it harder for them to read and understand it. \$\endgroup\$ – Vaillancourt May 4 '16 at 14:49
  • \$\begingroup\$ Yes, you can, but thats an idiotic hard work, you could encrypt it and make your game interpretate the encripted string instead of trying to decrypt it, that would have no sense and hackers wouldnt be able to read or modify it. But seriously, do you need that level of nonsensenes? \$\endgroup\$ – PRDeving May 4 '16 at 20:50