Hexen save woes

I’ve started investigating what could be wrong with Hexen savegames regarding the state of ACS scripts. Right now I’m feeling quite overwhelmed — this code is complicated, even convoluted. Particularly the ACS state is broken down into multiple parts: world state, map state, individual script states as thinkers, and deferred script run requests. Each part is saved and loaded separately.

Due to all the complexity, I’m not surprised we are having malfunctions.

There are many open questions.

  • What level(s) is the problem really at: is the savefile writing and reading somehow not synced properly, leading to invalid data?
  • Is this a platform-specific issue (Windows only, maybe)?
  • Are the load routines not reading the data in the same way as the save routines have written it? (there are many version-specific if/elses, and many different version numbers affecting various subsections of the data — perhaps some of these have been mixed up?)
  • Is the issue triggered only during certain circumstances, like when a script is currently running?
  • Are all the variables appropriately restored from the saved data (completely and at correct times)?

Reading issue #1846, it doesn’t even sound like a problem with ACS state (savegametool crashing?). Perhaps these are separate issues. Maybe I should just focus on figuring out what is messing up the ACS state on the hubs (Seven Portals, Heresiarch’s Seminary) when saving and loading the game.

I need to spend a lot more time studing the code before I can make heads or tails out of this. It is unfortunate that debugging takes so much time, when there isn’t that much time available to begin with… Ultimately it would be fantastic to have a truly object-oriented state serialization mechanism, where each object serializes itself and its contained objects, and not the current jumble of spaghetti that is a refactored version of the old C routines. In practice, this would mean a complete rewrite and a new save format (so far we’ve only changed the container format, not the saved data itself). As they are, the old save routines are a ticking time bomb: every change we do to them may trigger hard to find, game-breaking bugs.