diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-09-25 01:40:43 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-09-30 02:57:13 +0300 |
commit | 3a2bab265768c219b0c077eef10b69dfe8158131 (patch) | |
tree | d5274ccdbf40c1a57e8f1541a74e106fde4fbcbb /src/resources/mapdb.cpp | |
parent | abc334f8e88253e5393e27594c07cc56525b4e9a (diff) | |
download | manaplus-3a2bab265768c219b0c077eef10b69dfe8158131.tar.gz manaplus-3a2bab265768c219b0c077eef10b69dfe8158131.tar.bz2 manaplus-3a2bab265768c219b0c077eef10b69dfe8158131.tar.xz manaplus-3a2bab265768c219b0c077eef10b69dfe8158131.zip |
Load additional info about maps from maps.xml.
For now here only atlases information.
Diffstat (limited to 'src/resources/mapdb.cpp')
-rw-r--r-- | src/resources/mapdb.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/resources/mapdb.cpp b/src/resources/mapdb.cpp index 3c4347301..55c3d7306 100644 --- a/src/resources/mapdb.cpp +++ b/src/resources/mapdb.cpp @@ -31,6 +31,14 @@ namespace { bool mLoaded = false; MapDB::Maps mMaps; + MapDB::MapInfos mInfos; + MapDB::Atlases mAtlases; +} + +namespace MapDB +{ + void readMap(XmlNodePtr node); + void readAtlas(XmlNodePtr node); } void MapDB::load() @@ -38,6 +46,12 @@ void MapDB::load() if (mLoaded) unload(); + loadRemap(); + loadInfo(); +} + +void MapDB::loadRemap() +{ XML::Document *doc = new XML::Document( paths.getStringValue("maps") + "remap.xml"); @@ -69,6 +83,55 @@ void MapDB::load() mLoaded = true; } +void MapDB::readMap(XmlNodePtr node) +{ + const std::string map = XML::getProperty(node, "name", ""); + if (map.empty()) + return; + + for_each_xml_child_node(childNode, node) + { + if (xmlNameEqual(childNode, "atlas")) + { + const std::string atlas = XML::getProperty(childNode, "name", ""); + if (atlas.empty()) + continue; + mInfos[map].atlas = atlas; + } + } +} + +void MapDB::readAtlas(XmlNodePtr node) +{ + const std::string atlas = XML::getProperty(node, "name", ""); + if (atlas.empty()) + return; + for_each_xml_child_node(childNode, node) + { + if (xmlNameEqual(childNode, "file")) + { + const std::string file = XML::getProperty(childNode, "name", ""); + if (file.empty()) + continue; + mAtlases[atlas].push_back(file); + } + } +} + +void MapDB::loadInfo() +{ + XML::Document *doc = new XML::Document("maps.xml"); + + const XmlNodePtr root = doc->rootNode(); + + for_each_xml_child_node(node, root) + { + if (xmlNameEqual(node, "map")) + readMap(node); + else if (xmlNameEqual(node, "atlas")) + readAtlas(node); + } +} void MapDB::unload() { |