diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-08-27 21:26:15 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-08-27 21:26:15 +0300 |
commit | e6e9b2c524f28e18f7efa582ee0dd0ee1e1420df (patch) | |
tree | 02e52352e86985edc08308b22731473da7c9b4a9 /src/net/eathena | |
parent | 2dbb62e760853f88a19e6e783870de156d52f8c6 (diff) | |
download | manaverse-e6e9b2c524f28e18f7efa582ee0dd0ee1e1420df.tar.gz manaverse-e6e9b2c524f28e18f7efa582ee0dd0ee1e1420df.tar.bz2 manaverse-e6e9b2c524f28e18f7efa582ee0dd0ee1e1420df.tar.xz manaverse-e6e9b2c524f28e18f7efa582ee0dd0ee1e1420df.zip |
Move receive code from npchandler into separate file.
Diffstat (limited to 'src/net/eathena')
-rw-r--r-- | src/net/eathena/npchandler.cpp | 122 | ||||
-rw-r--r-- | src/net/eathena/npchandler.h | 15 | ||||
-rw-r--r-- | src/net/eathena/npcrecv.cpp | 109 | ||||
-rw-r--r-- | src/net/eathena/npcrecv.h | 42 |
4 files changed, 181 insertions, 107 deletions
diff --git a/src/net/eathena/npchandler.cpp b/src/net/eathena/npchandler.cpp index 7b376fbeb..1ed4cb077 100644 --- a/src/net/eathena/npchandler.cpp +++ b/src/net/eathena/npchandler.cpp @@ -30,7 +30,10 @@ #include "gui/widgets/createwidget.h" +#include "net/ea/npcrecv.h" + #include "net/eathena/messageout.h" +#include "net/eathena/npcrecv.h" #include "net/eathena/protocol.h" #include "net/ea/eaprotocol.h" @@ -74,70 +77,70 @@ void NpcHandler::handleMessage(Net::MessageIn &msg) switch (msg.getId()) { case SMSG_NPC_CHOICE: - processNpcChoice(msg); + Ea::NpcRecv::processNpcChoice(msg); break; case SMSG_NPC_MESSAGE: - processNpcMessage(msg); + Ea::NpcRecv::processNpcMessage(msg); break; case SMSG_NPC_CLOSE: - processNpcClose(msg); + Ea::NpcRecv::processNpcClose(msg); break; case SMSG_NPC_NEXT: - processNpcNext(msg); + Ea::NpcRecv::processNpcNext(msg); break; case SMSG_NPC_INT_INPUT: - processNpcIntInput(msg); + Ea::NpcRecv::processNpcIntInput(msg); break; case SMSG_NPC_STR_INPUT: - processNpcStrInput(msg); + Ea::NpcRecv::processNpcStrInput(msg); break; case SMSG_NPC_CUTIN: - processNpcCutin(msg); + NpcRecv::processNpcCutin(msg); break; case SMSG_NPC_VIEWPOINT: - processNpcViewPoint(msg); + NpcRecv::processNpcViewPoint(msg); break; case SMSG_NPC_SHOW_PROGRESS_BAR: - processNpcShowProgressBar(msg); + NpcRecv::processNpcShowProgressBar(msg); break; case SMSG_NPC_CLOSE_TIMEOUT: - processNpcCloseTimeout(msg); + NpcRecv::processNpcCloseTimeout(msg); break; case SMSG_NPC_COMMAND: - processNpcCommand(msg); + Ea::NpcRecv::processNpcCommand(msg); break; case SMSG_NPC_CHANGETITLE: - processChangeTitle(msg); + Ea::NpcRecv::processChangeTitle(msg); break; case SMSG_NPC_AREA: - processArea(msg); + NpcRecv::processArea(msg); break; case SMSG_NPC_SHOW_DIGIT: - processShowDigit(msg); + NpcRecv::processShowDigit(msg); break; case SMSG_NPC_PROGRESS_BAR_ABORT: - processProgressBarAbort(msg); + NpcRecv::processProgressBarAbort(msg); break; default: break; } - mDialog = nullptr; + Ea::NpcRecv::mDialog = nullptr; } void NpcHandler::talk(const BeingId npcId) const @@ -164,8 +167,8 @@ void NpcHandler::closeDialog(const BeingId npcId) NpcDialog *const dialog = (*it).second; if (dialog) dialog->close(); - if (dialog == mDialog) - mDialog = nullptr; + if (dialog == Ea::NpcRecv::mDialog) + Ea::NpcRecv::mDialog = nullptr; NpcDialog::mNpcDialogs.erase(it); } } @@ -298,7 +301,7 @@ BeingId NpcHandler::getNpc(Net::MessageIn &msg) const BeingId npcId = msg.readBeingId("npc id"); const NpcDialogs::const_iterator diag = NpcDialog::mNpcDialogs.find(npcId); - mDialog = nullptr; + Ea::NpcRecv::mDialog = nullptr; if (msg.getId() == SMSG_NPC_VIEWPOINT) return npcId; @@ -318,88 +321,23 @@ BeingId NpcHandler::getNpc(Net::MessageIn &msg) } else { - CREATEWIDGETV(mDialog, NpcDialog, npcId); - mDialog->saveCamera(); + CREATEWIDGETV(Ea::NpcRecv::mDialog, NpcDialog, npcId); + Ea::NpcRecv::mDialog->saveCamera(); if (localPlayer) localPlayer->stopWalking(false); - NpcDialog::mNpcDialogs[npcId] = mDialog; + NpcDialog::mNpcDialogs[npcId] = Ea::NpcRecv::mDialog; } } else { NpcDialog *const dialog = diag->second; - if (mDialog && mDialog != dialog) - mDialog->restoreCamera(); - mDialog = dialog; - if (mDialog) - mDialog->saveCamera(); + if (Ea::NpcRecv::mDialog && Ea::NpcRecv::mDialog != dialog) + Ea::NpcRecv::mDialog->restoreCamera(); + Ea::NpcRecv::mDialog = dialog; + if (Ea::NpcRecv::mDialog) + Ea::NpcRecv::mDialog->saveCamera(); } return npcId; } -void NpcHandler::processNpcCutin(Net::MessageIn &msg) -{ - UNIMPLIMENTEDPACKET; - mRequestLang = false; - msg.readString(64, "image name"); - msg.readUInt8("type"); -} - -void NpcHandler::processNpcViewPoint(Net::MessageIn &msg) -{ - UNIMPLIMENTEDPACKET; - mRequestLang = false; - // +++ probably need add nav point and start moving to it - msg.readInt32("npc id"); - msg.readInt32("type"); // 0 display for 15 sec, - // 1 display until teleport, - // 2 remove - msg.readInt32("x"); - msg.readInt32("y"); - msg.readUInt8("number"); // can be used for scripts - msg.readInt32("color"); -} - -void NpcHandler::processNpcShowProgressBar(Net::MessageIn &msg) -{ - UNIMPLIMENTEDPACKET; - mRequestLang = false; - // +++ probably need show progress bar in npc dialog - msg.readInt32("color"); - msg.readInt32("seconds"); -} - -void NpcHandler::processNpcCloseTimeout(Net::MessageIn &msg) -{ - UNIMPLIMENTEDPACKET; - mRequestLang = false; - // this packet send after npc closed by timeout. - msg.readInt32("npc id"); -} - -void NpcHandler::processArea(Net::MessageIn &msg) -{ - const int len = msg.readInt16("len"); - if (len < 12) - return; - Being *const dstBeing = actorManager->findBeing( - msg.readBeingId("npc id")); - const int area = msg.readInt32("area size"); - if (dstBeing) - dstBeing->setAreaSize(area); -} - -void NpcHandler::processShowDigit(Net::MessageIn &msg) -{ - UNIMPLIMENTEDPACKET; - - msg.readUInt8("type"); - msg.readInt32("value"); -} - -void NpcHandler::processProgressBarAbort(Net::MessageIn &msg) -{ - UNIMPLIMENTEDPACKET; -} - } // namespace EAthena diff --git a/src/net/eathena/npchandler.h b/src/net/eathena/npchandler.h index 3b35cadc5..bef960b30 100644 --- a/src/net/eathena/npchandler.h +++ b/src/net/eathena/npchandler.h @@ -88,21 +88,6 @@ class NpcHandler final : public MessageHandler, public Ea::NpcHandler void selectArrow(const int nameId) const override final; void selectAutoSpell(const int skillId) const override final; - - protected: - static void processNpcCutin(Net::MessageIn &msg); - - static void processNpcViewPoint(Net::MessageIn &msg); - - static void processNpcShowProgressBar(Net::MessageIn &msg); - - static void processNpcCloseTimeout(Net::MessageIn &msg); - - static void processArea(Net::MessageIn &msg); - - static void processShowDigit(Net::MessageIn &msg); - - static void processProgressBarAbort(Net::MessageIn &msg); }; } // namespace EAthena diff --git a/src/net/eathena/npcrecv.cpp b/src/net/eathena/npcrecv.cpp new file mode 100644 index 000000000..4bc1cf657 --- /dev/null +++ b/src/net/eathena/npcrecv.cpp @@ -0,0 +1,109 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2015 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/>. + */ + +#include "net/eathena/npcrecv.h" + +#include "actormanager.h" + +#include "being/localplayer.h" + +#include "gui/windows/npcdialog.h" + +#include "gui/widgets/createwidget.h" + +#include "net/ea/npcrecv.h" + +#include "net/eathena/messageout.h" +#include "net/eathena/protocol.h" + +#include "net/ea/eaprotocol.h" + +#include "debug.h" + +namespace EAthena +{ + + +void NpcRecv::processNpcCutin(Net::MessageIn &msg) +{ + UNIMPLIMENTEDPACKET; + Ea::NpcRecv::mRequestLang = false; + msg.readString(64, "image name"); + msg.readUInt8("type"); +} + +void NpcRecv::processNpcViewPoint(Net::MessageIn &msg) +{ + UNIMPLIMENTEDPACKET; + Ea::NpcRecv::mRequestLang = false; + // +++ probably need add nav point and start moving to it + msg.readInt32("npc id"); + msg.readInt32("type"); // 0 display for 15 sec, + // 1 display until teleport, + // 2 remove + msg.readInt32("x"); + msg.readInt32("y"); + msg.readUInt8("number"); // can be used for scripts + msg.readInt32("color"); +} + +void NpcRecv::processNpcShowProgressBar(Net::MessageIn &msg) +{ + UNIMPLIMENTEDPACKET; + Ea::NpcRecv::mRequestLang = false; + // +++ probably need show progress bar in npc dialog + msg.readInt32("color"); + msg.readInt32("seconds"); +} + +void NpcRecv::processNpcCloseTimeout(Net::MessageIn &msg) +{ + UNIMPLIMENTEDPACKET; + Ea::NpcRecv::mRequestLang = false; + // this packet send after npc closed by timeout. + msg.readInt32("npc id"); +} + +void NpcRecv::processArea(Net::MessageIn &msg) +{ + const int len = msg.readInt16("len"); + if (len < 12) + return; + Being *const dstBeing = actorManager->findBeing( + msg.readBeingId("npc id")); + const int area = msg.readInt32("area size"); + if (dstBeing) + dstBeing->setAreaSize(area); +} + +void NpcRecv::processShowDigit(Net::MessageIn &msg) +{ + UNIMPLIMENTEDPACKET; + + msg.readUInt8("type"); + msg.readInt32("value"); +} + +void NpcRecv::processProgressBarAbort(Net::MessageIn &msg) +{ + UNIMPLIMENTEDPACKET; +} + +} // namespace EAthena diff --git a/src/net/eathena/npcrecv.h b/src/net/eathena/npcrecv.h new file mode 100644 index 000000000..865d53f3a --- /dev/null +++ b/src/net/eathena/npcrecv.h @@ -0,0 +1,42 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2015 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_EATHENA_NPCRECV_H +#define NET_EATHENA_NPCRECV_H + +#include "net/ea/npchandler.h" + +#include "net/eathena/messagehandler.h" + +namespace EAthena +{ + namespace NpcRecv + { + void processNpcCutin(Net::MessageIn &msg); + void processNpcViewPoint(Net::MessageIn &msg); + void processNpcShowProgressBar(Net::MessageIn &msg); + void processNpcCloseTimeout(Net::MessageIn &msg); + void processArea(Net::MessageIn &msg); + void processShowDigit(Net::MessageIn &msg); + void processProgressBarAbort(Net::MessageIn &msg); + } // namespace NpcRecv +} // namespace EAthena + +#endif // NET_EATHENA_NPCRECV_H |