diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/commands.cpp | 21 | ||||
-rw-r--r-- | src/commands.h | 4 | ||||
-rw-r--r-- | src/net/chathandler.h | 34 | ||||
-rw-r--r-- | src/net/ea/chathandler.cpp | 54 | ||||
-rw-r--r-- | src/net/ea/chathandler.h | 39 | ||||
-rw-r--r-- | src/net/eathena/chathandler.cpp | 16 | ||||
-rw-r--r-- | src/net/eathena/chathandler.h | 15 | ||||
-rw-r--r-- | src/net/tmwa/chathandler.cpp | 20 | ||||
-rw-r--r-- | src/net/tmwa/chathandler.h | 14 |
9 files changed, 57 insertions, 160 deletions
diff --git a/src/commands.cpp b/src/commands.cpp index 80e276d8b..1beba22d5 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -88,7 +88,7 @@ static void outString(ChatTab *const tab, const std::string &str, { if (!tab) { - Net::getChatHandler()->me(def); + Net::getChatHandler()->me(def, GENERAL_CHANNEL); return; } @@ -114,7 +114,7 @@ static void outString(ChatTab *const tab, const std::string &str, break; } default: - Net::getChatHandler()->me(def); + Net::getChatHandler()->me(def, GENERAL_CHANNEL); break; } } @@ -362,23 +362,6 @@ impHandler0(cleanFonts) debugChatTab->chatLog(_("Cache cleaned")); } -impHandler(join) -{ - if (!tab) - return; - - const size_t pos = args.find(' '); - const std::string name(args, 0, pos); - const std::string password(args, pos + 1); - tab->chatLog(strprintf(_("Requesting to join channel %s."), name.c_str())); - Net::getChatHandler()->enterChannel(name, password); -} - -impHandler0(listChannels) -{ - Net::getChatHandler()->channelList(); -} - impHandler(createParty) { if (!tab) diff --git a/src/commands.h b/src/commands.h index 7d1cf80e1..5eb189718 100644 --- a/src/commands.h +++ b/src/commands.h @@ -52,8 +52,6 @@ namespace Commands decHandler(who); decHandler(msg); decHandler(query); - decHandler(join); - decHandler(listChannels); decHandler(clear); decHandler(cleanGraphics); decHandler(cleanFonts); @@ -140,8 +138,6 @@ static const CommandInfo commands[] = {"blacklist", &Commands::blackList}, {"enemy", &Commands::enemy}, {"erase", &Commands::erase}, - {"join", &Commands::join}, - {"list", &Commands::listChannels}, {"clear", &Commands::clear}, {"cleangraphics", &Commands::cleanGraphics}, {"cleanfonts", &Commands::cleanFonts}, diff --git a/src/net/chathandler.h b/src/net/chathandler.h index c21a30f74..e4fe2deb7 100644 --- a/src/net/chathandler.h +++ b/src/net/chathandler.h @@ -35,41 +35,23 @@ class ChatHandler { } virtual void talk(const std::string &text, - const std::string &channel) = 0; + const std::string &channel) const = 0; - virtual void talkRaw(const std::string &text) = 0; + virtual void talkRaw(const std::string &text) const = 0; - virtual void me(const std::string &text) = 0; + virtual void me(const std::string &text, + const std::string &channel) const = 0; virtual void privateMessage(const std::string &recipient, const std::string &text) = 0; - virtual void channelList() = 0; + virtual void who() const = 0; - virtual void enterChannel(const std::string &channel, - const std::string &password) = 0; + virtual void sendRaw(const std::string &args) const = 0; - virtual void quitChannel(int channelId) = 0; + virtual void ignoreAll() const = 0; - virtual void sendToChannel(int channelId, const std::string &text) = 0; - - virtual void userList(const std::string &channel) = 0; - - virtual void setChannelTopic(int channelId, - const std::string &text) = 0; - - virtual void setUserMode(int channelId, const std::string &name, - int mode) = 0; - - virtual void kickUser(int channelId, const std::string &name) = 0; - - virtual void who() = 0; - - virtual void sendRaw(const std::string &args) = 0; - - virtual void ignoreAll() = 0; - - virtual void unIgnoreAll() = 0; + virtual void unIgnoreAll() const = 0; }; } diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp index 36c79af77..6eb913d50 100644 --- a/src/net/ea/chathandler.cpp +++ b/src/net/ea/chathandler.cpp @@ -47,48 +47,11 @@ ChatHandler::ChatHandler() : { } -void ChatHandler::me(const std::string &text) +void ChatHandler::me(const std::string &text, const std::string &channel) const { + // here need string duplication std::string action = strprintf("*%s*", text.c_str()); - talk(action, GENERAL_CHANNEL); -} - -void ChatHandler::channelList() -{ -} - -void ChatHandler::enterChannel(const std::string &channel A_UNUSED, - const std::string &password A_UNUSED) -{ -} - -void ChatHandler::quitChannel(int channelId A_UNUSED) -{ -} - -void ChatHandler::sendToChannel(int channelId A_UNUSED, - const std::string &text A_UNUSED) -{ -} - -void ChatHandler::userList(const std::string &channel A_UNUSED) -{ -} - -void ChatHandler::setChannelTopic(int channelId A_UNUSED, - const std::string &text A_UNUSED) -{ -} - -void ChatHandler::setUserMode(int channelId A_UNUSED, - const std::string &name A_UNUSED, - int mode A_UNUSED) -{ -} - -void ChatHandler::kickUser(int channelId A_UNUSED, - const std::string &name A_UNUSED) -{ + talk(action, channel); } void ChatHandler::processWhisperResponse(Net::MessageIn &msg) @@ -259,7 +222,8 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) } } -void ChatHandler::processBeingChat(Net::MessageIn &msg, const bool channels) +void ChatHandler::processBeingChat(Net::MessageIn &msg, + const bool channels) const { if (!actorSpriteManager) return; @@ -319,8 +283,8 @@ void ChatHandler::processBeingChat(Net::MessageIn &msg, const bool channels) } } -void ChatHandler::processChat(Net::MessageIn &msg, bool normalChat, - bool channels) +void ChatHandler::processChat(Net::MessageIn &msg, const bool normalChat, + const bool channels) const { int chatMsgLength = msg.readInt16() - 4; std::string channel; @@ -369,7 +333,7 @@ void ChatHandler::processChat(Net::MessageIn &msg, bool normalChat, } } -void ChatHandler::processMVP(Net::MessageIn &msg) +void ChatHandler::processMVP(Net::MessageIn &msg) const { // Display MVP player const int id = msg.readInt32(); // id @@ -383,7 +347,7 @@ void ChatHandler::processMVP(Net::MessageIn &msg) } } -void ChatHandler::processIgnoreAllResponse(Net::MessageIn &msg) +void ChatHandler::processIgnoreAllResponse(Net::MessageIn &msg) const { const int action = msg.readInt8(); const int fail = msg.readInt8(); diff --git a/src/net/ea/chathandler.h b/src/net/ea/chathandler.h index d46b10057..416589e86 100644 --- a/src/net/ea/chathandler.h +++ b/src/net/ea/chathandler.h @@ -40,50 +40,21 @@ class ChatHandler : public Net::ChatHandler A_DELETE_COPY(ChatHandler) - virtual void talk(const std::string &text, - const std::string &channel) = 0; - - virtual void talkRaw(const std::string &text) = 0; - - void me(const std::string &text); - - virtual void privateMessage(const std::string &recipient, - const std::string &text) = 0; - - void channelList(); - - void enterChannel(const std::string &channel, - const std::string &password); - - void quitChannel(int channelId); - - void sendToChannel(int channelId, const std::string &text); - - void userList(const std::string &channel); - - void setChannelTopic(int channelId, const std::string &text); - - void setUserMode(int channelId, const std::string &name, int mode); - - void kickUser(int channelId, const std::string &name); - - virtual void who() = 0; - - virtual void sendRaw(const std::string &args) = 0; + void me(const std::string &text, const std::string &channel) const; virtual void processWhisperResponse(Net::MessageIn &msg); virtual void processWhisper(Net::MessageIn &msg); virtual void processBeingChat(Net::MessageIn &msg, - const bool channels); + const bool channels) const; virtual void processChat(Net::MessageIn &msg, bool normalChat, - bool channels); + const bool channels) const; - virtual void processMVP(Net::MessageIn &msg); + virtual void processMVP(Net::MessageIn &msg) const; - virtual void processIgnoreAllResponse(Net::MessageIn &msg); + virtual void processIgnoreAllResponse(Net::MessageIn &msg) const; protected: typedef std::queue<std::string> WhisperQueue; diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp index 55941e030..9ec9fe621 100644 --- a/src/net/eathena/chathandler.cpp +++ b/src/net/eathena/chathandler.cpp @@ -102,12 +102,12 @@ void ChatHandler::handleMessage(Net::MessageIn &msg) } void ChatHandler::talk(const std::string &text, - const std::string &channel A_UNUSED) + const std::string &channel A_UNUSED) const { if (!player_node) return; - std::string mes = std::string(player_node->getName()).append( + const std::string mes = std::string(player_node->getName()).append( " : ").append(text); MessageOut outMsg(CMSG_CHAT_MESSAGE); @@ -116,7 +116,7 @@ void ChatHandler::talk(const std::string &text, outMsg.writeString(mes, static_cast<int>(mes.length() + 1)); } -void ChatHandler::talkRaw(const std::string &mes) +void ChatHandler::talkRaw(const std::string &mes) const { MessageOut outMsg(CMSG_CHAT_MESSAGE); // Added + 1 in order to let eAthena parse admin commands correctly @@ -134,12 +134,12 @@ void ChatHandler::privateMessage(const std::string &recipient, mSentWhispers.push(recipient); } -void ChatHandler::who() +void ChatHandler::who() const { MessageOut outMsg(CMSG_WHO_REQUEST); } -void ChatHandler::sendRaw(const std::string &args) +void ChatHandler::sendRaw(const std::string &args) const { std::string line = args; std::string str; @@ -190,7 +190,7 @@ void ChatHandler::processRaw(MessageOut &outMsg, const std::string &line) } else { - std::string header = line.substr(0, pos); + const std::string header = line.substr(0, pos); std::string data = line.substr(pos + 1); if (header.length() != 1) return; @@ -248,13 +248,13 @@ void ChatHandler::processRaw(MessageOut &outMsg, const std::string &line) } } -void ChatHandler::ignoreAll() +void ChatHandler::ignoreAll() const { MessageOut outMsg(CMSG_IGNORE_ALL); outMsg.writeInt8(0); } -void ChatHandler::unIgnoreAll() +void ChatHandler::unIgnoreAll() const { MessageOut outMsg(CMSG_IGNORE_ALL); outMsg.writeInt8(1); diff --git a/src/net/eathena/chathandler.h b/src/net/eathena/chathandler.h index 928b7aeb0..737b3269c 100644 --- a/src/net/eathena/chathandler.h +++ b/src/net/eathena/chathandler.h @@ -42,22 +42,23 @@ class ChatHandler final : public MessageHandler, public Ea::ChatHandler void handleMessage(Net::MessageIn &msg); - void talk(const std::string &text, const std::string &channel); + void talk(const std::string &text, + const std::string &channel) const; - void talkRaw(const std::string &text); + void talkRaw(const std::string &text) const; void privateMessage(const std::string &recipient, const std::string &text); - void who(); + void who() const; - void sendRaw(const std::string &args); + void sendRaw(const std::string &args) const; - void ignoreAll(); + void ignoreAll() const; - void unIgnoreAll(); + void unIgnoreAll() const; - void processRaw(MessageOut &outMsg, const std::string &line); + static void processRaw(MessageOut &outMsg, const std::string &line); }; } // namespace EAthena diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp index b04d1604c..655a6d826 100644 --- a/src/net/tmwa/chathandler.cpp +++ b/src/net/tmwa/chathandler.cpp @@ -115,12 +115,13 @@ void ChatHandler::handleMessage(Net::MessageIn &msg) BLOCK_END("ChatHandler::handleMessage") } -void ChatHandler::talk(const std::string &text, const std::string &channel) +void ChatHandler::talk(const std::string &text, + const std::string &channel) const { if (!player_node) return; - std::string mes = std::string(player_node->getName()).append( + const std::string mes = std::string(player_node->getName()).append( " : ").append(text); if (serverVersion >= 8 && channel.size() == 3) @@ -142,7 +143,7 @@ void ChatHandler::talk(const std::string &text, const std::string &channel) } } -void ChatHandler::talkRaw(const std::string &mes) +void ChatHandler::talkRaw(const std::string &mes) const { MessageOut outMsg(CMSG_CHAT_MESSAGE); // Added + 1 in order to let eAthena parse admin commands correctly @@ -160,12 +161,12 @@ void ChatHandler::privateMessage(const std::string &recipient, mSentWhispers.push(recipient); } -void ChatHandler::who() +void ChatHandler::who() const { MessageOut outMsg(CMSG_WHO_REQUEST); } -void ChatHandler::sendRaw(const std::string &args) +void ChatHandler::sendRaw(const std::string &args) const { std::string line = args; std::string str; @@ -216,11 +217,10 @@ void ChatHandler::processRaw(MessageOut &outMsg, const std::string &line) } else { - std::string header = line.substr(0, pos); - std::string data = line.substr(pos + 1); + const std::string header = line.substr(0, pos); if (header.length() != 1) return; - + std::string data = line.substr(pos + 1); int i = 0; switch (header[0]) @@ -274,13 +274,13 @@ void ChatHandler::processRaw(MessageOut &outMsg, const std::string &line) } } -void ChatHandler::ignoreAll() +void ChatHandler::ignoreAll() const { MessageOut outMsg(CMSG_IGNORE_ALL); outMsg.writeInt8(0); } -void ChatHandler::unIgnoreAll() +void ChatHandler::unIgnoreAll() const { MessageOut outMsg(CMSG_IGNORE_ALL); outMsg.writeInt8(1); diff --git a/src/net/tmwa/chathandler.h b/src/net/tmwa/chathandler.h index 733010b37..d11b6ba32 100644 --- a/src/net/tmwa/chathandler.h +++ b/src/net/tmwa/chathandler.h @@ -42,22 +42,22 @@ class ChatHandler final : public MessageHandler, public Ea::ChatHandler void handleMessage(Net::MessageIn &msg); - void talk(const std::string &text, const std::string &channel); + void talk(const std::string &text, const std::string &channel) const; - void talkRaw(const std::string &text); + void talkRaw(const std::string &text) const; void privateMessage(const std::string &recipient, const std::string &text); - void who(); + void who() const; - void sendRaw(const std::string &args); + void sendRaw(const std::string &args) const; - void ignoreAll(); + void ignoreAll() const; - void unIgnoreAll(); + void unIgnoreAll() const; - void processRaw(MessageOut &outMsg, const std::string &line); + static void processRaw(MessageOut &outMsg, const std::string &line); }; } // namespace TmwAthena |