New OOTS products from CafePress
New OOTS t-shirts, ornaments, mugs, bags, and more
Results 1 to 12 of 12
  1. - Top - End - #1
    Barbarian in the Playground
     
    Domino Quartz's Avatar

    Join Date
    Feb 2012
    Location
    Auckland, NZ

    Default Should I use XML as a format for my configuration files?

    I am developing a game. The exact sort of game it is is not really relevant to the question I'm asking. However, what is relevant is that I want it to be able to be modified without compiling the .exe again. At the moment, I'm using a .ini file as my configuration file. The problem with that is that because of the complexity of the objects (not a very high level of complexity, but more than just a simple list of values) that get their values from the .ini file, the structure of my .ini file is starting to get a bit clunky. I've come to the conclusion that I need to use a different format, and I kind of like the look of XML. Should I use XML as a format for my configuration files? Why or why not? If not, what else should I use? Thanks in advance for any advice you can give me.
    Spoiler: Out-of-context quotes
    Show

    Quote Originally Posted by The Giant View Post
    Do not pass Go, do not collect $200.
    Quote Originally Posted by Kish View Post
    ...He would have to stay there permanently (without cake, somehow not breathing) for the prophecy to be fulfilled.
    Quote Originally Posted by ChristianSt View Post
    Maybe Blackwing is a Schrödinger's familiar.
    Any given member of the Order needs to do a quantum measurement to see if they remember him

    Azurite Name Inspirations
    Rich is a better writer than that!
    Free speech?

  2. - Top - End - #2
    Colossus in the Playground
     
    BlackDragon

    Join Date
    Feb 2007
    Location
    Manchester, UK
    Gender
    Male

    Default Re: Should I use XML as a format for my configuration files?

    XML has a pretty heavy overhead to just use as a configuration file--I'd be more inclined to use something a bit more lightweight like JSON.

  3. - Top - End - #3
    Ogre in the Playground
     
    NecromancerGuy

    Join Date
    May 2009

    Default Re: Should I use XML as a format for my configuration files?

    Yes. It's on the heavy side, but it allows for more complex structures and explanatory comments, unlike JSON. It also doesn't have to deal with YAML's whitespace sensitivity or ambiguity.
    ithilanor on Steam.

  4. - Top - End - #4
    Titan in the Playground
     
    Jasdoif's Avatar

    Join Date
    Mar 2007
    Location
    Oregon, USA

    Default Re: Should I use XML as a format for my configuration files?

    Quote Originally Posted by Domino Quartz View Post
    I am developing a game. The exact sort of game it is is not really relevant to the question I'm asking. However, what is relevant is that I want it to be able to be modified without compiling the .exe again. At the moment, I'm using a .ini file as my configuration file. The problem with that is that because of the complexity of the objects (not a very high level of complexity, but more than just a simple list of values) that get their values from the .ini file, the structure of my .ini file is starting to get a bit clunky. I've come to the conclusion that I need to use a different format, and I kind of like the look of XML. Should I use XML as a format for my configuration files? Why or why not? If not, what else should I use? Thanks in advance for any advice you can give me.
    First question: what you considering "configuration", that an INI file isn't up to the task?

    For generating the Index of the Giant's Comments; I use an XML file for the necessary information of the entries themselves, another for the overall layout of spoilers/tables/etc., and an INI file for tweaking the actual generation (file names, what version number is considered "current", the character limit of each post, etc.).
    Feytouched Banana eldritch disciple avatar by...me!

    The Index of the Giant's Comments VI―Making Dogma from Zapped Bananas

  5. - Top - End - #5
    Barbarian in the Playground
     
    OldWizardGuy

    Join Date
    Nov 2010
    Location
    California
    Gender
    Male

    Default Re: Should I use XML as a format for my configuration files?

    I've worked on games that use XML as a schema language. It works. (Of course, we invested several programmer-years just working on making a good asset pipeline; you may not have that luxury.)

    Actually reading XML at runtime can be a bit heavy. You may want to pre-process the XML if you worry about speed.

    Suggest using tags over attributes for as many things as possible. You can insert comments in between tags. You can't have comments in a list of attributes.

    Having XSD files was very useful. We had a system which generated C++ structures from the XSD, so that the C++ code was all just object->name, object->icon, etc. Much easier to read than having string constants. (And, of course, the XSD prevented typos in the tag / attribute names.) The pipeline knew about the C++ structures and made binary files which could be dropped directly into memory and immediately interpreted as the correct type of C++ structure. (Almost -- I think there was a pointer fix-up step at load time.)

    The games were Command and Conquer 3, Red Alert 3, and Command and Conquer 4. You can see the underlying XML and XSDs if you get the mod kits (don't know if they are still downloadable) and look through some of the tutorials
    Last edited by Sermil; 2020-07-15 at 08:40 PM. Reason: Added specific game names

  6. - Top - End - #6
    Barbarian in the Playground
     
    Domino Quartz's Avatar

    Join Date
    Feb 2012
    Location
    Auckland, NZ

    Default Re: Should I use XML as a format for my configuration files?

    Sorry for taking so long to respond to your posts, everyone. Thanks for your input.

    Quote Originally Posted by Jasdoif View Post
    First question: what you considering "configuration", that an INI file isn't up to the task?
    Maybe "configuration" isn't necessarily the right word, but it was what immediately came to mind. I guess it's less configuration and more specifications for attributes possessed by entities in my game. The reason why INI started to become clunky is that INI is good for simple sets of values that can be assigned to entities' attributes, but not good for more complex object definitions, which some of the entities in my game have. For example, some types of entities in my game have particle emitters attached to them, and I need to be able to specify not just the particle configuration defined elsewhere in the file, but also the position of the emitter relative to the entity, as well as the depth at which it should be rendered in the rendering layer the emitter is in. I could do this with an INI file (this is, in fact, what I have been doing), but having to get the value as a string, separate the string into parts, then parse the parts was becoming tiresome. It was also causing the INI file to get a bit ugly, and which value refers to which attribute could be rather unclear to anyone who isn't me.

    As for these:
    Quote Originally Posted by factotum View Post
    XML has a pretty heavy overhead to just use as a configuration file--I'd be more inclined to use something a bit more lightweight like JSON.
    Quote Originally Posted by IthilanorStPete View Post
    Yes. It's on the heavy side, but it allows for more complex structures and explanatory comments, unlike JSON. It also doesn't have to deal with YAML's whitespace sensitivity or ambiguity.
    I've pretty much decided that I will use JSON. XML is kind of clunky for different reasons, and JSON just looks nicer and easier to read than XML. If I need to specify what the values in the file mean (and it's not obvious from their names), I can document them in a separate file.
    Spoiler: Out-of-context quotes
    Show

    Quote Originally Posted by The Giant View Post
    Do not pass Go, do not collect $200.
    Quote Originally Posted by Kish View Post
    ...He would have to stay there permanently (without cake, somehow not breathing) for the prophecy to be fulfilled.
    Quote Originally Posted by ChristianSt View Post
    Maybe Blackwing is a Schrödinger's familiar.
    Any given member of the Order needs to do a quantum measurement to see if they remember him

    Azurite Name Inspirations
    Rich is a better writer than that!
    Free speech?

  7. - Top - End - #7
    Ettin in the Playground
     
    Kobold

    Join Date
    May 2009

    Default Re: Should I use XML as a format for my configuration files?

    Do you expect players to edit the file? If so, I would have a strong preference for a format designed to be handed in a plain text editor, rather than XML. I am thinking of the original Rome: Total War, which had dozens of ini files defining everything from the map, factions and characters to the properties of units and buildings, all easy to edit. I loved that, and was very annoyed when the franchise went to a much less accessible format.

    XML is good for defining and validating an entity of as much complexity as you like, but it adds a lot of overhead in building the schema.

    I am less familiar with JSON, but my perception is that it is deceptive in its simplicity, and may allow people to break the game in unpredictable ways without it being at all obvious what has happened.
    "None of us likes to be hated, none of us likes to be shunned. A natural result of these conditions is, that we consciously or unconsciously pay more attention to tuning our opinions to our neighbor’s pitch and preserving his approval than we do to examining the opinions searchingly and seeing to it that they are right and sound." - Mark Twain

  8. - Top - End - #8
    Troll in the Playground
     
    DwarfClericGuy

    Join Date
    Jun 2007

    Default Re: Should I use XML as a format for my configuration files?

    I think the first question that should be asked is: is this game going to have an online component? If so, you'll either want to encode the values and obfuscate the tag names in some way. Or use another format. Cause ... things like particle emitters that could be seen as obscuring view (like smoke grenades) would be rendered useless if you rely solely on the on-HD copy and don't do tamper checking.

    Or if you have some achievements for what under normal rules would be difficult to achieve, but a breeze if you, say, set damage to 99999 and enemy hp to 1.

    Edit: The recent BattleTech game is an example. Just about -everything- about the game was defined in JSON across directories. Weapons, mechs, mech components, planets, etc.

    Players could edit the files, no problem, to use a different ruleset. Or tweak the planets. Difficulty. Tech availability.

    Eventually, though, the devs decided that they'd have to do some validation checks after folks talked about how to do it. So they'd validate the JSONs against the originals and revert changes. I forget the exact reason why (It's been a while since I played that game thanks to some friends getting me into some survival horror...), but it's in my memory.
    Last edited by sihnfahl; 2020-07-24 at 10:45 AM.
    May you get EXACTLY what you wish for.

  9. - Top - End - #9
    Barbarian in the Playground
     
    OldWizardGuy

    Join Date
    Nov 2010
    Location
    California
    Gender
    Male

    Default Re: Should I use XML as a format for my configuration files?

    Depends on how the multiplayer is structured.

    If there's a central trusted server (like an MMORPG), the actual damage values can't be adjusted. Similarly, if all the players simulate the game in parallel (most RTSes), adjusting the damage values will just end the game with a desync. The only case where adjusting the damage values is a problem is when there is a single player acting as the sole source of truth. Then you have to trust the person you are playing with. (Even then, there are plenty of modded Minecraft multiplayers out there, who advertise certain mods.)

    Changing the graphics is more of a problem. Unless you are going full Stadia, everyone's machine has a copy of (at least part of) the game state that should be hidden from the player, and mods can reveal some of that. For instance, showing outlines behind walls, making heads big, having people blink red when they start charging a major power.

    But making the configuration files in one text format vs another is unlikely to make it more or less difficult to change the graphics settings. Even games without any text config files get cheat mods.

  10. - Top - End - #10
    Barbarian in the Playground
     
    PaladinGuy

    Join Date
    Sep 2016

    Default Re: Should I use XML as a format for my configuration files?

    Quote Originally Posted by Sermil View Post
    Depends on how the multiplayer is structured.
    But making the configuration files in one text format vs another is unlikely to make it more or less difficult to change the graphics settings. Even games without any text config files get cheat mods.
    And if the text file is ever the weak point there's always some form of.encryption and hashing to act as a bit of a halfway house between completely open and reasonably secure.
    Which you could make more or less complicated (and assuming the are converted back to text on file load, then decryption can just be bypassed to allow home/development files). I'm not sure how you'd set it up for best security and usability.

    I'm not sure about secret 'run time' data, encrypting the data stream is easy but at some point it has to be read by software that the user has access to. And even if you try to tie it into the program, I think anything you do, you could also fake. Even if you encrypt today's object positions with the last frame data (which itself requires you to be inflexible about timings and the like), that just means you need to draw that as well as the transparent walls version.
    Last edited by jayem; 2020-07-25 at 05:19 PM.

  11. - Top - End - #11
    Troll in the Playground
     
    DwarfClericGuy

    Join Date
    Jun 2007

    Default Re: Should I use XML as a format for my configuration files?

    Quote Originally Posted by Sermil View Post
    Changing the graphics is more of a problem. Unless you are going full Stadia, everyone's machine has a copy of (at least part of) the game state that should be hidden from the player, and mods can reveal some of that. For instance, showing outlines behind walls, making heads big, having people blink red when they start charging a major power.
    OP mentioned particle emitters as an example, including relative position to the attached object. To me, that would infer client-side variables for distance, intensity, translucency, etc.
    Hence me mentioning obfuscation and encoding the values in some way, if OP isn't going to use server validation and tamper checking.

    The BattleTech example I gave - well, they did have heat levels, damage done, range, etc, all part of the JSON. If memory serves. Hence mentioning the different rulesets that one could put up. Until they locked down and did tamper checking.
    May you get EXACTLY what you wish for.

  12. - Top - End - #12
    Barbarian in the Playground
     
    Domino Quartz's Avatar

    Join Date
    Feb 2012
    Location
    Auckland, NZ

    Default Re: Should I use XML as a format for my configuration files?

    There is no online component, or any other kind of multiplayer, in my game. If people end up playing my game, I don't mind too much if they change things to make the game easier, harder, or just different. Thanks for your advice anyway.
    Spoiler: Out-of-context quotes
    Show

    Quote Originally Posted by The Giant View Post
    Do not pass Go, do not collect $200.
    Quote Originally Posted by Kish View Post
    ...He would have to stay there permanently (without cake, somehow not breathing) for the prophecy to be fulfilled.
    Quote Originally Posted by ChristianSt View Post
    Maybe Blackwing is a Schrödinger's familiar.
    Any given member of the Order needs to do a quantum measurement to see if they remember him

    Azurite Name Inspirations
    Rich is a better writer than that!
    Free speech?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •