diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-08-28 00:47:23 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-08-28 00:47:23 +0300 |
commit | 7e0a84fc2b7493670dc8167aafb83c3811272eb3 (patch) | |
tree | 9c4323b69a5deb91f296638551f8ae06339803a8 /src/net/ea/partyhandler.cpp | |
parent | 60bb3d3235d4e25f5561bec1b8e717f58ff59b06 (diff) | |
download | ManaVerse-7e0a84fc2b7493670dc8167aafb83c3811272eb3.tar.gz ManaVerse-7e0a84fc2b7493670dc8167aafb83c3811272eb3.tar.bz2 ManaVerse-7e0a84fc2b7493670dc8167aafb83c3811272eb3.tar.xz ManaVerse-7e0a84fc2b7493670dc8167aafb83c3811272eb3.zip |
Move receive code from partyhandler into separate file.
Diffstat (limited to 'src/net/ea/partyhandler.cpp')
-rw-r--r-- | src/net/ea/partyhandler.cpp | 186 |
1 files changed, 10 insertions, 176 deletions
diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp index 83d5f04b4..0797e6e55 100644 --- a/src/net/ea/partyhandler.cpp +++ b/src/net/ea/partyhandler.cpp @@ -35,6 +35,8 @@ #include "net/messagein.h" +#include "net/ea/partyrecv.h" + #include "gui/widgets/tabs/chat/partytab.h" #include "utils/delete2.h" @@ -44,15 +46,11 @@ namespace Ea { -Party *taParty = nullptr; -PartyShareT PartyHandler::mShareExp = PartyShare::UNKNOWN; -PartyShareT PartyHandler::mShareItems = PartyShare::UNKNOWN; - PartyHandler::PartyHandler() : Net::PartyHandler() { - mShareExp = PartyShare::UNKNOWN; - mShareItems = PartyShare::UNKNOWN; + PartyRecv::mShareExp = PartyShare::UNKNOWN; + PartyRecv::mShareItems = PartyShare::UNKNOWN; taParty = Party::getParty(1); } @@ -75,183 +73,19 @@ void PartyHandler::clear() const taParty = nullptr; } -void PartyHandler::processPartyCreate(Net::MessageIn &msg) -{ - if (msg.readUInt8("flag")) - NotifyManager::notify(NotifyTypes::PARTY_CREATE_FAILED); - else - NotifyManager::notify(NotifyTypes::PARTY_CREATED); -} - -void PartyHandler::processPartySettingsContinue(Net::MessageIn &msg, - const PartyShareT exp, - const PartyShareT item) -{ - switch (exp) - { - case PartyShare::YES: - if (mShareExp == PartyShare::YES) - break; - mShareExp = PartyShare::YES; - NotifyManager::notify(NotifyTypes::PARTY_EXP_SHARE_ON); - break; - case PartyShare::NO: - if (mShareExp == PartyShare::NO) - break; - mShareExp = PartyShare::NO; - NotifyManager::notify(NotifyTypes::PARTY_EXP_SHARE_OFF); - break; - case PartyShare::NOT_POSSIBLE: - if (mShareExp == PartyShare::NOT_POSSIBLE) - break; - mShareExp = PartyShare::NOT_POSSIBLE; - NotifyManager::notify(NotifyTypes::PARTY_EXP_SHARE_ERROR); - break; - default: - case PartyShare::UNKNOWN: - UNIMPLIMENTEDPACKET; - break; - } - - switch (item) - { - case PartyShare::YES: - if (mShareItems == PartyShare::YES) - break; - mShareItems = PartyShare::YES; - NotifyManager::notify(NotifyTypes::PARTY_ITEM_SHARE_ON); - break; - case PartyShare::NO: - if (mShareItems == PartyShare::NO) - break; - mShareItems = PartyShare::NO; - NotifyManager::notify(NotifyTypes::PARTY_ITEM_SHARE_OFF); - break; - case PartyShare::NOT_POSSIBLE: - if (mShareItems == PartyShare::NOT_POSSIBLE) - break; - mShareItems = PartyShare::NOT_POSSIBLE; - NotifyManager::notify(NotifyTypes::PARTY_ITEM_SHARE_ERROR); - break; - default: - case PartyShare::UNKNOWN: - UNIMPLIMENTEDPACKET; - break; - } -} - -void PartyHandler::processPartyLeave(Net::MessageIn &msg) -{ - const BeingId id = msg.readBeingId("account id"); - const std::string nick = msg.readString(24, "nick"); - const int reason = msg.readUInt8("flag"); - if (!localPlayer) - return; - - if (id == localPlayer->getId()) - { - switch (reason) - { - case 0: - default: - NotifyManager::notify(NotifyTypes::PARTY_LEFT); - break; - - case 1: - NotifyManager::notify(NotifyTypes::PARTY_KICKED); - break; - - case 2: - NotifyManager::notify(NotifyTypes::PARTY_LEFT_DENY); - break; - - case 3: - NotifyManager::notify(NotifyTypes::PARTY_KICK_DENY); - break; - } - - if (reason >= 2) - return; - - if (Ea::taParty) - { - Ea::taParty->removeFromMembers(); - Ea::taParty->clearMembers(); - } - - delete2(partyTab) - - if (socialWindow && Ea::taParty) - socialWindow->removeTab(Ea::taParty); - localPlayer->setPartyName(""); - } - else - { - switch (reason) - { - case 0: - default: - NotifyManager::notify(NotifyTypes::PARTY_USER_LEFT, nick); - break; - - case 1: - NotifyManager::notify(NotifyTypes::PARTY_USER_KICKED, nick); - break; - - case 2: - NotifyManager::notify(NotifyTypes::PARTY_USER_LEFT_DENY, nick); - break; - - case 3: - NotifyManager::notify(NotifyTypes::PARTY_USER_KICK_DENY, nick); - break; - } - - if (reason >= 2) - return; - - if (actorManager) - { - Being *const b = actorManager->findBeing(id); - if (b && b->getType() == ActorType::Player) - { - b->setParty(nullptr); - b->setPartyName(""); - } - } - if (Ea::taParty) - Ea::taParty->removeMember(id); - } -} - -void PartyHandler::processPartyUpdateCoords(Net::MessageIn &msg) +ChatTab *PartyHandler::getTab() const { - const BeingId id = msg.readBeingId("account id"); - PartyMember *m = nullptr; - if (Ea::taParty) - m = Ea::taParty->getMember(id); - if (m) - { - m->setX(msg.readInt16("x")); - m->setY(msg.readInt16("y")); - } - else - { - msg.readInt16("x"); - msg.readInt16("y"); - } + return partyTab; } -ChatTab *PartyHandler::getTab() const +PartyShareT PartyHandler::getShareExperience() const { - return partyTab; + return PartyRecv::mShareExp; } -void PartyHandler::createTab() +PartyShareT PartyHandler::getShareItems() const { - partyTab = new PartyTab(chatWindow); - if (config.getBoolValue("showChatHistory")) - partyTab->loadFromLogFile("#Party"); + return PartyRecv::mShareItems; } } // namespace Ea |