summaryrefslogtreecommitdiff
path: root/src/statuseffect.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-03-21 16:52:59 +0300
committerAndrei Karas <akaras@inbox.ru>2016-03-21 16:52:59 +0300
commitac4e40a1408ad4d6fbcfce9d2bc6a0bc187ea5a4 (patch)
tree13314fbbb4945414b8be5d1d0236e1c41f88e8c8 /src/statuseffect.cpp
parent68857593b01b73d33fa1a12011cf9cb402db8a73 (diff)
downloadmv-ac4e40a1408ad4d6fbcfce9d2bc6a0bc187ea5a4.tar.gz
mv-ac4e40a1408ad4d6fbcfce9d2bc6a0bc187ea5a4.tar.bz2
mv-ac4e40a1408ad4d6fbcfce9d2bc6a0bc187ea5a4.tar.xz
mv-ac4e40a1408ad4d6fbcfce9d2bc6a0bc187ea5a4.zip
Split StatusEffect into StatusEffect and StatusEffectDB.
Diffstat (limited to 'src/statuseffect.cpp')
-rw-r--r--src/statuseffect.cpp156
1 files changed, 0 insertions, 156 deletions
diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp
index 591b70815..26e6d97b7 100644
--- a/src/statuseffect.cpp
+++ b/src/statuseffect.cpp
@@ -39,10 +39,6 @@
#include "debug.h"
-static void unloadMap(std::map<int, StatusEffect *> &map);
-
-bool StatusEffect::mLoaded = false;
-
StatusEffect::StatusEffect() :
mMessage(),
mSFXEffect(),
@@ -103,155 +99,3 @@ std::string StatusEffect::getAction() const
else
return mAction;
}
-
-
-// -- initialisation and static parts --
-
-
-typedef std::map<int, StatusEffect *> status_effect_map[2];
-
-static status_effect_map statusEffects;
-static std::map<int, int> blockEffectIndexMap;
-
-int StatusEffect::blockEffectIndexToEffectIndex(const int blockIndex)
-{
- if (blockEffectIndexMap.find(blockIndex) == blockEffectIndexMap.end())
- return -1;
- return blockEffectIndexMap[blockIndex];
-}
-
-StatusEffect *StatusEffect::getStatusEffect(const int index,
- const Enable enabling)
-{
- std::map<int, StatusEffect *> &effects
- = statusEffects[enabling == Enable_true];
- const std::map<int, StatusEffect *>::iterator it = effects.find(index);
- if (it != effects.end())
- return (*it).second;
- if (config.getBoolValue("unimplimentedLog"))
- {
- const std::string str = strprintf("Missing status effect: %d", index);
- logger->log(str);
- DebugMessageListener::distributeEvent(str);
- }
- return nullptr;
-}
-
-void StatusEffect::load()
-{
- if (mLoaded)
- unload();
-
- loadXmlFile(paths.getStringValue("statusEffectsFile"));
- loadXmlFile(paths.getStringValue("statusEffectsPatchFile"));
- loadXmlDir("statusEffectsPatchDir", loadXmlFile);
-
- mLoaded = true;
-}
-
-void StatusEffect::loadXmlFile(const std::string &fileName)
-{
- XML::Document doc(fileName, UseResman_true, SkipError_false);
- const XmlNodePtrConst rootNode = doc.rootNode();
-
- if (!rootNode || !xmlNameEqual(rootNode, "status-effects"))
- {
- logger->log("Error loading status effects file: " + fileName);
- return;
- }
-
- for_each_xml_child_node(node, rootNode)
- {
- if (xmlNameEqual(node, "include"))
- {
- const std::string incName = XML::getProperty(node, "name", "");
- if (!incName.empty())
- loadXmlFile(incName);
- continue;
- }
-
- status_effect_map *the_map = nullptr;
-
- const int index = atoi(XML::getProperty(node, "id", "-1").c_str());
-
- if (xmlNameEqual(node, "status-effect"))
- {
- the_map = &statusEffects;
- const int block_index = atoi(XML::getProperty(
- node, "block-id", "-1").c_str());
-
- if (index >= 0 && block_index >= 0)
- blockEffectIndexMap[block_index] = index;
- }
-
- if (the_map)
- {
- StatusEffect *startEffect = (*the_map)[1][index];
- StatusEffect *endEffect = (*the_map)[0][index];
- const std::string name = XML::getProperty(node, "name", "");
- if (!startEffect)
- startEffect = new StatusEffect;
- if (!endEffect)
- endEffect = new StatusEffect;
-
- startEffect->mName = name;
- startEffect->mIsPoison =
- (name == paths.getStringValue("poisonEffectName"));
- startEffect->mIsCart =
- (name == paths.getStringValue("cartEffectName"));
- startEffect->mIsRiding =
- (name == paths.getStringValue("ridingEffectName"));
- startEffect->mIsTrickDead =
- (name == paths.getStringValue("trickDeadEffectName"));
- startEffect->mIsPostDelay =
- (name == paths.getStringValue("postDelayName"));
- 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->mName = startEffect->mName;
- endEffect->mIsPoison = startEffect->mIsPoison;
- endEffect->mIsCart = startEffect->mIsCart;
- endEffect->mIsRiding = startEffect->mIsRiding;
- endEffect->mIsTrickDead = startEffect->mIsTrickDead;
- endEffect->mIsPostDelay = startEffect->mIsPostDelay;
- 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;
- }
- }
-}
-
-static void unloadMap(std::map<int, StatusEffect *> &map)
-{
- for (std::map<int, StatusEffect *>::iterator it = map.begin();
- it != map.end(); ++it)
- {
- delete (*it).second;
- }
-
- map.clear();
-}
-
-void StatusEffect::unload()
-{
- if (!mLoaded)
- return;
-
- unloadMap(statusEffects[0]);
- unloadMap(statusEffects[1]);
-
- mLoaded = false;
-}