4
\$\begingroup\$

My game is driven by a scripting language, and the user can save at almost anytime in the middle of the script, so the instruction number of the script engine must be saved. The problem is that the game state breaks when the script is changed. If the script is A B C D E and the player saved at C (the 3rd), and then the script is changed into X Y Z A B C D E, then the player will load at Z. I think my game will be updated infrequently even after release.

I think breaking the script into sections and autosaving in each new section. (in case of incompatibility: restart at autosave) However, are there any other ways to make save files forward-compatible? I want to hear some examples of especially RPGs with DLCs and patches.

\$\endgroup\$
5
  • 1
    \$\begingroup\$ I think you should load the game at C in both cases.. and have version numbers in your save games, and handle the missing stuff based on the version number. This can get horribly complicated though.. \$\endgroup\$ Dec 25, 2012 at 7:58
  • 1
    \$\begingroup\$ Starting at C both times, they would miss out on what XYZ had to offer. Sometimes changes are incompatible with existing saves. \$\endgroup\$
    – House
    Dec 25, 2012 at 8:13
  • 1
    \$\begingroup\$ @Byte56 such is life. I'd find it much stranger to find myself in a completely different part of the story when I load the game. And in his (or her) example, the player would miss X and Y in any case. \$\endgroup\$ Dec 25, 2012 at 8:25
  • \$\begingroup\$ @JariKomppa True enough. I suppose that's why such radical changes are usually kept out of updates. Or at least they are only applied to new games and the save games use their current scripts. \$\endgroup\$
    – House
    Dec 25, 2012 at 16:28
  • \$\begingroup\$ In Mass Effect 3, after installing Extended Cut, the I can no longer load the save at the final mission, but I can restart at the autosave "Citadel: The Return". \$\endgroup\$
    – Ming-Tang
    Mar 15, 2013 at 16:36

1 Answer 1

6
\$\begingroup\$
  1. Include a version number at the top of your save file. Increment the version number whenever you make a change to the format, and add code to your engine to allow it to read "old" versions and make any necessary revisions to the loaded data. Of course you will have to decide what kinds of revisions are appropriate. In a case like your example, where new items are added, you'll have to supply some default state for the new items, since old saves will have no state for them.

  2. When saving the state of characters, items, quests and the like, refer to them by some sort of "name" - not just by their index in an array or something like that. This allows you to add new content to the game and old saves will not be broken by changing the order of things.

    Note that by "name" I don't necessarily mean a string. You could use a string, but you could also use a hash value, or an integer ID number, as long as it's something assigned to the item once and for all, that will never change - i.e., not its address in memory or index in an array or anything like that.

\$\endgroup\$
1
  • \$\begingroup\$ I used to use that approach. I have since switched to putting version numbers on the data elements themselves. It makes the changes have far more confined effects. \$\endgroup\$ Dec 25, 2012 at 21:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .