Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
1  
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.. –  Jari Komppa Dec 25 '12 at 7:58
1  
Starting at C both times, they would miss out on what XYZ had to offer. Sometimes changes are incompatible with existing saves. –  Byte56 Dec 25 '12 at 8:13
1  
@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. –  Jari Komppa Dec 25 '12 at 8:25
    
@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. –  Byte56 Dec 25 '12 at 16:28
    
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". –  SHiNKiROU Mar 15 '13 at 16:36
add comment

1 Answer 1

up vote 6 down vote accepted
  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.

share|improve this answer
    
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. –  Loren Pechtel Dec 25 '12 at 21:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.