diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-03-20 13:41:18 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-03-22 00:08:12 +0300 |
commit | 5a8b8f4ad56914e1c75acd29807897ba1433c96f (patch) | |
tree | 4e29e8fee3e794ba4b69e383d3f0e12e6e8d62e0 | |
parent | 54ee7d240a8ab3a328d0f3f06f3b9627d4727c90 (diff) | |
download | plus-5a8b8f4ad56914e1c75acd29807897ba1433c96f.tar.gz plus-5a8b8f4ad56914e1c75acd29807897ba1433c96f.tar.bz2 plus-5a8b8f4ad56914e1c75acd29807897ba1433c96f.tar.xz plus-5a8b8f4ad56914e1c75acd29807897ba1433c96f.zip |
add netcode support for channels (for now evol only).
for now any channel ignored and used as general tab.
also change netcode version to 8.
-rw-r--r-- | src/gui/widgets/chattab.h | 6 | ||||
-rw-r--r-- | src/net/ea/adminhandler.cpp | 3 | ||||
-rw-r--r-- | src/net/ea/chathandler.cpp | 29 | ||||
-rw-r--r-- | src/net/ea/chathandler.h | 6 | ||||
-rw-r--r-- | src/net/eathena/chathandler.cpp | 4 | ||||
-rw-r--r-- | src/net/tmwa/chathandler.cpp | 37 | ||||
-rw-r--r-- | src/net/tmwa/network.cpp | 2 | ||||
-rw-r--r-- | src/net/tmwa/network.h | 2 | ||||
-rw-r--r-- | src/net/tmwa/protocol.h | 3 |
9 files changed, 71 insertions, 21 deletions
diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h index 0ac55811d..2f84a723c 100644 --- a/src/gui/widgets/chattab.h +++ b/src/gui/widgets/chattab.h @@ -32,8 +32,10 @@ class ScrollArea; -const std::string GENERAL_CHANNEL = "\000\000\000"; -const std::string TRADE_CHANNEL = "\000\000\001"; +//const std::string GENERAL_CHANNEL = "\000\000\000"; +//const std::string TRADE_CHANNEL = "\000\000\001"; +const std::string GENERAL_CHANNEL = ""; +const std::string TRADE_CHANNEL = ""; /** * A tab for the chat window. This is special to ease chat handling. diff --git a/src/net/ea/adminhandler.cpp b/src/net/ea/adminhandler.cpp index f6450a225..ca3fd034d 100644 --- a/src/net/ea/adminhandler.cpp +++ b/src/net/ea/adminhandler.cpp @@ -31,7 +31,8 @@ namespace Ea { -const std::string GENERAL_CHANNEL = "\000\000\000"; +//const std::string GENERAL_CHANNEL = "\000\000\000"; +const std::string GENERAL_CHANNEL = ""; void AdminHandler::kickName(const std::string &name) { diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp index 7be94ca3e..3a2c6ec2e 100644 --- a/src/net/ea/chathandler.cpp +++ b/src/net/ea/chathandler.cpp @@ -258,15 +258,25 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) } } -void ChatHandler::processBeingChat(Net::MessageIn &msg) +void ChatHandler::processBeingChat(Net::MessageIn &msg, const bool channels) { if (!actorSpriteManager) return; - const int chatMsgLength = msg.readInt16() - 8; + int chatMsgLength = msg.readInt16() - 8; Being *const being = actorSpriteManager->findBeing(msg.readInt32()); + if (!being) + return; + + if (channels) + { + chatMsgLength -= 3; + msg.readInt8(); // channel + msg.readInt8(); // channel + msg.readInt8(); // channel + } - if (!being || chatMsgLength <= 0) + if (chatMsgLength <= 0) return; std::string chatMsg = msg.readRawString(chatMsgLength); @@ -307,10 +317,17 @@ void ChatHandler::processBeingChat(Net::MessageIn &msg) } } -void ChatHandler::processChat(Net::MessageIn &msg, bool normalChat) +void ChatHandler::processChat(Net::MessageIn &msg, bool normalChat, + bool channels) { - const int chatMsgLength = msg.readInt16() - 4; - + int chatMsgLength = msg.readInt16() - 4; + if (channels) + { + chatMsgLength -= 3; + msg.readInt8(); // channel + msg.readInt8(); // channel + msg.readInt8(); // channel + } if (chatMsgLength <= 0) return; diff --git a/src/net/ea/chathandler.h b/src/net/ea/chathandler.h index 301289084..c9bdd3029 100644 --- a/src/net/ea/chathandler.h +++ b/src/net/ea/chathandler.h @@ -75,9 +75,11 @@ class ChatHandler : public Net::ChatHandler virtual void processWhisper(Net::MessageIn &msg); - virtual void processBeingChat(Net::MessageIn &msg); + virtual void processBeingChat(Net::MessageIn &msg, + const bool channels); - virtual void processChat(Net::MessageIn &msg, bool normalChat); + virtual void processChat(Net::MessageIn &msg, bool normalChat, + bool channels); virtual void processMVP(Net::MessageIn &msg); diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp index d6ed2c9be..0f62411b3 100644 --- a/src/net/eathena/chathandler.cpp +++ b/src/net/eathena/chathandler.cpp @@ -81,12 +81,12 @@ void ChatHandler::handleMessage(Net::MessageIn &msg) // Received speech from being case SMSG_BEING_CHAT: - processBeingChat(msg); + processBeingChat(msg, false); break; case SMSG_PLAYER_CHAT: case SMSG_GM_CHAT: - processChat(msg, msg.getId() == SMSG_PLAYER_CHAT); + processChat(msg, msg.getId() == SMSG_PLAYER_CHAT, false); break; case SMSG_MVP: diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp index 753272e4f..b44c5bf73 100644 --- a/src/net/tmwa/chathandler.cpp +++ b/src/net/tmwa/chathandler.cpp @@ -40,6 +40,7 @@ #include "debug.h" extern Net::ChatHandler *chatHandler; +extern int serverVersion; namespace TmwAthena { @@ -51,7 +52,9 @@ ChatHandler::ChatHandler() : static const uint16_t _messages[] = { SMSG_BEING_CHAT, + SMSG_BEING_CHAT2, SMSG_PLAYER_CHAT, + SMSG_PLAYER_CHAT2, SMSG_WHISPER, SMSG_WHISPER_RESPONSE, SMSG_GM_CHAT, @@ -82,12 +85,21 @@ void ChatHandler::handleMessage(Net::MessageIn &msg) // Received speech from being case SMSG_BEING_CHAT: - processBeingChat(msg); + processBeingChat(msg, false); + break; + + // Received speech from being + case SMSG_BEING_CHAT2: + processBeingChat(msg, true); break; case SMSG_PLAYER_CHAT: case SMSG_GM_CHAT: - processChat(msg, msg.getId() == SMSG_PLAYER_CHAT); + processChat(msg, msg.getId() == SMSG_PLAYER_CHAT, false); + break; + + case SMSG_PLAYER_CHAT2: + processChat(msg, true, true); break; case SMSG_MVP: @@ -111,10 +123,23 @@ void ChatHandler::talk(const std::string &text, const std::string &channel) std::string mes = std::string(player_node->getName()).append( " : ").append(text); - MessageOut outMsg(CMSG_CHAT_MESSAGE); - // Added + 1 in order to let eAthena parse admin commands correctly - outMsg.writeInt16(static_cast<short>(mes.length() + 4 + 1)); - outMsg.writeString(mes, static_cast<int>(mes.length() + 1)); + if (serverVersion >= 8 && channel.size() == 3) + { + MessageOut outMsg(CMSG_CHAT_MESSAGE2); + // Added + 1 in order to let eAthena parse admin commands correctly + outMsg.writeInt16(static_cast<short>(mes.length() + 4 + 3 + 1)); + outMsg.writeInt8(channel[0]); + outMsg.writeInt8(channel[1]); + outMsg.writeInt8(channel[2]); + outMsg.writeString(mes, static_cast<int>(mes.length() + 1)); + } + else + { + MessageOut outMsg(CMSG_CHAT_MESSAGE); + // Added + 1 in order to let eAthena parse admin commands correctly + outMsg.writeInt16(static_cast<short>(mes.length() + 4 + 1)); + outMsg.writeString(mes, static_cast<int>(mes.length() + 1)); + } } void ChatHandler::talkRaw(const std::string &mes) diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp index 957fdd5a3..94a462aba 100644 --- a/src/net/tmwa/network.cpp +++ b/src/net/tmwa/network.cpp @@ -83,7 +83,7 @@ short packet_lengths[] = // #0x0200 26, 0, 0, 0, 18, 0, 0, 0, 0, 0, 0, 19, 10, 0, 0, 0, 2, -1, 16, 0, 8, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - -1, 122, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + -1, 122, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; static const int packet_lengths_size diff --git a/src/net/tmwa/network.h b/src/net/tmwa/network.h index 66c1acb26..e2018fd37 100644 --- a/src/net/tmwa/network.h +++ b/src/net/tmwa/network.h @@ -38,7 +38,7 @@ * Protocol version, reported to the eAthena char and mapserver who can adjust * the protocol accordingly. */ -#define CLIENT_PROTOCOL_VERSION 7 +#define CLIENT_PROTOCOL_VERSION 8 #define CLIENT_TMW_PROTOCOL_VERSION 1 namespace TmwAthena diff --git a/src/net/tmwa/protocol.h b/src/net/tmwa/protocol.h index 7464cc877..f40599fa5 100644 --- a/src/net/tmwa/protocol.h +++ b/src/net/tmwa/protocol.h @@ -143,6 +143,7 @@ enum #define SMSG_BEING_EMOTION 0x00c0 #define SMSG_BEING_ACTION 0x008a /**< Attack, sit, stand up, ... */ #define SMSG_BEING_CHAT 0x008d /**< A being talks */ +#define SMSG_BEING_CHAT2 0x0223 /**< A being talks in channels */ #define SMSG_BEING_NAME_RESPONSE 0x0095 /**< Has to be requested */ #define SMSG_BEING_NAME_RESPONSE2 0x0220 /**< Has to be requested */ #define SMSG_BEING_CHANGE_DIRECTION 0x009c @@ -164,6 +165,7 @@ enum #define SMSG_NPC_INT_INPUT 0x0142 /**< Integer input */ #define SMSG_NPC_STR_INPUT 0x01d4 /**< String input */ #define SMSG_PLAYER_CHAT 0x008e /**< Player talks */ +#define SMSG_PLAYER_CHAT2 0x0224 /**< Player talks */ #define SMSG_WHISPER 0x0097 /**< Whisper Recieved */ #define SMSG_WHISPER_RESPONSE 0x0098 #define SMSG_GM_CHAT 0x009a /**< GM announce */ @@ -246,6 +248,7 @@ enum #define CMSG_CLIENT_QUIT 0x018A #define CMSG_CHAT_MESSAGE 0x008c +#define CMSG_CHAT_MESSAGE2 0x0222 #define CMSG_CHAT_WHISPER 0x0096 #define CMSG_CHAT_ANNOUNCE 0x0099 #define CMSG_CHAT_WHO 0x00c1 |