diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-06-25 00:25:18 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-06-25 01:44:06 +0300 |
commit | f939a7bbbc19bb69726377eed7b36542d6a5cf3f (patch) | |
tree | 1f68a58d3f0ae077696cfe8771599af9e089c113 /src/net | |
parent | 72168639865fb75a4c216b1058dc8412d4c81277 (diff) | |
download | manaverse-f939a7bbbc19bb69726377eed7b36542d6a5cf3f.tar.gz manaverse-f939a7bbbc19bb69726377eed7b36542d6a5cf3f.tar.bz2 manaverse-f939a7bbbc19bb69726377eed7b36542d6a5cf3f.tar.xz manaverse-f939a7bbbc19bb69726377eed7b36542d6a5cf3f.zip |
Add support for cutit and viewpoint packets in eAthena.
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/eathena/npchandler.cpp | 92 | ||||
-rw-r--r-- | src/net/eathena/npchandler.h | 7 | ||||
-rw-r--r-- | src/net/eathena/protocol.h | 3 |
3 files changed, 33 insertions, 69 deletions
diff --git a/src/net/eathena/npchandler.cpp b/src/net/eathena/npchandler.cpp index 8b64248e4..53b7d0b03 100644 --- a/src/net/eathena/npchandler.cpp +++ b/src/net/eathena/npchandler.cpp @@ -44,8 +44,7 @@ extern Net::NpcHandler *npcHandler; namespace EAthena { -NpcHandler::NpcHandler() : - mRequestLang(false) +NpcHandler::NpcHandler() { static const uint16_t _messages[] = { @@ -56,6 +55,8 @@ NpcHandler::NpcHandler() : SMSG_NPC_INT_INPUT, SMSG_NPC_STR_INPUT, SMSG_NPC_COMMAND, + SMSG_NPC_CUTIN, + SMSG_NPC_VIEWPOINT, 0 }; handledMessages = _messages; @@ -64,43 +65,47 @@ NpcHandler::NpcHandler() : void NpcHandler::handleMessage(Net::MessageIn &msg) { - int npcId = getNpc(msg, msg.getId() == SMSG_NPC_CHOICE - || msg.getId() == SMSG_NPC_MESSAGE); - - if (msg.getId() != SMSG_NPC_STR_INPUT) - mRequestLang = false; + int npcId = 0; switch (msg.getId()) { case SMSG_NPC_CHOICE: + npcId = getNpc(msg, true); processNpcChoice(msg); break; case SMSG_NPC_MESSAGE: + npcId = getNpc(msg, true); processNpcMessage(msg); break; case SMSG_NPC_CLOSE: + npcId = getNpc(msg, false); processNpcClose(msg); break; case SMSG_NPC_NEXT: + npcId = getNpc(msg, false); processNpcNext(msg); break; case SMSG_NPC_INT_INPUT: + npcId = getNpc(msg, false); processNpcIntInput(msg); break; case SMSG_NPC_STR_INPUT: - if (mRequestLang) - processLangReuqest(msg, npcId); - else - processNpcStrInput(msg); + npcId = getNpc(msg, false); + processNpcStrInput(msg); + break; + + case SMSG_NPC_CUTIN: + processNpcCutin(msg, npcId); break; - case SMSG_NPC_COMMAND: - processNpcCommand(msg, npcId); + case SMSG_NPC_VIEWPOINT: + npcId = getNpc(msg, true); + processNpcViewPoint(msg, npcId); break; default: @@ -249,61 +254,20 @@ int NpcHandler::getNpc(Net::MessageIn &msg, bool haveLength) return npcId; } -void NpcHandler::processNpcCommand(Net::MessageIn &msg, int npcId) +void NpcHandler::processNpcCutin(Net::MessageIn &msg A_UNUSED, int npcId A_UNUSED) { - const int cmd = msg.readInt16(); - switch (cmd) - { - case 0: - mRequestLang = true; - break; - - case 1: - if (viewport) - viewport->moveCameraToActor(npcId); - break; - - case 2: - if (viewport) - { - const int id = msg.readInt32(); - const int x = msg.readInt16(); - const int y = msg.readInt16(); - if (!id) - viewport->moveCameraToPosition(x, y); - else - viewport->moveCameraToActor(id, x, y); - } - break; - - case 3: - if (viewport) - viewport->returnCamera(); - break; - - case 4: - if (viewport) - { - msg.readInt32(); // id - const int x = msg.readInt16(); - const int y = msg.readInt16(); - viewport->moveCameraRelative(x, y); - } - break; - case 5: - closeDialog(npcId); - break; - - default: - logger->log("unknown npc command: %d", cmd); - break; - } + msg.readString(64); // image name + msg.readInt8(); // type } -void NpcHandler::processLangReuqest(Net::MessageIn &msg A_UNUSED, int npcId) +void NpcHandler::processNpcViewPoint(Net::MessageIn &msg A_UNUSED, + int npcId A_UNUSED) { - mRequestLang = false; - stringInput(npcId, getLangSimple()); + msg.readInt32(); // type + msg.readInt32(); // x + msg.readInt32(); // y + msg.readInt8(); // byte + msg.readInt32(); // color } } // namespace EAthena diff --git a/src/net/eathena/npchandler.h b/src/net/eathena/npchandler.h index 855450f4f..f905c7fff 100644 --- a/src/net/eathena/npchandler.h +++ b/src/net/eathena/npchandler.h @@ -66,12 +66,9 @@ class NpcHandler : public MessageHandler, public Ea::NpcHandler int getNpc(Net::MessageIn &msg, bool haveLength); - void processNpcCommand(Net::MessageIn &msg, int npcId); + void processNpcCutin(Net::MessageIn &msg, int npcId); - void processLangReuqest(Net::MessageIn &msg, int npcId); - - private: - bool mRequestLang; + void processNpcViewPoint(Net::MessageIn &msg, int npcId); }; } // namespace EAthena diff --git a/src/net/eathena/protocol.h b/src/net/eathena/protocol.h index f26a07131..3f98fed26 100644 --- a/src/net/eathena/protocol.h +++ b/src/net/eathena/protocol.h @@ -344,4 +344,7 @@ enum #define SMSG_MAP_CHAR_ID 0x0283 #define SMSG_PLAYER_SHORTCUTS 0x02b9 #define SMSG_PLAYER_SHOW_EQUIP 0x02da +#define SMSG_NPC_CUTIN 0x01b3 +#define SMSG_NPC_VIEWPOINT 0x0144 + #endif |