summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/being/localplayer.cpp6
-rw-r--r--src/being/localplayer.h4
-rw-r--r--src/being/playerinfo.cpp16
-rw-r--r--src/being/playerinfo.h11
-rw-r--r--src/gui/dialogsmanager.cpp8
-rw-r--r--src/gui/dialogsmanager.h4
-rw-r--r--src/gui/widgets/statspage.cpp4
-rw-r--r--src/gui/widgets/statspage.h4
-rw-r--r--src/gui/widgets/statspagebasic.cpp6
-rw-r--r--src/gui/widgets/statspagebasic.h4
-rw-r--r--src/gui/windows/charselectdialog.cpp8
-rw-r--r--src/gui/windows/chatwindow.cpp12
-rw-r--r--src/gui/windows/chatwindow.h4
-rw-r--r--src/gui/windows/inventorywindow.cpp4
-rw-r--r--src/gui/windows/inventorywindow.h4
-rw-r--r--src/gui/windows/killstats.cpp85
-rw-r--r--src/gui/windows/killstats.h12
-rw-r--r--src/gui/windows/ministatuswindow.cpp26
-rw-r--r--src/gui/windows/ministatuswindow.h4
-rw-r--r--src/gui/windows/statuswindow.cpp28
-rw-r--r--src/gui/windows/statuswindow.h8
-rw-r--r--src/listeners/attributelistener.cpp4
-rw-r--r--src/listeners/attributelistener.h8
-rw-r--r--src/utils/cast.h2
24 files changed, 167 insertions, 109 deletions
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index 981234ec4..7a64dea24 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -1246,8 +1246,8 @@ void LocalPlayer::statChanged(const AttributesT id,
}
void LocalPlayer::attributeChanged(const AttributesT id,
- const int oldVal,
- const int newVal)
+ const int64_t oldVal,
+ const int64_t newVal)
{
PRAGMA45(GCC diagnostic push)
PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
@@ -1260,7 +1260,7 @@ void LocalPlayer::attributeChanged(const AttributesT id,
if (oldVal > newVal)
break;
- const int change = newVal - oldVal;
+ const int change = CAST_S32(newVal - oldVal);
addXpMessage(change);
break;
}
diff --git a/src/being/localplayer.h b/src/being/localplayer.h
index 7840bc665..9af5b9d3c 100644
--- a/src/being/localplayer.h
+++ b/src/being/localplayer.h
@@ -399,8 +399,8 @@ class LocalPlayer final : public Being,
{ return mTarget != nullptr ? mTarget->mY : mLastAttackY; }
void attributeChanged(const AttributesT id,
- const int oldVal,
- const int newVal) override final;
+ const int64_t oldVal,
+ const int64_t newVal) override final;
void statChanged(const AttributesT id,
const int oldVal1,
diff --git a/src/being/playerinfo.cpp b/src/being/playerinfo.cpp
index 33541a465..f24d97331 100644
--- a/src/being/playerinfo.cpp
+++ b/src/being/playerinfo.cpp
@@ -72,7 +72,7 @@ std::set<int> mProtectedItems;
// --- Triggers ---------------------------------------------------------------
void triggerAttr(const AttributesT id,
- const int old)
+ const int64_t old)
{
AttributeListener::distributeEvent(id, old,
mData.mAttributes.find(id)->second);
@@ -87,7 +87,7 @@ void triggerStat(const AttributesT id,
// --- Attributes -------------------------------------------------------------
-int getAttribute(const AttributesT id)
+int64_t getAttribute64(const AttributesT id)
{
const AtrIntMap::const_iterator it = mData.mAttributes.find(id);
if (it != mData.mAttributes.end())
@@ -95,11 +95,19 @@ int getAttribute(const AttributesT id)
return 0;
}
+int32_t getAttribute(const AttributesT id)
+{
+ const AtrIntMap::const_iterator it = mData.mAttributes.find(id);
+ if (it != mData.mAttributes.end())
+ return CAST_S32(it->second);
+ return 0;
+}
+
void setAttribute(const AttributesT id,
- const int value,
+ const int64_t value,
const Notify notify)
{
- const int old = mData.mAttributes[id];
+ const int64_t old = mData.mAttributes[id];
mData.mAttributes[id] = value;
if (notify == Notify_true)
triggerAttr(id, old);
diff --git a/src/being/playerinfo.h b/src/being/playerinfo.h
index 004691e86..5528a1c3d 100644
--- a/src/being/playerinfo.h
+++ b/src/being/playerinfo.h
@@ -52,7 +52,7 @@ struct Stat final
int expNeed;
};
-typedef std::map<AttributesT, int> AtrIntMap;
+typedef std::map<AttributesT, int64_t> AtrIntMap;
typedef std::map<AttributesT, Stat> StatMap;
/**
@@ -94,12 +94,15 @@ namespace PlayerInfo
/**
* Returns the value of the given attribute.
*/
- int getAttribute(const AttributesT id) A_WARN_UNUSED;
+ int64_t getAttribute64(const AttributesT id) A_WARN_UNUSED;
+
+ int32_t getAttribute(const AttributesT id) A_WARN_UNUSED;
/**
* Changes the value of the given attribute.
*/
- void setAttribute(const AttributesT id, const int value,
+ void setAttribute(const AttributesT id,
+ const int64_t value,
const Notify notify = Notify_true);
int getSkillLevel(const int id) A_WARN_UNUSED;
@@ -225,7 +228,7 @@ namespace PlayerInfo
void stateChange(const StateT state);
void triggerAttr(const AttributesT id,
- const int old);
+ const int64_t old);
void triggerStat(const AttributesT id,
const int old1,
diff --git a/src/gui/dialogsmanager.cpp b/src/gui/dialogsmanager.cpp
index 979db937d..8f63662db 100644
--- a/src/gui/dialogsmanager.cpp
+++ b/src/gui/dialogsmanager.cpp
@@ -156,8 +156,8 @@ void DialogsManager::playerDeath()
#ifndef DYECMD
void DialogsManager::attributeChanged(const AttributesT id,
- const int oldVal,
- const int newVal)
+ const int64_t oldVal,
+ const int64_t newVal)
{
if (id == Attributes::TOTAL_WEIGHT)
{
@@ -215,8 +215,8 @@ void DialogsManager::attributeChanged(const AttributesT id,
#else // DYECMD
void DialogsManager::attributeChanged(const AttributesT id A_UNUSED,
- const int oldVal A_UNUSED,
- const int newVal A_UNUSED)
+ const int64_t oldVal A_UNUSED,
+ const int64_t newVal A_UNUSED)
{
}
#endif // DYECMD
diff --git a/src/gui/dialogsmanager.h b/src/gui/dialogsmanager.h
index 501e9211d..04ace68e2 100644
--- a/src/gui/dialogsmanager.h
+++ b/src/gui/dialogsmanager.h
@@ -56,8 +56,8 @@ class DialogsManager final : public AttributeListener,
void playerDeath() override final;
void attributeChanged(const AttributesT id,
- const int oldVal,
- const int newVal) override final;
+ const int64_t oldVal,
+ const int64_t newVal) override final;
};
extern DialogsManager *dialogsManager;
diff --git a/src/gui/widgets/statspage.cpp b/src/gui/widgets/statspage.cpp
index 5fa58f2e5..0540b1a24 100644
--- a/src/gui/widgets/statspage.cpp
+++ b/src/gui/widgets/statspage.cpp
@@ -70,8 +70,8 @@ void StatsPage::widgetResized(const Event &event A_UNUSED)
}
void StatsPage::attributeChanged(const AttributesT id,
- const int oldVal A_UNUSED,
- const int newVal A_UNUSED)
+ const int64_t oldVal A_UNUSED,
+ const int64_t newVal A_UNUSED)
{
const Attrs::const_iterator it = mAttrs.find(id);
if (it != mAttrs.end() && (it->second != nullptr))
diff --git a/src/gui/widgets/statspage.h b/src/gui/widgets/statspage.h
index 36a43bf6f..ad62aebeb 100644
--- a/src/gui/widgets/statspage.h
+++ b/src/gui/widgets/statspage.h
@@ -45,8 +45,8 @@ class StatsPage final : public Container,
void widgetResized(const Event &event) override final;
void attributeChanged(const AttributesT id,
- const int oldVal,
- const int newVal) override final;
+ const int64_t oldVal,
+ const int64_t newVal) override final;
void statChanged(const AttributesT id,
const int oldVal1,
diff --git a/src/gui/widgets/statspagebasic.cpp b/src/gui/widgets/statspagebasic.cpp
index ec00026d4..249d4f337 100644
--- a/src/gui/widgets/statspagebasic.cpp
+++ b/src/gui/widgets/statspagebasic.cpp
@@ -89,8 +89,8 @@ void StatsPageBasic::statChanged(const AttributesT id,
}
void StatsPageBasic::attributeChanged(const AttributesT id,
- const int oldVal A_UNUSED,
- const int newVal)
+ const int64_t oldVal A_UNUSED,
+ const int64_t newVal)
{
PRAGMA45(GCC diagnostic push)
PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
@@ -99,7 +99,7 @@ void StatsPageBasic::attributeChanged(const AttributesT id,
case Attributes::PLAYER_CHAR_POINTS:
mCharacterPointsLabel->setCaption(strprintf(
// TRANSLATORS: status window label
- _("Character points: %d"), newVal));
+ _("Character points: %d"), CAST_S32(newVal)));
mCharacterPointsLabel->adjustSize();
// Update all attributes
diff --git a/src/gui/widgets/statspagebasic.h b/src/gui/widgets/statspagebasic.h
index 7390e4985..d56b8aeff 100644
--- a/src/gui/widgets/statspagebasic.h
+++ b/src/gui/widgets/statspagebasic.h
@@ -45,8 +45,8 @@ class StatsPageBasic final : public Container,
void widgetResized(const Event &event) override final;
void attributeChanged(const AttributesT id,
- const int oldVal,
- const int newVal) override final;
+ const int64_t oldVal,
+ const int64_t newVal) override final;
void statChanged(const AttributesT id,
const int oldVal1,
diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp
index c44464de1..d7ba2ea83 100644
--- a/src/gui/windows/charselectdialog.cpp
+++ b/src/gui/windows/charselectdialog.cpp
@@ -48,6 +48,7 @@
#include "net/net.h"
#include "net/serverfeatures.h"
+#include "utils/cast.h"
#include "utils/foreach.h"
#include "resources/db/unitsdb.h"
@@ -241,10 +242,12 @@ void CharSelectDialog::action(const ActionEvent &event)
if (data == nullptr)
return;
+ const std::string strExp = toString(CAST_U64(
+ character->data.mAttributes[Attributes::PLAYER_EXP]));
const std::string msg = strprintf(
// TRANSLATORS: char select dialog. player info message.
_("Hp: %u/%u\nMp: %u/%u\nLevel: %u\n"
- "Experience: %u\nMoney: %s"),
+ "Experience: %s\nMoney: %s"),
CAST_U32(
character->data.mAttributes[Attributes::PLAYER_HP]),
CAST_U32(
@@ -255,8 +258,7 @@ void CharSelectDialog::action(const ActionEvent &event)
character->data.mAttributes[Attributes::PLAYER_MAX_MP]),
CAST_U32(
character->data.mAttributes[Attributes::PLAYER_LEVEL]),
- CAST_U32(
- character->data.mAttributes[Attributes::PLAYER_EXP]),
+ strExp.c_str(),
UnitsDb::formatCurrency(
character->data.mAttributes[Attributes::MONEY]).c_str());
CREATEWIDGET(OkDialog, data->getName(), msg,
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp
index 9728fe52f..091548381 100644
--- a/src/gui/windows/chatwindow.cpp
+++ b/src/gui/windows/chatwindow.cpp
@@ -1023,8 +1023,8 @@ void ChatWindow::statChanged(const AttributesT id,
}
void ChatWindow::attributeChanged(const AttributesT id,
- const int oldVal,
- const int newVal)
+ const int64_t oldVal,
+ const int64_t newVal)
{
if (!mShowBattleEvents)
return;
@@ -1036,17 +1036,19 @@ void ChatWindow::attributeChanged(const AttributesT id,
{
if (oldVal > newVal)
break;
- const int change = newVal - oldVal;
+ const int64_t change = newVal - oldVal;
if (change != 0)
{
battleChatLog(std::string("+").append(toString(
- change)).append(" xp"),
+ CAST_U64(change))).append(" xp"),
ChatMsgType::BY_SERVER);
}
break;
}
case Attributes::PLAYER_LEVEL:
- battleChatLog(std::string("Level: ").append(toString(newVal)),
+ battleChatLog(std::string(
+ "Level: ").append(toString(CAST_S32(
+ newVal))),
ChatMsgType::BY_SERVER);
break;
default:
diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h
index 080e36738..2328a012f 100644
--- a/src/gui/windows/chatwindow.h
+++ b/src/gui/windows/chatwindow.h
@@ -295,8 +295,8 @@ class ChatWindow final : public Window,
void selectTabByType(const ChatTabTypeT &type);
void attributeChanged(const AttributesT id,
- const int oldVal,
- const int newVal) override final;
+ const int64_t oldVal,
+ const int64_t newVal) override final;
void statChanged(const AttributesT id,
const int oldVal1,
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp
index 7a3716291..f973f250f 100644
--- a/src/gui/windows/inventorywindow.cpp
+++ b/src/gui/windows/inventorywindow.cpp
@@ -1007,8 +1007,8 @@ void InventoryWindow::unsetInventory()
}
void InventoryWindow::attributeChanged(const AttributesT id,
- const int oldVal A_UNUSED,
- const int newVal A_UNUSED)
+ const int64_t oldVal A_UNUSED,
+ const int64_t newVal A_UNUSED)
{
if (id == Attributes::TOTAL_WEIGHT
|| id == Attributes::MAX_WEIGHT
diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h
index e1acc962b..81cfd38e4 100644
--- a/src/gui/windows/inventorywindow.h
+++ b/src/gui/windows/inventorywindow.h
@@ -154,8 +154,8 @@ class InventoryWindow final : public Window,
void unsetInventory();
void attributeChanged(const AttributesT id,
- const int oldVal,
- const int newVal) override final;
+ const int64_t oldVal,
+ const int64_t newVal) override final;
void combineItems(const int index1,
const int index2);
diff --git a/src/gui/windows/killstats.cpp b/src/gui/windows/killstats.cpp
index da3b6224e..002bfcaf3 100644
--- a/src/gui/windows/killstats.cpp
+++ b/src/gui/windows/killstats.cpp
@@ -111,8 +111,8 @@ KillStats::KillStats() :
if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
- const int xp(PlayerInfo::getAttribute(Attributes::PLAYER_EXP));
- int xpNextLevel(PlayerInfo::getAttribute(Attributes::PLAYER_EXP_NEEDED));
+ const int64_t xp(PlayerInfo::getAttribute64(Attributes::PLAYER_EXP));
+ int64_t xpNextLevel(PlayerInfo::getAttribute64(Attributes::PLAYER_EXP_NEEDED));
if (xpNextLevel == 0)
xpNextLevel = 1;
@@ -122,13 +122,20 @@ KillStats::KillStats() :
localPlayer->getLevel(), static_cast<double>(xp)
/ static_cast<double>(xpNextLevel) * 100.0));
+ const std::string strXp = toString(CAST_U64(xp));
+ const std::string strXpNextLevel = toString(CAST_U64(xpNextLevel));
+ const std::string strXpLeft = toString(CAST_U64(xpNextLevel - xp));
+ const std::string strXpPercent = toString(CAST_U64(xpNextLevel / 100));
// TRANSLATORS: kill stats window label
- mLine2 = new Label(this, strprintf(_("Exp: %d/%d Left: %d"),
- xp, xpNextLevel, xpNextLevel - xp));
+ mLine2 = new Label(this, strprintf(_("Exp: %s/%s Left: %s"),
+ strXp.c_str(),
+ strXpNextLevel.c_str(),
+ strXpLeft.c_str()));
// TRANSLATORS: kill stats window label
- mLine3 = new Label(this, strprintf(_("1%% = %d exp, avg mob for 1%%: %s"),
- xpNextLevel / 100, "?"));
+ mLine3 = new Label(this, strprintf(_("1%% = %s exp, avg mob for 1%%: %s"),
+ strXpPercent.c_str(),
+ "?"));
place(0, 0, mLine1, 6).setPadding(0);
place(0, 1, mLine2, 6).setPadding(0);
@@ -160,8 +167,10 @@ void KillStats::action(const ActionEvent &event)
{
mKillCounter = 0;
mExpCounter = 0;
- mLine3->setCaption(strprintf("1%% = %d exp, avg mob for 1%%: %s",
- PlayerInfo::getAttribute(Attributes::PLAYER_EXP_NEEDED) / 100,
+ const std::string strXpPercent = toString(CAST_U64(
+ PlayerInfo::getAttribute64(Attributes::PLAYER_EXP_NEEDED) / 100));
+ mLine3->setCaption(strprintf("1%% = %s exp, avg mob for 1%%: %s",
+ strXpPercent.c_str(),
"?"));
// TRANSLATORS: kill stats window label
mLine4->setCaption(strprintf(_("Kills: %s, total exp: %s"), "?", "?"));
@@ -199,9 +208,9 @@ void KillStats::resetTimes()
m15minSpeed = 0;
}
-void KillStats::gainXp(int xp)
+void KillStats::gainXp(int64_t xp)
{
- const int expNeed = PlayerInfo::getAttribute(
+ const int64_t expNeed = PlayerInfo::getAttribute64(
Attributes::PLAYER_EXP_NEEDED);
if (xp == expNeed)
xp = 0;
@@ -218,7 +227,7 @@ void KillStats::gainXp(int xp)
const float AvgExp = static_cast<float>(mExpCounter)
/ static_cast<float>(mKillCounter);
- int xpNextLevel(expNeed);
+ int64_t xpNextLevel(expNeed);
if (mKillTimer == 0)
mKillTimer = cur_time;
@@ -231,21 +240,28 @@ void KillStats::gainXp(int xp)
if (timeDiff <= 0.001)
timeDiff = 1;
- const int exp = PlayerInfo::getAttribute(Attributes::PLAYER_EXP);
+ const int64_t exp = PlayerInfo::getAttribute64(Attributes::PLAYER_EXP);
// TRANSLATORS: kill stats window label
mLine1->setCaption(strprintf(_("Level: %d at %f%%"),
localPlayer->getLevel(), static_cast<double>(exp)
/ static_cast<double>(xpNextLevel) * 100.0));
+ const std::string strXp = toString(CAST_U64(exp));
+ const std::string strXpNextLevel = toString(CAST_U64(xpNextLevel));
+ const std::string strXpLeft = toString(CAST_U64(xpNextLevel - exp));
+ const std::string strXpPercent = toString(CAST_U64(xpNextLevel / 100));
// TRANSLATORS: kill stats window label
- mLine2->setCaption(strprintf(_("Exp: %d/%d Left: %d"), exp,
- xpNextLevel, xpNextLevel - exp));
+ mLine2->setCaption(strprintf(_("Exp: %s/%s Left: %s"),
+ strXp.c_str(),
+ strXpNextLevel.c_str(),
+ strXpLeft.c_str()));
if (AvgExp >= -0.001F && AvgExp <= 0.001F)
{
// TRANSLATORS: kill stats window label
- mLine3->setCaption(strprintf(_("1%% = %d exp, avg mob for 1%%: %s"),
- xpNextLevel / 100, "?"));
+ mLine3->setCaption(strprintf(_("1%% = %s exp, avg mob for 1%%: %s"),
+ strXpPercent.c_str(),
+ "?"));
// TRANSLATORS: kill stats window label
mLine5->setCaption(strprintf(_("Avg Exp: %s"),
@@ -258,8 +274,8 @@ void KillStats::gainXp(int xp)
else
{
// TRANSLATORS: kill stats window label
- mLine3->setCaption(strprintf(_("1%% = %d exp, avg mob for 1%%: %s"),
- xpNextLevel / 100, toString((static_cast<float>(
+ mLine3->setCaption(strprintf(_("1%% = %s exp, avg mob for 1%%: %s"),
+ strXpPercent.c_str(), toString((static_cast<float>(
xpNextLevel) / 100) / AvgExp).c_str()));
// TRANSLATORS: kill stats window label
@@ -279,8 +295,10 @@ void KillStats::gainXp(int xp)
toString(mKillTCounter / timeDiff).c_str(),
toString(mExpTCounter / timeDiff).c_str()));
- // TRANSLATORS: kill stats window label
- mLastKillExpLabel->setCaption(strprintf("%s %d", _("Last kill exp:"), xp));
+ mLastKillExpLabel->setCaption(strprintf("%s %s",
+ // TRANSLATORS: kill stats window label
+ _("Last kill exp:"),
+ strXp.c_str()));
recalcStats();
update();
@@ -294,7 +312,7 @@ void KillStats::recalcStats()
// Need Update Exp Counter
if (curTime - m1minExpTime > 60)
{
- const int newExp = PlayerInfo::getAttribute(Attributes::PLAYER_EXP);
+ const int64_t newExp = PlayerInfo::getAttribute(Attributes::PLAYER_EXP);
if (m1minExpTime != 0)
m1minSpeed = newExp - m1minExpNum;
else
@@ -315,7 +333,7 @@ void KillStats::recalcStats()
if (curTime - m5minExpTime > 60*5)
{
- const int newExp = PlayerInfo::getAttribute(Attributes::PLAYER_EXP);
+ const int64_t newExp = PlayerInfo::getAttribute(Attributes::PLAYER_EXP);
if (m5minExpTime != 0)
m5minSpeed = newExp - m5minExpNum;
else
@@ -326,7 +344,7 @@ void KillStats::recalcStats()
if (curTime - m15minExpTime > 60*15)
{
- const int newExp = PlayerInfo::getAttribute(Attributes::PLAYER_EXP);
+ const int64_t newExp = PlayerInfo::getAttribute(Attributes::PLAYER_EXP);
if (m15minExpTime != 0)
m15minSpeed = newExp - m15minExpNum;
else
@@ -342,7 +360,9 @@ void KillStats::update()
BLOCK_START("KillStats::update")
mExpSpeed1Label->setCaption(strprintf(ngettext("Exp speed per %d min: %s",
- "Exp speed per %d min: %s", 1), 1, toString(m1minSpeed).c_str()));
+ "Exp speed per %d min: %s", 1),
+ 1,
+ toString(m1minSpeed).c_str()));
if (m1minSpeed != 0)
{
@@ -362,7 +382,9 @@ void KillStats::update()
mExpTime1Label->adjustSize();
mExpSpeed5Label->setCaption(strprintf(ngettext("Exp speed per %d min: %s",
- "Exp speed per %d min: %s", 5), 5, toString(m5minSpeed / 5).c_str()));
+ "Exp speed per %d min: %s", 5),
+ 5,
+ toString(m5minSpeed / 5).c_str()));
mExpSpeed5Label->adjustSize();
if (m5minSpeed != 0)
@@ -406,8 +428,8 @@ void KillStats::update()
}
void KillStats::attributeChanged(const AttributesT id,
- const int oldVal,
- const int newVal)
+ const int64_t oldVal,
+ const int64_t newVal)
{
PRAGMA45(GCC diagnostic push)
PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
@@ -418,12 +440,16 @@ void KillStats::attributeChanged(const AttributesT id,
gainXp(newVal - oldVal);
break;
case Attributes::PLAYER_LEVEL:
+ {
+ const std::string strXpPercent = toString(CAST_U64(
+ PlayerInfo::getAttribute(
+ Attributes::PLAYER_EXP_NEEDED) / 100));
mKillCounter = 0;
mKillTCounter = 0;
mExpCounter = 0;
mExpTCounter = 0;
- mLine3->setCaption(strprintf("1%% = %d exp, avg mob for 1%%: %s",
- PlayerInfo::getAttribute(Attributes::PLAYER_EXP_NEEDED) / 100,
+ mLine3->setCaption(strprintf("1%% = %s exp, avg mob for 1%%: %s",
+ strXpPercent.c_str(),
"?"));
mLine4->setCaption(strprintf(
// TRANSLATORS: kill stats window label
@@ -440,6 +466,7 @@ void KillStats::attributeChanged(const AttributesT id,
resetTimes();
update();
break;
+ }
default:
break;
}
diff --git a/src/gui/windows/killstats.h b/src/gui/windows/killstats.h
index 5e7b65df0..d471e1f73 100644
--- a/src/gui/windows/killstats.h
+++ b/src/gui/windows/killstats.h
@@ -54,7 +54,7 @@ class KillStats final : public Window,
*/
void action(const ActionEvent &event) override final;
- void gainXp(int Xp);
+ void gainXp(int64_t Xp);
/**
* Recalc stats if needed
@@ -69,8 +69,8 @@ class KillStats final : public Window,
void resetTimes();
void attributeChanged(const AttributesT id,
- const int oldVal,
- const int newVal) override final;
+ const int64_t oldVal,
+ const int64_t newVal) override final;
private:
time_t mKillTimer; /**< Timer for kill stats. */
@@ -99,15 +99,15 @@ class KillStats final : public Window,
int mExpTCounter; /**< Timer Exp counter. */
time_t m1minExpTime;
- int m1minExpNum;
+ int64_t m1minExpNum;
int m1minSpeed;
time_t m5minExpTime;
- int m5minExpNum;
+ int64_t m5minExpNum;
int m5minSpeed;
time_t m15minExpTime;
- int m15minExpNum;
+ int64_t m15minExpNum;
int m15minSpeed;
};
diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp
index ba92a0739..64d1a1175 100644
--- a/src/gui/windows/ministatuswindow.cpp
+++ b/src/gui/windows/ministatuswindow.cpp
@@ -268,8 +268,8 @@ void MiniStatusWindow::statChanged(const AttributesT id A_UNUSED,
}
void MiniStatusWindow::attributeChanged(const AttributesT id,
- const int oldVal A_UNUSED,
- const int newVal A_UNUSED)
+ const int64_t oldVal A_UNUSED,
+ const int64_t newVal A_UNUSED)
{
PRAGMA45(GCC diagnostic push)
PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
@@ -366,20 +366,28 @@ void MiniStatusWindow::mouseMoved(MouseEvent &event)
PlayerInfo::getAttribute(Attributes::PLAYER_LEVEL));
}
- const int exp = PlayerInfo::getAttribute(Attributes::PLAYER_EXP);
- const int expNeed = PlayerInfo::getAttribute(
+ const int64_t exp = PlayerInfo::getAttribute64(Attributes::PLAYER_EXP);
+ const int64_t expNeed = PlayerInfo::getAttribute64(
Attributes::PLAYER_EXP_NEEDED);
+ const std::string str = toString(CAST_U64(exp)) +
+ "/" +
+ toString(CAST_U64(expNeed));
if (exp > expNeed)
{
- textPopup->show(x + rect.x, y + rect.y, level, strprintf("%d/%d",
- exp, expNeed));
+ textPopup->show(x + rect.x,
+ y + rect.y,
+ level,
+ str);
}
else
{
- textPopup->show(x + rect.x, y + rect.y, level, strprintf("%d/%d",
- exp, expNeed),
+ const std::string str2 = toString(CAST_U64(expNeed - exp));
+ textPopup->show(x + rect.x,
+ y + rect.y,
+ level,
+ str,
// TRANSLATORS: status bar label
- strprintf("%s: %d", _("Need"), expNeed - exp));
+ strprintf("%s: %s", _("Need"), str2.c_str()));
}
mStatusPopup->hide();
}
diff --git a/src/gui/windows/ministatuswindow.h b/src/gui/windows/ministatuswindow.h
index 4221673a8..9d6e19ac7 100644
--- a/src/gui/windows/ministatuswindow.h
+++ b/src/gui/windows/ministatuswindow.h
@@ -91,8 +91,8 @@ class MiniStatusWindow final : public Window,
Rect getChildrenArea() override final A_WARN_UNUSED;
void attributeChanged(const AttributesT id,
- const int oldVal,
- const int newVal) override final;
+ const int64_t oldVal,
+ const int64_t newVal) override final;
void statChanged(const AttributesT id,
const int oldVal1,
diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp
index cfff8e62f..62da4e71d 100644
--- a/src/gui/windows/statuswindow.cpp
+++ b/src/gui/windows/statuswindow.cpp
@@ -125,11 +125,13 @@ StatusWindow::StatusWindow() :
getThemeColor(ThemeColorId::HP_BAR_OUTLINE));
mHpBar->setSelectable(false);
- max = PlayerInfo::getAttribute(Attributes::PLAYER_EXP_NEEDED);
+ const int64_t maxExp = PlayerInfo::getAttribute64(
+ Attributes::PLAYER_EXP_NEEDED);
mXpBar = new ProgressBar(this,
- max != 0 ?
- static_cast<float>(PlayerInfo::getAttribute(Attributes::PLAYER_EXP)) /
- static_cast<float>(max) : static_cast<float>(0),
+ maxExp != 0 ?
+ static_cast<float>(PlayerInfo::getAttribute64(
+ Attributes::PLAYER_EXP)) /
+ static_cast<float>(maxExp) : static_cast<float>(0),
80,
0,
ProgressColorId::PROG_EXP,
@@ -340,8 +342,8 @@ void StatusWindow::statChanged(const AttributesT id,
}
void StatusWindow::attributeChanged(const AttributesT id,
- const int oldVal A_UNUSED,
- const int newVal)
+ const int64_t oldVal A_UNUSED,
+ const int64_t newVal)
{
PRAGMA45(GCC diagnostic push)
PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
@@ -371,7 +373,8 @@ void StatusWindow::attributeChanged(const AttributesT id,
case Attributes::PLAYER_LEVEL:
// TRANSLATORS: status window label
- mLvlLabel->setCaption(strprintf(_("Level: %d"), newVal));
+ mLvlLabel->setCaption(strprintf(_("Level: %d"),
+ CAST_S32(newVal)));
mLvlLabel->adjustSize();
break;
@@ -439,8 +442,8 @@ void StatusWindow::updateMPBar(ProgressBar *const bar,
}
void StatusWindow::updateProgressBar(ProgressBar *const bar,
- const int value,
- const int max,
+ const int64_t value,
+ const int64_t max,
const bool percent)
{
if (bar == nullptr)
@@ -451,7 +454,7 @@ void StatusWindow::updateProgressBar(ProgressBar *const bar,
// TRANSLATORS: status bar label
bar->setText(_("Max"));
bar->setProgress(1);
- bar->setText(toString(value));
+ bar->setText(toString(CAST_U64(value)));
}
else
{
@@ -464,7 +467,10 @@ void StatusWindow::updateProgressBar(ProgressBar *const bar,
}
else
{
- bar->setText(toString(value).append("/").append(toString(max)));
+ bar->setText(toString(
+ CAST_U64(value)).append(
+ "/").append(toString(
+ CAST_U64(max))));
}
bar->setProgress(progress);
}
diff --git a/src/gui/windows/statuswindow.h b/src/gui/windows/statuswindow.h
index 01277c220..daced90b2 100644
--- a/src/gui/windows/statuswindow.h
+++ b/src/gui/windows/statuswindow.h
@@ -73,8 +73,8 @@ class StatusWindow final : public Window,
void updateStatusBar(ProgressBar *const bar,
const bool percent = true) const;
static void updateProgressBar(ProgressBar *const bar,
- const int value,
- const int max,
+ const int64_t value,
+ const int64_t max,
const bool percent);
static void updateProgressBar(ProgressBar *const bar,
const AttributesT id,
@@ -83,8 +83,8 @@ class StatusWindow final : public Window,
void action(const ActionEvent &event) override;
void attributeChanged(const AttributesT id,
- const int oldVal,
- const int newVal) override final;
+ const int64_t oldVal,
+ const int64_t newVal) override final;
void statChanged(const AttributesT id,
const int oldVal1,
diff --git a/src/listeners/attributelistener.cpp b/src/listeners/attributelistener.cpp
index 0680a27eb..696f9a120 100644
--- a/src/listeners/attributelistener.cpp
+++ b/src/listeners/attributelistener.cpp
@@ -27,8 +27,8 @@
defineListener(AttributeListener)
void AttributeListener::distributeEvent(const AttributesT id,
- const int oldVal,
- const int newVal)
+ const int64_t oldVal,
+ const int64_t newVal)
{
FOR_EACH (STD_VECTOR<AttributeListener*>::iterator,
it, mListeners)
diff --git a/src/listeners/attributelistener.h b/src/listeners/attributelistener.h
index 634dd2d61..87b634af2 100644
--- a/src/listeners/attributelistener.h
+++ b/src/listeners/attributelistener.h
@@ -33,12 +33,12 @@ class AttributeListener notfinal
A_DELETE_COPY(AttributeListener)
virtual void attributeChanged(const AttributesT id,
- const int oldVal,
- const int newVal) = 0;
+ const int64_t oldVal,
+ const int64_t newVal) = 0;
static void distributeEvent(const AttributesT id,
- const int oldVal,
- const int newVal);
+ const int64_t oldVal,
+ const int64_t newVal);
defineListenerHeader(AttributeListener)
};
diff --git a/src/utils/cast.h b/src/utils/cast.h
index 9b6289ebc..f12f1badb 100644
--- a/src/utils/cast.h
+++ b/src/utils/cast.h
@@ -28,6 +28,8 @@
#define CAST_U16 static_cast<uint16_t>
#define CAST_S32 static_cast<int32_t>
#define CAST_U32 static_cast<uint32_t>
+#define CAST_S64 static_cast<int64_t>
+#define CAST_U64 static_cast<uint64_t>
#define CAST_SIZE static_cast<size_t>
#endif // UTILS_CAST_H