How to stop users from manipulating Game Save Data

Started by
61 comments, last by BHXSpecter 9 years, 11 months ago

I've been building a role playing game on PC using the Java language for 2 months.

I managed to implement a "save and load system" in 3 days.

The roadblock currently with development is "it is really easy to find the textfile from the game's folder and just start editing the numbers which can ruin the game exploration and balance."

The save file needs to be a textfile because Java has this file input and output object that knows how to handle textfile. I am not sure if it can handle any other file extensions.

What are my options to stop users from manipulating a game save data text file?

gameSaveData.txt


MapScreen: 0
Map Position: 0 0
Camera: 245 -215
Character's Level: 5
Character's Life: 50
Character's MaxLife: 50
Gold Amount: 29
NPC0: FINISHED
NPC1: FINISHED
Advertisement

As long as the user has access to the file, it can be modified. You can stop the average user from being able to make sense of the file by obfuscation (encrypt it, or compress it).

I would just leave it in plain text, and just not bother with stopping the people from modifying the game saves.

If you must not allow it, you will have to store the game saves in a remote hard drive, so that users can't access it.

So long as your game is offline, players cheating hurt others in no way. If a user wants to enjoy your game by cheating, let 'em. Your job as a game developer is to give them a product they enjoy, not to force them to enjoy it the way you want them to.

If you want to make them work for it, you can encode your file. Simply moving to a binary format instead of text at least stops the casual cheaters for the first few days if you're lucky. If you're unlucky then it takes them months or years because your game is unpopular and nobody is really trying.

I assume your game is offline as storing save game information on players' local disks in an online game is pure madness.

Sean Middleditch – Game Systems Engineer – Join my team!

First thing, don't make it so readable tongue.png Use meaningless labels, and no newlines so it's a pain to find the number you're after.

Second, do some sort of encryption on the numbers (could be as simple as differential encoding, so changing one number modifies everything after it).

For a single player game, there's no need to prevent save hacking... just deter it so the player doesn't feel like they're wasting time by playing the game when it would be so easy to type in a number. If anyone cares enough to make a save editor tool, let them have their fun.

So long as your game is offline, players cheating hurt others in no way. If a user wants to enjoy your game by cheating, let 'em. Your job as a game developer is to give them a product they enjoy, not to force them to enjoy it the way you want them to.

If you want to make them work for it, you can encode your file. Simply moving to a binary format instead of text at least stops the casual cheaters for the first few days if you're lucky. If you're unlucky then it takes them months or years because your game is unpopular and nobody is really trying.

I assume your game is offline as storing save game information on players' local disks in an online game is pure madness.

Although I agree you should let people play a game a way they want to, I don't even remotely agree that people should basically be encouraged to cheat by leaving things open to generic editing. Even making saves binary adds quite a bit of protection because the amount of effort and knowledge required to change the saves then goes up significantly.

I'm actually not sure where this apparent encouragement online about cheating in games came from, for some reason people seem to think cheating is only a thing when it affects other people. If anything you should be encouraging people to not cheat unless they're doing something like messing around after they beat the game, which is something that should not require screwing with the save file anyway.

First thing, don't make it so readable tongue.png Use meaningless labels, and no newlines so it's a pain to find the number you're after.

Second, do some sort of encryption on the numbers (could be as simple as differential encoding, so changing one number modifies everything after it).

For a single player game, there's no need to prevent save hacking... just deter it so the player doesn't feel like they're wasting time by playing the game when it would be so easy to type in a number. If anyone cares enough to make a save editor tool, let them have their fun.

Actually.. yeah, pretty much this. Although quite frankly you shouldn't need to obfuscate it really, in most cases just saving files in binary is enough of a deterrent to people. I'd only worry if its a five second change to make you invincible in your game or something, then its a little TOO open.

The save file needs to be a textfile because Java has this file input and output object that knows how to handle textfile. I am not sure if it can handle any other file extensions.


Java, a language with a full-featured standard library, does actually support more than text files. If you just want to mess around at a low level, you can work with the DataInputStream/DataOutputStream classes to write ints, floats, bytes, and other primitives. It's fairly simple to do.

There's another option: Java also has a feature called serialization. You can use this feature with the ObjectInputStream/ObjectOutputStream classes. Serialization is somewhat automatic - you provide support with things like a couple of special interfaces: Serializable and Externalizable, a special keyword "transient", and a variable you defined named serialVersionUID.

Anything written in binary will still be hacked if someone really cares, but at least it'll take some effort, and you'll learn a little bit more about Java.


So long as your game is offline, players cheating hurt others in no way. If a user wants to enjoy your game by cheating, let 'em. Your job as a game developer is to give them a product they enjoy, not to force them to enjoy it the way you want them to.

You got a point there.

