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

Author Topic: Data storage  (Read 4608 times)

0 Members and 1 Guest are viewing this topic.

Raphman

  • Newbie
  • *
  • Posts: 40
    • View Profile
    • Email
Data storage
« on: April 13, 2013, 09:17:44 pm »
Hello there guys. I apologize if this is in the wrong section, but it seemed like the appropriate place to post this.

I've been developing a J-styled RPG for a while now, and  I've been loading everything manually in the code.  I decided that it's time to off-load some of this stuff to files, and load them in from said files.

Now, while I'm focusing on Windows development right now, I think I'll eventually want to port my game over to Linux, so I need to keep things portable.

Things I want to store include:

Player/Monster stats
Player/Monster spritesheet locations
Battle backgrounds
Battle monster groups
eventually I'm going to be storing Tile maps/info also.

Now I've done some research and I've narrowed it down to a few options:
YAML
XML
INI (My research lead me to think that this would be the best for windows data files, but it's not portable without third party libraries)

So, what do you guys think would be best to use? Also, I'd eventually like to market this game, so if it's a library (boost comes to mind), It would be necessary for the license of said library to allow for that.

Or maybe I should just suck it up and write my own file format/ parser?

I appreciate all the help these forums are, Thanks in advance guys!
« Last Edit: April 13, 2013, 09:39:11 pm by Raphman »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Data storage
« Reply #1 on: April 13, 2013, 11:04:45 pm »
It entirely depends how you want to implement it.
Writing a ini reader is the most simplest approach and might not need an additional library. With YAML and XML parsing, it's usually not worth to reinvent the wheel.
Personally I'd probably chose YAML, since it's a more descriptive format than ini and less filled than XML.

But as I said it all depends on how you want to load it and even when, maybe you want to even use different formats.

Well know parsers:
tinyxml2
yamlcpp
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Raphman

  • Newbie
  • *
  • Posts: 40
    • View Profile
    • Email
Re: Data storage
« Reply #2 on: April 13, 2013, 11:12:08 pm »
Thanks for the response! It seems that the latest version of Yaml doesn't support Windows currently. Maybe I'll just go with the .ini route (and write my own parser) for now then decide whether it's worth it to go YAML later on.

I appreciate it greatly!

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Data storage
« Reply #3 on: April 13, 2013, 11:13:36 pm »
Quote
It seems that the latest version of Yaml doesn't support Windows currently
Text files are always portable(except the line ending nonsense but langauges usually stick to one of them for every os), it's not yaml, it's just yamlcpp(a parser) that doesn't work on windows. But XML has 3252 parsers while yaml has next to none. :-\
« Last Edit: April 13, 2013, 11:16:47 pm by FRex »
Back to C++ gamedev with SFML in May 2023

Raphman

  • Newbie
  • *
  • Posts: 40
    • View Profile
    • Email
Re: Data storage
« Reply #4 on: April 13, 2013, 11:38:33 pm »
Now I don't claim to know much about XML vs YAML vs ini, but from what I see on various  forums, XML is kinda on the way out at least in popularity. I suppose it's all personal preference/needs of the project. I have a lot more research/thinking to do.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Data storage
« Reply #5 on: April 13, 2013, 11:39:25 pm »
it's just yamlcpp(a parser) that doesn't work on windows.
Just use version 3 and everything works perfectly fine. No need to constantly be on the bleeding edge of technology. ;D
« Last Edit: April 13, 2013, 11:41:20 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Raphman

  • Newbie
  • *
  • Posts: 40
    • View Profile
    • Email
Re: Data storage
« Reply #6 on: April 13, 2013, 11:44:35 pm »
True, but I don't know, I have a thing about using the latest and greatest. Which is why I'm using SFML 2 :)

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Data storage
« Reply #7 on: April 13, 2013, 11:55:05 pm »
You can always choose something like Lua.
Tank is using Lua and Yaml for Flex World, I'm sure he will have something to say if he looks here. :P
Back to C++ gamedev with SFML in May 2023

Raphman

  • Newbie
  • *
  • Posts: 40
    • View Profile
    • Email
Re: Data storage
« Reply #8 on: April 14, 2013, 12:09:11 am »
Very interesting that you mention Lua, I was eventually going to make editors to allow my designer to manipulate stuff, and was probably going to include Lua or Ruby so he could  manipulate stuff without needing me. I never thought of using said scripting language to just load files. Thanks for the input.

The Terminator

  • Full Member
  • ***
  • Posts: 224
  • Windows and Mac C++ Developer
    • View Profile
Re: Data storage
« Reply #9 on: April 14, 2013, 12:09:35 am »
Lua is a good choice. There are wrappers out there for Lua and SFML.
Current Projects:
Technoport

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Data storage
« Reply #10 on: April 14, 2013, 12:51:58 am »
For Lua I suggest Luatable(I found it recently but it looks alright), it's zlib. https://bitbucket.org/jacobalbano/luatable
Just 4 files, super tiny, works with 5.2, two headers and two sources. It's c++11 technically but it takes 5 or so changes to make it work without it, but it takes away that nice {} constructor.
« Last Edit: April 14, 2013, 12:56:16 am by FRex »
Back to C++ gamedev with SFML in May 2023

Raphman

  • Newbie
  • *
  • Posts: 40
    • View Profile
    • Email
Re: Data storage
« Reply #11 on: April 14, 2013, 06:19:16 am »
Sweet, it's very light weight, nice. I can deal with c++11 so that's no problem, thanks a bunch!

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Data storage
« Reply #12 on: April 14, 2013, 12:55:53 pm »
Just read through the code few times because there are some silly things in it, like that:
bool
        Value::loadFromString(const std::string& source)
        {
                LuaState L;

                if (luaL_dofile(L, source.c_str()) == 1)//<<-- that should be dostring, not dofile..
                {
                        return false;
                }

                lua_pushglobaltable(L);
                fillTable(L, -1, *this);

                return true;
        }

        bool
        Value::loadFromFile(const std::string& file)
        {
                LuaState L;

                if (luaL_dofile(L, file.c_str()) == 1)
                {
                        return false;
                }

                lua_pushglobaltable(L);
                fillTable(L, -1, *this);

                return true;
        }
Back to C++ gamedev with SFML in May 2023

Raphman

  • Newbie
  • *
  • Posts: 40
    • View Profile
    • Email
Re: Data storage
« Reply #13 on: April 14, 2013, 03:01:21 pm »
Haha what a great mistake, I probably would have not noticed that. Thank you very much!
o

Well, what do you know, YAML-CPP just fixed it's windows error. I think I'll use that as opposed to Lua for now. Once I actually make the GUIs for the editors I'll integrate Lua. Thank you very much!
« Last Edit: April 14, 2013, 05:04:57 pm by Raphman »

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Data storage
« Reply #14 on: April 18, 2013, 09:33:33 pm »
I got pissed with LuaTable and wrote my own table loader that is(imo) easier to use and has nicer interface, it is quite similar but doesn't inherit map, doesn't coerce types so easily and doesn't overload [] so stupidly(uses () for const read only access), if someone wants to try something different too tell me and I'll share.
Back to C++ gamedev with SFML in May 2023