From 542d2ba78d84e0fa051e0620ccab5fb3a0c711e3 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 21 Mar 2016 17:59:29 +0300 Subject: Load from status-effects.xml new fields. option, opt1, opt2, opt3. --- src/resources/db/statuseffectdb.cpp | 46 ++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/src/resources/db/statuseffectdb.cpp b/src/resources/db/statuseffectdb.cpp index d6e5039f2..4390f79fe 100644 --- a/src/resources/db/statuseffectdb.cpp +++ b/src/resources/db/statuseffectdb.cpp @@ -45,6 +45,11 @@ namespace typedef std::map IdToEffectMap[2]; bool mLoaded = false; IdToEffectMap statusEffects; + std::map optionToIdMap; + std::map opt1ToIdMap; + std::map opt2ToIdMap; + std::map opt3ToIdMap; + std::map blockIdToIdMap; } // namespace @@ -109,15 +114,28 @@ void StatusEffectDB::loadXmlFile(const std::string &fileName) continue; } - const int index = XML::getProperty(node, "id", -1); - const int block_index = atoi(XML::getProperty( - node, "block-id", "-1").c_str()); - - if (index >= 0 && block_index >= 0) - blockIdToIdMap[block_index] = index; - - StatusEffect *startEffect = statusEffects[1][index]; - StatusEffect *endEffect = statusEffects[0][index]; + const int id = XML::getProperty(node, "id", -1); + + // legacy field. Only for clients 1.6.3.12 and older + const int blockId = XML::getProperty(node, "block-id", -1); + if (id >= 0 && blockId >= 0) + blockIdToIdMap[blockId] = id; + + const int option = XML::getProperty(node, "option", 0); + const int opt1 = XML::getProperty(node, "opt1", 0); + const int opt2 = XML::getProperty(node, "opt2", 0); + const int opt3 = XML::getProperty(node, "opt3", 0); + if (option != 0) + optionToIdMap[option] = id; + if (opt1 != 0) + opt1ToIdMap[opt1] = id; + if (opt2 != 0) + opt2ToIdMap[opt2] = id; + if (opt3 != 0) + opt3ToIdMap[opt3] = id; + + StatusEffect *startEffect = statusEffects[1][id]; + StatusEffect *endEffect = statusEffects[0][id]; const std::string name = XML::getProperty(node, "name", ""); if (!startEffect) startEffect = new StatusEffect; @@ -158,8 +176,8 @@ void StatusEffectDB::loadXmlFile(const std::string &fileName) endEffect->mParticleEffect = XML::getProperty( node, "end-particle", ""); - statusEffects[1][index] = startEffect; - statusEffects[0][index] = endEffect; + statusEffects[1][id] = startEffect; + statusEffects[0][id] = endEffect; } } @@ -182,5 +200,11 @@ void StatusEffectDB::unload() unloadMap(statusEffects[0]); unloadMap(statusEffects[1]); + optionToIdMap.clear(); + opt1ToIdMap.clear(); + opt2ToIdMap.clear(); + opt3ToIdMap.clear(); + blockIdToIdMap.clear(); + mLoaded = false; } -- cgit v1.2.3-60-g2f50