diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-08-07 22:07:10 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-08-07 22:07:10 +0300 |
commit | 7229e881f1a0f7910eb84637d123b33fa9d7ce07 (patch) | |
tree | 7dddd2750a3d38695c5c879f3554da6c2c7f5c34 /src | |
parent | 344a88446cc1e15780de41c1187f40d18de7b60e (diff) | |
download | manaverse-7229e881f1a0f7910eb84637d123b33fa9d7ce07.tar.gz manaverse-7229e881f1a0f7910eb84637d123b33fa9d7ce07.tar.bz2 manaverse-7229e881f1a0f7910eb84637d123b33fa9d7ce07.tar.xz manaverse-7229e881f1a0f7910eb84637d123b33fa9d7ce07.zip |
Improve inherit fields code in itemdb.cpp
Diffstat (limited to 'src')
-rw-r--r-- | src/resources/db/itemdb.cpp | 95 |
1 files changed, 48 insertions, 47 deletions
diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp index 68cb5b3bb..b25e2d7e8 100644 --- a/src/resources/db/itemdb.cpp +++ b/src/resources/db/itemdb.cpp @@ -472,30 +472,43 @@ void ItemDB::loadXmlFile(const std::string &fileName, } } - if (view == 0 && inheritItemInfo != nullptr) - view = inheritItemInfo->getView(); - itemInfo->setView(view); - if (weight == 0 && inheritItemInfo != nullptr) - weight = inheritItemInfo->getWeight(); - itemInfo->setWeight(weight); - if (attackAction.empty() && inheritItemInfo != nullptr) - attackAction = inheritItemInfo->getAttackAction(); - itemInfo->setAttackAction(attackAction); - if (skyAttackAction.empty() && inheritItemInfo != nullptr) - skyAttackAction = inheritItemInfo->getSkyAttackAction(); - itemInfo->setSkyAttackAction(skyAttackAction); - if (waterAttackAction.empty() && inheritItemInfo != nullptr) - waterAttackAction = inheritItemInfo->getWaterAttackAction(); - itemInfo->setWaterAttackAction(waterAttackAction); - if (rideAttackAction.empty() && inheritItemInfo != nullptr) - rideAttackAction = inheritItemInfo->getRideAttackAction(); - itemInfo->setRideAttackAction(rideAttackAction); - if (attackRange == 0 && inheritItemInfo != nullptr) - attackRange = inheritItemInfo->getAttackRange(); - itemInfo->setAttackRange(attackRange); + std::string effect; + readFields(effect, node, requiredFields); + readFields(effect, node, addFields); + std::string temp = XML::langProperty(node, "effect", ""); + if (!effect.empty() && !temp.empty()) + effect.append(" / "); + effect.append(temp); if (inheritItemInfo) { + if (view == 0) + view = inheritItemInfo->getView(); + if (weight == 0) + weight = inheritItemInfo->getWeight(); + if (attackAction.empty()) + attackAction = inheritItemInfo->getAttackAction(); + if (skyAttackAction.empty()) + skyAttackAction = inheritItemInfo->getSkyAttackAction(); + if (waterAttackAction.empty()) + waterAttackAction = inheritItemInfo->getWaterAttackAction(); + if (rideAttackAction.empty()) + rideAttackAction = inheritItemInfo->getRideAttackAction(); + if (attackRange == 0) + attackRange = inheritItemInfo->getAttackRange(); + if (hitEffectId == 0) + hitEffectId = inheritItemInfo->getHitEffectId(); + if (criticalEffectId == 0) + criticalEffectId = inheritItemInfo->getCriticalHitEffectId(); + if (missEffectId == 0) + missEffectId = inheritItemInfo->getMissEffectId(); + if (colors.empty()) + colors = inheritItemInfo->getColorsListName(); + if (iconColors.empty()) + iconColors = inheritItemInfo->getIconColorsListName(); + if (effect.empty()) + effect = inheritItemInfo->getEffect(); + const MissileInfo &inheritMissile = inheritItemInfo->getMissileConst(); if (missileParticle.empty()) @@ -509,47 +522,35 @@ void ItemDB::loadXmlFile(const std::string &fileName, if (missileDieDistance == 8.0F) missileDieDistance = inheritMissile.dieDistance; } - MissileInfo &missile = itemInfo->getMissile(); - missile.particle = missileParticle; - missile.z = missileZ; - missile.lifeTime = missileLifeTime; - missile.speed = missileSpeed; - missile.dieDistance = missileDieDistance; - if (hitEffectId == 0 && inheritItemInfo != nullptr) - hitEffectId = inheritItemInfo->getHitEffectId(); + itemInfo->setView(view); + itemInfo->setWeight(weight); + itemInfo->setAttackAction(attackAction); + itemInfo->setSkyAttackAction(skyAttackAction); + itemInfo->setWaterAttackAction(waterAttackAction); + itemInfo->setRideAttackAction(rideAttackAction); + itemInfo->setAttackRange(attackRange); itemInfo->setHitEffectId(hitEffectId); - if (criticalEffectId == 0 && inheritItemInfo != nullptr) - criticalEffectId = inheritItemInfo->getCriticalHitEffectId(); itemInfo->setCriticalHitEffectId(criticalEffectId); - if (missEffectId == 0 && inheritItemInfo != nullptr) - missEffectId = inheritItemInfo->getMissEffectId(); itemInfo->setMissEffectId(missEffectId); itemInfo->setDrawBefore(-1, parseSpriteName(drawBefore)); itemInfo->setDrawAfter(-1, parseSpriteName(drawAfter)); itemInfo->setDrawPriority(-1, drawPriority); - if (colors.empty() && inheritItemInfo != nullptr) - colors = inheritItemInfo->getColorsListName(); itemInfo->setColorsList(colors); - if (iconColors.empty() && inheritItemInfo != nullptr) - iconColors = inheritItemInfo->getIconColorsListName(); itemInfo->setIconColorsList(iconColors); itemInfo->setMaxFloorOffsetX(maxFloorOffsetX); itemInfo->setMaxFloorOffsetY(maxFloorOffsetY); itemInfo->setPickupCursor(XML::getProperty( node, "pickupCursor", "pickup")); - - std::string effect; - readFields(effect, node, requiredFields); - readFields(effect, node, addFields); - std::string temp = XML::langProperty(node, "effect", ""); - if (!effect.empty() && !temp.empty()) - effect.append(" / "); - effect.append(temp); - if (effect.empty() && inheritItemInfo != nullptr) - effect = inheritItemInfo->getEffect(); itemInfo->setEffect(effect); + MissileInfo &missile = itemInfo->getMissile(); + missile.particle = missileParticle; + missile.z = missileZ; + missile.lifeTime = missileLifeTime; + missile.speed = missileSpeed; + missile.dieDistance = missileDieDistance; + for_each_xml_child_node(itemChild, node) { if (xmlNameEqual(itemChild, "sprite")) |