So the next thing I wanted to do was getting saving and loading to work. The Wintermute Engine has a, I would say, rather sophisticated save system. Basically it is possible to save an entire object graph into a file and then getting it back later, without the user code having to do anything about it apart from saving it’s own state (actually, the engine handles things in a way such that loading and saving can be handled by the same function for the object being saved/loaded in). Essentially this is achieved by registering newly instantiated objects (via new overload) and keeping them in a special container class.
Now there are some caveats here, for example when one is dealing with a subclass of a class with such a new overload, which actually is not supposed to be registered. In this case one has to disable the whole registering process via a flag, something I had to find out via debugging and comparing with the WME code.
Another problem is compability with ScummVM savegames. The 3d code adds new classing and member variables, which are going to end up in the save file. This would lead to inconsistencies betweem save files from ScummVM and ResidualVM. The proposed solution here is to only save/load the 3d classes and variables in case we are playing a 3d game, which should work but I have not tested this yet.
Also loading a save file in Alpha Polaris seems to introduce at least one bug, certain info texts disappear too quickly and thus are not readable. Also text input (which is required at certain times in the game) is not possible anymore.
One reason I started too work on save files was actually to be able to play the whole game since after a while the performance would drop so much that I had to stop the game. Turned out that the problem here were memory leaks. Fixing them made it possible to play the whole game in one go, without any saves (which basically are broken at the moment). This is very good news as it means there is no big stuff missing which would be required to finish the game. It also showed that the leaks were indeed fixed since memory usage became stable after a while (although 2GB still seems a little bit too much to me).