diff options
-rw-r--r-- | src/net/tmwa/chathandler.cpp | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp index 640d04c1..00d29662 100644 --- a/src/net/tmwa/chathandler.cpp +++ b/src/net/tmwa/chathandler.cpp @@ -110,7 +110,8 @@ void ChatHandler::handleMessage(Net::MessageIn &msg) break; // Received speech from being - case SMSG_BEING_CHAT: { + case SMSG_BEING_CHAT: + { chatMsgLength = msg.readInt16() - 8; being = beingManager->findBeing(msg.readInt32()); @@ -121,24 +122,42 @@ void ChatHandler::handleMessage(Net::MessageIn &msg) std::string::size_type pos = chatMsg.find(" : ", 0); std::string sender_name = ((pos == std::string::npos) - ? "" - : chatMsg.substr(0, pos)); + ? "" : chatMsg.substr(0, pos)); - // 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)) - localChatTab->chatLog(chatMsg, BY_OTHER); + if (sender_name != being->getName() + && being->getType() == Being::PLAYER) + { + if (!being->getName().empty()) + sender_name = being->getName(); + } + else + { + chatMsg.erase(0, pos + 3); + } - chatMsg.erase(0, pos + 3); trim(chatMsg); - if (player_relations.hasPermission(sender_name, PlayerRelation::SPEECH_FLOAT)) + // 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) + { + localChatTab->chatLog(removeColors(sender_name) + " : " + + chatMsg, BY_OTHER); + } + + if (player_relations.hasPermission(sender_name, + PlayerRelation::SPEECH_FLOAT)) + { being->setSpeech(chatMsg, SPEECH_TIME); + } break; } case SMSG_PLAYER_CHAT: - case SMSG_GM_CHAT: { + case SMSG_GM_CHAT: + { chatMsgLength = msg.readInt16() - 4; if (chatMsgLength <= 0) |