Jump to content
  • Advertisement
Sign in to follow this  
raidzero

Best approach to loading and saving game data?

This topic is 2297 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement

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.


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


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.


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

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.


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

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


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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!