added support for properly named attack-strength tag (and keep support for old name)
This commit is contained in:
parent
f45987d59a
commit
ada8810666
|
@ -762,7 +762,10 @@ void AttackSkillType::load(const XmlNode *sn, const XmlNode *attackBoostsNode,
|
|||
endPathWithSlash(currentPath);
|
||||
|
||||
//misc
|
||||
attackStrength= sn->getChild("attack-strenght")->getAttribute("value")->getIntValue();
|
||||
std::vector<string> attackStrengthXMLTags;
|
||||
attackStrengthXMLTags.push_back("attack-strenght");
|
||||
attackStrengthXMLTags.push_back("attack-strength");
|
||||
attackStrength= sn->getChildWithAliases(attackStrengthXMLTags)->getAttribute("value")->getIntValue();
|
||||
attackVar= sn->getChild("attack-var")->getAttribute("value")->getIntValue();
|
||||
|
||||
if(attackVar < 0) {
|
||||
|
|
|
@ -102,10 +102,14 @@ void UpgradeTypeBase::load(const XmlNode *upgradeNode, string upgradename) {
|
|||
}
|
||||
|
||||
attackStrengthIsMultiplier = false;
|
||||
if(upgradeNode->hasChild("attack-strenght") == true) {
|
||||
attackStrength= upgradeNode->getChild("attack-strenght")->getAttribute("value")->getIntValue();
|
||||
if(upgradeNode->getChild("attack-strenght")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME,false) != NULL) {
|
||||
attackStrengthIsMultiplier = upgradeNode->getChild("attack-strenght")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME)->getBoolValue();
|
||||
|
||||
std::vector<string> attackStrengthXMLTags;
|
||||
attackStrengthXMLTags.push_back("attack-strenght");
|
||||
attackStrengthXMLTags.push_back("attack-strength");
|
||||
if(upgradeNode->hasChildWithAliases(attackStrengthXMLTags) == true) {
|
||||
attackStrength= upgradeNode->getChildWithAliases(attackStrengthXMLTags)->getAttribute("value")->getIntValue();
|
||||
if(upgradeNode->getChildWithAliases(attackStrengthXMLTags)->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME,false) != NULL) {
|
||||
attackStrengthIsMultiplier = upgradeNode->getChildWithAliases(attackStrengthXMLTags)->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME)->getBoolValue();
|
||||
|
||||
//printf("Found attackStrengthIsMultiplier = %d\n",attackStrengthIsMultiplier);
|
||||
}
|
||||
|
|
|
@ -178,9 +178,11 @@ public:
|
|||
|
||||
XmlNode *getChild(unsigned int i) const;
|
||||
XmlNode *getChild(const string &childName, unsigned int childIndex=0) const;
|
||||
XmlNode *getChildWithAliases(vector<string> childNameList, unsigned int childIndex=0) const;
|
||||
vector<XmlNode *> getChildList(const string &childName) const;
|
||||
bool hasChildAtIndex(const string &childName, int childIndex=0) const;
|
||||
bool hasChild(const string &childName) const;
|
||||
bool hasChildWithAliases(vector<string> childNameList) const;
|
||||
int clearChild(const string &childName);
|
||||
|
||||
|
||||
|
|
|
@ -750,8 +750,9 @@ vector<XmlNode *> XmlNode::getChildList(const string &childName) const {
|
|||
}
|
||||
|
||||
XmlNode *XmlNode::getChild(const string &childName, unsigned int i) const {
|
||||
if(superNode && !hasChildNoSuper(childName))
|
||||
if(superNode && hasChildNoSuper(childName) == false) {
|
||||
return superNode->getChild(childName,i);
|
||||
}
|
||||
if(i >= children.size()) {
|
||||
throw megaglest_runtime_error("\"" + name + "\" node doesn't have "+intToStr(i+1)+" children named \"" + childName + "\"\n\nTree: "+getTreeString());
|
||||
}
|
||||
|
@ -769,6 +770,39 @@ XmlNode *XmlNode::getChild(const string &childName, unsigned int i) const{
|
|||
throw megaglest_runtime_error("Node \""+getName()+"\" doesn't have "+intToStr(i+1)+" children named \""+childName+"\"\n\nTree: "+getTreeString());
|
||||
}
|
||||
|
||||
bool XmlNode::hasChildNoSuper(const string &childName) const {
|
||||
//int count= 0;
|
||||
for(unsigned int j = 0; j < children.size(); ++j) {
|
||||
if(children[j]->getName() == childName) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
XmlNode * XmlNode::getChildWithAliases(vector<string> childNameList, unsigned int childIndex) const {
|
||||
for(int aliasIndex = 0; aliasIndex < childNameList.size(); ++aliasIndex) {
|
||||
const string &childName = childNameList[aliasIndex];
|
||||
if(superNode && hasChildNoSuper(childName) == false) {
|
||||
return superNode->getChild(childName,childIndex);
|
||||
}
|
||||
if(childIndex >= children.size()) {
|
||||
throw megaglest_runtime_error("\"" + name + "\" node doesn't have "+intToStr(childIndex+1)+" children named \"" + childName + "\"\n\nTree: "+getTreeString());
|
||||
}
|
||||
|
||||
int count= 0;
|
||||
for(unsigned int j = 0; j < children.size(); ++j) {
|
||||
if(children[j]->getName() == childName) {
|
||||
if(count == childIndex) {
|
||||
return children[j];
|
||||
}
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw megaglest_runtime_error("Node \""+getName()+"\" doesn't have "+intToStr(childIndex+1)+" children named \""+ (childNameList.empty() ? "???" : childNameList[0]) +"\"\n\nTree: "+getTreeString());
|
||||
}
|
||||
|
||||
bool XmlNode::hasChildAtIndex(const string &childName, int i) const {
|
||||
if(superNode && !hasChildNoSuper(childName))
|
||||
return superNode->hasChildAtIndex(childName,i);
|
||||
|
@ -790,14 +824,16 @@ bool XmlNode::hasChild(const string &childName) const {
|
|||
return hasChildNoSuper(childName) || (superNode && superNode->hasChild(childName));
|
||||
}
|
||||
|
||||
bool XmlNode::hasChildNoSuper(const string &childName) const {
|
||||
//int count= 0;
|
||||
for(unsigned int j = 0; j < children.size(); ++j) {
|
||||
if(children[j]->getName() == childName) {
|
||||
return true;
|
||||
bool XmlNode::hasChildWithAliases(vector<string> childNameList) const {
|
||||
bool result = false;
|
||||
for(int aliasIndex = 0; aliasIndex < childNameList.size(); ++aliasIndex) {
|
||||
const string &childName = childNameList[aliasIndex];
|
||||
result = hasChild(childName);
|
||||
if(result == true) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return result;
|
||||
}
|
||||
|
||||
XmlNode *XmlNode::addChild(const string &name, const string text) {
|
||||
|
|
Loading…
Reference in New Issue