Adding loading/saving on-the-fly...hmm..not really
I trapped myself with one of this minor feature: loading/saving
Yes, it sounds simple. After more than 10 years of developing an engine/game I came to the conclusion that it is time to add it now. It turned out to be one of the tougher challenges of the last years.
When you got a C++ engine and lot of scripted code (whole game logic), then you have a problem here.
So, how to save your game ? There come two approaches to mind.
You serialize every object in your game to a file. You must have some special handling for associations between objects. I use a unique id for each object and save only the ids for references. Thought after loading your game data you need to reconnect the references.
A problem with this approach is, that you need a lot of post processing and you need to change class models to support it (I.e. some script languages like lua supports refering functions). You can regard this as an almost 1:1 memory copy of you game data.
The major advantage of this technique is, that you can easily add and remove data from your game. The mechnism works almost automatically. But there're some pitfalls. First your saved gamedata is really fixed to one version of your game. Reloading it with an newer version could easily lead to some disaster. This is really an issue while developing a game and when you need to release some bugfixes.
Instead of just saving a copy of the whole data to a file you export and import the data. In this case you define some kind of save-fileformat for each object, relation etc. When importing it you need some kind of special parser for each entity to create and connect the according objects in your engine.
The major advantage is, that this is a clean approach and you can change the game code while keeping the save files (just adjust the importer). But you need to put some work into it whenever you change the fileformat. But this could lead to high maintainance costs at development time.
Well, after forgetting about save files for years, I choose to go for de-/serialisation. I would have prefered the import/export approach, but it is just too expensive. To soften the negative upgrade effect (new game version makes older save files obsolete), I choose to use some kind of weak references to static content. Therefore I divided the data into permanent and persistent data. Permanent data are shared, static data which are used independendly by dynamically created content. I.e. game rules, templates etc. This static content get unique ids at design time and will not be saved to a save file. When reloading a file I can reconnect objects to this version dependent data. This allows me to upgrade and change the game to some extend without making the save files obsolete.
Once the game has been released I fear that a major game update will lead to obsolete save files, but this could happen to import/export files too. Atleast minor updates should work as long as I'm careful about changing the code and content.