diff options
Diffstat (limited to 'src/net/eathena')
-rw-r--r-- | src/net/eathena/chathandler.cpp | 47 | ||||
-rw-r--r-- | src/net/eathena/chathandler.h | 2 | ||||
-rw-r--r-- | src/net/eathena/packets.h | 2 | ||||
-rw-r--r-- | src/net/eathena/protocol.h | 2 |
4 files changed, 49 insertions, 4 deletions
diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp index 9e1954679..4c3340836 100644 --- a/src/net/eathena/chathandler.cpp +++ b/src/net/eathena/chathandler.cpp @@ -31,6 +31,7 @@ #include "gui/windows/chatwindow.h" #include "net/mercenaryhandler.h" +#include "net/serverfeatures.h" #include "net/eathena/messageout.h" #include "net/eathena/protocol.h" @@ -71,6 +72,7 @@ ChatHandler::ChatHandler() : SMSG_CHAT_DISPLAY, SMSG_CHAT_JOIN_ACK, SMSG_CHAT_LEAVE, + SMSG_CHAT_JOIN_CHANNEL, 0 }; handledMessages = _messages; @@ -147,6 +149,10 @@ void ChatHandler::handleMessage(Net::MessageIn &msg) processChatLeave(msg); break; + case SMSG_CHAT_JOIN_CHANNEL: + processJoinChannel(msg); + break; + default: break; } @@ -600,9 +606,44 @@ void ChatHandler::processChatLeave(Net::MessageIn &msg) void ChatHandler::joinChannel(const std::string &channel) { - // to join channel need use gm commands or send something. - // here we sending invisible message. - channelMessage(channel, "\302\202\302"); + if (serverFeatures->haveJoinChannel()) + { + createOutPacket(CMSG_CHAT_JOIN_CHANNEL); + outMsg.writeString(channel, 24, "channel name"); + } + else + { + channelMessage(channel, "\302\202\302"); + } +} + +void ChatHandler::processJoinChannel(Net::MessageIn &msg) +{ + if (!chatWindow) + return; + + const std::string channel = msg.readString(24, "channel name"); + int flag = msg.readUInt8("flag"); + + if (channel.size() < 2) + return; + switch (flag) + { + case 0: + default: + chatWindow->channelChatLog(channel, + // TRANSLATORS: chat message + strprintf(_("Can't open channel. Channel " + "%s is not exists."), channel.c_str()), + ChatMsgType::BY_SERVER, false, false); + break; + + case 1: + case 2: + chatWindow->addChannelTab(std::string("#").append( + channel.substr(1)), false); + break; + } } } // namespace EAthena diff --git a/src/net/eathena/chathandler.h b/src/net/eathena/chathandler.h index c48d74470..f3893521e 100644 --- a/src/net/eathena/chathandler.h +++ b/src/net/eathena/chathandler.h @@ -113,6 +113,8 @@ class ChatHandler final : public MessageHandler, public Ea::ChatHandler static void processChatJoinAck(Net::MessageIn &msg); static void processChatLeave(Net::MessageIn &msg); + + static void processJoinChannel(Net::MessageIn &msg); }; } // namespace EAthena diff --git a/src/net/eathena/packets.h b/src/net/eathena/packets.h index 1945f4c0d..afec3c4e2 100644 --- a/src/net/eathena/packets.h +++ b/src/net/eathena/packets.h @@ -281,7 +281,7 @@ int16_t packet_lengths[] = //0 1 2 3 4 5 6 7 8 9 a b c d e f //0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 // #0x0B00 - 16, -1, 10, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 16, -1, 10, -1, -1, -1, -1, 0, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/src/net/eathena/protocol.h b/src/net/eathena/protocol.h index ccbf2ac19..7834b3c14 100644 --- a/src/net/eathena/protocol.h +++ b/src/net/eathena/protocol.h @@ -249,6 +249,7 @@ #define SMSG_CHAT_DISPLAY 0x00d7 #define SMSG_CHAT_JOIN_ACK 0x00db #define SMSG_CHAT_LEAVE 0x00dd +#define SMSG_CHAT_JOIN_CHANNEL 0x0b08 #define SMSG_MAIL_OPEN_WINDOW 0x0260 @@ -347,6 +348,7 @@ #define CMSG_CHAT_WHISPER 0x0096 #define CMSG_CHAT_WHO 0x00c1 #define CMSG_CHAT_JOIN 0x00d9 +#define CMSG_CHAT_JOIN_CHANNEL 0x0b07 #define CMSG_BATTLE_CHAT_MESSAGE 0x02db #define CMSG_CREAYE_CHAT_ROOM 0x00d5 |