Putting the 'role' back in role-playing games since 2002.
Donate to Codex
Good Old Games
  • Welcome to rpgcodex.net, a site dedicated to discussing computer based role-playing games in a free and open fashion. We're less strict than other forums, but please refer to the rules.

    "This message is awaiting moderator approval": All new users must pass through our moderation queue before they will be able to post normally. Until your account has "passed" your posts will only be visible to yourself (and moderators) until they are approved. Give us a week to get around to approving / deleting / ignoring your mundane opinion on crap before hassling us about it. Once you have passed the moderation period (think of it as a test), you will be able to post normally, just like all the other retards.

Recommendations for a saving/loading system, and map

desocupado

Magister
Joined
Nov 17, 2008
Messages
1,802
So, what system would you guys suggest? (I'm using C++)

I have a couple of arrays of raw pointers (only discovered smart pointers after I had started the project) and some other stuff. I researched a bit, and saw that serialization is usually used, to binary and json. But I might go xml for my maps, so I was wondering if I could use xml for both maps and the saving system.

As for the maps, I'm wondering if I try to modify the custom xml thing that tiled uses, or just keep using text.

Thing is, I'm having a bit of trouble on reading the data from file. I have a solution right now using a text file and it's working, but I want to add some customization to the map files (victory conditions, events and stuff).

For example, if I always have 3 numbers in a line after "Rocky terrain", like this:
Rocky_Terrain
10,23,18,

Then it's trivial to read the data. But if I have a variable number of numbers under "Rocky_Terrain", then I'm not sure how to deal with that when reading. Maybe checking the failbit? I'm trying to figure the way of least effort here.

XML data seems more robust, but there's a learning curve...

What's easier/simpler for a small project?
 
Last edited:
Self-Ejected

Davaris

Self-Ejected
Developer
Joined
Mar 7, 2005
Messages
6,547
Location
Idiocracy
I haven't watched it yet, but I'd also take a look at this guy's approach. If he does things the way he normally does, loading and saving would be simple, error proof and virtually instant.

https://hero.handmade.network/episodes

Well you would have to set it up right, because he is probably dumping memory in one write. If you are using C++ in the OO way, you wouldn't be able to do it. Still worth a look if you are interested.
https://hero.handmade.network/episodes
 
Last edited:

Snorkack

Arcane
Patron
Joined
Jan 8, 2015
Messages
2,975
Location
Lower Bavaria
Shadorwun: Hong Kong
While reinventing the wheel can have its merits for inexperienced developers, file parsing isn't necessarily the most rewarding thing to implement. I would simply use one of the countless oss xml parsing/writing libraries out there ( apache xerces for example).
Serializing to binary/json is probably how 'the big guys' would do, but xml isn't a bad choice in your case since it is human readable and debuggable. The xml learning curve certainly isn't as steep as writing programs that use raw pointers without producing memory violations/leaks...
 
Self-Ejected

Davaris

Self-Ejected
Developer
Joined
Mar 7, 2005
Messages
6,547
Location
Idiocracy
The xml learning curve certainly isn't as steep as writing programs that use raw pointers without producing memory violations/leaks...

His method can't do that. You would have to watch the relevant parts of his show to find out.

But again, if you haven't started out writing your game using his way, its probably too late to use these methods. Still worth a look so you can see what you have been missing.
 
Last edited:

As an Amazon Associate, rpgcodex.net earns from qualifying purchases.
Back
Top Bottom