summaryrefslogtreecommitdiff
path: root/src/statuseffect.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-01-18 20:02:27 +0300
committerAndrei Karas <akaras@inbox.ru>2014-01-18 20:02:27 +0300
commitfb5d0e7762f692948dddebd3deb38a0bd20de5f2 (patch)
treeafe2c0d8cf75738fd847af37dc166e0c338f7493 /src/statuseffect.cpp
parent8a5603e487f682f5f67bc2cedae81249aa138f5b (diff)
parente9e343366fbfbe9a6343089ff113354524f3f306 (diff)
downloadplus-fb5d0e7762f692948dddebd3deb38a0bd20de5f2.tar.gz
plus-fb5d0e7762f692948dddebd3deb38a0bd20de5f2.tar.bz2
plus-fb5d0e7762f692948dddebd3deb38a0bd20de5f2.tar.xz
plus-fb5d0e7762f692948dddebd3deb38a0bd20de5f2.zip
Merge branch 'master' into stable
Diffstat (limited to 'src/statuseffect.cpp')
-rw-r--r--src/statuseffect.cpp35
1 files changed, 28 insertions, 7 deletions
diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp
index 018fe39ec..049c010b3 100644
--- a/src/statuseffect.cpp
+++ b/src/statuseffect.cpp
@@ -22,12 +22,13 @@
#include "statuseffect.h"
+#include "configuration.h"
#include "logger.h"
#include "soundmanager.h"
#include "gui/widgets/tabs/chattab.h"
-#include "configuration.h"
+#include "resources/beingcommon.h"
#include <map>
@@ -127,17 +128,34 @@ void StatusEffect::load()
if (mLoaded)
unload();
- XML::Document doc(paths.getStringValue("statusEffectsFile"));
- const XmlNodePtr rootNode = doc.rootNode();
+ loadXmlFile(paths.getStringValue("statusEffectsFile"));
+ loadXmlFile(paths.getStringValue("statusEffectsPatchFile"));
+ loadXmlDir("statusEffectsPatchDir", loadXmlFile);
+
+ mLoaded = true;
+}
+
+void StatusEffect::loadXmlFile(const std::string &fileName)
+{
+ XML::Document doc(fileName);
+ const XmlNodePtrConst rootNode = doc.rootNode();
if (!rootNode || !xmlNameEqual(rootNode, "status-effects"))
{
- logger->log1("Error loading status effects file");
+ logger->log("Error loading status effects file: " + fileName);
return;
}
for_each_xml_child_node(node, rootNode)
{
+ if (xmlNameEqual(node, "include"))
+ {
+ const std::string name = XML::getProperty(node, "name", "");
+ if (!name.empty())
+ loadXmlFile(name);
+ continue;
+ }
+
status_effect_map *the_map = nullptr;
const int index = atoi(XML::getProperty(node, "id", "-1").c_str());
@@ -158,8 +176,12 @@ void StatusEffect::load()
if (the_map)
{
- StatusEffect *const startEffect = new StatusEffect;
- StatusEffect *const endEffect = new StatusEffect;
+ StatusEffect *startEffect = (*the_map)[1][index];
+ StatusEffect *endEffect = (*the_map)[0][index];
+ if (!startEffect)
+ startEffect = new StatusEffect;
+ if (!endEffect)
+ endEffect = new StatusEffect;
startEffect->mMessage = XML::getProperty(
node, "start-message", "");
@@ -182,7 +204,6 @@ void StatusEffect::load()
(*the_map)[0][index] = endEffect;
}
}
- mLoaded = true;
}
static void unloadMap(std::map<int, StatusEffect *> &map)