summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-07-30 20:37:30 +0300
committerAndrei Karas <akaras@inbox.ru>2015-07-30 20:37:48 +0300
commit69704874b67c3cae63ee7d27634bbffa4cc4f6e2 (patch)
treef6a1d56199a3d0e5f2fcfb4e6670cb833c890ab3 /src
parent003ce4b2567b85b5a129c78fcf75cd73c455d557 (diff)
downloadplus-69704874b67c3cae63ee7d27634bbffa4cc4f6e2.tar.gz
plus-69704874b67c3cae63ee7d27634bbffa4cc4f6e2.tar.bz2
plus-69704874b67c3cae63ee7d27634bbffa4cc4f6e2.tar.xz
plus-69704874b67c3cae63ee7d27634bbffa4cc4f6e2.zip
Add support for include tag in badges.xml.
Also add patches and parts support for badges.xml
Diffstat (limited to 'src')
-rw-r--r--src/defaults.cpp2
-rw-r--r--src/resources/db/badgesdb.cpp24
-rw-r--r--src/utils/xmlutils.cpp1
3 files changed, 24 insertions, 3 deletions
diff --git a/src/defaults.cpp b/src/defaults.cpp
index 2d1a4f77b..bbb0f467e 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -596,6 +596,8 @@ DefaultsData* getPathsDefaults()
AddDEF("defaultCommandsFile", "defaultcommands.xml");
AddDEF("defaultcommandsPatchFile", "defaultcommands_patch.xml");
AddDEF("defaultcommandsPatchDir", "defaultcommands.d");
+ AddDEF("badgesFile", "badges.xml");
+ AddDEF("badgesPatchFile", "badges_patch.xml");
AddDEF("poisonEffectName", "poison");
AddDEF("cartEffectName", "cart");
AddDEF("ridingEffectName", "riding");
diff --git a/src/resources/db/badgesdb.cpp b/src/resources/db/badgesdb.cpp
index d7476c7f0..9efd57d82 100644
--- a/src/resources/db/badgesdb.cpp
+++ b/src/resources/db/badgesdb.cpp
@@ -20,6 +20,10 @@
#include "resources/db/badgesdb.h"
+#include "configuration.h"
+
+#include "resources/beingcommon.h"
+
#include "utils/xmlutils.h"
#include "debug.h"
@@ -32,9 +36,11 @@ namespace
bool mLoaded = false;
}
-static void loadDB(const std::string &name, BadgesInfos &arr)
+static void loadXmlFile(const std::string &file,
+ const std::string &name,
+ BadgesInfos &arr)
{
- readXmlStringMap("badges.xml",
+ readXmlStringMap(file,
"badges",
name,
"badge",
@@ -43,6 +49,20 @@ static void loadDB(const std::string &name, BadgesInfos &arr)
arr);
}
+static void loadDB(const std::string &name, BadgesInfos &arr)
+{
+ loadXmlFile(paths.getStringValue("badgesFile"),
+ name, arr);
+ loadXmlFile(paths.getStringValue("badgesPatchFile"),
+ name, arr);
+
+ StringVect listVect;
+ BeingCommon::getIncludeFiles(paths.getStringValue(
+ "badgesPatchDir"), listVect, ".xml");
+ FOR_EACH (StringVectCIter, itVect, listVect)
+ loadXmlFile(*itVect, name, arr);
+}
+
void BadgesDB::load()
{
if (mLoaded)
diff --git a/src/utils/xmlutils.cpp b/src/utils/xmlutils.cpp
index c437b0175..68ed3adb7 100644
--- a/src/utils/xmlutils.cpp
+++ b/src/utils/xmlutils.cpp
@@ -79,7 +79,6 @@ void readXmlStringMap(const std::string &fileName,
const std::string &attributeValueName,
std::map<std::string, std::string> &arr)
{
- arr.clear();
XML::Document doc(fileName, UseResman_true, SkipError_false);
const XmlNodePtrConst rootNode = doc.rootNode();