A presentation on implementing save games
I recently gave a private presentation on how to implement save games. This is the blog post based on that. I wrote the presentation pretty quickly, so this is not the best structured blog post ever, but hopefully it's useful to someone.
Should you listen to me?
I don't consider myself an expert on save games, but I have worked on them at various stages in my career.
Amberstar, Ambermoon, and Albion, the first three games I worked on, were big CRPGs. The first two games saved to floppy disk, Albion only saved to hard drive. The logic wasn't very complicated, because these games did not use dynamic data structures. The save game consisted of fixed data structures and simple arrays.
As part of my work on the mission systems in Watch Dogs: Legion I also worked on the save games. I did not work on the save game system itself: that was legacy code. But I did spend a lot of time on the code for saving and loading mission data. My number one worry on Legion was something going wrong with the save games. If you mess up mission save data, you can erase enormous amounts of progress, or create corrupted or stuck save games. This actually happened on Amberstar, and back then I had to explain this directly to players, on the phone.
Quite recently I designed and implemented a save game system from scratch. The game that it's a part of has not been released, so it's hard to say if it would survive the crucible of shipping. But it did work during development, and, most encouragingly, other programmers used it, and said nice things about it.
Assumptions
Here are my assumptions for the rest of this blog post:
- You've got a decently complicated game, with multiple programmers working on multiple systems over a period of years.
- You want console support and online support.
- Your game is multiplayer.
- Your game is open world.
- The game supports auto-saving.
- The whole save game fits in memory.
- Your engine has some kind of system to serialize and deserialize arbitrary data structures to something saveable. In the rest of this blog post I am going to assume we're using JSON, but it doesn't have to be that.