summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/guild.cpp17
-rw-r--r--src/guild.h9
-rw-r--r--src/net/eathena/guildrecv.cpp51
-rw-r--r--src/net/eathena/guildrecv.h1
-rw-r--r--src/net/eathena/packetsin.inc13
5 files changed, 90 insertions, 1 deletions
diff --git a/src/guild.cpp b/src/guild.cpp
index 35349e5d3..b188bf864 100644
--- a/src/guild.cpp
+++ b/src/guild.cpp
@@ -169,6 +169,23 @@ GuildMember *Guild::getMember(const BeingId accountId,
return nullptr;
}
+GuildMember *Guild::getMemberByCharId(const int charId) const
+{
+ MemberList::const_iterator itr = mMembers.begin();
+ const MemberList::const_iterator itr_end = mMembers.end();
+ while (itr != itr_end)
+ {
+ if ((*itr) != nullptr &&
+ (*itr)->mCharId == charId)
+ {
+ return (*itr);
+ }
+ ++itr;
+ }
+
+ return nullptr;
+}
+
GuildMember *Guild::getMember(const std::string &name) const
{
MemberList::const_iterator itr = mMembers.begin();
diff --git a/src/guild.h b/src/guild.h
index 47f6f3e7e..064a75d28 100644
--- a/src/guild.h
+++ b/src/guild.h
@@ -107,6 +107,13 @@ class Guild final : public AvatarListModel
const A_WARN_UNUSED;
/**
+ * Find a member by char ID.
+ *
+ * @return the member with the given ID, or NULL if they don't exist.
+ */
+ GuildMember *getMemberByCharId(const int charId) const A_WARN_UNUSED;
+
+ /**
* Find a member by name.
*
* @return the member with the given name, or NULL if they don't exist.
@@ -133,7 +140,7 @@ class Guild final : public AvatarListModel
void removeMember(const GuildMember *const member);
/**
- * Removes a member from the guild.
+ * Removes a member from the guild by account id.
*/
void removeMember(const BeingId id);
diff --git a/src/net/eathena/guildrecv.cpp b/src/net/eathena/guildrecv.cpp
index 48546b6cf..5fa99bb78 100644
--- a/src/net/eathena/guildrecv.cpp
+++ b/src/net/eathena/guildrecv.cpp
@@ -505,6 +505,57 @@ void GuildRecv::processGuildLeave(Net::MessageIn &msg)
}
}
+void GuildRecv::processGuildLeave2(Net::MessageIn &msg)
+{
+ const int charId = msg.readInt32("char id");
+ msg.readString(40, "message");
+ std::string nick;
+
+ if (taGuild != nullptr)
+ {
+ const GuildMember *const member = taGuild->getMemberByCharId(charId);
+ if (member != nullptr)
+ {
+ nick = member->getName();
+ taGuild->removeMember(member);
+ }
+ }
+
+ if (localPlayer == nullptr)
+ return;
+
+ if (charId == PlayerInfo::getCharId())
+ {
+ if (taGuild != nullptr)
+ {
+ taGuild->removeFromMembers();
+ taGuild->clearMembers();
+ localPlayer->removeGuild(taGuild->getId());
+ }
+ NotifyManager::notify(NotifyTypes::GUILD_LEFT);
+ delete2(guildTab)
+
+ if ((socialWindow != nullptr) && (taGuild != nullptr))
+ socialWindow->removeTab(taGuild);
+ if (actorManager != nullptr)
+ actorManager->updatePlayerColors();
+ }
+ else
+ {
+ NotifyManager::notify(NotifyTypes::GUILD_USER_LEFT, nick);
+ if (actorManager != nullptr)
+ {
+ Being *const b = actorManager->findBeingByName(
+ nick, ActorType::Player);
+
+ if (b != nullptr)
+ b->clearGuilds();
+ if (taGuild != nullptr)
+ taGuild->removeMember(nick);
+ }
+ }
+}
+
void GuildRecv::processGuildMessage(Net::MessageIn &msg)
{
const int msgLength = msg.readInt16("len") - 4;
diff --git a/src/net/eathena/guildrecv.h b/src/net/eathena/guildrecv.h
index 951bf6519..733e98633 100644
--- a/src/net/eathena/guildrecv.h
+++ b/src/net/eathena/guildrecv.h
@@ -53,6 +53,7 @@ namespace EAthena
void processGuildInvite(Net::MessageIn &msg);
void processGuildInviteAck(Net::MessageIn &msg);
void processGuildLeave(Net::MessageIn &msg);
+ void processGuildLeave2(Net::MessageIn &msg);
void processGuildMessage(Net::MessageIn &msg);
void processGuildReqAlliance(Net::MessageIn &msg);
void processGuildReqAllianceAck(Net::MessageIn &msg);
diff --git a/src/net/eathena/packetsin.inc b/src/net/eathena/packetsin.inc
index 52660ad5b..fbc9ee818 100644
--- a/src/net/eathena/packetsin.inc
+++ b/src/net/eathena/packetsin.inc
@@ -990,6 +990,18 @@ if (packetVersion >= 20160921)
packet(SMSG_VENDING_ITEMS_LIST, 0x0800, -1, &VendingRecv::processItemsList, 20160921);
}
+// 20160921 re
+if (packetVersionRe >= 20160921)
+{
+ packet(SMSG_GUILD_LEAVE2, 0x0a83, 46, &GuildRecv::processGuildLeave2, 20160921);
+}
+
+// 20161019 main
+if (packetVersionMain >= 20161019)
+{
+ packet(SMSG_GUILD_LEAVE2, 0x0a83, 46, &GuildRecv::processGuildLeave2, 20161019);
+}
+
// 20161026
if (packetVersion >= 20161026)
{
@@ -1103,6 +1115,7 @@ if (packets_zero == true)
packet(SMSG_PARTY_INFO, 0x0a44, -1, &PartyRecv::processPartyInfo, 20171018);
packet(SMSG_PARTY_MEMBER_JOB_LEVEL, 0x0abd, 10, &PartyRecv::processPartyMemberJobLevel, 20171018);
packet(SMSG_MVP_EXP, 0x010b, 6, &ChatRecv::processMVPExp, 20171018);
+ packet(SMSG_GUILD_LEAVE2, 0x0a83, 46, &GuildRecv::processGuildLeave2, 20171018);
}
// 20171207