Protect Resources from users

Started by
6 comments, last by Captain P 13 years, 7 months ago
Hi all,

Anybody have good advice on the following?

If my app uses text files to implement save and load functions, how can they be protected or hidden or whatever, basically so the user cannot just go into the folder containg them and edit them, thus ruining their app, the same goes for image files used for example. How is this done usually? I understand that image files can be built into the binary as resources, but for data that needs writing to that can't be the option.

cheers
Advertisement
Put the files into a zip file or other archive format. Call it a day.
If someone really wants to, they are going to read the files. Its happened to most games out there. The best you can do is hide all that stuff from the casual user who doesn't want to bother figuring out how to mod/edit it.

Check out physfs
You could also read and write your save files in binary format. I don't have a lot of experience with doing this, but shouldn't be too hard to do.

Michael RhodesTiger Studios Web Designhttp://tigerstudios.net
You could add some kind of checksum.
For example if you are saving the city the player is in and the gold.
take all of the city name characters integer values and add them to gold. and add this to the end of the file. There is unlimited algorithms to do that though, it was just an example.

I am pretty sure nobody figures out how you did the checksum, if you do it right
Yea, i think the binary will be the most straightforward thing really, cheers all
If you're doing this with the express purpose of trying to prevent users from modifying files on their system, you're probably wasting time. Simply choose an easy option, like shoving everything into a .zip file or a simple manually-written file format and be done with it.

There's nothing you can do to prevent users from getting at data that you store or display on their machine. "Protecting" yourself against this is silly and usually just annoys users.
I second PhysFS as an elegant solution but I have also had luck with using SQLite3 db files and storing resources as blobs. I don't even use config files anymore since I started using SQLite. There are lots of tools available to view/manage the db files outside of your game as well which makes a quick edit here and there super simple.

While SQLite has it's differences and limitations compared to MS SQL server or MySQL you will probably be surprised as how well suited it is for games***.


*** It is very well suited for the client side of games. For anything that requires concurrency among multiple db connections then a traditional RDBMS is better suited.
Evillive2
Quote:Original post by rogster001
If my app uses text files to implement save and load functions, how can they be protected or hidden or whatever, basically so the user cannot just go into the folder containg them and edit them, thus ruining their app, the same goes for image files used for example.

I would argue that, by the time a user actually wants to modify his savegame files, he is either annoyed by the game or simply bored with it. A better solution would thus be to improve the gameplay.

After all, if a player cheats, that's his problem. And even that is still better than a player just quitting your game - at least he's still showing some interest. I know I've had some fun modifying games in the past - sometimes more fun than playing them the way they were supposed to be played. ;)


Either way, just go for something simple and easy during development. A text-based format is easier to debug than a binary one. With some anticipation, you can always swap it for a different format later on, or throw some compression on top of it.
Create-ivity - a game development blog Mouseover for more information.

This topic is closed to new replies.

Advertisement