summaryrefslogtreecommitdiff
path: root/src/resources/db
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-01-06 18:08:30 +0300
committerAndrei Karas <akaras@inbox.ru>2014-01-06 18:08:30 +0300
commitd8f56c2b9a68de7bba8f5848b126bd25741eb494 (patch)
treef3da0c5853f75b3c9601b4b3a7f23dbc95d5dddd /src/resources/db
parent2ba34797598a310bd31d46a43246cf6f88d6db74 (diff)
downloadmv-d8f56c2b9a68de7bba8f5848b126bd25741eb494.tar.gz
mv-d8f56c2b9a68de7bba8f5848b126bd25741eb494.tar.bz2
mv-d8f56c2b9a68de7bba8f5848b126bd25741eb494.tar.xz
mv-d8f56c2b9a68de7bba8f5848b126bd25741eb494.zip
add support for include in pets.xml.
Diffstat (limited to 'src/resources/db')
-rw-r--r--src/resources/db/petdb.cpp23
-rw-r--r--src/resources/db/petdb.h4
2 files changed, 21 insertions, 6 deletions
diff --git a/src/resources/db/petdb.cpp b/src/resources/db/petdb.cpp
index c235200a6..7dcfd63e3 100644
--- a/src/resources/db/petdb.cpp
+++ b/src/resources/db/petdb.cpp
@@ -47,23 +47,36 @@ void PETDB::load()
unload();
logger->log1("Initializing PET database...");
+ loadXmlFile(paths.getStringValue("petsFile"));
+ mLoaded = true;
+}
- XML::Document doc(paths.getStringValue("petsFile"));
+void PETDB::loadXmlFile(const std::string &fileName)
+{
+ XML::Document doc(fileName);
const XmlNodePtr rootNode = doc.rootNode();
if (!rootNode || !xmlNameEqual(rootNode, "pets"))
{
logger->log("PET Database: Error while loading %s!",
- paths.getStringValue("petsFile").c_str());
- mLoaded = true;
+ fileName.c_str());
return;
}
// iterate <pet>s
for_each_xml_child_node(petNode, rootNode)
{
- if (!xmlNameEqual(petNode, "pet"))
+ if (xmlNameEqual(petNode, "include"))
+ {
+ const std::string name = XML::getProperty(petNode, "name", "");
+ if (!name.empty())
+ loadXmlFile(name);
+ continue;
+ }
+ else if (!xmlNameEqual(petNode, "pet"))
+ {
continue;
+ }
const int id = XML::getProperty(petNode, "id", 0);
if (id == 0)
@@ -151,8 +164,6 @@ void PETDB::load()
mPETInfos[id] = currentInfo;
}
-
- mLoaded = true;
}
void PETDB::unload()
diff --git a/src/resources/db/petdb.h b/src/resources/db/petdb.h
index e3ed9a7da..75175f5c5 100644
--- a/src/resources/db/petdb.h
+++ b/src/resources/db/petdb.h
@@ -23,6 +23,8 @@
#ifndef RESOURCES_DB_PETDB_H
#define RESOURCES_DB_PETDB_H
+#include <string>
+
#include "localconsts.h"
class BeingInfo;
@@ -31,6 +33,8 @@ namespace PETDB
{
void load();
+ void loadXmlFile(const std::string &fileName);
+
void unload();
BeingInfo *get(const int id) A_WARN_UNUSED;