diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-01-06 15:01:55 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-01-06 15:01:55 +0300 |
commit | 9c83e992d7f7b0a53e102df6265066fc25141dfa (patch) | |
tree | ef4102273b9b9f626e16ef41ba07549809b67c82 /src | |
parent | b7ee14cadb1e5675f7e36565aec1fe39e55ccc34 (diff) | |
download | plus-9c83e992d7f7b0a53e102df6265066fc25141dfa.tar.gz plus-9c83e992d7f7b0a53e102df6265066fc25141dfa.tar.bz2 plus-9c83e992d7f7b0a53e102df6265066fc25141dfa.tar.xz plus-9c83e992d7f7b0a53e102df6265066fc25141dfa.zip |
Add support for include in avatars.xml.
Diffstat (limited to 'src')
-rw-r--r-- | src/resources/db/avatardb.cpp | 16 | ||||
-rw-r--r-- | src/resources/db/avatardb.h | 4 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/resources/db/avatardb.cpp b/src/resources/db/avatardb.cpp index 8ff58efc5..100803a2a 100644 --- a/src/resources/db/avatardb.cpp +++ b/src/resources/db/avatardb.cpp @@ -43,20 +43,32 @@ void AvatarDB::load() { if (mLoaded) unload(); + loadXmlFile(paths.getStringValue("avatarsFile")); +} - XML::Document doc(paths.getStringValue("avatarsFile")); +void AvatarDB::loadXmlFile(const std::string &fileName) +{ + XML::Document doc(fileName); const XmlNodePtr rootNode = doc.rootNode(); if (!rootNode || !xmlNameEqual(rootNode, "avatars")) { logger->log("Avatars Database: Error while loading %s!", - paths.getStringValue("avatarsFile").c_str()); + fileName.c_str()); mLoaded = true; return; } for_each_xml_child_node(avatarNode, rootNode) { + if (xmlNameEqual(avatarNode, "include")) + { + const std::string name = XML::getProperty(avatarNode, "name", ""); + if (!name.empty()) + loadXmlFile(name); + continue; + } + if (!xmlNameEqual(avatarNode, "avatar")) continue; diff --git a/src/resources/db/avatardb.h b/src/resources/db/avatardb.h index 0b4894c9c..f86ac4882 100644 --- a/src/resources/db/avatardb.h +++ b/src/resources/db/avatardb.h @@ -23,6 +23,8 @@ #ifndef RESOURCES_DB_AVATARDB_H #define RESOURCES_DB_AVATARDB_H +#include <string> + #include "localconsts.h" class BeingInfo; @@ -34,6 +36,8 @@ namespace AvatarDB void unload(); BeingInfo *get(const int id) A_WARN_UNUSED; + + void loadXmlFile(const std::string &fileName); } #endif // RESOURCES_DB_AVATARDB_H |