So long as your game is offline, players cheating hurt others in no way. If a user wants to enjoy your game by cheating, let 'em. Your job as a game developer is to give them a product they enjoy, not to force them to enjoy it the way you want them to.

[...]

Although I agree you should let people play a game a way they want to, I don't even remotely agree that people should basically be encouraged to cheat by leaving things open to generic editing. Even making saves binary adds quite a bit of protection because the amount of effort and knowledge required to change the saves then goes up significantly.

I'm actually not sure where this apparent encouragement online about cheating in games came from, for some reason people seem to think cheating is only a thing when it affects other people. If anything you should be encouraging people to not cheat unless they're doing something like messing around after they beat the game, which is something that should not require screwing with the save file anyway.

For me, its two main points. The first is that if someone goes to the trouble of trying to modify a save file, it's probably because of a failure of the game. It's either too hard for them, too boring, or maybe the save points are too far away and some progress was lost due to a game crash or whatever. And for a singleplayer game, who are they hurting by this 'cheat'?

The second main point is development time misspent. Now, yeah, swapping to binary for a save file isn't exactly a huge cost (and that is fine move imho), but I've seen time and again people delving into encryption algorithms and various obfuscation techniques and obsessing over something that the majority of players aren't even going to bother doing, and those that do -- well, see the first point.

And as an aside, if all your files are text, there is a nice side benefit of your game being easily moddable. Sure someone might mod your game to make all the bad guys have 1 hit point, but someone else might add new enemies, swap art, or create a super hard mode.

And for a singleplayer game, who are they hurting by this 'cheat'?

And here is a prime example of why I don't like people that spread nonsense like that, it isn't "cheating" its cheating. It is changing the game save file to manipulate your progress, it is bypassing the coded rules of the game, and to me its like some crappy debate or something. There's no morals or "oh its opinion" it is cheating.

In fact that's the part that gets me is 90% of the time the people that do exactly that will almost religiously defend the idea that they aren't cheating, because they don't want to feel like they're doing something wrong or whatever. I mean if you want to cheat, sure, cheat, admit it, but cheat.

But there is no moral debate here, editing a games files to change your progress is cheating, simple as that. I also find it silly that people objectify the idea that unless someone else is affected by your cheating that you shouldn't strive to avoid it. Reality check: you shouldn't encourage people to cheat in games, the entire point of games is to overcome the challenge presented by the developer.

This is not a "does a tree make a sound" debate, if you cheat at solitaire it is still cheating, if you cheat at minesweeper it is still cheating, someone does not have to observe you cheating in order for you to be cheating.

The second main point is development time misspent. Now, yeah, swapping to binary for a save file isn't exactly a huge cost (and that is fine move imho), but I've seen time and again people delving into encryption algorithms and various obfuscation techniques and obsessing over something that the majority of players aren't even going to bother doing, and those that do -- well, see the first point.

I can't really take this as much of a point because honestly even in a scenario of someone going stupidly overboard like encrypting save files and something it would still be a very minimalistic time investment. If someone wants to whine about this taking so long to implement I'd probably ask them why they're spending a month installing crappy DRM into their game then too, along with a dozen other bad ideas they're probably using.

And as an aside, if all your files are text, there is a nice side benefit of your game being easily moddable. Sure someone might mod your game to make all the bad guys have 1 hit point, but someone else might add new enemies, swap art, or create a super hard mode.

Yeah lets encourage horrible modding practices like Minecraft while we're at it. If modding your game is a thing it should be designed as a thing, not, "hey lets leave protections off so everyone can hack the hell out of my game by changing files." Lets not even begin to mention how silly distributing such a mod would be. "Oh here, just.. overwrite all your saves with this.. or all your config files."

On topic, yeah hexadecimal is enough + maybe compression will discourage 99.9% of your players from altering your game, which is more than enough because nothing will ever discourage the rest.

This is not a "does a tree make a sound" debate, if you cheat at solitaire it is still cheating, if you cheat at minesweeper it is still cheating, someone does not have to observe you cheating in order for you to be cheating.

Yes cheating is cheating. No one said otherwise. So what, exactly ? How is that of any consequence ?

I am talking about single player only, multiplayer, is of course, a very different beast.

I still remember fondly the time i did my first hexadecimal hack on Civilization 1 games, allowing me to play as the barbarians, or to extend the game various game's limits. I am not even sure that I would actually be a coder now if it hasn't been possible for me to do so. It can also extends a game's life (spent way too much time having fun altering GTA:SA data and save files).

This "cheating is bad" point isn't an argument at all in single player. The goal of a game is to provide fun to those who play it. How the player is getting his fun is none of your concern no more that whatever else he does in private (same goes with modding for that matter). He doesn't prevent others from enjoying the game the way "it's meant to be played".

This topic is closed to new replies.

Advertisement