Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1075918 Posts in 44152 Topics- by 36120 Members - Latest Member: Royalhandstudios

December 29, 2014, 03:02:49 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)Updating saved data
Pages: [1]
Print
Author Topic: Updating saved data  (Read 518 times)
JasonPickering
Level 10
*****



View Profile WWW Email
« on: August 14, 2011, 08:12:20 PM »

alright so this is not so much a specific code problem as more of a Theory problem.

how do you update a save file to contain new data for say an expansion, without overwriting a players current data.

lets say a player has unlocked 3 of the heroes in the game. now I go and update it with a new hero. how do I make sure that when I over write the new save data. to have an area for the new hero it wont overwrite the players current stats. does this make sense I can give a better example if needed.
Logged

TheLastBanana
Level 8
***



View Profile WWW Email
« Reply #1 on: August 14, 2011, 08:16:32 PM »

You could include version information in the save file's header. That way, when you update to a new version, you can convert the save file to its new format before saving. Or am I misunderstanding you?
Logged

ஒழுக்கின்மை
Level 10
*****


Also known as रिंकू.

RinkuHero
View Profile WWW Email
« Reply #2 on: August 14, 2011, 08:28:20 PM »

add stuff to the end of the save file if you need to save additional stuff
Logged

rivon
Level 10
*****



View Profile
« Reply #3 on: August 15, 2011, 09:11:47 AM »

1) Use different save file for the expansion
2) Use XML or something for the save files and a structure like this:
Code:
<campaign name="The Original Game">
    <stuff>...</stuff>
</campaign>
<campaign name="The Original Game: The Original DLC">
    <stuff>...</stuff>
</campaign>
('campaign' could be 'game' or 'levelset' or something)

When loading the save file just read the 'campaign' with the right name.
Logged
Evan Balster
Level 10
*****


I live in this head.


View Profile WWW Email
« Reply #4 on: August 15, 2011, 10:02:26 AM »

I write support for backwards compatibility into every file format I make aside from configuration files.  A version number and loader code with some if-statements specific to parts of the file that have been added or removed after a given version will do the trick nicely.

Code:
versionNumber = readInt();

if (versionNumber < 2)
{
  int removedDataValue = readInt();
  newDataValue = convertDataValue(removedDataValue);
}
incumbentDataValue = readInt();
if (versionNumber > 1) newDataValue = readInt()

See, there I have a format that originally had two values, but then made a formatting change to the first and stuck it on the end.


I actually wrote a massive serialization engine that automates this for me, but I go on  Tongue
Logged

Creativity births expression.  Curiosity births exploration.
Our work is as soil to these seeds; our art is what grows from them...


Wreath, SoundSelf, Infinite Blank, Cave Story+, <plaid/audio>
bateleur
Level 10
*****



View Profile
« Reply #5 on: August 15, 2011, 11:45:46 AM »

I write support for backwards compatibility into every file format I make

This is good thinking, but for those of us who tend not to it's pretty easy to retrofit. Look at the start of the save file and if it begins "version x.y" then that's the version number. If it doesn't then it can be assumed to be a version 1.0 save file!
Logged

Glaiel-Gamer
Moderator
Level 10
******


Stoleurface!


View Profile WWW Email
« Reply #6 on: August 15, 2011, 12:19:00 PM »

This is good thinking, but for those of us who tend not to it's pretty easy to retrofit. Look at the start of the save file and if it begins "version x.y" then that's the version number. If it doesn't then it can be assumed to be a version 1.0 save file!

This assumes that "version x.y" isn't also valid data for the first field in the file type.

heh
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic