I am moving the game data to XML format.
Well what is XML http://en.wikipedia.org/wiki/XML everyone knows.
Using it should have 3 advantages :
- Self-Description of the used data ( no misterious byte sequences " it might be health, it might be color of eyes ;"
External checking of map file validity -- if say xmllinit validates files against proper XSD http://en.wikipedia.org/wiki/Xsd template, than the OD program won't crash
Composability and data reuse -- using the xs::include directive we can insert one file definitions into another ( similar to c++ include but smarter )
What needs to be done ?
- Transition from level/Tile.level to the bunch of XML's files and their XSD templates ( OD_path/XML [ ALREADY DONE] )
Writing the proper XML parser , which would read the data.
I want to use libxml++ , which handles two common methods of XML parsing : http://libxmlplusplus.sourceforge.net/docs/manual/html/ar01s02.html#id2504579 : DOM and SAX plus one minor TextReader . I can use either SAX or TextReader -- those are two methods which use bottom-up parsing approach .
SAX looks more nice , plus it is possible to parse in chunks, that is send data to parser and ask to parse it a little instead of sending the whole file at once .
For now from the point of view of XML , game data is one big entity GameMap, which is splitted across number of files , due to magic of xi:include directive :
- {l Code}: {l Select All Code}
<?xml version="1.0" encoding="UTF-8"?>
<GameMap xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="file:/home/tom/Opendungeons/opendungeons/XML/xsd/MapDefinitionSchema.xsd"
xmlns:xi="http://www.w3.org/2001/XInclude">
<MapSizeX>
400
</MapSizeX>
<MapSizeY>
400
</MapSizeY>
<xi:include href="../Seats/SeatList.xml"/>
<xi:include href="../Goals/GoalList.xml"/>
<xi:include href="../TileContainers/TileContainerList.xml"/>
<xi:include href="../Rooms/RoomList.xml"/>
<xi:include href="../Traps/TrapList.xml"/>
<xi:include href="../Lights/LightList.xml"/>
<xi:include href="../CreatureDefinitions/CreatureDefinitionList.xml"/>
<xi:include href="../Actors/ActorList.xml"/>
</GameMap>
Problem is we need to write our own procedure for unfolding the xi:include directives. For now the fullty unfolded GameMap file would size about 1MB .
Also the bottleneck is the file seek on disc.
Instead of waiting endlessly for both file read and than parsing we can send each small chunk we already have to the parsing .
The most common pattern for that is Pipes, I have had to implent Pipe templates which would be similar to Unix pipes , but use c++11 std lib facilities ; I have already come up with template hierarchy , there is even small demo ... http://pastebin.com/stVLyeUd it works pretty nice , though you would like some syntatic sugar when setting pipes instead of
- {l Code}: {l Select All Code}
NumberSource<long> localSource;
PipeDouble<long> localPipe;
localSource.setSink(&localPipe);
OutputSink<long> localSink;
localPipe.setSink(&localSink);
That's what would help us processing XML xs:include
More later....
Bertram and others : Ask more what do you want to know about that .