From 68a7dd225969fcdfb9c07b99db43756a2b1dec7c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 27 Sep 2017 01:34:49 +0300 Subject: Change attributes value type to int64. --- src/being/localplayer.cpp | 6 +++--- src/being/localplayer.h | 4 ++-- src/being/playerinfo.cpp | 16 ++++++++++++---- src/being/playerinfo.h | 11 +++++++---- 4 files changed, 24 insertions(+), 13 deletions(-) (limited to 'src/being') 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 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 AtrIntMap; +typedef std::map AtrIntMap; typedef std::map 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, -- cgit v1.2.3-60-g2f50