summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-09-27 23:43:44 +0300
committerAndrei Karas <akaras@inbox.ru>2017-09-27 23:43:44 +0300
commita8041ac28118de1caef73bdac9567c9a7e25e41f (patch)
treef5c9842626b0ebeb6328566fbd1f0a424fb9af47
parentf70dcfe0a82db3aee879953f117d12aecc4fce85 (diff)
downloadplus-a8041ac28118de1caef73bdac9567c9a7e25e41f.tar.gz
plus-a8041ac28118de1caef73bdac9567c9a7e25e41f.tar.bz2
plus-a8041ac28118de1caef73bdac9567c9a7e25e41f.tar.xz
plus-a8041ac28118de1caef73bdac9567c9a7e25e41f.zip
Fix some issues with int64 to int32 implicit conversions.
-rw-r--r--src/being/localplayer.cpp4
-rw-r--r--src/gui/dialogsmanager.cpp2
-rw-r--r--src/gui/widgets/characterdisplay.cpp2
-rw-r--r--src/gui/windows/charselectdialog.cpp4
-rw-r--r--src/gui/windows/killstats.cpp11
-rw-r--r--src/gui/windows/killstats.h2
-rw-r--r--src/gui/windows/statuswindow.cpp4
-rw-r--r--src/resources/db/unitsdb.cpp15
-rw-r--r--src/resources/db/unitsdb.h7
9 files changed, 36 insertions, 15 deletions
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index 2fc20f6f2..1a12a3808 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -1245,7 +1245,7 @@ void LocalPlayer::attributeChanged(const AttributesT id,
break;
}
case Attributes::PLAYER_BASE_LEVEL:
- mLevel = newVal;
+ mLevel = CAST_S32(newVal);
break;
case Attributes::PLAYER_HP:
if (oldVal != 0 && newVal == 0)
@@ -1264,7 +1264,7 @@ void LocalPlayer::attributeChanged(const AttributesT id,
{
return;
}
- const int64_t change = newVal - oldVal;
+ const int32_t change = CAST_S32(newVal - oldVal);
addJobMessage(change);
break;
}
diff --git a/src/gui/dialogsmanager.cpp b/src/gui/dialogsmanager.cpp
index 8f63662db..f24352a43 100644
--- a/src/gui/dialogsmanager.cpp
+++ b/src/gui/dialogsmanager.cpp
@@ -168,7 +168,7 @@ void DialogsManager::attributeChanged(const AttributesT id,
percent = 50;
const int max = PlayerInfo::getAttribute(
Attributes::MAX_WEIGHT) * percent / 100;
- const int total = oldVal;
+ const int total = CAST_S32(oldVal);
if (newVal >= max && total < max)
{
weightNoticeTime = cur_time + 5;
diff --git a/src/gui/widgets/characterdisplay.cpp b/src/gui/widgets/characterdisplay.cpp
index efc256516..e5743615a 100644
--- a/src/gui/widgets/characterdisplay.cpp
+++ b/src/gui/widgets/characterdisplay.cpp
@@ -143,7 +143,7 @@ void CharacterDisplay::mouseMoved(MouseEvent &event A_UNUSED)
CAST_U32(
mCharacter->data.mAttributes[Attributes::PLAYER_BASE_LEVEL])),
// TRANSLATORS: character money
- strprintf(_("Money: %s"), UnitsDb::formatCurrency(
+ strprintf(_("Money: %s"), UnitsDb::formatCurrency64(
mCharacter->data.mAttributes[Attributes::MONEY]).c_str()));
}
else
diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp
index aa4a80b4a..7b43aca09 100644
--- a/src/gui/windows/charselectdialog.cpp
+++ b/src/gui/windows/charselectdialog.cpp
@@ -259,8 +259,8 @@ void CharSelectDialog::action(const ActionEvent &event)
CAST_U32(
character->data.mAttributes[Attributes::PLAYER_BASE_LEVEL]),
strExp.c_str(),
- UnitsDb::formatCurrency(
- character->data.mAttributes[Attributes::MONEY]).c_str());
+ UnitsDb::formatCurrency(CAST_S32(
+ character->data.mAttributes[Attributes::MONEY])).c_str());
CREATEWIDGET(OkDialog, data->getName(), msg,
// TRANSLATORS: ok dialog button
_("OK"),
diff --git a/src/gui/windows/killstats.cpp b/src/gui/windows/killstats.cpp
index a110f21f1..ec6d331d8 100644
--- a/src/gui/windows/killstats.cpp
+++ b/src/gui/windows/killstats.cpp
@@ -288,7 +288,8 @@ void KillStats::gainXp(int64_t xp)
}
// TRANSLATORS: kill stats window label
mLine4->setCaption(strprintf(_("Kills: %s, total exp: %s"),
- toString(mKillCounter).c_str(), toString(mExpCounter).c_str()));
+ toString(mKillCounter).c_str(),
+ toString(CAST_U64(mExpCounter)).c_str()));
// TRANSLATORS: kill stats window label
mLine7->setCaption(strprintf(_("Kills/Min: %s, Exp/Min: %s"),
@@ -314,7 +315,7 @@ void KillStats::recalcStats()
{
const int64_t newExp = PlayerInfo::getAttribute(Attributes::PLAYER_EXP);
if (m1minExpTime != 0)
- m1minSpeed = newExp - m1minExpNum;
+ m1minSpeed = CAST_S32(newExp - m1minExpNum);
else
m1minSpeed = 0;
m1minExpTime = curTime;
@@ -326,7 +327,7 @@ void KillStats::recalcStats()
const int newExp = PlayerInfo::getAttribute(
Attributes::PLAYER_EXP_NEEDED);
if (m1minExpTime != 0)
- m1minSpeed = newExp - m1minExpNum;
+ m1minSpeed = CAST_S32(newExp - m1minExpNum);
mStatsReUpdated = true;
m1minExpNum = newExp;
}
@@ -335,7 +336,7 @@ void KillStats::recalcStats()
{
const int64_t newExp = PlayerInfo::getAttribute(Attributes::PLAYER_EXP);
if (m5minExpTime != 0)
- m5minSpeed = newExp - m5minExpNum;
+ m5minSpeed = CAST_S32(newExp - m5minExpNum);
else
m5minSpeed = 0;
m5minExpTime = curTime;
@@ -346,7 +347,7 @@ void KillStats::recalcStats()
{
const int64_t newExp = PlayerInfo::getAttribute(Attributes::PLAYER_EXP);
if (m15minExpTime != 0)
- m15minSpeed = newExp - m15minExpNum;
+ m15minSpeed = CAST_S32(newExp - m15minExpNum);
else
m15minSpeed = 0;
m15minExpTime = curTime;
diff --git a/src/gui/windows/killstats.h b/src/gui/windows/killstats.h
index d471e1f73..a57c5c439 100644
--- a/src/gui/windows/killstats.h
+++ b/src/gui/windows/killstats.h
@@ -94,7 +94,7 @@ class KillStats final : public Window,
Label *mLastKillExpLabel A_NONNULLPOINTER;
int mKillCounter; /**< Session Kill counter. */
- int mExpCounter; /**< Session Exp counter. */
+ int64_t mExpCounter; /**< Session Exp counter. */
int mKillTCounter; /**< Timer Kill counter. */
int mExpTCounter; /**< Timer Exp counter. */
diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp
index b86e3e847..092e401c2 100644
--- a/src/gui/windows/statuswindow.cpp
+++ b/src/gui/windows/statuswindow.cpp
@@ -311,7 +311,7 @@ void StatusWindow::attributeChanged(const AttributesT id,
case Attributes::MONEY:
// TRANSLATORS: status window label
mMoneyLabel->setCaption(strprintf(_("Money: %s"),
- UnitsDb::formatCurrency(newVal).c_str()));
+ UnitsDb::formatCurrency64(newVal).c_str()));
mMoneyLabel->adjustSize();
break;
@@ -347,7 +347,7 @@ void StatusWindow::attributeChanged(const AttributesT id,
}
else
{
- lvl = (expNeed - 20000) / 150;
+ lvl = CAST_S32((expNeed - 20000) / 150);
blocked = true;
PlayerInfo::setAttribute(Attributes::PLAYER_JOB_LEVEL,
lvl);
diff --git a/src/resources/db/unitsdb.cpp b/src/resources/db/unitsdb.cpp
index aac6b72e3..a32786b84 100644
--- a/src/resources/db/unitsdb.cpp
+++ b/src/resources/db/unitsdb.cpp
@@ -325,6 +325,12 @@ std::string UnitsDb::formatCurrency(const int value)
return formatUnit(value, defaultCurrency);
}
+std::string UnitsDb::formatCurrency64(const int64_t value)
+{
+ return formatUnit(CAST_S32(value),
+ defaultCurrency);
+}
+
std::string UnitsDb::formatCurrency(std::string name,
const int value)
{
@@ -333,6 +339,15 @@ std::string UnitsDb::formatCurrency(std::string name,
return formatUnit(value, mCurrencies[name]);
}
+std::string UnitsDb::formatCurrency64(std::string name,
+ const int64_t value)
+{
+ if (mCurrencies.find(name) == mCurrencies.end())
+ name = DEFAULT_CURRENCY;
+ return formatUnit(CAST_S32(value),
+ mCurrencies[name]);
+}
+
std::string UnitsDb::formatWeight(const int value)
{
return formatUnit(value, defaultWeight);
diff --git a/src/resources/db/unitsdb.h b/src/resources/db/unitsdb.h
index 0681567c0..859adaabc 100644
--- a/src/resources/db/unitsdb.h
+++ b/src/resources/db/unitsdb.h
@@ -46,11 +46,16 @@ namespace UnitsDb
*/
std::string formatCurrency(const int value) A_WARN_UNUSED;
+ std::string formatCurrency64(const int64_t value) A_WARN_UNUSED;
+
/**
* Formats the given number in the correct currency format.
*/
std::string formatCurrency(std::string name,
- const int value) A_WARN_UNUSED;
+ const int value) A_WARN_UNUSED;
+
+ std::string formatCurrency64(std::string name,
+ const int64_t value) A_WARN_UNUSED;
/**
* Formats the given number in the correct weight/mass format.