diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-02-16 14:13:14 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-02-16 17:04:46 +0300 |
commit | 88b62a5e35961c738c70ae193ee49943caf7f625 (patch) | |
tree | 2511767e3e2b20b63e0db8041203869a3036b1a6 /src/net | |
parent | ce87c6e969dd2af24e50341e6da86918d4cf52a6 (diff) | |
download | mv-88b62a5e35961c738c70ae193ee49943caf7f625.tar.gz mv-88b62a5e35961c738c70ae193ee49943caf7f625.tar.bz2 mv-88b62a5e35961c738c70ae193ee49943caf7f625.tar.xz mv-88b62a5e35961c738c70ae193ee49943caf7f625.zip |
Move processBeingChat from ea namespace into eathena and tmwa.
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/ea/chathandler.cpp | 79 | ||||
-rw-r--r-- | src/net/ea/chathandler.h | 2 | ||||
-rw-r--r-- | src/net/eathena/chathandler.cpp | 62 | ||||
-rw-r--r-- | src/net/eathena/chathandler.h | 2 | ||||
-rw-r--r-- | src/net/tmwa/chathandler.cpp | 79 | ||||
-rw-r--r-- | src/net/tmwa/chathandler.h | 2 |
6 files changed, 145 insertions, 81 deletions
diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp index 08ea82980..50df82ff3 100644 --- a/src/net/ea/chathandler.cpp +++ b/src/net/ea/chathandler.cpp @@ -161,85 +161,6 @@ void ChatHandler::processWhisperResponseContinue(const uint8_t type) BLOCK_END("ChatHandler::processWhisperResponse") } -void ChatHandler::processBeingChat(Net::MessageIn &msg) -{ - if (!actorManager) - return; - - BLOCK_START("ChatHandler::processBeingChat") - const bool channels = msg.getId() == SMSG_BEING_CHAT2; - int chatMsgLength = msg.readInt16("len") - 8; - Being *const being = actorManager->findBeing(msg.readInt32("being id")); - if (!being) - { - BLOCK_END("ChatHandler::processBeingChat") - return; - } - - std::string channel; - if (channels) - { - chatMsgLength -= 3; - channel = msg.readUInt8("channel byte 0"); - channel += msg.readUInt8("channel byte 1"); - channel += msg.readUInt8("channel byte 2"); - } - - if (chatMsgLength <= 0) - { - BLOCK_END("ChatHandler::processBeingChat") - return; - } - - std::string chatMsg = msg.readRawString(chatMsgLength, "message"); - - if (being->getType() == ActorType::Player) - being->setTalkTime(); - - const size_t pos = chatMsg.find(" : ", 0); - std::string sender_name = ((pos == std::string::npos) - ? "" : chatMsg.substr(0, pos)); - - if (serverFeatures->haveIncompleteChatMessages()) - { - // work around for "new" tmw server - sender_name = being->getName(); - if (sender_name.empty()) - sender_name = "?"; - } - else if (sender_name != being->getName() - && being->getType() == ActorType::Player) - { - if (!being->getName().empty()) - sender_name = being->getName(); - } - else - { - chatMsg.erase(0, pos + 3); - } - - trim(chatMsg); - - bool allow(true); - // We use getIgnorePlayer instead of ignoringPlayer here - // because ignorePlayer' side effects are triggered - // right below for Being::IGNORE_SPEECH_FLOAT. - if (player_relations.checkPermissionSilently(sender_name, - PlayerRelation::SPEECH_LOG) && chatWindow) - { - allow = chatWindow->resortChatLog( - removeColors(sender_name).append(" : ").append(chatMsg), - ChatMsgType::BY_OTHER, channel, false, true); - } - - if (allow && player_relations.hasPermission(sender_name, - PlayerRelation::SPEECH_FLOAT)) - { - being->setSpeech(chatMsg, channel); - } - BLOCK_END("ChatHandler::processBeingChat") -} - void ChatHandler::processMVP(Net::MessageIn &msg) { BLOCK_START("ChatHandler::processMVP") diff --git a/src/net/ea/chathandler.h b/src/net/ea/chathandler.h index 6ca511b4b..5792bedac 100644 --- a/src/net/ea/chathandler.h +++ b/src/net/ea/chathandler.h @@ -50,8 +50,6 @@ class ChatHandler notfinal : public Net::ChatHandler void me(const std::string &restrict text, const std::string &restrict channel) const override final; - static void processBeingChat(Net::MessageIn &msg); - static void processMVP(Net::MessageIn &msg); static void processIgnoreAllResponse(Net::MessageIn &msg); diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp index 5aa12c53a..41fc78f3b 100644 --- a/src/net/eathena/chathandler.cpp +++ b/src/net/eathena/chathandler.cpp @@ -683,4 +683,66 @@ void ChatHandler::processWhisperContinue(const std::string &nick, BLOCK_END("ChatHandler::processWhisper") } +void ChatHandler::processBeingChat(Net::MessageIn &msg) +{ + if (!actorManager) + return; + + BLOCK_START("ChatHandler::processBeingChat") + int chatMsgLength = msg.readInt16("len") - 8; + Being *const being = actorManager->findBeing(msg.readInt32("being id")); + if (!being) + { + BLOCK_END("ChatHandler::processBeingChat") + return; + } + + if (chatMsgLength <= 0) + { + BLOCK_END("ChatHandler::processBeingChat") + return; + } + + std::string chatMsg = msg.readRawString(chatMsgLength, "message"); + + if (being->getType() == ActorType::Player) + being->setTalkTime(); + + const size_t pos = chatMsg.find(" : ", 0); + std::string sender_name = ((pos == std::string::npos) + ? "" : chatMsg.substr(0, pos)); + + if (sender_name != being->getName() + && being->getType() == ActorType::Player) + { + if (!being->getName().empty()) + sender_name = being->getName(); + } + else + { + chatMsg.erase(0, pos + 3); + } + + trim(chatMsg); + + bool allow(true); + // We use getIgnorePlayer instead of ignoringPlayer here + // because ignorePlayer' side effects are triggered + // right below for Being::IGNORE_SPEECH_FLOAT. + if (player_relations.checkPermissionSilently(sender_name, + PlayerRelation::SPEECH_LOG) && chatWindow) + { + allow = chatWindow->resortChatLog( + removeColors(sender_name).append(" : ").append(chatMsg), + ChatMsgType::BY_OTHER, GENERAL_CHANNEL, false, true); + } + + if (allow && player_relations.hasPermission(sender_name, + PlayerRelation::SPEECH_FLOAT)) + { + being->setSpeech(chatMsg, GENERAL_CHANNEL); + } + BLOCK_END("ChatHandler::processBeingChat") +} + } // namespace EAthena diff --git a/src/net/eathena/chathandler.h b/src/net/eathena/chathandler.h index 3b38c5a25..095a545d6 100644 --- a/src/net/eathena/chathandler.h +++ b/src/net/eathena/chathandler.h @@ -120,6 +120,8 @@ class ChatHandler final : public MessageHandler, public Ea::ChatHandler static void processWhisperContinue(const std::string &nick, std::string chatMsg); + + static void processBeingChat(Net::MessageIn &msg); }; } // namespace EAthena diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp index 59e180269..9413bf4ea 100644 --- a/src/net/tmwa/chathandler.cpp +++ b/src/net/tmwa/chathandler.cpp @@ -601,4 +601,83 @@ void ChatHandler::processWhisperContinue(const std::string &nick, BLOCK_END("ChatHandler::processWhisper") } +void ChatHandler::processBeingChat(Net::MessageIn &msg) +{ + if (!actorManager) + return; + + BLOCK_START("ChatHandler::processBeingChat") + const bool channels = msg.getId() == SMSG_BEING_CHAT2; + int chatMsgLength = msg.readInt16("len") - 8; + Being *const being = actorManager->findBeing(msg.readInt32("being id")); + if (!being) + { + BLOCK_END("ChatHandler::processBeingChat") + return; + } + + std::string channel; + if (channels) + { + chatMsgLength -= 3; + channel = msg.readUInt8("channel byte 0"); + channel += msg.readUInt8("channel byte 1"); + channel += msg.readUInt8("channel byte 2"); + } + + if (chatMsgLength <= 0) + { + BLOCK_END("ChatHandler::processBeingChat") + return; + } + + std::string chatMsg = msg.readRawString(chatMsgLength, "message"); + + if (being->getType() == ActorType::Player) + being->setTalkTime(); + + const size_t pos = chatMsg.find(" : ", 0); + std::string sender_name = ((pos == std::string::npos) + ? "" : chatMsg.substr(0, pos)); + + if (serverFeatures->haveIncompleteChatMessages()) + { + // work around for "new" tmw server + sender_name = being->getName(); + if (sender_name.empty()) + sender_name = "?"; + } + else if (sender_name != being->getName() + && being->getType() == ActorType::Player) + { + if (!being->getName().empty()) + sender_name = being->getName(); + } + else + { + chatMsg.erase(0, pos + 3); + } + + trim(chatMsg); + + bool allow(true); + // We use getIgnorePlayer instead of ignoringPlayer here + // because ignorePlayer' side effects are triggered + // right below for Being::IGNORE_SPEECH_FLOAT. + if (player_relations.checkPermissionSilently(sender_name, + PlayerRelation::SPEECH_LOG) && chatWindow) + { + allow = chatWindow->resortChatLog( + removeColors(sender_name).append(" : ").append(chatMsg), + ChatMsgType::BY_OTHER, channel, false, true); + } + + if (allow && player_relations.hasPermission(sender_name, + PlayerRelation::SPEECH_FLOAT)) + { + being->setSpeech(chatMsg, channel); + } + BLOCK_END("ChatHandler::processBeingChat") +} + } // namespace TmwAthena diff --git a/src/net/tmwa/chathandler.h b/src/net/tmwa/chathandler.h index 1f7f82d50..167190115 100644 --- a/src/net/tmwa/chathandler.h +++ b/src/net/tmwa/chathandler.h @@ -98,6 +98,8 @@ class ChatHandler final : public MessageHandler, public Ea::ChatHandler static void processWhisperContinue(const std::string &nick, std::string chatMsg); + + static void processBeingChat(Net::MessageIn &msg); }; } // namespace TmwAthena |