diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-03-21 17:59:29 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-03-21 17:59:29 +0300 |
commit | 542d2ba78d84e0fa051e0620ccab5fb3a0c711e3 (patch) | |
tree | 22dad7ad37b5032c8e19fcdab85f9199ad81afba /src | |
parent | e9b69db0da8303d541f52e7579ce3e90f973ef37 (diff) | |
download | manaplus-542d2ba78d84e0fa051e0620ccab5fb3a0c711e3.tar.gz manaplus-542d2ba78d84e0fa051e0620ccab5fb3a0c711e3.tar.bz2 manaplus-542d2ba78d84e0fa051e0620ccab5fb3a0c711e3.tar.xz manaplus-542d2ba78d84e0fa051e0620ccab5fb3a0c711e3.zip |
Load from status-effects.xml new fields. option, opt1, opt2, opt3.
Diffstat (limited to 'src')
-rw-r--r-- | src/resources/db/statuseffectdb.cpp | 46 |
1 files 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<int, StatusEffect *> IdToEffectMap[2]; bool mLoaded = false; IdToEffectMap statusEffects; + std::map<int, int> optionToIdMap; + std::map<int, int> opt1ToIdMap; + std::map<int, int> opt2ToIdMap; + std::map<int, int> opt3ToIdMap; + std::map<int, int> 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; } |