diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/resources/db/petdb.cpp | 23 | ||||
-rw-r--r-- | src/resources/db/petdb.h | 4 |
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; |