Jump to content
  • Advertisement
Sign in to follow this  
m0nkfish

Saving/Loading Game State

This topic is 3495 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'm surprised to find that there don't seem to be any GDnet articles on saving and loading game states. I mean this in the traditional sense of saving your progress and loading old savegames. I've read a few articles about how to save and load individual POD/structs to disk and load them again using binary read/write. However, there don't seem to be any guidelines on how to apply this to an entire game state. At a guess, I'd say have some sort of "mark" on things that should and should not be saved, then iterate through all objects and write to disk, then mirror the process for loading. This means that one function has access to every saveable object... Are there any agreed "do"s and "don't"s here?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
This means that one function has access to every saveable object...


Not necessarily. Each object could know how to write itself and some function would just tell the appropriate things to write themselves.

Share this post


Link to post
Share on other sites
Try searching the web for the term 'serialization'. I thought there was a gamedev article on this a while back, but if there was I can't find it.

The main difficulty is saving and restoring pointers between game objects, which isn't trivial since objects are usually in different places when they're reloaded. Other than that, you'll need some way of identifying what each object in the save file is, so that you can call the appropriate constructor.

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!