summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/itemxmlutils.cpp25
-rw-r--r--src/utils/itemxmlutils.h5
2 files changed, 30 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()));
+ }
+}
diff --git a/src/utils/itemxmlutils.h b/src/utils/itemxmlutils.h
index 66f5d8fcd..c0f2860cb 100644
--- a/src/utils/itemxmlutils.h
+++ b/src/utils/itemxmlutils.h
@@ -21,6 +21,7 @@
#ifndef UTILS_ITEMXMLUTILS_H
#define UTILS_ITEMXMLUTILS_H
+#include "utils/vector.h"
#include "utils/xml.h"
#include "resources/itemfieldinfos.h"
@@ -31,4 +32,8 @@ void readItemStatsString(std::string &effect,
XmlNodeConstPtr node,
const ItemFieldInfos &fields);
+void readItemStatsVector(STD_VECTOR<std::string> &effect,
+ XmlNodeConstPtr node,
+ const ItemFieldInfos &fields);
+
#endif // UTILS_ITEMXMLUTILS_H