summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-29 21:42:33 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-29 22:43:38 +0300
commit3411edb5d3ae07d247421e4b8f7936a22b7b4027 (patch)
tree63685d0979938a42a62b3f0a880663bb06f4e8ca /src/net
parent390e5da0f9ecc4407aa7d4bcba1af5730db56271 (diff)
downloadmv-3411edb5d3ae07d247421e4b8f7936a22b7b4027.tar.gz
mv-3411edb5d3ae07d247421e4b8f7936a22b7b4027.tar.bz2
mv-3411edb5d3ae07d247421e4b8f7936a22b7b4027.tar.xz
mv-3411edb5d3ae07d247421e4b8f7936a22b7b4027.zip
Convert Attributes enum into strong typed enum.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/ea/playerhandler.cpp7
-rw-r--r--src/net/ea/playerhandler.h2
-rw-r--r--src/net/eathena/charserverhandler.cpp11
-rw-r--r--src/net/eathena/playerhandler.cpp2
-rw-r--r--src/net/eathena/playerhandler.h2
-rw-r--r--src/net/playerhandler.h5
-rw-r--r--src/net/tmwa/charserverhandler.cpp13
-rw-r--r--src/net/tmwa/playerhandler.cpp2
-rw-r--r--src/net/tmwa/playerhandler.h2
9 files changed, 25 insertions, 21 deletions
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index 0003a0a7e..8d4937236 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -61,7 +61,7 @@ PlayerHandler::PlayerHandler()
{
}
-void PlayerHandler::decreaseAttribute(const int attr A_UNUSED) const
+void PlayerHandler::decreaseAttribute(const AttributesT attr A_UNUSED) const
{
}
@@ -198,13 +198,14 @@ void PlayerHandler::processPlayerStatUpdate3(Net::MessageIn &msg)
void PlayerHandler::processPlayerStatUpdate4(Net::MessageIn &msg)
{
BLOCK_START("PlayerHandler::processPlayerStatUpdate4")
- const int type = msg.readInt16("type");
+ const uint16_t type = msg.readInt16("type");
const uint8_t ok = msg.readUInt8("flag");
const int value = msg.readUInt8("value");
if (ok != 1)
{
- const int oldValue = PlayerInfo::getStatBase(type);
+ const int oldValue = PlayerInfo::getStatBase(
+ static_cast<AttributesT>(type));
const int points = PlayerInfo::getAttribute(Attributes::CHAR_POINTS)
+ oldValue - value;
PlayerInfo::setAttribute(Attributes::CHAR_POINTS, points);
diff --git a/src/net/ea/playerhandler.h b/src/net/ea/playerhandler.h
index 760f52af7..4f443c8bf 100644
--- a/src/net/ea/playerhandler.h
+++ b/src/net/ea/playerhandler.h
@@ -42,7 +42,7 @@ class PlayerHandler notfinal : public Net::PlayerHandler
A_DELETE_COPY(PlayerHandler)
- void decreaseAttribute(const int attr) const override final;
+ void decreaseAttribute(const AttributesT attr) const override final;
void ignorePlayer(const std::string &player,
const bool ignore) const override final;
diff --git a/src/net/eathena/charserverhandler.cpp b/src/net/eathena/charserverhandler.cpp
index 76005d968..94530f407 100644
--- a/src/net/eathena/charserverhandler.cpp
+++ b/src/net/eathena/charserverhandler.cpp
@@ -257,11 +257,12 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg,
character->dummy = tempPlayer;
- for (int i = 0; i < 6; i++)
- {
- character->data.mStats[i + Attributes::STR].base
- = msg.readUInt8("stat");
- }
+ character->data.mStats[Attributes::STR].base = msg.readUInt8("str");
+ character->data.mStats[Attributes::AGI].base = msg.readUInt8("agi");
+ character->data.mStats[Attributes::VIT].base = msg.readUInt8("vit");
+ character->data.mStats[Attributes::INT].base = msg.readUInt8("int");
+ character->data.mStats[Attributes::DEX].base = msg.readUInt8("dex");
+ character->data.mStats[Attributes::LUK].base = msg.readUInt8("luk");
character->slot = msg.readInt16("character slot id");
msg.readInt16("rename");
diff --git a/src/net/eathena/playerhandler.cpp b/src/net/eathena/playerhandler.cpp
index a4e4586f2..f2627c605 100644
--- a/src/net/eathena/playerhandler.cpp
+++ b/src/net/eathena/playerhandler.cpp
@@ -227,7 +227,7 @@ void PlayerHandler::emote(const uint8_t emoteId) const
outMsg.writeInt8(emoteId, "emote id");
}
-void PlayerHandler::increaseAttribute(const int attr) const
+void PlayerHandler::increaseAttribute(const AttributesT attr) const
{
if (attr >= Attributes::STR && attr <= Attributes::LUK)
{
diff --git a/src/net/eathena/playerhandler.h b/src/net/eathena/playerhandler.h
index fc84db326..49572f0b1 100644
--- a/src/net/eathena/playerhandler.h
+++ b/src/net/eathena/playerhandler.h
@@ -44,7 +44,7 @@ class PlayerHandler final : public MessageHandler, public Ea::PlayerHandler
void stopAttack() const override final;
void emote(const uint8_t emoteId) const override final;
- void increaseAttribute(const int attr) const override final;
+ void increaseAttribute(const AttributesT attr) const override final;
void increaseSkill(const uint16_t skillId) const override final;
void pickUp(const FloorItem *const floorItem) const override final;
diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h
index 5fde7db54..6f31cf7ac 100644
--- a/src/net/playerhandler.h
+++ b/src/net/playerhandler.h
@@ -25,6 +25,7 @@
#include "flooritem.h"
+#include "enums/being/attributes.h"
#include "enums/being/beingaction.h"
#include "enums/simpletypes/beingid.h"
@@ -49,9 +50,9 @@ class PlayerHandler notfinal
virtual void emote(const uint8_t emoteId) const = 0;
- virtual void increaseAttribute(const int attr) const = 0;
+ virtual void increaseAttribute(const AttributesT attr) const = 0;
- virtual void decreaseAttribute(const int attr) const = 0;
+ virtual void decreaseAttribute(const AttributesT attr) const = 0;
virtual void increaseSkill(const uint16_t skillId) const = 0;
diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp
index 0ae7bfc4f..6662009b3 100644
--- a/src/net/tmwa/charserverhandler.cpp
+++ b/src/net/tmwa/charserverhandler.cpp
@@ -147,7 +147,7 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg,
PlayerInfoBackend &data = character->data;
data.mAttributes[Attributes::EXP] = msg.readInt32("exp");
data.mAttributes[Attributes::MONEY] = msg.readInt32("money");
- Stat &jobStat = data.mStats[static_cast<size_t>(Attributes::JOB)];
+ Stat &jobStat = data.mStats[Attributes::JOB];
jobStat.exp = msg.readInt32("job");
const int temp = msg.readInt32("job level");
@@ -197,11 +197,12 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg,
character->dummy = tempPlayer;
- for (int i = 0; i < 6; i++)
- {
- character->data.mStats[i + Attributes::STR].base
- = msg.readUInt8("stat");
- }
+ character->data.mStats[Attributes::STR].base = msg.readUInt8("str");
+ character->data.mStats[Attributes::AGI].base = msg.readUInt8("agi");
+ character->data.mStats[Attributes::VIT].base = msg.readUInt8("vit");
+ character->data.mStats[Attributes::INT].base = msg.readUInt8("int");
+ character->data.mStats[Attributes::DEX].base = msg.readUInt8("dex");
+ character->data.mStats[Attributes::LUK].base = msg.readUInt8("luk");
if (withColors)
{
diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp
index 95b157c00..d2871a456 100644
--- a/src/net/tmwa/playerhandler.cpp
+++ b/src/net/tmwa/playerhandler.cpp
@@ -146,7 +146,7 @@ void PlayerHandler::emote(const uint8_t emoteId) const
outMsg.writeInt8(emoteId, "emote id");
}
-void PlayerHandler::increaseAttribute(const int attr) const
+void PlayerHandler::increaseAttribute(const AttributesT attr) const
{
if (attr >= Attributes::STR && attr <= Attributes::LUK)
{
diff --git a/src/net/tmwa/playerhandler.h b/src/net/tmwa/playerhandler.h
index d8f159e8b..d831d7ab3 100644
--- a/src/net/tmwa/playerhandler.h
+++ b/src/net/tmwa/playerhandler.h
@@ -44,7 +44,7 @@ class PlayerHandler final : public MessageHandler, public Ea::PlayerHandler
void stopAttack() const override final;
void emote(const uint8_t emoteId) const override final;
- void increaseAttribute(const int attr) const override final;
+ void increaseAttribute(const AttributesT attr) const override final;
void increaseSkill(const uint16_t skillId) const override final;
void pickUp(const FloorItem *const floorItem) const override final;