diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-06-03 14:31:43 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-06-03 14:31:43 +0300 |
commit | b643a5c48d53dbeca7672e3c8b5182f9d698abcb (patch) | |
tree | ab596dc9a0c573764c1e0b427f22303faa1bfec1 /src/net | |
parent | 6281c1281fe85a1c75155df44c99aa843561a4f2 (diff) | |
download | manaplus-b643a5c48d53dbeca7672e3c8b5182f9d698abcb.tar.gz manaplus-b643a5c48d53dbeca7672e3c8b5182f9d698abcb.tar.bz2 manaplus-b643a5c48d53dbeca7672e3c8b5182f9d698abcb.tar.xz manaplus-b643a5c48d53dbeca7672e3c8b5182f9d698abcb.zip |
Convert PacketShare enum into strong typed enum.
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/ea/partyhandler.cpp | 48 | ||||
-rw-r--r-- | src/net/ea/partyhandler.h | 14 | ||||
-rw-r--r-- | src/net/eathena/partyhandler.cpp | 14 | ||||
-rw-r--r-- | src/net/eathena/partyhandler.h | 6 | ||||
-rw-r--r-- | src/net/partyhandler.h | 11 | ||||
-rw-r--r-- | src/net/tmwa/partyhandler.cpp | 14 | ||||
-rw-r--r-- | src/net/tmwa/partyhandler.h | 6 |
7 files changed, 54 insertions, 59 deletions
diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp index 1af9ba7ef..6b0be87e9 100644 --- a/src/net/ea/partyhandler.cpp +++ b/src/net/ea/partyhandler.cpp @@ -45,14 +45,14 @@ namespace Ea { Party *taParty = nullptr; -Net::PartyShare::Type PartyHandler::mShareExp = Net::PartyShare::UNKNOWN; -Net::PartyShare::Type PartyHandler::mShareItems = Net::PartyShare::UNKNOWN; +PartyShareT PartyHandler::mShareExp = PartyShare::UNKNOWN; +PartyShareT PartyHandler::mShareItems = PartyShare::UNKNOWN; PartyHandler::PartyHandler() : Net::PartyHandler() { - mShareExp = Net::PartyShare::UNKNOWN; - mShareItems = Net::PartyShare::UNKNOWN; + mShareExp = PartyShare::UNKNOWN; + mShareItems = PartyShare::UNKNOWN; taParty = Party::getParty(1); } @@ -84,27 +84,27 @@ void PartyHandler::processPartyCreate(Net::MessageIn &msg) } void PartyHandler::processPartySettingsContinue(Net::MessageIn &msg, - const int16_t exp, - const int16_t item) + const PartyShareT exp, + const PartyShareT item) { switch (exp) { - case Net::PartyShare::YES: - if (mShareExp == Net::PartyShare::YES) + case PartyShare::YES: + if (mShareExp == PartyShare::YES) break; - mShareExp = Net::PartyShare::YES; + mShareExp = PartyShare::YES; NotifyManager::notify(NotifyTypes::PARTY_EXP_SHARE_ON); break; - case Net::PartyShare::NO: - if (mShareExp == Net::PartyShare::NO) + case PartyShare::NO: + if (mShareExp == PartyShare::NO) break; - mShareExp = Net::PartyShare::NO; + mShareExp = PartyShare::NO; NotifyManager::notify(NotifyTypes::PARTY_EXP_SHARE_OFF); break; - case Net::PartyShare::NOT_POSSIBLE: - if (mShareExp == Net::PartyShare::NOT_POSSIBLE) + case PartyShare::NOT_POSSIBLE: + if (mShareExp == PartyShare::NOT_POSSIBLE) break; - mShareExp = Net::PartyShare::NOT_POSSIBLE; + mShareExp = PartyShare::NOT_POSSIBLE; NotifyManager::notify(NotifyTypes::PARTY_EXP_SHARE_ERROR); break; default: @@ -114,22 +114,22 @@ void PartyHandler::processPartySettingsContinue(Net::MessageIn &msg, switch (item) { - case Net::PartyShare::YES: - if (mShareItems == Net::PartyShare::YES) + case PartyShare::YES: + if (mShareItems == PartyShare::YES) break; - mShareItems = Net::PartyShare::YES; + mShareItems = PartyShare::YES; NotifyManager::notify(NotifyTypes::PARTY_ITEM_SHARE_ON); break; - case Net::PartyShare::NO: - if (mShareItems == Net::PartyShare::NO) + case PartyShare::NO: + if (mShareItems == PartyShare::NO) break; - mShareItems = Net::PartyShare::NO; + mShareItems = PartyShare::NO; NotifyManager::notify(NotifyTypes::PARTY_ITEM_SHARE_OFF); break; - case Net::PartyShare::NOT_POSSIBLE: - if (mShareItems == Net::PartyShare::NOT_POSSIBLE) + case PartyShare::NOT_POSSIBLE: + if (mShareItems == PartyShare::NOT_POSSIBLE) break; - mShareItems = Net::PartyShare::NOT_POSSIBLE; + mShareItems = PartyShare::NOT_POSSIBLE; NotifyManager::notify(NotifyTypes::PARTY_ITEM_SHARE_ERROR); break; default: diff --git a/src/net/ea/partyhandler.h b/src/net/ea/partyhandler.h index 12dec8c6c..453aced1d 100644 --- a/src/net/ea/partyhandler.h +++ b/src/net/ea/partyhandler.h @@ -44,12 +44,10 @@ class PartyHandler notfinal : public Net::PartyHandler void join(const int partyId) const override final; - Net::PartyShare::Type getShareExperience() - const override final A_WARN_UNUSED + PartyShareT getShareExperience() const override final A_WARN_UNUSED { return mShareExp; } - Net::PartyShare::Type getShareItems() - const override final A_WARN_UNUSED + PartyShareT getShareItems() const override final A_WARN_UNUSED { return mShareItems; } static void reload(); @@ -68,11 +66,11 @@ class PartyHandler notfinal : public Net::PartyHandler static void processPartyUpdateCoords(Net::MessageIn &msg); static void processPartySettingsContinue(Net::MessageIn &msg, - const int16_t exp, - const int16_t item); + const PartyShareT exp, + const PartyShareT item); - static Net::PartyShare::Type mShareExp; - static Net::PartyShare::Type mShareItems; + static PartyShareT mShareExp; + static PartyShareT mShareItems; }; extern Party *taParty; diff --git a/src/net/eathena/partyhandler.cpp b/src/net/eathena/partyhandler.cpp index d886270ae..f22e5aabc 100644 --- a/src/net/eathena/partyhandler.cpp +++ b/src/net/eathena/partyhandler.cpp @@ -199,9 +199,9 @@ void PartyHandler::chat(const std::string &text) const } // +++ must be 3 types item, exp, pickup -void PartyHandler::setShareExperience(const Net::PartyShare::Type share) const +void PartyHandler::setShareExperience(const PartyShareT share) const { - if (share == Net::PartyShare::NOT_POSSIBLE) + if (share == PartyShare::NOT_POSSIBLE) return; createOutPacket(CMSG_PARTY_SETTINGS); @@ -210,9 +210,9 @@ void PartyHandler::setShareExperience(const Net::PartyShare::Type share) const } // +++ must be 3 types item, exp, pickup -void PartyHandler::setShareItems(const Net::PartyShare::Type share) const +void PartyHandler::setShareItems(const PartyShareT share) const { - if (share == Net::PartyShare::NOT_POSSIBLE) + if (share == PartyShare::NOT_POSSIBLE) return; createOutPacket(CMSG_PARTY_SETTINGS); @@ -266,8 +266,10 @@ void PartyHandler::processPartySettings(Net::MessageIn &msg) } msg.readInt32("party exp"); - const int16_t exp = msg.readInt8("exp"); - const int16_t item = msg.readInt8("item"); + const PartyShareT exp = static_cast<PartyShareT>( + msg.readInt8("share exp")); + const PartyShareT item = static_cast<PartyShareT>( + msg.readInt8("share item")); processPartySettingsContinue(msg, exp, item); } diff --git a/src/net/eathena/partyhandler.h b/src/net/eathena/partyhandler.h index 614307954..22cabd81e 100644 --- a/src/net/eathena/partyhandler.h +++ b/src/net/eathena/partyhandler.h @@ -56,11 +56,9 @@ class PartyHandler final : public MessageHandler, public Ea::PartyHandler void chat(const std::string &text) const override final; - void setShareExperience(const Net::PartyShare::Type share) - const override final; + void setShareExperience(const PartyShareT share) const override final; - void setShareItems(const Net::PartyShare::Type share) - const override final; + void setShareItems(const PartyShareT share) const override final; void changeLeader(const std::string &name) const override final; diff --git a/src/net/partyhandler.h b/src/net/partyhandler.h index 2d148d247..f93f07b44 100644 --- a/src/net/partyhandler.h +++ b/src/net/partyhandler.h @@ -54,16 +54,13 @@ class PartyHandler notfinal virtual void chat(const std::string &text) const = 0; - virtual Net::PartyShare::Type getShareExperience() - const A_WARN_UNUSED = 0; + virtual PartyShareT getShareExperience() const A_WARN_UNUSED = 0; - virtual void setShareExperience(const Net::PartyShare::Type - share) const = 0; + virtual void setShareExperience(const PartyShareT share) const = 0; - virtual Net::PartyShare::Type getShareItems() const A_WARN_UNUSED = 0; + virtual PartyShareT getShareItems() const A_WARN_UNUSED = 0; - virtual void setShareItems(const Net::PartyShare::Type - share) const = 0; + virtual void setShareItems(const PartyShareT share) const = 0; virtual void changeLeader(const std::string &name) const = 0; diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp index 8bb143d75..f503b666c 100644 --- a/src/net/tmwa/partyhandler.cpp +++ b/src/net/tmwa/partyhandler.cpp @@ -183,9 +183,9 @@ void PartyHandler::chat(const std::string &text) const outMsg.writeString(text, static_cast<int>(text.length()), "text"); } -void PartyHandler::setShareExperience(const Net::PartyShare::Type share) const +void PartyHandler::setShareExperience(const PartyShareT share) const { - if (share == Net::PartyShare::NOT_POSSIBLE) + if (share == PartyShare::NOT_POSSIBLE) return; createOutPacket(CMSG_PARTY_SETTINGS); @@ -193,9 +193,9 @@ void PartyHandler::setShareExperience(const Net::PartyShare::Type share) const outMsg.writeInt16(static_cast<int16_t>(mShareItems), "share items"); } -void PartyHandler::setShareItems(const Net::PartyShare::Type share) const +void PartyHandler::setShareItems(const PartyShareT share) const { - if (share == Net::PartyShare::NOT_POSSIBLE) + if (share == PartyShare::NOT_POSSIBLE) return; createOutPacket(CMSG_PARTY_SETTINGS); @@ -214,8 +214,10 @@ void PartyHandler::processPartySettings(Net::MessageIn &msg) } // These seem to indicate the sharing mode for exp and items - const int16_t exp = msg.readInt16("share exp"); - const int16_t item = msg.readInt16("share items"); + const PartyShareT exp = static_cast<PartyShareT>( + msg.readInt16("share exp")); + const PartyShareT item = static_cast<PartyShareT>( + msg.readInt16("share items")); processPartySettingsContinue(msg, exp, item); } diff --git a/src/net/tmwa/partyhandler.h b/src/net/tmwa/partyhandler.h index 3768964a5..af18e2d14 100644 --- a/src/net/tmwa/partyhandler.h +++ b/src/net/tmwa/partyhandler.h @@ -56,11 +56,9 @@ class PartyHandler final : public MessageHandler, public Ea::PartyHandler void chat(const std::string &text) const override final; - void setShareExperience(const Net::PartyShare::Type share) - const override final; + void setShareExperience(const PartyShareT share) const override final; - void setShareItems(const Net::PartyShare::Type - share) const override final; + void setShareItems(const PartyShareT share) const override final; void changeLeader(const std::string &name) const override final; |