Original Post
🔒 Locked
Saving/Loading Data
Advertisement
XML is one way to do it.
XML is preferred if you want the data to be human readable.
I prefer binary serialization, that way you just output your classes to the file stream and save. To read you do the reverse. The nice part it that you can save your game in the current state without really much work.
theTroll
XML is preferred if you want the data to be human readable.
I prefer binary serialization, that way you just output your classes to the file stream and save. To read you do the reverse. The nice part it that you can save your game in the current state without really much work.
theTroll
For production you often want a more efficient binary format, but text-based formats are very useful during development, for ease of editing and visualisation.
Personally I am not fond of XML, I find it overly verbose and hard to read/edit. You should have a look at YAML before deciding - it is a more modern (and very readable) standard for textual data.
Personally I am not fond of XML, I find it overly verbose and hard to read/edit. You should have a look at YAML before deciding - it is a more modern (and very readable) standard for textual data.
One approach that has worked well for me is to store all of your save data into a class or struct (that can contain nested classes/struct) and then serialize them to disk.
If your classes/structs contain many fields you can write generic serialize functions to handle each field. If you want to have a text version of your saved data (as swiftcoder suggested) you can have a separate path in your serialize functions that spit out text instead of binary data.
If your classes/structs contain many fields you can write generic serialize functions to handle each field. If you want to have a text version of your saved data (as swiftcoder suggested) you can have a separate path in your serialize functions that spit out text instead of binary data.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement