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);
|
endPathWithSlash(currentPath);
|
||||||
|
|
||||||
//misc
|
//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();
|
attackVar= sn->getChild("attack-var")->getAttribute("value")->getIntValue();
|
||||||
|
|
||||||
if(attackVar < 0) {
|
if(attackVar < 0) {
|
||||||
|
|
|
@ -102,10 +102,14 @@ void UpgradeTypeBase::load(const XmlNode *upgradeNode, string upgradename) {
|
||||||
}
|
}
|
||||||
|
|
||||||
attackStrengthIsMultiplier = false;
|
attackStrengthIsMultiplier = false;
|
||||||
if(upgradeNode->hasChild("attack-strenght") == true) {
|
|
||||||
attackStrength= upgradeNode->getChild("attack-strenght")->getAttribute("value")->getIntValue();
|
std::vector<string> attackStrengthXMLTags;
|
||||||
if(upgradeNode->getChild("attack-strenght")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME,false) != NULL) {
|
attackStrengthXMLTags.push_back("attack-strenght");
|
||||||
attackStrengthIsMultiplier = upgradeNode->getChild("attack-strenght")->getAttribute(VALUE_PERCENT_MULTIPLIER_KEY_NAME)->getBoolValue();
|
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);
|
//printf("Found attackStrengthIsMultiplier = %d\n",attackStrengthIsMultiplier);
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,9 +178,11 @@ public:
|
||||||
|
|
||||||
XmlNode *getChild(unsigned int i) const;
|
XmlNode *getChild(unsigned int i) const;
|
||||||
XmlNode *getChild(const string &childName, unsigned int childIndex=0) 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;
|
vector<XmlNode *> getChildList(const string &childName) const;
|
||||||
bool hasChildAtIndex(const string &childName, int childIndex=0) const;
|
bool hasChildAtIndex(const string &childName, int childIndex=0) const;
|
||||||
bool hasChild(const string &childName) const;
|
bool hasChild(const string &childName) const;
|
||||||
|
bool hasChildWithAliases(vector<string> childNameList) const;
|
||||||
int clearChild(const string &childName);
|
int clearChild(const string &childName);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -749,10 +749,11 @@ vector<XmlNode *> XmlNode::getChildList(const string &childName) const {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlNode *XmlNode::getChild(const string &childName, unsigned int i) 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);
|
return superNode->getChild(childName,i);
|
||||||
if(i>=children.size()){
|
}
|
||||||
|
if(i >= children.size()) {
|
||||||
throw megaglest_runtime_error("\"" + name + "\" node doesn't have "+intToStr(i+1)+" children named \"" + childName + "\"\n\nTree: "+getTreeString());
|
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());
|
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 {
|
bool XmlNode::hasChildAtIndex(const string &childName, int i) const {
|
||||||
if(superNode && !hasChildNoSuper(childName))
|
if(superNode && !hasChildNoSuper(childName))
|
||||||
return superNode->hasChildAtIndex(childName,i);
|
return superNode->hasChildAtIndex(childName,i);
|
||||||
|
@ -789,15 +823,17 @@ bool XmlNode::hasChildAtIndex(const string &childName, int i) const {
|
||||||
bool XmlNode::hasChild(const string &childName) const {
|
bool XmlNode::hasChild(const string &childName) const {
|
||||||
return hasChildNoSuper(childName) || (superNode && superNode->hasChild(childName));
|
return hasChildNoSuper(childName) || (superNode && superNode->hasChild(childName));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XmlNode::hasChildNoSuper(const string &childName) const {
|
bool XmlNode::hasChildWithAliases(vector<string> childNameList) const {
|
||||||
//int count= 0;
|
bool result = false;
|
||||||
for(unsigned int j = 0; j < children.size(); ++j) {
|
for(int aliasIndex = 0; aliasIndex < childNameList.size(); ++aliasIndex) {
|
||||||
if(children[j]->getName() == childName) {
|
const string &childName = childNameList[aliasIndex];
|
||||||
return true;
|
result = hasChild(childName);
|
||||||
|
if(result == true) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlNode *XmlNode::addChild(const string &name, const string text) {
|
XmlNode *XmlNode::addChild(const string &name, const string text) {
|
||||||
|
|
Loading…
Reference in New Issue