diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-12-03 20:32:25 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-12-03 20:32:25 +0300 |
commit | 9a62661a3b833f7f74f65c1733af8d3a25af9702 (patch) | |
tree | 13bd1fb55d4be5af266b3fb6a5a566c7e701649a /src/net/eathena/chathandler.cpp | |
parent | a7f634fe64f9ec9064e59eee4338d58100f605fb (diff) | |
download | manaverse-9a62661a3b833f7f74f65c1733af8d3a25af9702.tar.gz manaverse-9a62661a3b833f7f74f65c1733af8d3a25af9702.tar.bz2 manaverse-9a62661a3b833f7f74f65c1733af8d3a25af9702.tar.xz manaverse-9a62661a3b833f7f74f65c1733af8d3a25af9702.zip |
eathena: add packets CMSG_CHAT_JOIN_CHANNEL 0x0b07 and SMSG_CHAT_JOIN_CHANNEL 0x0b08
Diffstat (limited to 'src/net/eathena/chathandler.cpp')
-rw-r--r-- | src/net/eathena/chathandler.cpp | 47 |
1 files changed, 44 insertions, 3 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 |