summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-06-03 14:31:43 +0300
committerAndrei Karas <akaras@inbox.ru>2015-06-03 14:31:43 +0300
commitb643a5c48d53dbeca7672e3c8b5182f9d698abcb (patch)
treeab596dc9a0c573764c1e0b427f22303faa1bfec1
parent6281c1281fe85a1c75155df44c99aa843561a4f2 (diff)
downloadmanaplus-b643a5c48d53dbeca7672e3c8b5182f9d698abcb.tar.gz
manaplus-b643a5c48d53dbeca7672e3c8b5182f9d698abcb.tar.bz2
manaplus-b643a5c48d53dbeca7672e3c8b5182f9d698abcb.tar.xz
manaplus-b643a5c48d53dbeca7672e3c8b5182f9d698abcb.zip
Convert PacketShare enum into strong typed enum.
-rw-r--r--src/enums/net/partyshare.h21
-rw-r--r--src/gui/widgets/tabs/chat/partytab.cpp24
-rw-r--r--src/net/ea/partyhandler.cpp48
-rw-r--r--src/net/ea/partyhandler.h14
-rw-r--r--src/net/eathena/partyhandler.cpp14
-rw-r--r--src/net/eathena/partyhandler.h6
-rw-r--r--src/net/partyhandler.h11
-rw-r--r--src/net/tmwa/partyhandler.cpp14
-rw-r--r--src/net/tmwa/partyhandler.h6
9 files changed, 75 insertions, 83 deletions
diff --git a/src/enums/net/partyshare.h b/src/enums/net/partyshare.h
index ad07ecf72..82f55e13d 100644
--- a/src/enums/net/partyshare.h
+++ b/src/enums/net/partyshare.h
@@ -23,18 +23,15 @@
#ifndef ENUMS_NET_PARTYSHARE_H
#define ENUMS_NET_PARTYSHARE_H
-namespace Net
+#include "enums/simpletypes/enumdefines.h"
+
+enumStart(PartyShare)
{
- namespace PartyShare
- {
- enum Type
- {
- UNKNOWN = -1,
- NO,
- YES,
- NOT_POSSIBLE = 2
- };
- }
-} // namespace Net
+ UNKNOWN = -1,
+ NO,
+ YES,
+ NOT_POSSIBLE = 2
+}
+enumEnd(PartyShare);
#endif // ENUMS_NET_PARTYSHARE_H
diff --git a/src/gui/widgets/tabs/chat/partytab.cpp b/src/gui/widgets/tabs/chat/partytab.cpp
index 489f03c94..cb458f1fe 100644
--- a/src/gui/widgets/tabs/chat/partytab.cpp
+++ b/src/gui/widgets/tabs/chat/partytab.cpp
@@ -93,22 +93,22 @@ bool PartyTab::handleCommand(const std::string &restrict type,
{
switch (partyHandler->getShareItems())
{
- case Net::PartyShare::YES:
+ case PartyShare::YES:
// TRANSLATORS: chat message
chatLog(_("Item sharing enabled."),
ChatMsgType::BY_SERVER);
return true;
- case Net::PartyShare::NO:
+ case PartyShare::NO:
// TRANSLATORS: chat message
chatLog(_("Item sharing disabled."),
ChatMsgType::BY_SERVER);
return true;
- case Net::PartyShare::NOT_POSSIBLE:
+ case PartyShare::NOT_POSSIBLE:
// TRANSLATORS: chat message
chatLog(_("Item sharing not possible."),
ChatMsgType::BY_SERVER);
return true;
- case Net::PartyShare::UNKNOWN:
+ case PartyShare::UNKNOWN:
// TRANSLATORS: chat message
chatLog(_("Item sharing unknown."),
ChatMsgType::BY_SERVER);
@@ -124,11 +124,11 @@ bool PartyTab::handleCommand(const std::string &restrict type,
{
case 1:
partyHandler->setShareItems(
- Net::PartyShare::YES);
+ PartyShare::YES);
break;
case 0:
partyHandler->setShareItems(
- Net::PartyShare::NO);
+ PartyShare::NO);
break;
case -1:
chatLog(strprintf(BOOLEAN_OPTIONS, "item"),
@@ -144,22 +144,22 @@ bool PartyTab::handleCommand(const std::string &restrict type,
{
switch (partyHandler->getShareExperience())
{
- case Net::PartyShare::YES:
+ case PartyShare::YES:
// TRANSLATORS: chat message
chatLog(_("Experience sharing enabled."),
ChatMsgType::BY_SERVER);
return true;
- case Net::PartyShare::NO:
+ case PartyShare::NO:
// TRANSLATORS: chat message
chatLog(_("Experience sharing disabled."),
ChatMsgType::BY_SERVER);
return true;
- case Net::PartyShare::NOT_POSSIBLE:
+ case PartyShare::NOT_POSSIBLE:
// TRANSLATORS: chat message
chatLog(_("Experience sharing not possible."),
ChatMsgType::BY_SERVER);
return true;
- case Net::PartyShare::UNKNOWN:
+ case PartyShare::UNKNOWN:
// TRANSLATORS: chat message
chatLog(_("Experience sharing unknown."),
ChatMsgType::BY_SERVER);
@@ -175,11 +175,11 @@ bool PartyTab::handleCommand(const std::string &restrict type,
{
case 1:
partyHandler->setShareExperience(
- Net::PartyShare::YES);
+ PartyShare::YES);
break;
case 0:
partyHandler->setShareExperience(
- Net::PartyShare::NO);
+ PartyShare::NO);
break;
case -1:
chatLog(strprintf(BOOLEAN_OPTIONS, "exp"),
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;