summaryrefslogtreecommitdiff
path: root/src/being
diff options
context:
space:
mode:
Diffstat (limited to 'src/being')
-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
4 files changed, 24 insertions, 13 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,