Jump to content
  • Advertisement
Sign in to follow this  
HellRiZZer

Optional Values in Save/Load

This topic is 4620 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I've got a question I couldn't solve yet, it drives me nuts :) For example, I have an archive file that I use to serialize data into. But for example, I leave it to the user to either have or not some member attributes. For example, they may choose to have no texture or no material in some class, but how do I will know if they exist when I load data from file? I mean, if its all written in binary, theres no way to tell when I'm loading whats the next chunk of data represents, right? So, what should I do? One way is to create a 'weak' or 'null' object like in Game Programming Gems, but that would require every object that is serializable to have one of them. Please suggest what should I do. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Here is what i would try.

Break the system down to a more general level.
You have
Objects
-Graphical properties
--texture
--material
--color
-physical properties
--sound
--solidity
--mass
...

So that you serialize a "graphics property" attribute on every object, instead of
worring about updating all your object members when you change the graphical end.
You just have to update your GraphicsProperty structure/class with the new data.

I can only think to use NULL value markers for all items not used.
And chunk ID's would make the easiest solution if you ever want to add functionality to your Objects.
But, if you don't anticipate changing the Objects property list that much, use bitmarkers.
When writing/reading a file load each property in some set order. In the file you can then store a '0' or '1' bit to represent if a field is there. So read a bit, check for a 1, if so start reading the chunk, otherwise move on.

Maybe that will give you some ideas.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!