Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


saving and loading

This topic is 5237 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

When it comes to saving and loading game data, is better to read and write each variable value to the disk, or the much easier writing and reading of entire classes to the disk? I''m currently writing the characte class to the disk however there seems to be a problem with it since occasionally the save file becomes corrupted and causes the program to crash. ----------------------------------------------------- Writer, Programer, Cook, I''m a Jack of all Trades Current Design project Chaos Factor Design Document

Share this post

Link to post
Share on other sites
Look up data serializing on google. It''s a technique used by most games out there. You simply serialize different values into differently-sized blocks of data (say, 32 and 64 bytes).

Although a very clean (and simple) approach is modeling an ABC (Abstract Base Class) with nothing else than two pure virtual methods. One for saving and one for loading. Then, each class that needs to be saved and loaded implements the two methods in its own way.
These methods could write to a static RAM buffer while the program is running, then on program shutdown the data gets flushed into a file on the HDD. Then again when the program starts, the file is opened and the static RAM buffer restored, letting the classes that previously saved their states to load data and reinitialize themselves.

That is of course a very abstract idea and not a model of how things can work to the point. You''d have to figure out the middle-layers yourself.

Share this post

Link to post
Share on other sites

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