fix(Core): Fix guild bank update broadcasts (#13520)

Fix guild bank update broadcasts
This commit is contained in:
Mickaël Mauger
2022-11-11 20:25:24 +01:00
committed by GitHub
parent f32b34ef44
commit 2c4df1054e
3 changed files with 30 additions and 10 deletions

View File

@@ -1798,8 +1798,14 @@ void Guild::SendBankTabData(WorldSession* session, uint8 tabId, bool sendAllSlot
_SendBankContent(session, tabId, sendAllSlots);
}
void Guild::SendBankTabsInfo(WorldSession* session, bool sendAllSlots /*= false*/) const
void Guild::SendBankTabsInfo(WorldSession* session, bool sendAllSlots /*= false*/)
{
Member* member = GetMember(session->GetPlayer()->GetGUID());
if (!member)
return;
member->SubscribeToGuildBankUpdatePackets();
_SendBankList(session, 0, sendAllSlots);
}
@@ -1809,12 +1815,17 @@ void Guild::SendBankTabText(WorldSession* session, uint8 tabId) const
tab->SendText(this, session);
}
void Guild::SendPermissions(WorldSession* session) const
void Guild::SendPermissions(WorldSession* session)
{
Member const* member = GetMember(session->GetPlayer()->GetGUID());
Member* member = GetMember(session->GetPlayer()->GetGUID());
if (!member)
return;
// We are unsubscribing here since it is the only reliable way to handle /reload from player as
// GuildPermissionsQuery is sent on each reload, and we don't want to send partial changes while client
// doesn't know the full state
member->UnsubscribeFromGuildBankUpdatePackets();
uint8 rankId = member->GetRankId();
WorldPackets::Guild::GuildPermissionsQueryResults queryResult;
@@ -1857,8 +1868,6 @@ void Guild::SendLoginInfo(WorldSession* session)
LOG_DEBUG("guild", "SMSG_GUILD_EVENT [{}] MOTD", session->GetPlayerInfo());
SendBankTabsInfo(session);
Player* player = session->GetPlayer();
HandleRoster(session);
@@ -2878,13 +2887,17 @@ void Guild::_SendBankList(WorldSession* session /* = nullptr*/, uint8 tabId /*=
LOG_DEBUG("guild", "SMSG_GUILD_BANK_LIST [{}]: TabId: {}, FullSlots: {}, slots: {}",
session->GetPlayerInfo(), tabId, sendAllSlots, packet.WithdrawalsRemaining);
}
else /// @todo - Probably this is just sent to session + those that have sent CMSG_GUILD_BANKER_ACTIVATE
else
{
packet.Write();
for (auto const& [guid, member] : m_members)
{
if (!member.ShouldReceiveBankPartialUpdatePackets())
continue;
if (!_MemberHasTabRights(member.GetGUID(), tabId, GUILD_BANK_RIGHT_VIEW_TAB))
continue;
Player* player = member.FindPlayer();
if (!player)
continue;

View File

@@ -306,7 +306,8 @@ public: // pussywizard: public class Member
m_class(0),
m_flags(GUILDMEMBER_STATUS_NONE),
m_accountId(0),
m_rankId(rankId)
m_rankId(rankId),
receiveGuildBankUpdatePackets(false)
{
}
@@ -353,6 +354,10 @@ public: // pussywizard: public class Member
inline Player* FindPlayer() const { return ObjectAccessor::FindConnectedPlayer(m_guid); }
void SubscribeToGuildBankUpdatePackets() { receiveGuildBankUpdatePackets = true; }
void UnsubscribeFromGuildBankUpdatePackets() { receiveGuildBankUpdatePackets = false; }
[[nodiscard]] bool ShouldReceiveBankPartialUpdatePackets() const { return receiveGuildBankUpdatePackets; }
private:
uint32 m_guildId;
// Fields from characters table
@@ -371,6 +376,8 @@ public: // pussywizard: public class Member
std::string m_officerNote;
std::array<int32, GUILD_BANK_MAX_TABS + 1> m_bankWithdraw = {};
bool receiveGuildBankUpdatePackets;
};
// pussywizard: public GetMember
@@ -718,10 +725,10 @@ public:
void SendInfo(WorldSession* session) const;
void SendEventLog(WorldSession* session) const;
void SendBankLog(WorldSession* session, uint8 tabId) const;
void SendBankTabsInfo(WorldSession* session, bool showTabs = false) const;
void SendBankTabsInfo(WorldSession* session, bool showTabs = false);
void SendBankTabData(WorldSession* session, uint8 tabId, bool sendAllSlots) const;
void SendBankTabText(WorldSession* session, uint8 tabId) const;
void SendPermissions(WorldSession* session) const;
void SendPermissions(WorldSession* session);
void SendMoneyInfo(WorldSession* session) const;
void SendLoginInfo(WorldSession* session);

View File

@@ -290,7 +290,7 @@ void WorldSession::HandleGuildBankerActivate(WorldPackets::Guild::GuildBankActiv
guild->SendBankTabsInfo(this, packet.FullUpdate);
}
// Called when opening guild bank tab only (first one)
// Called when opening guild bank tab only
void WorldSession::HandleGuildBankQueryTab(WorldPackets::Guild::GuildBankQueryTab& packet)
{
LOG_DEBUG("guild", "CMSG_GUILD_BANK_QUERY_TAB [{}]: Go: [{}], TabId: {}, ShowTabs: {}"