summaryrefslogtreecommitdiff
path: root/src/utils/itemxmlutils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/itemxmlutils.cpp')
-rw-r--r--src/utils/itemxmlutils.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/utils/itemxmlutils.cpp b/src/utils/itemxmlutils.cpp
index cbf642c4f..2f849b8ce 100644
--- a/src/utils/itemxmlutils.cpp
+++ b/src/utils/itemxmlutils.cpp
@@ -54,3 +54,28 @@ void readItemStatsString(std::string &effect,
value.c_str()));
}
}
+
+void readItemStatsVector(STD_VECTOR<std::string> &effect,
+ XmlNodeConstPtr node,
+ const ItemFieldInfos &fields)
+{
+ if (translator == nullptr)
+ return;
+
+ FOR_EACH (ItemFieldInfos::const_iterator, it, fields)
+ {
+ const std::string fieldName = (*it).first;
+ const ItemFieldType *const field = (*it).second;
+
+ std::string value = XML::getProperty(node,
+ fieldName.c_str(),
+ "");
+ if (value.empty())
+ continue;
+ if (field->sign && isDigit(value))
+ value = std::string("+").append(value);
+ const std::string format = translator->getStr(field->description);
+ effect.push_back(strprintf(format.c_str(),
+ value.c_str()));
+ }
+}