summaryrefslogtreecommitdiff
path: root/src/net/eathena/clanrecv.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2018-02-10 01:25:51 +0300
committerAndrei Karas <akaras@inbox.ru>2018-02-11 04:28:43 +0300
commit219afd10cf1dc8f7e75273706c2de3a06305e637 (patch)
tree5e1be1c457016104c5ea9bbf0d07ee2f491ef9d8 /src/net/eathena/clanrecv.cpp
parentbdf970bde1ce41aa364fc0065ac0cd23e37ec29f (diff)
downloadmanaverse-219afd10cf1dc8f7e75273706c2de3a06305e637.tar.gz
manaverse-219afd10cf1dc8f7e75273706c2de3a06305e637.tar.bz2
manaverse-219afd10cf1dc8f7e75273706c2de3a06305e637.tar.xz
manaverse-219afd10cf1dc8f7e75273706c2de3a06305e637.zip
Add basic support for clans.
Diffstat (limited to 'src/net/eathena/clanrecv.cpp')
-rw-r--r--src/net/eathena/clanrecv.cpp50
1 files changed, 43 insertions, 7 deletions
diff --git a/src/net/eathena/clanrecv.cpp b/src/net/eathena/clanrecv.cpp
index bf16627b2..d70d7d876 100644
--- a/src/net/eathena/clanrecv.cpp
+++ b/src/net/eathena/clanrecv.cpp
@@ -20,11 +20,19 @@
#include "net/eathena/clanrecv.h"
+#include "configuration.h"
+#include "logger.h"
+
#include "being/claninfo.h"
+#include "gui/widgets/tabs/chat/clantab.h"
+
+#include "gui/windows/chatwindow.h"
+
#include "net/messagein.h"
-#include "logger.h"
+#include "utils/checkutils.h"
+#include "utils/delete2.h"
#include "debug.h"
@@ -50,6 +58,7 @@ void ClanRecv::processClanInfo(Net::MessageIn &msg)
clanInfo.antagonistClans.push_back(
msg.readString(24, "antagonist clan name"));
}
+ createTab();
}
void ClanRecv::processClanOnlineCount(Net::MessageIn &msg)
@@ -58,20 +67,47 @@ void ClanRecv::processClanOnlineCount(Net::MessageIn &msg)
clanInfo.totalMembers = msg.readInt16("total members count");
}
-void ClanRecv::processClanLeave(Net::MessageIn &msg)
+void ClanRecv::processClanLeave(Net::MessageIn &msg A_UNUSED)
{
- UNIMPLEMENTEDPACKET;
+ delete2(clanTab);
}
void ClanRecv::processClanChat(Net::MessageIn &msg)
{
- UNIMPLEMENTEDPACKET;
const int chatMsgLength = msg.readInt16("len") - 4 - 24;
if (chatMsgLength <= 0)
return;
- msg.readInt16("len");
- msg.readString(24, "player name");
- msg.readString(chatMsgLength, "message");
+ msg.readString(24, "player name (unused)");
+ std::string chatMsg = msg.readString(chatMsgLength, "message");
+ if (clanTab == nullptr)
+ {
+ reportAlways("received clan chat messages without clan.");
+ return;
+ }
+ const size_t pos = chatMsg.find(" : ", 0);
+ if (pos != std::string::npos)
+ {
+ const std::string sender_name = chatMsg.substr(0, pos);
+ chatMsg.erase(0, pos + 3);
+ trim(chatMsg);
+ clanTab->chatLog(sender_name, chatMsg);
+ }
+ else
+ {
+ clanTab->chatLog(chatMsg,
+ ChatMsgType::BY_SERVER,
+ IgnoreRecord_false,
+ TryRemoveColors_true);
+ }
+}
+
+void ClanRecv::createTab()
+{
+ if (clanTab != nullptr)
+ return;
+ clanTab = new ClanTab(chatWindow);
+ if (config.getBoolValue("showChatHistory"))
+ clanTab->loadFromLogFile("#Clan");
}
} // namespace EAthena