summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2018-11-27 21:12:28 +0300
committerAndrei Karas <akaras@inbox.ru>2018-11-27 21:12:28 +0300
commit2734f4a788dad6faf960d53de00da74ebff69bd5 (patch)
tree340b0f641708b4060be755ea1d5d581dbcbe8e63 /src
parent0c20db8d108c4123fcc3ecb343759e68567a4d4e (diff)
downloadmanaverse-2734f4a788dad6faf960d53de00da74ebff69bd5.tar.gz
manaverse-2734f4a788dad6faf960d53de00da74ebff69bd5.tar.bz2
manaverse-2734f4a788dad6faf960d53de00da74ebff69bd5.tar.xz
manaverse-2734f4a788dad6faf960d53de00da74ebff69bd5.zip
Fix dispaly '+' on stats with negative values.
Diffstat (limited to 'src')
-rw-r--r--src/utils/itemxmlutils.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/utils/itemxmlutils.cpp b/src/utils/itemxmlutils.cpp
index ac8e48e2b..7362441b9 100644
--- a/src/utils/itemxmlutils.cpp
+++ b/src/utils/itemxmlutils.cpp
@@ -29,6 +29,15 @@
#include "debug.h"
+static void convertSignedValue(std::string &outStr,
+ const std::string &srcStr)
+{
+ if (!srcStr.empty() && srcStr[0] != '-')
+ outStr = std::string("+").append(srcStr);
+ else
+ outStr = srcStr;
+}
+
static bool readField(ItemFieldInfos::const_iterator it,
XmlNodeConstPtr node,
std::string &combined)
@@ -52,8 +61,8 @@ static bool readField(ItemFieldInfos::const_iterator it,
std::string value2;
if (field->sign)
{
- value1 = std::string("+").append(tokens[0]);
- value2 = std::string("+").append(tokens[1]);
+ convertSignedValue(value1, tokens[0]);
+ convertSignedValue(value2, tokens[1]);
}
else
{
@@ -67,7 +76,7 @@ static bool readField(ItemFieldInfos::const_iterator it,
else
{
if (field->sign)
- value = std::string("+").append(value);
+ convertSignedValue(value, value);
}
const std::string format = translator->getStr(field->description);
combined = strprintf(format.c_str(),