Sign in to follow this  
raidzero

Best approach to loading and saving game data?

Recommended Posts

raidzero    112
I've been doing some research on ways to read and write data but don't know which is the best way to go about it.

As for the writing data how do I go about saving? I went and looked through other game's save files. Why are some not in plain text? I assume they're encrypted or need to be opened with an appropriate editor.

For loading from a file, I could create some values in a text file and have it read to the game but what if I wanted to add descriptions or commentary to the file so I know what values are which and not have it read by the game? I thought about using Regular Expressions to cut out the stuff I don't need when the game is reading but is that doing more than I really need to? I'm just throwing ideas around and hoping to get some feedback.

Share this post


Link to post
Share on other sites
alnite    3436
[quote name='Key' timestamp='1333651235' post='4928562']
I've been doing some research on ways to read and write data but don't know which is the best way to go about it.
[/quote]

It depends on the game and what you want to save. There's no one universal saved game format.

[quote]
As for the writing data how do I go about saving? I went and looked through other game's save files. Why are some not in plain text? I assume they're encrypted or need to be opened with an appropriate editor.[/quote]

Reasons why games are not in saved in plain text to prevent cheating, and save bytes (binary format generally takes up less space in disks than text). If saved games are human-readable, then it makes it very easy for anyone to modify it. You can, for example, change your character stats all to 100 if you present them right there in plain text format. You can still do it even in binary, but at least it'd deter enough people.

[quote]
For loading from a file, I could create some values in a text file and have it read to the game but what if I wanted to add descriptions or commentary to the file so I know what values are which and not have it read by the game? I thought about using Regular Expressions to cut out the stuff I don't need when the game is reading but is that doing more than I really need to? I'm just throwing ideas around and hoping to get some feedback.
[/quote]

Ideally, you want to be able to save in both text format and binary format. During development, you save it in text-based format (your own, XML, JSON, whatever), and you can put all the comments you want. When you are ready to release, you switch it to binary, removing all the unnecessary comments.

Share this post


Link to post
Share on other sites
raidzero    112
[quote name='alnite' timestamp='1333654553' post='4928577']
Reasons why games are not in saved in plain text to prevent cheating, and save bytes (binary format generally takes up less space in disks than text). If saved games are human-readable, then it makes it very easy for anyone to modify it. You can, for example, change your character stats all to 100 if you present them right there in plain text format. You can still do it even in binary, but at least it'd deter enough people.
[/quote]

I looked into saving data into binary format but I'm not very familiar with it. Is there any way to convert values into binary format through an online application? I get things like ô SOH NUL NUL

Share this post


Link to post
Share on other sites
laztrezort    1058
[quote name='Key' timestamp='1333662461' post='4928602']
I looked into saving data into binary format but I'm not very familiar with it. Is there any way to convert values into binary format through an online application? I get things like ô SOH NUL NUL
[/quote]

Typically whatever language/framework you are programming in will have some sort of binary input/output library or routines available that interface with the operating system, and provide a way to directly read or write binary data to an from a disk file. The specifics of how this is accomplished varies widely, however. What exactly are you trying to do?

Share this post


Link to post
Share on other sites
Maxine    122
You might wanna check the settings files. Those let you store variables that can be saved/loaded. When you save them they are saved even when your application is shut down.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this