Updating save files in new game versions

Hello!

My question is: Is there another better way to do the process below, that I don’t know of?

The game I’m releasing on Steam has some crucial things to be saved so everything functions properly. Things like player progress and game settings are stored in one file.

The problem comes when I need to push an update where I’ve added new features to the game. Let’s say I’ve added player leveling and now I need to not only make additions to the save file but change values based on which version the game is updated from. For example, I’ve added player leveling but have to clear the player’s saved money in the new update.

The solution that I’ve come up with is the following:

I will create a “version manager” in my game that is going to keep track of what was the last launched version of my game, then when an update comes if the game’s version is mismatched with the one saved in the save file, run “patches” that are specific for every update. Every patch from the old version has to be run sequentially until the saved game version matches the newest version.

The patches are custom code written to change things in the save file if a new version is detected. These patches can be stacked, so for example, if the player last launched the game in version 1.2 and the latest update is 1.5, at launch the game will go through 3 patches sequentially to make up for the versions that the game was not launched on.

Here’s how that’s going to look like in the version manager:

Save file game version = V1.2
Game version = V1.5

Patches for versions:
:arrow_down: V1.3: Adds +10 coins to the player’s inventory
:arrow_down: V1.4: Clears the player level
:arrow_down: V1.5: Adds +50 coins to the player’s inventory

So these “patches” will be executed upon game launch allowing me to change things to already existing save files, allowing the users not to lose any progress.

What do you think? Is that a good system for updating things in already existing save files?

1 Like

It’s good to think about this kind of thing.

Something that I think is a much more pressing question, which might not have occurred to you yet, is if you change the ‘shape’ of the savegame, what happens then?

Because the system then tries to load your MySaveGame1.0 into a MySaveGame1.1 shaped thing.

I was worried about that for quite a while, and in fact made separate savegames for all new variables I wanted to add. In fact, is doesn’t matter, and the system ‘serializes’ the variable in the savegame, which means as long as you have the save type of variable with the same name, you should be ok.

But I would advise against change names or types of variables :slight_smile:

I don’t think you religiously need to path from one version to another. It’s quite ok for V1.4 to take precedence over all previous versions, without updates. It really depends on what data needs to be carried over, if any.

1 Like

I’m quite aware that if I were to change the name of an already-existing variable, it’s going to reset it for the users who already have a saved file. When I already have shaped the save file structure in one way, there is no going back from that.

If I were to scrap a feature that is already in the version manager’s patches and the user’s seaves, I would need to work around deleting it entirely, because that has the potential to break something.

I usually won’t consider making every variable a separate file, because while yes it might be a little bit cleaner, it has the same kind of problem, because what happens when you have to reset the player money in one version, but then another add 10 coins to their inventory. Also, it brings the problem where players can just upload and download save files for the different variables, allowing them to easily alter the different variables. While tools like Cheat Engine exist, they may not be as user-friendly as just replacing a file.

In my version manager system, it is quite important to go through every patch sequentially because that’s the only way I’m able to ensure that no matter what the users will get the the same changes as the new users without a save file. (eg. The starting money is changed from 0 to 10. In that case, I will create a patch that will give 10 coins to every existing player)

The only difference is that the new users are just beginning with the default values for the variables, while for the already existing users, I alter the required things in their save file so everyone gets the same experience.

That’s what I’m saying, you can, as long as it’s only adding or removing variables.

I didn’t have a file for each variable, only the new concepts.

1 Like

Okay! Thanks for your time. It was important for me to check how another person would approach this. It was a pleasure talking with you! :grin:

I’ve already made a prototype of that system and think it might work! I tested it with an old save file (The one that the Steam players currently have) where that system doesn’t exist, and I was able to achieve my goal of altering the save file and laying the grounds for better save file management across the future versions. :smile:

1 Like