summaryrefslogtreecommitdiff
path: root/src/statuseffect.cpp
diff options
context:
space:
mode:
authorPrzemysław Grzywacz <nexather@gmail.com>2013-05-24 18:55:53 +0200
committerPrzemysław Grzywacz <nexather@gmail.com>2013-05-24 18:55:53 +0200
commit05dc1666dc794ed6aa7f6568b768c652f8922c4e (patch)
treeaf83e22418e912e8eb8b2bc6b9595da344f461c1 /src/statuseffect.cpp
parent703cd73c0baa82d5f8ae3a1b390401f17de32f7a (diff)
parentf9cd8a5d6b4460ffcb945979d1e8cd8ebadc9b8d (diff)
downloadmana-05dc1666dc794ed6aa7f6568b768c652f8922c4e.tar.gz
mana-05dc1666dc794ed6aa7f6568b768c652f8922c4e.tar.bz2
mana-05dc1666dc794ed6aa7f6568b768c652f8922c4e.tar.xz
mana-05dc1666dc794ed6aa7f6568b768c652f8922c4e.zip
Merge remote-tracking branch 'origin/master' into lpc2012 branch
Diffstat (limited to 'src/statuseffect.cpp')
-rw-r--r--src/statuseffect.cpp82
1 files changed, 37 insertions, 45 deletions
diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp
index 659aeaf3..bdaaf566 100644
--- a/src/statuseffect.cpp
+++ b/src/statuseffect.cpp
@@ -1,7 +1,7 @@
/*
* The Mana Client
* Copyright (C) 2008-2009 The Mana World Development Team
- * Copyright (C) 2009-2012 The Mana Developers
+ * Copyright (C) 2009-2013 The Mana Developers
*
* This file is part of The Mana Client.
*
@@ -25,8 +25,6 @@
#include "log.h"
#include "sound.h"
-#include "utils/xml.h"
-
#include "configuration.h"
#include <map>
@@ -114,58 +112,52 @@ StatusEffect *StatusEffect::getStunEffect(int index, bool enabling)
return stunEffects[enabling][index];
}
-void StatusEffect::load()
+void StatusEffect::init()
{
if (mLoaded)
unload();
+}
- XML::Document doc(STATUS_EFFECTS_FILE);
- xmlNodePtr rootNode = doc.rootNode();
-
- if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "status-effects"))
+void StatusEffect::readStatusEffectNode(xmlNodePtr node, const std::string &filename)
+{
+ status_effect_map *the_map = NULL;
+ int index = atoi(XML::getProperty(node, "id", "-1").c_str());
+ if (xmlStrEqual(node->name, BAD_CAST "status-effect"))
{
- logger->log("Error loading status effects file: " STATUS_EFFECTS_FILE);
- return;
+ the_map = &statusEffects;
+ int block_index = atoi(XML::getProperty(node, "block-id", "-1").c_str());
+
+ if (index >= 0 && block_index >= 0)
+ blockEffectIndexMap[block_index] = index;
}
+ else if (xmlStrEqual(node->name, BAD_CAST "stun-effect"))
+ the_map = &stunEffects;
- for_each_xml_child_node(node, rootNode)
+ if (the_map)
{
- status_effect_map *the_map = NULL;
-
- int index = atoi(XML::getProperty(node, "id", "-1").c_str());
-
- if (xmlStrEqual(node->name, BAD_CAST "status-effect"))
- {
- the_map = &statusEffects;
- int block_index = atoi(XML::getProperty(node, "block-id", "-1").c_str());
-
- if (index >= 0 && block_index >= 0)
- blockEffectIndexMap[block_index] = index;
+ StatusEffect *startEffect = new StatusEffect;
+ StatusEffect *endEffect = new StatusEffect;
+
+ startEffect->mMessage = XML::getProperty(node, "start-message", "");
+ startEffect->mSFXEffect = XML::getProperty(node, "start-audio", "");
+ startEffect->mParticleEffect = XML::getProperty(node, "start-particle", "");
+ startEffect->mIcon = XML::getProperty(node, "icon", "");
+ startEffect->mAction = XML::getProperty(node, "action", "");
+ startEffect->mPersistentParticleEffect = (XML::getProperty(node, "persistent-particle-effect", "no")) != "no";
+
+ endEffect->mMessage = XML::getProperty(node, "end-message", "");
+ endEffect->mSFXEffect = XML::getProperty(node, "end-audio", "");
+ endEffect->mParticleEffect = XML::getProperty(node, "end-particle", "");
+
+ (*the_map)[1][index] = startEffect;
+ (*the_map)[0][index] = endEffect;
+ }
- }
- else if (xmlStrEqual(node->name, BAD_CAST "stun-effect"))
- the_map = &stunEffects;
+}
- if (the_map)
- {
- StatusEffect *startEffect = new StatusEffect;
- StatusEffect *endEffect = new StatusEffect;
-
- startEffect->mMessage = XML::getProperty(node, "start-message", "");
- startEffect->mSFXEffect = XML::getProperty(node, "start-audio", "");
- startEffect->mParticleEffect = XML::getProperty(node, "start-particle", "");
- startEffect->mIcon = XML::getProperty(node, "icon", "");
- startEffect->mAction = XML::getProperty(node, "action", "");
- startEffect->mPersistentParticleEffect = (XML::getProperty(node, "persistent-particle-effect", "no")) != "no";
-
- endEffect->mMessage = XML::getProperty(node, "end-message", "");
- endEffect->mSFXEffect = XML::getProperty(node, "end-audio", "");
- endEffect->mParticleEffect = XML::getProperty(node, "end-particle", "");
-
- (*the_map)[1][index] = startEffect;
- (*the_map)[0][index] = endEffect;
- }
- }
+void StatusEffect::checkStatus()
+{
+ mLoaded = true;
}
void unloadMap(std::map<int, StatusEffect *> map)