Jump to content
  • Advertisement

Recommended Posts

Hi

Im using binary files to save and load savegames. But when you list your savegames for the user you want some metadata such as date/time, gameday, difficulty, map name etc so the user more easily can identify which savegame they want to load.

What is the prefered way of doing it?

1. When saving, save metadata first in the file. Then do a function "scanSaveFiles()" before showing the available savefiles for the user. This will read each "header" of each file (reads the first section of the binary file without actually loading that game) and can then show the info to the user.

2. When saving, update a table of savegame-metadata held by the "gameMaster" that holds other stuff like user options, progress etc. However this seems bad since if the user manually moves or modifies the savefiles the table of savegame-metadata will no longer sync with the actual save files.

Or any other smarter way of doing it?

Edited by suliman

Share this post


Link to post
Share on other sites
Advertisement

Yes agree, first option. Also when dealing with save game files, especially binary ones, make sure it has some sort of future proof about it.  I.e. you'll probably want to add things to your save game in future versions of the game (after release), Will your game handle loading old versions of your game save data..
 

Share this post


Link to post
Share on other sites

Version compatibility is always a topic not just for savegames but also for anything that is serialized/deserialized. A text or property file format could help here so unknown properties will be skipped while new ones will be held empty.

The option to have some kind of header in your save files is currently the best one for your situation because a save file is the main entity you need to maintain, when storing metadata, you need to know if a file has moved, was replaced or renamed what may become a huge management overhead while you just want to "simply show some information".

On the other hand you then will have file access every time you just want to see what your last save files are so the "database" solution has the advantage of keeping disk access as small as possible. Some games prefer this solution when for example the player has made his own character you would like to show as seen here

ddo_3.jpg

 

A middle course solution would be to gather a players save files at startup of the game or as a background task when you are sure your player wont have access to the save game area for a few seconds to generate your meta database at this point from disk until you update it next time

Share this post


Link to post
Share on other sites

I like the 1st method.  It also directly allows your players to move save files either for backup purposes, or to other machines, or in most cases if you let them choose save locations, to something like a Dropbox folder.

I understand wanting to "gather" all the information in a single place...but I think a few milliseconds to do that when you hit the "load" button is fine.  Even a spinning hard drive shouldn't have trouble reading several headers of savegame files really quick, especially if they are binary files(which you are currently discussing).  Even if it were a couple of seconds I think it would be an acceptable amount of time for a player to wait, especially since it let's them easily select the file they want, without having to go search for it, remember what it was called, or anything like that.

Share this post


Link to post
Share on other sites

FILE *stream; fopen() fread(), fwrite() and fclose() are your friends......oh yes fseek() is your friend too

Edited by Snaked

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

  • 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!