summaryrefslogtreecommitdiff
path: root/src/net/eathena
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
parentbdf970bde1ce41aa364fc0065ac0cd23e37ec29f (diff)
downloadmv-219afd10cf1dc8f7e75273706c2de3a06305e637.tar.gz
mv-219afd10cf1dc8f7e75273706c2de3a06305e637.tar.bz2
mv-219afd10cf1dc8f7e75273706c2de3a06305e637.tar.xz
mv-219afd10cf1dc8f7e75273706c2de3a06305e637.zip
Add basic support for clans.
Diffstat (limited to 'src/net/eathena')
-rw-r--r--src/net/eathena/clanrecv.cpp50
-rw-r--r--src/net/eathena/clanrecv.h1
-rw-r--r--src/net/eathena/generalhandler.cpp2
3 files changed, 46 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
diff --git a/src/net/eathena/clanrecv.h b/src/net/eathena/clanrecv.h
index 6f864bfcc..02e3b7d48 100644
--- a/src/net/eathena/clanrecv.h
+++ b/src/net/eathena/clanrecv.h
@@ -34,6 +34,7 @@ namespace EAthena
void processClanOnlineCount(Net::MessageIn &msg);
void processClanLeave(Net::MessageIn &msg);
void processClanChat(Net::MessageIn &msg);
+ void createTab();
} // namespace ClanRecv
} // namespace EAthena
diff --git a/src/net/eathena/generalhandler.cpp b/src/net/eathena/generalhandler.cpp
index aaf762d3f..4f1d0c086 100644
--- a/src/net/eathena/generalhandler.cpp
+++ b/src/net/eathena/generalhandler.cpp
@@ -28,6 +28,7 @@
#include "gui/windows/skilldialog.h"
#include "gui/windows/socialwindow.h"
+#include "gui/widgets/tabs/chat/clantab.h"
#include "gui/widgets/tabs/chat/guildtab.h"
#include "gui/widgets/tabs/chat/partytab.h"
@@ -243,6 +244,7 @@ void GeneralHandler::gameEnded() const
delete2(guildTab);
delete2(partyTab);
+ delete2(clanTab);
}
} // namespace EAthena