summaryrefslogtreecommitdiff
path: root/src/net/eathena
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/eathena')
-rw-r--r--src/net/eathena/chathandler.cpp52
-rw-r--r--src/net/eathena/chathandler.h3
2 files changed, 55 insertions, 0 deletions
diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp
index 8a689bd47..63a936164 100644
--- a/src/net/eathena/chathandler.cpp
+++ b/src/net/eathena/chathandler.cpp
@@ -24,9 +24,17 @@
#include "being/localplayer.h"
+#include "gui/chatconsts.h"
+
+#include "gui/widgets/tabs/chattab.h"
+
+#include "gui/windows/chatwindow.h"
+
#include "net/eathena/messageout.h"
#include "net/eathena/protocol.h"
+#include "utils/stringutils.h"
+
#include <string>
#include "debug.h"
@@ -250,4 +258,48 @@ void ChatHandler::unIgnoreAll() const
outMsg.writeInt8(1);
}
+void ChatHandler::processChat(Net::MessageIn &msg)
+{
+ BLOCK_START("ChatHandler::processChat")
+ const bool normalChat = msg.getId() == SMSG_PLAYER_CHAT;
+ int chatMsgLength = msg.readInt16() - 4;
+ if (chatMsgLength <= 0)
+ {
+ BLOCK_END("ChatHandler::processChat")
+ return;
+ }
+
+ std::string chatMsg = msg.readRawString(chatMsgLength);
+ const size_t pos = chatMsg.find(" : ", 0);
+
+ if (normalChat)
+ {
+ bool allow(true);
+ if (chatWindow)
+ {
+ allow = chatWindow->resortChatLog(chatMsg,
+ ChatMsgType::BY_PLAYER,
+ GENERAL_CHANNEL,
+ false, true);
+ }
+
+ if (pos != std::string::npos)
+ chatMsg.erase(0, pos + 3);
+
+ trim(chatMsg);
+
+ if (localPlayer)
+ {
+ if (chatWindow || mShowMotd)
+ localPlayer->setSpeech(chatMsg, GENERAL_CHANNEL);
+ }
+ }
+ else if (localChatTab)
+ {
+ if (chatWindow)
+ chatWindow->addGlobalMessage(chatMsg);
+ }
+ BLOCK_END("ChatHandler::processChat")
+}
+
} // namespace EAthena
diff --git a/src/net/eathena/chathandler.h b/src/net/eathena/chathandler.h
index 3efaf2d31..397f947ff 100644
--- a/src/net/eathena/chathandler.h
+++ b/src/net/eathena/chathandler.h
@@ -58,6 +58,9 @@ class ChatHandler final : public MessageHandler, public Ea::ChatHandler
static void processRaw(MessageOut &restrict outMsg,
const std::string &restrict line);
+
+ protected:
+ void processChat(Net::MessageIn &msg);
};
} // namespace EAthena