diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-02-16 12:27:52 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-02-16 12:27:52 +0300 |
commit | 47d811c90a4655b69f1846c16150efebbfa4ccfa (patch) | |
tree | 6624874f4da16cb900fc7aa730e5b0ccde4a0c9f /src | |
parent | 08fbe14b1b261b5652f90212fd268d371302e762 (diff) | |
download | plus-47d811c90a4655b69f1846c16150efebbfa4ccfa.tar.gz plus-47d811c90a4655b69f1846c16150efebbfa4ccfa.tar.bz2 plus-47d811c90a4655b69f1846c16150efebbfa4ccfa.tar.xz plus-47d811c90a4655b69f1846c16150efebbfa4ccfa.zip |
Move processWhisperContinue from ea namespace into eathena and tmwa.
Diffstat (limited to 'src')
-rw-r--r-- | src/net/ea/chathandler.cpp | 123 | ||||
-rw-r--r-- | src/net/ea/chathandler.h | 3 | ||||
-rw-r--r-- | src/net/eathena/chathandler.cpp | 28 | ||||
-rw-r--r-- | src/net/eathena/chathandler.h | 3 | ||||
-rw-r--r-- | src/net/tmwa/chathandler.cpp | 127 | ||||
-rw-r--r-- | src/net/tmwa/chathandler.h | 3 |
6 files changed, 160 insertions, 127 deletions
diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp index 79be52a7d..08ea82980 100644 --- a/src/net/ea/chathandler.cpp +++ b/src/net/ea/chathandler.cpp @@ -24,14 +24,12 @@ #include "actormanager.h" #include "configuration.h" -#include "guildmanager.h" #include "notifymanager.h" #include "being/being.h" #include "being/playerrelations.h" #include "gui/windows/chatwindow.h" -#include "gui/windows/shopwindow.h" #include "gui/widgets/tabs/chat/gmtab.h" @@ -163,127 +161,6 @@ void ChatHandler::processWhisperResponseContinue(const uint8_t type) BLOCK_END("ChatHandler::processWhisperResponse") } -void ChatHandler::processWhisperContinue(const std::string &nick, - std::string chatMsg) -{ - // ignoring future whisper messages - if (chatMsg.find("\302\202G") == 0 || chatMsg.find("\302\202A") == 0) - { - BLOCK_END("ChatHandler::processWhisper") - return; - } - // remove first unicode space if this is may be whisper command. - if (chatMsg.find("\302\202!") == 0) - chatMsg = chatMsg.substr(2); - - if (nick != "Server") - { - if (guildManager && GuildManager::getEnableGuildBot() - && nick == "guild" && guildManager->processGuildMessage(chatMsg)) - { - BLOCK_END("ChatHandler::processWhisper") - return; - } - - if (player_relations.hasPermission(nick, PlayerRelation::WHISPER)) - { - const bool tradeBot = config.getBoolValue("tradebot"); - const bool showMsg = !config.getBoolValue("hideShopMessages"); - if (player_relations.hasPermission(nick, PlayerRelation::TRADE)) - { - if (shopWindow) - { // commands to shop from player - if (chatMsg.find("!selllist ") == 0) - { - if (tradeBot) - { - if (showMsg && chatWindow) - chatWindow->addWhisper(nick, chatMsg); - shopWindow->giveList(nick, ShopWindow::SELL); - } - } - else if (chatMsg.find("!buylist ") == 0) - { - if (tradeBot) - { - if (showMsg && chatWindow) - chatWindow->addWhisper(nick, chatMsg); - shopWindow->giveList(nick, ShopWindow::BUY); - } - } - else if (chatMsg.find("!buyitem ") == 0) - { - if (showMsg && chatWindow) - chatWindow->addWhisper(nick, chatMsg); - if (tradeBot) - { - shopWindow->processRequest(nick, chatMsg, - ShopWindow::BUY); - } - } - else if (chatMsg.find("!sellitem ") == 0) - { - if (showMsg && chatWindow) - chatWindow->addWhisper(nick, chatMsg); - if (tradeBot) - { - shopWindow->processRequest(nick, chatMsg, - ShopWindow::SELL); - } - } - else if (chatMsg.length() > 3 - && chatMsg.find("\302\202") == 0) - { - chatMsg = chatMsg.erase(0, 2); - if (showMsg && chatWindow) - chatWindow->addWhisper(nick, chatMsg); - if (chatMsg.find("B1") == 0 || chatMsg.find("S1") == 0) - shopWindow->showList(nick, chatMsg); - } - else if (chatWindow) - { - chatWindow->addWhisper(nick, chatMsg); - } - } - else if (chatWindow) - { - chatWindow->addWhisper(nick, chatMsg); - } - } - else - { - if (chatWindow && (showMsg || (chatMsg.find("!selllist") != 0 - && chatMsg.find("!buylist") != 0))) - { - chatWindow->addWhisper(nick, chatMsg); - } - } - } - } - else if (localChatTab) - { - if (gmChatTab && strStartWith(chatMsg, "[GM] ")) - { - chatMsg = chatMsg.substr(5); - const size_t pos = chatMsg.find(": ", 0); - if (pos == std::string::npos) - { - gmChatTab->chatLog(chatMsg); - } - else - { - gmChatTab->chatLog(chatMsg.substr(0, pos), - chatMsg.substr(pos + 2)); - } - } - else - { - localChatTab->chatLog(chatMsg, ChatMsgType::BY_SERVER); - } - } - BLOCK_END("ChatHandler::processWhisper") -} - void ChatHandler::processBeingChat(Net::MessageIn &msg) { if (!actorManager) diff --git a/src/net/ea/chathandler.h b/src/net/ea/chathandler.h index b5f77eb64..6ca511b4b 100644 --- a/src/net/ea/chathandler.h +++ b/src/net/ea/chathandler.h @@ -58,9 +58,6 @@ class ChatHandler notfinal : public Net::ChatHandler void clear() override final; - static void processWhisperContinue(const std::string &nick, - std::string chatMsg); - static void processWhisperResponseContinue(const uint8_t type); protected: diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp index 3def53afd..5aa12c53a 100644 --- a/src/net/eathena/chathandler.cpp +++ b/src/net/eathena/chathandler.cpp @@ -25,11 +25,14 @@ #include "actormanager.h" #include "being/localplayer.h" +#include "being/playerrelations.h" #include "gui/chatconsts.h" #include "gui/windows/chatwindow.h" +#include "gui/widgets/tabs/chat/chattab.h" + #include "net/mercenaryhandler.h" #include "net/serverfeatures.h" @@ -655,4 +658,29 @@ void ChatHandler::partChannel(const std::string &channel) } } +void ChatHandler::processWhisperContinue(const std::string &nick, + std::string chatMsg) +{ + // ignoring future whisper messages + if (chatMsg.find("\302\202G") == 0 || chatMsg.find("\302\202A") == 0) + { + BLOCK_END("ChatHandler::processWhisper") + return; + } + // remove first unicode space if this is may be whisper command. + if (chatMsg.find("\302\202!") == 0) + chatMsg = chatMsg.substr(2); + + if (nick != "Server") + { + if (player_relations.hasPermission(nick, PlayerRelation::WHISPER)) + chatWindow->addWhisper(nick, chatMsg); + } + else if (localChatTab) + { + localChatTab->chatLog(chatMsg, ChatMsgType::BY_SERVER); + } + BLOCK_END("ChatHandler::processWhisper") +} + } // namespace EAthena diff --git a/src/net/eathena/chathandler.h b/src/net/eathena/chathandler.h index e4a588fef..3b38c5a25 100644 --- a/src/net/eathena/chathandler.h +++ b/src/net/eathena/chathandler.h @@ -117,6 +117,9 @@ class ChatHandler final : public MessageHandler, public Ea::ChatHandler static void processChatLeave(Net::MessageIn &msg); static void processJoinChannel(Net::MessageIn &msg); + + static void processWhisperContinue(const std::string &nick, + std::string chatMsg); }; } // namespace EAthena diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp index 866a0be63..59e180269 100644 --- a/src/net/tmwa/chathandler.cpp +++ b/src/net/tmwa/chathandler.cpp @@ -23,14 +23,18 @@ #include "net/tmwa/chathandler.h" #include "actormanager.h" +#include "configuration.h" +#include "guildmanager.h" #include "being/localplayer.h" +#include "being/playerrelations.h" #include "gui/chatconsts.h" -#include "gui/widgets/tabs/chat/chattab.h" +#include "gui/widgets/tabs/chat/gmtab.h" #include "gui/windows/chatwindow.h" +#include "gui/windows/shopwindow.h" #include "net/serverfeatures.h" @@ -476,4 +480,125 @@ void ChatHandler::partChannel(const std::string &channel A_UNUSED) { } +void ChatHandler::processWhisperContinue(const std::string &nick, + std::string chatMsg) +{ + // ignoring future whisper messages + if (chatMsg.find("\302\202G") == 0 || chatMsg.find("\302\202A") == 0) + { + BLOCK_END("ChatHandler::processWhisper") + return; + } + // remove first unicode space if this is may be whisper command. + if (chatMsg.find("\302\202!") == 0) + chatMsg = chatMsg.substr(2); + + if (nick != "Server") + { + if (guildManager && GuildManager::getEnableGuildBot() + && nick == "guild" && guildManager->processGuildMessage(chatMsg)) + { + BLOCK_END("ChatHandler::processWhisper") + return; + } + + if (player_relations.hasPermission(nick, PlayerRelation::WHISPER)) + { + const bool tradeBot = config.getBoolValue("tradebot"); + const bool showMsg = !config.getBoolValue("hideShopMessages"); + if (player_relations.hasPermission(nick, PlayerRelation::TRADE)) + { + if (shopWindow) + { // commands to shop from player + if (chatMsg.find("!selllist ") == 0) + { + if (tradeBot) + { + if (showMsg && chatWindow) + chatWindow->addWhisper(nick, chatMsg); + shopWindow->giveList(nick, ShopWindow::SELL); + } + } + else if (chatMsg.find("!buylist ") == 0) + { + if (tradeBot) + { + if (showMsg && chatWindow) + chatWindow->addWhisper(nick, chatMsg); + shopWindow->giveList(nick, ShopWindow::BUY); + } + } + else if (chatMsg.find("!buyitem ") == 0) + { + if (showMsg && chatWindow) + chatWindow->addWhisper(nick, chatMsg); + if (tradeBot) + { + shopWindow->processRequest(nick, chatMsg, + ShopWindow::BUY); + } + } + else if (chatMsg.find("!sellitem ") == 0) + { + if (showMsg && chatWindow) + chatWindow->addWhisper(nick, chatMsg); + if (tradeBot) + { + shopWindow->processRequest(nick, chatMsg, + ShopWindow::SELL); + } + } + else if (chatMsg.length() > 3 + && chatMsg.find("\302\202") == 0) + { + chatMsg = chatMsg.erase(0, 2); + if (showMsg && chatWindow) + chatWindow->addWhisper(nick, chatMsg); + if (chatMsg.find("B1") == 0 || chatMsg.find("S1") == 0) + shopWindow->showList(nick, chatMsg); + } + else if (chatWindow) + { + chatWindow->addWhisper(nick, chatMsg); + } + } + else if (chatWindow) + { + chatWindow->addWhisper(nick, chatMsg); + } + } + else + { + if (chatWindow && (showMsg || (chatMsg.find("!selllist") != 0 + && chatMsg.find("!buylist") != 0))) + { + chatWindow->addWhisper(nick, chatMsg); + } + } + } + } + else if (localChatTab) + { + if (gmChatTab && strStartWith(chatMsg, "[GM] ")) + { + chatMsg = chatMsg.substr(5); + const size_t pos = chatMsg.find(": ", 0); + if (pos == std::string::npos) + { + gmChatTab->chatLog(chatMsg); + } + else + { + gmChatTab->chatLog(chatMsg.substr(0, pos), + chatMsg.substr(pos + 2)); + } + } + else + { + localChatTab->chatLog(chatMsg, ChatMsgType::BY_SERVER); + } + } + BLOCK_END("ChatHandler::processWhisper") +} + } // namespace TmwAthena diff --git a/src/net/tmwa/chathandler.h b/src/net/tmwa/chathandler.h index fc5fd885a..1f7f82d50 100644 --- a/src/net/tmwa/chathandler.h +++ b/src/net/tmwa/chathandler.h @@ -95,6 +95,9 @@ class ChatHandler final : public MessageHandler, public Ea::ChatHandler static void processWhisper(Net::MessageIn &msg); static void processWhisperResponse(Net::MessageIn &msg); + + static void processWhisperContinue(const std::string &nick, + std::string chatMsg); }; } // namespace TmwAthena |