summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-09-02 01:22:24 +0300
committerAndrei Karas <akaras@inbox.ru>2014-09-06 01:18:55 +0300
commit41b5a7c2e41e161aa34579a1271d7a4842f02faf (patch)
tree992beb601ff3648cc19ac5bfa0988e4c8340bae3 /src
parent0fb04d3b0c2390c8ad34c833a44416caf0437fe0 (diff)
downloadmanaplus-41b5a7c2e41e161aa34579a1271d7a4842f02faf.tar.gz
manaplus-41b5a7c2e41e161aa34579a1271d7a4842f02faf.tar.bz2
manaplus-41b5a7c2e41e161aa34579a1271d7a4842f02faf.tar.xz
manaplus-41b5a7c2e41e161aa34579a1271d7a4842f02faf.zip
Move processChat from ea namespace into tmwa and eathena.
Diffstat (limited to 'src')
-rw-r--r--src/net/ea/chathandler.cpp74
-rw-r--r--src/net/ea/chathandler.h2
-rw-r--r--src/net/eathena/chathandler.cpp52
-rw-r--r--src/net/eathena/chathandler.h3
-rw-r--r--src/net/tmwa/chathandler.cpp82
-rw-r--r--src/net/tmwa/chathandler.h3
6 files changed, 140 insertions, 76 deletions
diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp
index f24811966..205c17824 100644
--- a/src/net/ea/chathandler.cpp
+++ b/src/net/ea/chathandler.cpp
@@ -345,80 +345,6 @@ void ChatHandler::processBeingChat(Net::MessageIn &msg) const
BLOCK_END("ChatHandler::processBeingChat")
}
-void ChatHandler::processChat(Net::MessageIn &msg)
-{
- BLOCK_START("ChatHandler::processChat")
- const bool channels = msg.getId() == SMSG_PLAYER_CHAT2;
- const bool normalChat = msg.getId() == SMSG_PLAYER_CHAT
- || msg.getId() == SMSG_PLAYER_CHAT2;
- int chatMsgLength = msg.readInt16() - 4;
- std::string channel;
- if (channels)
- {
- chatMsgLength -= 3;
- channel = msg.readUInt8();
- channel += msg.readUInt8();
- channel += msg.readUInt8();
- }
- 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,
- channel, false, true);
- }
-
- if (channel.empty())
- {
- const std::string senseStr("You sense the following: ");
- if (actorManager && !chatMsg.find(senseStr))
- {
- actorManager->parseLevels(
- chatMsg.substr(senseStr.size()));
- }
- }
-
- if (pos == std::string::npos && !mShowMotd
- && mSkipping && channel.empty())
- {
- // skip motd from "new" tmw server
- if (mMotdTime == -1)
- mMotdTime = cur_time + 1;
- else if (mMotdTime == cur_time || mMotdTime < cur_time)
- mSkipping = false;
- BLOCK_END("ChatHandler::processChat")
- return;
- }
-
- if (pos != std::string::npos)
- chatMsg.erase(0, pos + 3);
-
- trim(chatMsg);
-
- if (localPlayer)
- {
- if ((chatWindow || mShowMotd) && allow)
- localPlayer->setSpeech(chatMsg, channel);
- }
- }
- else if (localChatTab)
- {
- if (chatWindow)
- chatWindow->addGlobalMessage(chatMsg);
- }
- BLOCK_END("ChatHandler::processChat")
-}
-
void ChatHandler::processMVP(Net::MessageIn &msg) const
{
BLOCK_START("ChatHandler::processMVP")
diff --git a/src/net/ea/chathandler.h b/src/net/ea/chathandler.h
index 1db8d6001..897949432 100644
--- a/src/net/ea/chathandler.h
+++ b/src/net/ea/chathandler.h
@@ -54,8 +54,6 @@ class ChatHandler notfinal : public Net::ChatHandler
virtual void processBeingChat(Net::MessageIn &msg) const;
- virtual void processChat(Net::MessageIn &msg);
-
virtual void processMVP(Net::MessageIn &msg) const;
virtual void processIgnoreAllResponse(Net::MessageIn &msg) const;
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
diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp
index ef89d966d..58a4ea73f 100644
--- a/src/net/tmwa/chathandler.cpp
+++ b/src/net/tmwa/chathandler.cpp
@@ -22,11 +22,19 @@
#include "net/tmwa/chathandler.h"
+#include "actormanager.h"
+
#include "being/localplayer.h"
+#include "gui/widgets/tabs/chattab.h"
+
+#include "gui/windows/chatwindow.h"
+
#include "net/tmwa/messageout.h"
#include "net/tmwa/protocol.h"
+#include "utils/stringutils.h"
+
#include <string>
#include "debug.h"
@@ -281,4 +289,78 @@ void ChatHandler::unIgnoreAll() const
outMsg.writeInt8(1);
}
+void ChatHandler::processChat(Net::MessageIn &msg)
+{
+ BLOCK_START("ChatHandler::processChat")
+ const bool channels = msg.getId() == SMSG_PLAYER_CHAT2;
+ const bool normalChat = msg.getId() == SMSG_PLAYER_CHAT
+ || msg.getId() == SMSG_PLAYER_CHAT2;
+ int chatMsgLength = msg.readInt16() - 4;
+ std::string channel;
+ if (channels)
+ {
+ chatMsgLength -= 3;
+ channel = msg.readUInt8();
+ channel += msg.readUInt8();
+ channel += msg.readUInt8();
+ }
+ 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,
+ channel, false, true);
+ }
+
+ if (channel.empty())
+ {
+ const std::string senseStr("You sense the following: ");
+ if (actorManager && !chatMsg.find(senseStr))
+ {
+ actorManager->parseLevels(
+ chatMsg.substr(senseStr.size()));
+ }
+ }
+
+ if (pos == std::string::npos && !mShowMotd
+ && mSkipping && channel.empty())
+ {
+ // skip motd from "new" tmw server
+ if (mMotdTime == -1)
+ mMotdTime = cur_time + 1;
+ else if (mMotdTime == cur_time || mMotdTime < cur_time)
+ mSkipping = false;
+ BLOCK_END("ChatHandler::processChat")
+ return;
+ }
+
+ if (pos != std::string::npos)
+ chatMsg.erase(0, pos + 3);
+
+ trim(chatMsg);
+
+ if (localPlayer)
+ {
+ if ((chatWindow || mShowMotd) && allow)
+ localPlayer->setSpeech(chatMsg, channel);
+ }
+ }
+ else if (localChatTab)
+ {
+ if (chatWindow)
+ chatWindow->addGlobalMessage(chatMsg);
+ }
+ BLOCK_END("ChatHandler::processChat")
+}
+
} // namespace TmwAthena
diff --git a/src/net/tmwa/chathandler.h b/src/net/tmwa/chathandler.h
index c4f51fec7..a9f5ce352 100644
--- a/src/net/tmwa/chathandler.h
+++ b/src/net/tmwa/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 TmwAthena