From 59143e174f946c66e2e437e32b6f6b28c506115a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 2 Aug 2010 03:13:49 +0300 Subject: Fix chat spoofing. Remove colors from nicks in public chat. Signed-off-by: Chuck Miller --- src/net/tmwa/chathandler.cpp | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) (limited to 'src/net') 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) -- cgit v1.2.3-70-g09d2 From 12b0ff6204dd64627a3824ba624000424551f054 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Mon, 2 Aug 2010 20:49:37 -0600 Subject: Fix enet version check Tested-by: BaseBallBoy --- src/net/manaserv/connection.cpp | 4 ++++ src/net/manaserv/network.cpp | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'src/net') diff --git a/src/net/manaserv/connection.cpp b/src/net/manaserv/connection.cpp index 98076c8a..fbd2ed22 100644 --- a/src/net/manaserv/connection.cpp +++ b/src/net/manaserv/connection.cpp @@ -60,7 +60,11 @@ bool Connection::connect(const std::string &address, short port) enetAddress.port = port; // Initiate the connection, allocating channel 0. +#ifdef ENET_VERSION_MAJOR + mConnection = enet_host_connect(mClient, &enetAddress, 1, 0); +#else mConnection = enet_host_connect(mClient, &enetAddress, 1); +#endif if (!mConnection) { diff --git a/src/net/manaserv/network.cpp b/src/net/manaserv/network.cpp index f97a54d2..4b9751d7 100644 --- a/src/net/manaserv/network.cpp +++ b/src/net/manaserv/network.cpp @@ -53,7 +53,11 @@ void initialize() logger->error("Failed to initialize ENet."); } +#ifdef ENET_VERSION_MAJOR + client = enet_host_create(NULL, 3, 0, 0, 0); +#else client = enet_host_create(NULL, 3, 0, 0); +#endif if (!client) { -- cgit v1.2.3-70-g09d2