How to load a modified SaveGame

I have a custom SaveGame-derived class for storing game settings, and after adding a property to it, older versions of that class will no longer successfully cast after being loaded from disk. The initial class creation works fine, and the SaveGame object loads from disk, but casting the loaded object to my MPE_SaveGame class does not work.

One variable in the class is a struct for game settings, and I added a field to that. I’ve since removed that field and reverted the struct back to its old state, and have actually phased out its use (besides loading old save data if that cast would work), which means I now have individual fields for everything for saving purposes on that same class. Is that enough to keep the class from casting?

I’m not averse to writing custom versioned deserialization, but I don’t know where to start in UE4 if that’s what needs to happen.

I don’t know if there is a specific internal solution for this, but I would just keep a copy of each save data class and try to cast to the newest one. Then try casting to the second most recent… and so on. In each iteration of the SaveGame, make a function to migrate it from atleast the most recent version. Then resave with the newest.

A friend suggested something similar over lunch today - so is it pretty much a given that you need to create a new SaveGame class each time you need to add to the data being saved (assuming you’re not using something open-ended like an array or map)?

That’s my guess.

And yah, if you save everything to some generic dictionary, then you’d never have to change the save game class. Or atleast add a table like that for new stuff for later.

Then when you had big changes, you could always do the new class migration tactic.