summaryrefslogtreecommitdiff
path: root/src/resources/db/itemdb.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2018-02-10 05:09:16 +0300
committerAndrei Karas <akaras@inbox.ru>2018-02-11 04:28:43 +0300
commitce34b402281f75cb1e9d214c925382fdc522455b (patch)
tree6d2cb57028ad67449da2ab4f95ef7f562d1d4823 /src/resources/db/itemdb.cpp
parent29181589eb79d3afdf337e2517b4fa43d8bbdd59 (diff)
downloadmanaverse-ce34b402281f75cb1e9d214c925382fdc522455b.tar.gz
manaverse-ce34b402281f75cb1e9d214c925382fdc522455b.tar.bz2
manaverse-ce34b402281f75cb1e9d214c925382fdc522455b.tar.xz
manaverse-ce34b402281f75cb1e9d214c925382fdc522455b.zip
Move reading and combining item stats into separate file.
Diffstat (limited to 'src/resources/db/itemdb.cpp')
-rw-r--r--src/resources/db/itemdb.cpp36
1 files changed, 5 insertions, 31 deletions
diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp
index d0889a808..fcb0d5651 100644
--- a/src/resources/db/itemdb.cpp
+++ b/src/resources/db/itemdb.cpp
@@ -48,6 +48,7 @@
#include "utils/delete2.h"
#include "utils/dtor.h"
#include "utils/foreach.h"
+#include "utils/itemxmlutils.h"
#include "utils/stdmove.h"
#include "utils/stringmap.h"
@@ -130,33 +131,6 @@ static std::string useButton2FromItemType(const ItemDbTypeT &type)
return std::string();
}
-static void readFields(std::string &effect,
- XmlNodeConstPtr node,
- const ItemFieldDb::FieldInfos &fields)
-{
- if (translator == nullptr)
- return;
-
- FOR_EACH (ItemFieldDb::FieldInfos::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 (!effect.empty())
- effect.append(" / ");
- if (field->sign && isDigit(value))
- value = std::string("+").append(value);
- const std::string format = translator->getStr(field->description);
- effect.append(strprintf(format.c_str(),
- value.c_str()));
- }
-}
-
static void initStatic()
{
mConstructed = true;
@@ -311,9 +285,9 @@ void ItemDB::loadXmlFile(const std::string &fileName,
return;
}
- const ItemFieldDb::FieldInfos &requiredFields =
+ const ItemFieldInfos &requiredFields =
ItemFieldDb::getRequiredFields();
- const ItemFieldDb::FieldInfos &addFields =
+ const ItemFieldInfos &addFields =
ItemFieldDb::getAddFields();
for_each_xml_child_node(node, rootNode)
@@ -526,8 +500,8 @@ void ItemDB::loadXmlFile(const std::string &fileName,
}
std::string effect;
- readFields(effect, node, requiredFields);
- readFields(effect, node, addFields);
+ readItemStatsString(effect, node, requiredFields);
+ readItemStatsString(effect, node, addFields);
std::string temp = XML::langProperty(node, "effect", "");
if (!effect.empty() && !temp.empty())
effect.append(" / ");