diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-05-20 18:28:49 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-05-20 18:28:49 +0300 |
commit | 2f879820ee0e07b94a7c8189b8b7ab0720c3e208 (patch) | |
tree | 0d9c1a55cfb304c5e3fa5ea81b0202cb0e7f307d | |
parent | d4b88a7ebce6222c34928c49925f972515593e89 (diff) | |
download | manaplus-2f879820ee0e07b94a7c8189b8b7ab0720c3e208.tar.gz manaplus-2f879820ee0e07b94a7c8189b8b7ab0720c3e208.tar.bz2 manaplus-2f879820ee0e07b94a7c8189b8b7ab0720c3e208.tar.xz manaplus-2f879820ee0e07b94a7c8189b8b7ab0720c3e208.zip |
Move partyshare into separate file.
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/net/ea/gui/partytab.cpp | 28 | ||||
-rw-r--r-- | src/net/ea/partyhandler.cpp | 40 | ||||
-rw-r--r-- | src/net/ea/partyhandler.h | 8 | ||||
-rw-r--r-- | src/net/eathena/partyhandler.cpp | 8 | ||||
-rw-r--r-- | src/net/eathena/partyhandler.h | 5 | ||||
-rw-r--r-- | src/net/partyhandler.h | 18 | ||||
-rw-r--r-- | src/net/partyshare.h | 37 | ||||
-rw-r--r-- | src/net/tmwa/partyhandler.cpp | 8 | ||||
-rw-r--r-- | src/net/tmwa/partyhandler.h | 5 |
11 files changed, 99 insertions, 60 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1272714af..f69598c91 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -496,6 +496,7 @@ SET(SRCS net/net.h net/netconsts.h net/partyhandler.h + net/partyshare.h net/pethandler.h net/playerhandler.h net/registrationoptions.h diff --git a/src/Makefile.am b/src/Makefile.am index e1362e8ae..8f22a71bf 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -608,6 +608,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ net/netconsts.h \ net/npchandler.h \ net/partyhandler.h \ + net/partyshare.h \ net/pethandler.h \ net/playerhandler.h \ net/registrationoptions.h \ diff --git a/src/net/ea/gui/partytab.cpp b/src/net/ea/gui/partytab.cpp index 659ee9660..15ef5fc80 100644 --- a/src/net/ea/gui/partytab.cpp +++ b/src/net/ea/gui/partytab.cpp @@ -102,22 +102,22 @@ bool PartyTab::handleCommand(const std::string &restrict type, { switch (Net::getPartyHandler()->getShareItems()) { - case PARTY_SHARE: + case Net::PartyShare::YES: // TRANSLATORS: chat message chatLog(_("Item sharing enabled."), ChatMsgType::BY_SERVER); return true; - case PARTY_SHARE_NO: + case Net::PartyShare::NO: // TRANSLATORS: chat message chatLog(_("Item sharing disabled."), ChatMsgType::BY_SERVER); return true; - case PARTY_SHARE_NOT_POSSIBLE: + case Net::PartyShare::NOT_POSSIBLE: // TRANSLATORS: chat message chatLog(_("Item sharing not possible."), ChatMsgType::BY_SERVER); return true; - case PARTY_SHARE_UNKNOWN: + case Net::PartyShare::UNKNOWN: // TRANSLATORS: chat message chatLog(_("Item sharing unknown."), ChatMsgType::BY_SERVER); @@ -132,10 +132,12 @@ bool PartyTab::handleCommand(const std::string &restrict type, switch (opt) { case 1: - Net::getPartyHandler()->setShareItems(PARTY_SHARE); + Net::getPartyHandler()->setShareItems( + Net::PartyShare::YES); break; case 0: - Net::getPartyHandler()->setShareItems(PARTY_SHARE_NO); + Net::getPartyHandler()->setShareItems( + Net::PartyShare::NO); break; case -1: chatLog(strprintf(BOOLEAN_OPTIONS, "item")); @@ -150,22 +152,22 @@ bool PartyTab::handleCommand(const std::string &restrict type, { switch (Net::getPartyHandler()->getShareExperience()) { - case PARTY_SHARE: + case Net::PartyShare::YES: // TRANSLATORS: chat message chatLog(_("Experience sharing enabled."), ChatMsgType::BY_SERVER); return true; - case PARTY_SHARE_NO: + case Net::PartyShare::NO: // TRANSLATORS: chat message chatLog(_("Experience sharing disabled."), ChatMsgType::BY_SERVER); return true; - case PARTY_SHARE_NOT_POSSIBLE: + case Net::PartyShare::NOT_POSSIBLE: // TRANSLATORS: chat message chatLog(_("Experience sharing not possible."), ChatMsgType::BY_SERVER); return true; - case PARTY_SHARE_UNKNOWN: + case Net::PartyShare::UNKNOWN: // TRANSLATORS: chat message chatLog(_("Experience sharing unknown."), ChatMsgType::BY_SERVER); @@ -180,10 +182,12 @@ bool PartyTab::handleCommand(const std::string &restrict type, switch (opt) { case 1: - Net::getPartyHandler()->setShareExperience(PARTY_SHARE); + Net::getPartyHandler()->setShareExperience( + Net::PartyShare::YES); break; case 0: - Net::getPartyHandler()->setShareExperience(PARTY_SHARE_NO); + Net::getPartyHandler()->setShareExperience( + Net::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 51ef473f1..be672f760 100644 --- a/src/net/ea/partyhandler.cpp +++ b/src/net/ea/partyhandler.cpp @@ -47,8 +47,8 @@ PartyTab *partyTab = nullptr; Party *taParty = nullptr; PartyHandler::PartyHandler() : - mShareExp(PARTY_SHARE_UNKNOWN), - mShareItems(PARTY_SHARE_UNKNOWN) + mShareExp(Net::PartyShare::UNKNOWN), + mShareItems(Net::PartyShare::UNKNOWN) { taParty = Party::getParty(1); } @@ -253,22 +253,22 @@ void PartyHandler::processPartySettings(Net::MessageIn &msg) switch (exp) { - case PARTY_SHARE: - if (mShareExp == PARTY_SHARE) + case Net::PartyShare::YES: + if (mShareExp == Net::PartyShare::YES) break; - mShareExp = PARTY_SHARE; + mShareExp = Net::PartyShare::YES; NotifyManager::notify(NotifyManager::PARTY_EXP_SHARE_ON); break; - case PARTY_SHARE_NO: - if (mShareExp == PARTY_SHARE_NO) + case Net::PartyShare::NO: + if (mShareExp == Net::PartyShare::NO) break; - mShareExp = PARTY_SHARE_NO; + mShareExp = Net::PartyShare::NO; NotifyManager::notify(NotifyManager::PARTY_EXP_SHARE_OFF); break; - case PARTY_SHARE_NOT_POSSIBLE: - if (mShareExp == PARTY_SHARE_NOT_POSSIBLE) + case Net::PartyShare::NOT_POSSIBLE: + if (mShareExp == Net::PartyShare::NOT_POSSIBLE) break; - mShareExp = PARTY_SHARE_NOT_POSSIBLE; + mShareExp = Net::PartyShare::NOT_POSSIBLE; NotifyManager::notify(NotifyManager::PARTY_EXP_SHARE_ERROR); break; default: @@ -278,22 +278,22 @@ void PartyHandler::processPartySettings(Net::MessageIn &msg) switch (item) { - case PARTY_SHARE: - if (mShareItems == PARTY_SHARE) + case Net::PartyShare::YES: + if (mShareItems == Net::PartyShare::YES) break; - mShareItems = PARTY_SHARE; + mShareItems = Net::PartyShare::YES; NotifyManager::notify(NotifyManager::PARTY_ITEM_SHARE_ON); break; - case PARTY_SHARE_NO: - if (mShareItems == PARTY_SHARE_NO) + case Net::PartyShare::NO: + if (mShareItems == Net::PartyShare::NO) break; - mShareItems = PARTY_SHARE_NO; + mShareItems = Net::PartyShare::NO; NotifyManager::notify(NotifyManager::PARTY_ITEM_SHARE_OFF); break; - case PARTY_SHARE_NOT_POSSIBLE: - if (mShareItems == PARTY_SHARE_NOT_POSSIBLE) + case Net::PartyShare::NOT_POSSIBLE: + if (mShareItems == Net::PartyShare::NOT_POSSIBLE) break; - mShareItems = PARTY_SHARE_NOT_POSSIBLE; + mShareItems = Net::PartyShare::NOT_POSSIBLE; NotifyManager::notify(NotifyManager::PARTY_ITEM_SHARE_ERROR); break; default: diff --git a/src/net/ea/partyhandler.h b/src/net/ea/partyhandler.h index 24923bd4a..19f66a238 100644 --- a/src/net/ea/partyhandler.h +++ b/src/net/ea/partyhandler.h @@ -46,10 +46,10 @@ class PartyHandler : public Net::PartyHandler void join(const int partyId) const override final; - PartyShare getShareExperience() const override final A_WARN_UNUSED + Net::PartyShare getShareExperience() const override final A_WARN_UNUSED { return mShareExp; } - PartyShare getShareItems() const override final A_WARN_UNUSED + Net::PartyShare getShareItems() const override final A_WARN_UNUSED { return mShareItems; } static void reload(); @@ -79,8 +79,8 @@ class PartyHandler : public Net::PartyHandler virtual void processPartyMessage(Net::MessageIn &msg) const; protected: - PartyShare mShareExp; - PartyShare mShareItems; + Net::PartyShare mShareExp; + Net::PartyShare mShareItems; }; extern PartyTab *partyTab; diff --git a/src/net/eathena/partyhandler.cpp b/src/net/eathena/partyhandler.cpp index b41fd36d1..e1c385c4c 100644 --- a/src/net/eathena/partyhandler.cpp +++ b/src/net/eathena/partyhandler.cpp @@ -183,9 +183,9 @@ void PartyHandler::chat(const std::string &text) const outMsg.writeString(text, static_cast<int>(text.length())); } -void PartyHandler::setShareExperience(const PartyShare share) const +void PartyHandler::setShareExperience(const Net::PartyShare share) const { - if (share == PARTY_SHARE_NOT_POSSIBLE) + if (share == Net::PartyShare::NOT_POSSIBLE) return; MessageOut outMsg(CMSG_PARTY_SETTINGS); @@ -193,9 +193,9 @@ void PartyHandler::setShareExperience(const PartyShare share) const outMsg.writeInt16(static_cast<int16_t>(mShareItems)); } -void PartyHandler::setShareItems(const PartyShare share) const +void PartyHandler::setShareItems(const Net::PartyShare share) const { - if (share == PARTY_SHARE_NOT_POSSIBLE) + if (share == Net::PartyShare::NOT_POSSIBLE) return; MessageOut outMsg(CMSG_PARTY_SETTINGS); diff --git a/src/net/eathena/partyhandler.h b/src/net/eathena/partyhandler.h index 0c69f5da9..87bd50543 100644 --- a/src/net/eathena/partyhandler.h +++ b/src/net/eathena/partyhandler.h @@ -59,9 +59,10 @@ class PartyHandler final : public MessageHandler, public Ea::PartyHandler void chat(const std::string &text) const override final; - void setShareExperience(const PartyShare share) const override final; + void setShareExperience(const Net::PartyShare share) + const override final; - void setShareItems(const PartyShare share) const override final; + void setShareItems(const Net::PartyShare share) const override final; }; } // namespace EAthena diff --git a/src/net/partyhandler.h b/src/net/partyhandler.h index 4a4e8ec82..a582ba9d0 100644 --- a/src/net/partyhandler.h +++ b/src/net/partyhandler.h @@ -27,18 +27,12 @@ #include "gui/widgets/tabs/chattab.h" +#include "net/partyshare.h" + #include <string> class Being; -enum PartyShare -{ - PARTY_SHARE_UNKNOWN = -1, - PARTY_SHARE_NO, - PARTY_SHARE, - PARTY_SHARE_NOT_POSSIBLE = 2 -}; - namespace Net { @@ -67,13 +61,13 @@ class PartyHandler virtual void chat(const std::string &text) const = 0; - virtual PartyShare getShareExperience() const A_WARN_UNUSED = 0; + virtual Net::PartyShare getShareExperience() const A_WARN_UNUSED = 0; - virtual void setShareExperience(const PartyShare share) const = 0; + virtual void setShareExperience(const Net::PartyShare share) const = 0; - virtual PartyShare getShareItems() const A_WARN_UNUSED = 0; + virtual Net::PartyShare getShareItems() const A_WARN_UNUSED = 0; - virtual void setShareItems(const PartyShare share) const = 0; + virtual void setShareItems(const Net::PartyShare share) const = 0; virtual void clear() const = 0; diff --git a/src/net/partyshare.h b/src/net/partyshare.h new file mode 100644 index 000000000..e35ff6382 --- /dev/null +++ b/src/net/partyshare.h @@ -0,0 +1,37 @@ +/* + * The ManaPlus Client + * Copyright (C) 2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef NET_PARTYSHARE_H +#define NET_PARTYSHARE_H + +namespace Net +{ + enum PartyShare + { + UNKNOWN = -1, + NO, + YES, + NOT_POSSIBLE = 2 + }; +} // namespace Net + +#endif // NET_PARTYSHARE_H diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp index 310d71783..634ecbff5 100644 --- a/src/net/tmwa/partyhandler.cpp +++ b/src/net/tmwa/partyhandler.cpp @@ -185,9 +185,9 @@ void PartyHandler::chat(const std::string &text) const outMsg.writeString(text, static_cast<int>(text.length())); } -void PartyHandler::setShareExperience(const PartyShare share) const +void PartyHandler::setShareExperience(const Net::PartyShare share) const { - if (share == PARTY_SHARE_NOT_POSSIBLE) + if (share == Net::PartyShare::NOT_POSSIBLE) return; MessageOut outMsg(CMSG_PARTY_SETTINGS); @@ -195,9 +195,9 @@ void PartyHandler::setShareExperience(const PartyShare share) const outMsg.writeInt16(static_cast<int16_t>(mShareItems)); } -void PartyHandler::setShareItems(const PartyShare share) const +void PartyHandler::setShareItems(const Net::PartyShare share) const { - if (share == PARTY_SHARE_NOT_POSSIBLE) + if (share == Net::PartyShare::NOT_POSSIBLE) return; MessageOut outMsg(CMSG_PARTY_SETTINGS); diff --git a/src/net/tmwa/partyhandler.h b/src/net/tmwa/partyhandler.h index 6a52c3321..ae4249143 100644 --- a/src/net/tmwa/partyhandler.h +++ b/src/net/tmwa/partyhandler.h @@ -59,9 +59,10 @@ class PartyHandler final : public MessageHandler, public Ea::PartyHandler void chat(const std::string &text) const override final; - void setShareExperience(const PartyShare share) const override final; + void setShareExperience(const Net::PartyShare share) + const override final; - void setShareItems(const PartyShare share) const override final; + void setShareItems(const Net::PartyShare share) const override final; }; } // namespace TmwAthena |