summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/resources/mapdb.cpp63
-rw-r--r--src/resources/mapdb.h16
2 files changed, 78 insertions, 1 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()
{
diff --git a/src/resources/mapdb.h b/src/resources/mapdb.h
index 0d13428ee..b8fd954fa 100644
--- a/src/resources/mapdb.h
+++ b/src/resources/mapdb.h
@@ -22,19 +22,29 @@
#ifndef MAPDB_H
#define MAPDB_H
+#include "utils/stringvector.h"
+
#include <map>
-#include <string>
/**
* Color information database.
*/
namespace MapDB
{
+ struct MapInfo
+ {
+ std::string atlas;
+ };
+
/**
* Loads the map remap data from <code>maps\remap.xml</code>.
*/
void load();
+ void loadRemap();
+
+ void loadInfo();
+
/**
* Clear the remap data
*/
@@ -45,6 +55,10 @@ namespace MapDB
// Maps DB
typedef std::map<std::string, std::string> Maps;
typedef Maps::iterator MapIterator;
+ // map to infos map
+ typedef std::map<std::string, MapInfo> MapInfos;
+ // atlas to files map
+ typedef std::map<std::string, StringVect> Atlases;
}
#endif