Hmm, an XML format does have some advantages over the GBM/MGM format, particularly in extensibility.
I'd rather we use numbers than names, as the actual objects, resources, and surfaces are tileset and techtree dependent.
However, XMLs are huge because they add a lot of fluff. How we either:
- Use JSON -- it's also a human readable format with tools in pretty much every language, but it's much more compact (XML is super verbose) and the use of JSON arrays is ideal for handling a matrix of data, which is what the map format really is. I'm not really sure about C++ libraries, but in my experience in using the GSON Java library, it's far easier to read and write than XML.
- or standardize some compression wrapper. That is, set some type of compression format that can be used to compress the map. For example, we already support 7z in MG, so we could put the map in a 7z archive (with the map file having the same name as the archive). The map is tiny and only has to be unpacked once, so this should be a mostly negligible overhead. Should result in smaller sizes than the current binary format. This could be combined with using JSON (and would get better file size reduction, anyway).
Sample of how this could look in the JSON format:
{
"headerInfo": "someInfo",
"moreInfo": "foo",
"aBoolean": true,
"aNumber": 12,
[
[
{
"altitude": 10,
"surface": 1,
"resource": 1
},
{
"altitude": 0,
"surface": 4
}
],
[
{
"altitude": 10,
"surface": 1,
"resource": 1
},
{
"altitude": 0,
"surface": 4
}
]
]
}
As we can see, we have a top level object (the map), some data for that (header stuff like authors, etc), and then an array of rows, which are arrays of cells. Whitespace is optional and included only for readability.
I like the format, this will add more flexibility when the Lua scripting is integrated in the future,
You could make gold change places in maps or making labyrinth from set of arrays and much more.
This isn't true. Adding an XML (or whatever) version will not change the game. After all, the GBM/MGM format currently represents this same information (just in a format that is difficult to read -- but not
that difficult for computers -- and human readability doesn't mean much given that you'll use a map editor for any serious map creation). I'm not sure what limitations are currently preventing lua from changing the map in-game (although it's a long time feature request), but it's not the map format.
The only advantages I can think of is that textual formats like this handle unnecessary data well (which is good for adding new features -- avoids breaking older versions) and possibly making parsers easier (but well documented binary formats aren't that much harder to make). I'm not sure about XML, since it doesn't correlate well with objects, but the JSON format can sometimes be converted directly to objects, which makes it far, far easier to read files in. In fact, creating a reader for the above JSON format is so easy it's laughable (create an object template, let JSON do the hard work, and then iterate through your newly populated arrays).