How do you store data?
What do you guys and gals use to store data like player progress and inventory items, i.e. data that changes over time and must be saved compared to static data like level layouts or monster stats?
If you save to files what format do you use (XML, JSON, etc)?
Do you encrypt your data? What methodology do you use?
I realise this kind of question can be engine/OS specific.
If you save to files what format do you use (XML, JSON, etc)?
Do you encrypt your data? What methodology do you use?
I realise this kind of question can be engine/OS specific.
Comments
(I actually just use unencrypted JSON. It's flexible, human-read/writable, standardised, well-supported, and 100% compatible with cloud facilities like Parse).
I don't have code by hand, but I use something like this:
which I found on the interwebs.
For each class I want to save I then do this (I'm writing off the top of my head here):
Then just modify the first bit of code so that data = inventory.GetInventorySave()
Something like that. Dunno if this was at all useful for you but whatever :P It's also really very easily extendable. When you add a class that needs saving, simply create its serializable save class, and send it back to your BinaryFormatter/Stream/File.
http://project.soom.la/
Other simple data like character progress or inventory state can be saved with Unreal's config system.
So far we've been lucky enough not to have a game where we'd want to worry about encryption.
In my own engine (used for a growing stack of prototypes), I use a custom serializer which results in something similar to JSON (but better! :p ).
In some situations (like a really basic game with no real 'engine'), I just use the file stream straight such as:
Usually it gets a bit more dressing, but that's the gist of it.
I'm a big fan of JSON myself - it has all the human readibility benefits of XML, but it's way less verbose and actually more flexible as a result. My second best would probably be custom binary formats (which I've used a lot in the past), but those are harder to maintain, and generally less useful unless you're very conscious about save data bandwidth and size.
I made a variation that does away with the quotation mark clutter and makes '=' interchangeable with the ':' and a couple other things... Sorry for rattling on about it. I know no one cares about my grandchildren photos, but the compulsion of pride is too strong :p And then, because internet, everyone else also has the crack.
I'd be interested to hear, though, how effective save encryption is. Is that obstacle enough to reduce cheating in a meaningful way or is the leaderboard just flooded with the 1000 people that did google for the crack.