summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2010-08-02 03:13:49 +0300
committerChuck Miller <shadowmil@gmail.com>2010-08-01 22:09:47 -0400
commit59143e174f946c66e2e437e32b6f6b28c506115a (patch)
tree9b58a041ca8953678430836cccc7beb5a8921396
parentca41ffae88c1363a04e3c3ed6b84511e865af4f6 (diff)
downloadmana-client-59143e174f946c66e2e437e32b6f6b28c506115a.tar.gz
mana-client-59143e174f946c66e2e437e32b6f6b28c506115a.tar.bz2
mana-client-59143e174f946c66e2e437e32b6f6b28c506115a.tar.xz
mana-client-59143e174f946c66e2e437e32b6f6b28c506115a.zip
Fix chat spoofing. Remove colors from nicks in public chat.
Signed-off-by: Chuck Miller <shadowmil@gmail.com>
-rw-r--r--src/net/tmwa/chathandler.cpp39
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)