Page 1 of 1

How to prevent cheating in PBEM by "doctoring" TXT

Posted: Wed Aug 15, 2007 2:44 pm
by Peter Stauffenberg
I'm playing a PBEM game with Happycat and we are implementing some house rules and changes. E. g. I suggested that we should alter the rail capacity for each side and suggested Allies: 2, Axis: 3 Russia: 4. He agreed this was a good idea and I altered the General.txt file and sent it to him too.

I then opened our existing on-going save game to make my moves and noticed the change I made for possible use in future games ALREADY was possible to use in the existing game. No information is given that the TXT file is altered. Happycat could use it too with no warnings.

I therefore realized that this means players can alter all TXT files at any time to "doctor" the rules for the game. E. g. is it possible to go into the units.txt file and make all the Axis units stronger and Allied units weaker and not let the Axis units use oil. So every time you make a move for your side you're cheating. When the save file is sent to the other player he will use the normal txt file and not get a warning about the first playing having doctored with the file.

This is a very easy way of cheating that's impossible to detect unless the cheating player becomes too greedy and gives his garrisons strength of 9 and movement of 9 and they destroyed the opponent armor units like they were understrength garrisons.

So I wonder if it's possible for a future version of the game to save all the contents from the TXT files used in the game to the save file when you save the game. Every time you load a save game you compare the content from the TXT file stored in the save game with the content of your own TXT files on the computer. If the values aren't the same then a dialog box should pop up telling that there is a mismatch and maybe what the mismatch is. Then it will not be possible to cheat by altering your own TXT files. Because the content of your TXT files will be stored into the save game you send to your opponent and compared with his TXT files when he opens your last save game file.

I know most people play and don't cheat. You have to trust your opponents. But reality shows that when you play on Internet and can hide behind nicknames etc. some people cheat. Especially if you can earn some ranks etc. like in Company of Heroes. My above example can't remove cheating completely, but it will make it harder to get a big advantage.

So I wondered if this is possible to do in for a future patch or is it too complicated?

Posted: Wed Aug 15, 2007 2:57 pm
by IainMcNeil
That's an interesting one. I'm not sure what the options are but we'll have a look and see if anything can be done.

Posted: Wed Aug 15, 2007 5:00 pm
by Peter Stauffenberg
I guess you load the content of the TXT files stored on the local computer when you load the save game. All you need to do is to save the data you read from the TXT to the new data file when the player saves his turn. Then the save game contains the "rules" the turn was performed with.

So when the next player loads the save game he receives from his opponent the game will load the TXT data from the local computer of the next player and compare it will the data stored in the save game. If they are the same then the player can continue his game. If they are not the same the game should abort with a message saying there is a mismatch between the TXT files. Then the next player will know the first player has doctored his TXT files.

This will NOT affect any mods because all that is required is that both player have the same TXT data. It doesn't have to be the same as the original game.

Posted: Wed Aug 15, 2007 5:23 pm
by IainMcNeil
What if the player swithed back before sending the turn - it doesnt really solve the problem.

It needs something more complex I'm afraid which is where it gets tricky :)

Posted: Wed Aug 15, 2007 6:32 pm
by Peter Stauffenberg
No it doesn't have to be more tricky. The code today reads the TXT files when loading the game and these values will be used for performing everything during the player turn. The player can change the TXT files how much he wants to afterwards, but it won't affect the current turn.

The player must save the game so he can send the save file to his opponent. All you need to do is to save the TXT file values stored in the memory of the computer to the save game. This ensures that the save game will contain the SAME values as the turn was processed with. The save game is encrypted so it's hard to doctor the values within there.

You always need to read the TXT files when loading the game because the values can be different than the original ones. So some place in the computer while the game is active will these values be stored. No player can change these values after they've been loaded. When you save the game you simply save the values you read at the beginning of the turn (the values stored in variables in the program code). So it's not possible to cheat with such a method.

The other player can alter the TXT file before he loads the save game, but if he does that the game will abort anyway because the TXT files are not the same. But if the other player loads the game and it's aborted then he knows the first player performed his turn with different TXT data than he's using himself. Then he knows the first player must have changed them, probably in his favour and thus cheating.

So the key here is to read the data from the TXT file when you load the game and keep these values for the entire turn stored in the computer and save the stored values to the new save game.

I guess you don't read the TXT files locally every time something is happening during a turn? That is very inefficient. I guess you load all TXT values when the game load (that's one reason the loading time is quite long) and store all these values into variables. When you need to know the content of one value you just check the variable. That is much quicker and I'm 99% sure this is the way you have programmed it. :)

Posted: Wed Aug 15, 2007 11:33 pm
by sagji
One trick is that when you read a TXT file you also calulate a digest - such as MD5 or SHA-1. If this value doesn't match the one stored in the saved game then there is an error.

Posted: Thu Aug 16, 2007 8:16 am
by davetheroad
Does calculating this digest or whatever take into account the change of even one letter or number in the text file?
If so this might be the way to do it as only one variable is stored in the save file for each text file. Of course this might be pointless if the devious gamer could read and change that variable.
Dave

Posted: Thu Aug 16, 2007 8:54 am
by IainMcNeil
I'll have to ask Johan. Cheat prevention is on the wish list, but I dont think its as easy as you suggest :)

Posted: Thu Aug 16, 2007 12:32 pm
by sagji
davetheroad wrote:Does calculating this digest or whatever take into account the change of even one letter or number in the text file?
If so this might be the way to do it as only one variable is stored in the save file for each text file. Of course this might be pointless if the devious gamer could read and change that variable.
Dave
Yes any change will alter the digest - even adding a space on the end of a line.

Posted: Fri Aug 17, 2007 4:45 pm
by Happycat
I suppose that inadvertant cheating is possible too. Presumably, if you are playing a PBEM with one person, utilizing an altered text file that has been agreed upon by both parties. you need to remember to restore the original "vanilla" text file for any other PBEM you are involved in, where mods are NOT being used? And, if you keep flipping back and forth between text files, does this affect the digest?

Posted: Sun Aug 19, 2007 4:04 pm
by sagji
Happycat wrote:I suppose that inadvertant cheating is possible too. Presumably, if you are playing a PBEM with one person, utilizing an altered text file that has been agreed upon by both parties. you need to remember to restore the original "vanilla" text file for any other PBEM you are involved in, where mods are NOT being used? And, if you keep flipping back and forth between text files, does this affect the digest?
Each file will have its own unique value for the digest, so this will tell you if you have the wrong file for the game you are loading, but won't tell you which file is the right one.

Posted: Sun Aug 19, 2007 4:23 pm
by Happycat
Sagi: if one is playing multiple "mods", is there an easy way to keep this from happening inadvertantly? What I have been doing is changing file names (labelling the generic files with the prefix "vanilla" while using a mod file), and then changing them back. It is a bit tedious, and perhaps there is a better way? What about multiple directorys for the entire game? (i.e. is it possible to have more than one installation of the game on the computer? Or will it confuse the registry?)