Implementing game save files
by Quentin Headen · in Torque Game Builder · 06/06/2011 (6:04 am) · 9 replies
Hello everyone! I am currently in the process of implementing save files for my games. Basically, I want the player to be able to save their progress. I was originally thinking about using simple txt files, but if I save data the regular way, by using a regular file stream, the data will be open for the player to modify. This of course makes it super easy for the player to cheat.
So I would like to know, what is a secure way of creating save files? Is there a way I can write files in binary mode instead of text mode?
Please help me with this, it is very important to the game.
Thanks
So I would like to know, what is a secure way of creating save files? Is there a way I can write files in binary mode instead of text mode?
Please help me with this, it is very important to the game.
Thanks
About the author
Just your average programmer who tries to finish the projects he starts. :) I am currently focused on creating games with Torque engines. My website is http://phaseshiftsoftware.com
#2
if $checkPoint1 == true then on level load, set up the scene accordingly etc etc.
06/06/2011 (2:45 pm)
the easiest way I can think of is checkpoints.if $checkPoint1 == true then on level load, set up the scene accordingly etc etc.
#3
06/15/2011 (5:19 am)
well, it seems that when ever I use the save method to save a file with a specific file name in a specific location, I can't find that file on my hard disk at all. The interesting thing is that although I couldn't find the saved file on disk I could read the file, the info that was written is also there. If I can't find it on the disk, the player most probably can not either.
#4
And then of course, the corresponding decryption in the read functions.
Not really THAT secure, but anyone who opened the file in a text editor would just see gibberish.
XOR is also very fast.
06/15/2011 (3:35 pm)
Are you OK with source edits? Seems like it'd be pretty easy to add an optional "XOR" encryption to functions like writeline, export, etc... whatever you're using to write the data.And then of course, the corresponding decryption in the read functions.
Not really THAT secure, but anyone who opened the file in a text editor would just see gibberish.
XOR is also very fast.
#5
Torque saves your files in a special directory called the Application Data Directory. This is after version 1.6.
06/15/2011 (4:55 pm)
"well, it seems that when ever I use the save method to save a file with a specific file name in a specific location, I can't find that file on my hard disk at all."Torque saves your files in a special directory called the Application Data Directory. This is after version 1.6.
#6
The files are written where they should be written (according to newfangled standards), \Users\UserName\Appdata\Roaming\CompanyName\GameName\
Though that really doesn't have much to do with this thread!
06/15/2011 (6:08 pm)
What Kevin said.The files are written where they should be written (according to newfangled standards), \Users\UserName\Appdata\Roaming\CompanyName\GameName\
Though that really doesn't have much to do with this thread!
#7
06/18/2011 (9:00 am)
I did a windows search on the entire hard disk and still could not find the saved files. It's strange but that is the case.
#8
06/20/2011 (8:02 am)
Well, TGE/A and T3D have a system in place that allows use of zip files as "directories" for storage of resources, etc. I haven't looked at the TGB source in a few months but they might have carried it forward. Zip files support encryption, and you should be able to simply tell it to do so, provide a password and go. It's not totally secure, but most casual gamers aren't into cracking encrypted files.
#9
06/20/2011 (2:29 pm)
Yah my theory of just setting globals is wayyy off. So how does one do this?
Torque Owner Rpahut
There is also an option of attaching some kind of checksum value to the saves, so your code can check if file was edited or not.
Binary doesn't automatically makes files edit-safe - user can have text editor, and equally easy a hex editor too. Question is - why would he bother to edit files, and why would you bother to prevent him from doing so? If it's an online game, you better keep sensitive game data off client's machine completely, otherwise just let him do whatever he wants.