diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-04-01 14:13:11 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-04-01 14:13:11 -0600 |
commit | b987a2806dbcd87a23850901f6f0b86f0801086c (patch) | |
tree | e373f4869436f830c2cdeeeaf34a941560ded3fe /src/net/ea/chathandler.cpp | |
parent | 6ef22b50f3d0c2410af5bd2543bedc0b3d692f83 (diff) | |
download | mana-b987a2806dbcd87a23850901f6f0b86f0801086c.tar.gz mana-b987a2806dbcd87a23850901f6f0b86f0801086c.tar.bz2 mana-b987a2806dbcd87a23850901f6f0b86f0801086c.tar.xz mana-b987a2806dbcd87a23850901f6f0b86f0801086c.zip |
Create a few more handlers for eAthena
Map, chat, and admin have been finished (to the degree they handle all
existing cases).
Diffstat (limited to 'src/net/ea/chathandler.cpp')
-rw-r--r-- | src/net/ea/chathandler.cpp | 79 |
1 files changed, 71 insertions, 8 deletions
diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp index 6aca58a3..3628784d 100644 --- a/src/net/ea/chathandler.cpp +++ b/src/net/ea/chathandler.cpp @@ -24,6 +24,7 @@ #include "net/ea/protocol.h" #include "net/messagein.h" +#include "net/messageout.h" #include "being.h" #include "beingmanager.h" @@ -34,13 +35,14 @@ #include "utils/gettext.h" #include "utils/stringutils.h" +#include "utils/strprintf.h" #include <string> -extern Being *player_node; - #define SERVER_NAME "Server" +ChatHandler *chatHandler; + ChatHandler::ChatHandler() { static const Uint16 _messages[] = { @@ -49,11 +51,11 @@ ChatHandler::ChatHandler() SMSG_WHISPER, SMSG_WHISPER_RESPONSE, SMSG_GM_CHAT, - SMSG_WHO_ANSWER, 0x10c, // MVP 0 }; handledMessages = _messages; + chatHandler = this; } void ChatHandler::handleMessage(MessageIn &msg) @@ -159,11 +161,6 @@ void ChatHandler::handleMessage(MessageIn &msg) break; } - case SMSG_WHO_ANSWER: - localChatTab->chatLog("Online users: " + toString(msg.readInt32()), - BY_SERVER); - break; - case 0x010c: // Display MVP player msg.readInt32(); // id @@ -171,3 +168,69 @@ void ChatHandler::handleMessage(MessageIn &msg) break; } } + +void ChatHandler::talk(const std::string &text) +{ + std::string mes = player_node->getName() + " : " + text; + + MessageOut outMsg(CMSG_CHAT_MESSAGE); + // Added + 1 in order to let eAthena parse admin commands correctly + outMsg.writeInt16(text.length() + 4 + 1); + outMsg.writeString(text, text.length() + 1); +} + +void ChatHandler::me(const std::string &text) +{ + std::string action = strprintf("*%s*", text.c_str()); + + talk(text); +} + +void ChatHandler::privateMessage(const std::string &recipient, + const std::string &text) +{ + MessageOut outMsg(CMSG_CHAT_WHISPER); + outMsg.writeInt16(text.length() + 28); + outMsg.writeString(recipient, 24); + outMsg.writeString(text, text.length()); +} + +void ChatHandler::channelList() +{ + // TODO +} + +void ChatHandler::enterChannel(int channelId, const std::string &password) +{ + // TODO +} + +void ChatHandler::quitChannel(int channelId) +{ + // TODO +} + +void ChatHandler::sendToChannel(int channelId, const std::string &text) +{ + // TODO +} + +void ChatHandler::userList(int channelId) +{ + // TODO +} + +void ChatHandler::setChannelTopic(int channelId, const std::string &text) +{ + // TODO +} + +void ChatHandler::setUserMode(int channelId, const std::string &name, int mode) +{ + // TODO +} + +void ChatHandler::kickUser(int channelId, const std::string &name) +{ + // TODO +} |