mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 01:37:37 +01:00
Core/Packets:
* renamed CMSG_GUILD_BANKER_ACTIVATE to CMSG_GUILD_BANK_ACTIVATE and updated handler to packet class * renamed SMSG_GUILD_BANK_LIST to SMSG_GUILD_BANK_QUERY_RESULTS and updated packets to packet class * Updated CMSG_GUILD_BANK_QUERY_TAB, CMSG_GUILD_BANK_BUY_TAB and CMSG_GUILD_BANK_UPDATE_TAB handlers to packet class * fixed displaying sockets, reforged stats and enchantments for items in the guild bank
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include "DatabaseEnv.h"
|
||||
#include "GuildFinderMgr.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "GuildPackets.h"
|
||||
#include "Language.h"
|
||||
#include "Log.h"
|
||||
#include "Map.h"
|
||||
@@ -3601,65 +3602,55 @@ void Guild::_SendBankContentUpdate(uint8 tabId, SlotIds slots) const
|
||||
{
|
||||
if (BankTab const* tab = GetBankTab(tabId))
|
||||
{
|
||||
ByteBuffer tabData;
|
||||
WorldPacket data(SMSG_GUILD_BANK_LIST, 1200);
|
||||
data.WriteBit(0);
|
||||
data.WriteBits(slots.size(), 20); // Item count
|
||||
data.WriteBits(0, 22); // Tab count
|
||||
WorldPackets::Guild::GuildBankQueryResults packet;
|
||||
packet.FullUpdate = true; // @todo
|
||||
packet.Tab = int32(tabId);
|
||||
packet.Money = m_bankMoney;
|
||||
|
||||
for (SlotIds::const_iterator itr = slots.begin(); itr != slots.end(); ++itr)
|
||||
{
|
||||
data.WriteBit(0);
|
||||
|
||||
Item const* tabItem = tab->GetItem(*itr);
|
||||
uint32 enchantCount = 0;
|
||||
|
||||
WorldPackets::Guild::GuildBankItemInfo itemInfo;
|
||||
|
||||
itemInfo.Slot = int32(*itr);
|
||||
itemInfo.Item.ItemID = int32(tabItem ? tabItem->GetEntry() : 0);
|
||||
itemInfo.Count = int32(tabItem ? tabItem->GetCount() : 0);
|
||||
itemInfo.Charges = int32(tabItem ? abs(tabItem->GetSpellCharges()) : 0);
|
||||
itemInfo.RandomPropertiesID = int32(tabItem ? tabItem->GetItemRandomPropertyId() : 0);
|
||||
itemInfo.RandomPropertiesSeed = int32(tabItem ? tabItem->GetItemSuffixFactor() : 0);
|
||||
itemInfo.EnchantmentID = int32(tabItem ? tabItem->GetEnchantmentId(EnchantmentSlot(PERM_ENCHANTMENT_SLOT)) : 0);
|
||||
itemInfo.OnUseEnchantmentID = int32(tabItem ? tabItem->GetEnchantmentId(EnchantmentSlot(BONUS_ENCHANTMENT_SLOT)) : 0);
|
||||
itemInfo.ReforgeEnchantmentID = int32(tabItem ? tabItem->GetEnchantmentId(EnchantmentSlot(REFORGE_ENCHANTMENT_SLOT)) : 0);
|
||||
itemInfo.Flags = int32(tabItem ? tabItem->GetInt32Value(ITEM_FIELD_FLAGS) : 0);
|
||||
itemInfo.Locked = false;
|
||||
|
||||
if (tabItem)
|
||||
{
|
||||
for (uint32 enchSlot = 0; enchSlot < MAX_ENCHANTMENT_SLOT; ++enchSlot)
|
||||
uint8 slotIndex = 0;
|
||||
for (uint8 enchSlot = SOCK_ENCHANTMENT_SLOT; enchSlot <= SOCK_ENCHANTMENT_SLOT_3; enchSlot++)
|
||||
{
|
||||
if (uint32 enchantId = tabItem->GetEnchantmentId(EnchantmentSlot(enchSlot)))
|
||||
{
|
||||
tabData << uint32(enchantId);
|
||||
tabData << uint32(enchSlot);
|
||||
++enchantCount;
|
||||
WorldPackets::Item::ItemGemData gem;
|
||||
gem.EnchantmentId = enchantId;
|
||||
gem.Slot = slotIndex;
|
||||
itemInfo.SocketEnchant.push_back(gem);
|
||||
}
|
||||
slotIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
data.WriteBits(enchantCount, 23); // enchantment count
|
||||
|
||||
tabData << uint32(0);
|
||||
tabData << uint32(0);
|
||||
tabData << uint32(0);
|
||||
tabData << uint32(tabItem ? tabItem->GetCount() : 0); // ITEM_FIELD_STACK_COUNT
|
||||
tabData << uint32(*itr);
|
||||
tabData << uint32(0);
|
||||
tabData << uint32(tabItem ? tabItem->GetEntry() : 0);
|
||||
tabData << uint32(tabItem ? tabItem->GetItemRandomPropertyId() : 0);
|
||||
tabData << uint32(tabItem ? abs(tabItem->GetSpellCharges()) : 0); // Spell charges
|
||||
tabData << uint32(tabItem ? tabItem->GetItemSuffixFactor() : 0); // SuffixFactor
|
||||
packet.ItemInfo.push_back(itemInfo);
|
||||
}
|
||||
|
||||
data.FlushBits();
|
||||
|
||||
data << uint64(m_bankMoney);
|
||||
if (!tabData.empty())
|
||||
data.append(tabData);
|
||||
|
||||
data << uint32(tabId);
|
||||
|
||||
size_t rempos = data.wpos();
|
||||
data << uint32(0); // Item withdraw amount, will be filled later
|
||||
|
||||
for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
|
||||
if (_MemberHasTabRights(itr->second->GetGUID(), tabId, GUILD_BANK_RIGHT_VIEW_TAB))
|
||||
if (Player* player = itr->second->FindPlayer())
|
||||
{
|
||||
data.put<uint32>(rempos, uint32(_GetMemberRemainingSlots(itr->second, tabId)));
|
||||
player->SendDirectMessage(&data);
|
||||
packet.WithdrawalsRemaining = _GetMemberRemainingSlots(itr->second, tabId);
|
||||
player->GetSession()->SendPacket(packet.Write());
|
||||
}
|
||||
|
||||
TC_LOG_DEBUG("guild", "WORLD: Sent (SMSG_GUILD_BANK_LIST)");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3687,25 +3678,44 @@ void Guild::_BroadcastEvent(GuildEvents guildEvent, ObjectGuid guid, char const*
|
||||
TC_LOG_DEBUG("guild", "SMSG_GUILD_EVENT [Broadcast] Event: %s (%u)", _GetGuildEventString(guildEvent).c_str(), guildEvent);
|
||||
}
|
||||
|
||||
void Guild::SendBankList(WorldSession* session, uint8 tabId, bool withContent, bool withTabInfo) const
|
||||
void Guild::SendBankList(WorldSession* session, uint8 tabId, bool fullUpdate) const
|
||||
{
|
||||
Member const* member = GetMember(session->GetPlayer()->GetGUID());
|
||||
if (!member) // Shouldn't happen, just in case
|
||||
return;
|
||||
|
||||
ByteBuffer tabData;
|
||||
WorldPacket data(SMSG_GUILD_BANK_LIST, 500);
|
||||
data.WriteBit(0);
|
||||
WorldPackets::Guild::GuildBankQueryResults packet;
|
||||
|
||||
packet.Money = m_bankMoney;
|
||||
packet.WithdrawalsRemaining = _GetMemberRemainingSlots(member, tabId);
|
||||
packet.Tab = int32(tabId);
|
||||
packet.FullUpdate = fullUpdate;
|
||||
|
||||
// TabInfo
|
||||
if (fullUpdate)
|
||||
{
|
||||
packet.TabInfo.reserve(_GetPurchasedTabsSize());
|
||||
for (uint8 i = 0; i < _GetPurchasedTabsSize(); ++i)
|
||||
{
|
||||
WorldPackets::Guild::GuildBankTabInfo tabInfo;
|
||||
tabInfo.TabIndex = i;
|
||||
tabInfo.Name = m_bankTabs[i]->GetName();
|
||||
tabInfo.Icon = m_bankTabs[i]->GetIcon();
|
||||
packet.TabInfo.push_back(tabInfo);
|
||||
}
|
||||
}
|
||||
|
||||
// ItemInfo
|
||||
uint32 itemCount = 0;
|
||||
if (withContent && _MemberHasTabRights(session->GetPlayer()->GetGUID(), tabId, GUILD_BANK_RIGHT_VIEW_TAB))
|
||||
if (fullUpdate && _MemberHasTabRights(session->GetPlayer()->GetGUID(), tabId, GUILD_BANK_RIGHT_VIEW_TAB))
|
||||
if (BankTab const* tab = GetBankTab(tabId))
|
||||
for (uint8 slotId = 0; slotId < GUILD_BANK_MAX_SLOTS; ++slotId)
|
||||
if (tab->GetItem(slotId))
|
||||
++itemCount;
|
||||
|
||||
data.WriteBits(itemCount, 20);
|
||||
data.WriteBits(withTabInfo ? _GetPurchasedTabsSize() : 0, 22);
|
||||
if (withContent && _MemberHasTabRights(session->GetPlayer()->GetGUID(), tabId, GUILD_BANK_RIGHT_VIEW_TAB))
|
||||
packet.ItemInfo.reserve(itemCount);
|
||||
|
||||
if (fullUpdate && _MemberHasTabRights(session->GetPlayer()->GetGUID(), tabId, GUILD_BANK_RIGHT_VIEW_TAB))
|
||||
{
|
||||
if (BankTab const* tab = GetBankTab(tabId))
|
||||
{
|
||||
@@ -3713,65 +3723,41 @@ void Guild::SendBankList(WorldSession* session, uint8 tabId, bool withContent, b
|
||||
{
|
||||
if (Item* tabItem = tab->GetItem(slotId))
|
||||
{
|
||||
data.WriteBit(0);
|
||||
WorldPackets::Guild::GuildBankItemInfo itemInfo;
|
||||
|
||||
uint32 enchants = 0;
|
||||
for (uint32 ench = 0; ench < MAX_ENCHANTMENT_SLOT; ++ench)
|
||||
itemInfo.Slot = int32(slotId);
|
||||
itemInfo.Item.ItemID = tabItem->GetEntry();
|
||||
itemInfo.Count = int32(tabItem->GetCount());
|
||||
itemInfo.Charges = int32(abs(tabItem->GetSpellCharges()));
|
||||
itemInfo.RandomPropertiesID = int32(tabItem->GetItemRandomPropertyId());
|
||||
itemInfo.RandomPropertiesSeed = int32(tabItem->GetItemSuffixFactor());
|
||||
itemInfo.EnchantmentID = tabItem->GetEnchantmentId(EnchantmentSlot(PERM_ENCHANTMENT_SLOT));
|
||||
itemInfo.OnUseEnchantmentID = tabItem->GetEnchantmentId(EnchantmentSlot(BONUS_ENCHANTMENT_SLOT));
|
||||
itemInfo.ReforgeEnchantmentID = tabItem->GetEnchantmentId(EnchantmentSlot(REFORGE_ENCHANTMENT_SLOT));
|
||||
itemInfo.Flags = tabItem->GetInt32Value(ITEM_FIELD_FLAGS);
|
||||
|
||||
uint8 slotIndex = 0;
|
||||
for (uint8 enchSlot = SOCK_ENCHANTMENT_SLOT; enchSlot <= SOCK_ENCHANTMENT_SLOT_3; enchSlot++)
|
||||
{
|
||||
if (uint32 enchantId = tabItem->GetEnchantmentId(EnchantmentSlot(ench)))
|
||||
if (uint32 enchantId = tabItem->GetEnchantmentId(EnchantmentSlot(enchSlot)))
|
||||
{
|
||||
tabData << uint32(enchantId);
|
||||
tabData << uint32(ench);
|
||||
++enchants;
|
||||
WorldPackets::Item::ItemGemData gem;
|
||||
gem.EnchantmentId = enchantId;
|
||||
gem.Slot = slotIndex;
|
||||
itemInfo.SocketEnchant.push_back(gem);
|
||||
}
|
||||
slotIndex++;
|
||||
}
|
||||
|
||||
data.WriteBits(enchants, 23);
|
||||
itemInfo.Locked = false;
|
||||
|
||||
tabData << uint32(0);
|
||||
tabData << uint32(0);
|
||||
tabData << uint32(0);
|
||||
tabData << uint32(tabItem->GetCount()); // ITEM_FIELD_STACK_COUNT
|
||||
tabData << uint32(slotId);
|
||||
tabData << uint32(0);
|
||||
tabData << uint32(tabItem->GetEntry());
|
||||
tabData << uint32(tabItem->GetItemRandomPropertyId());
|
||||
tabData << uint32(abs(tabItem->GetSpellCharges())); // Spell charges
|
||||
tabData << uint32(tabItem->GetItemSuffixFactor()); // SuffixFactor
|
||||
packet.ItemInfo.push_back(itemInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (withTabInfo)
|
||||
{
|
||||
for (uint8 i = 0; i < _GetPurchasedTabsSize(); ++i)
|
||||
{
|
||||
data.WriteBits(m_bankTabs[i]->GetIcon().length(), 9);
|
||||
data.WriteBits(m_bankTabs[i]->GetName().length(), 7);
|
||||
}
|
||||
}
|
||||
|
||||
data.FlushBits();
|
||||
|
||||
if (withTabInfo)
|
||||
{
|
||||
for (uint8 i = 0; i < _GetPurchasedTabsSize(); ++i)
|
||||
{
|
||||
data.WriteString(m_bankTabs[i]->GetIcon());
|
||||
data << uint32(i);
|
||||
data.WriteString(m_bankTabs[i]->GetName());
|
||||
}
|
||||
}
|
||||
|
||||
data << uint64(m_bankMoney);
|
||||
if (!tabData.empty())
|
||||
data.append(tabData);
|
||||
|
||||
data << uint32(tabId);
|
||||
data << uint32(_GetMemberRemainingSlots(member, tabId));
|
||||
|
||||
session->SendPacket(&data);
|
||||
session->SendPacket(packet.Write());
|
||||
|
||||
TC_LOG_DEBUG("guild", "WORLD: Sent (SMSG_GUILD_BANK_LIST)");
|
||||
}
|
||||
|
||||
@@ -798,7 +798,7 @@ public:
|
||||
void SendGuildRankInfo(WorldSession* session) const;
|
||||
void SendEventLog(WorldSession* session) const;
|
||||
void SendBankLog(WorldSession* session, uint8 tabId) const;
|
||||
void SendBankList(WorldSession* session, uint8 tabId, bool withContent, bool withTabInfo) const;
|
||||
void SendBankList(WorldSession* session, uint8 tabId, bool fullUpdate) const;
|
||||
void SendGuildXP(WorldSession* session = nullptr) const;
|
||||
void SendBankTabText(WorldSession* session, uint8 tabId) const;
|
||||
void SendPermissions(WorldSession* session) const;
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "DatabaseEnv.h"
|
||||
#include "Guild.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "GuildPackets.h"
|
||||
#include "Log.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Player.h"
|
||||
@@ -395,16 +396,12 @@ void WorldSession::HandleGuildPermissions(WorldPacket& /* recvPacket */)
|
||||
}
|
||||
|
||||
// Called when clicking on Guild bank gameobject
|
||||
void WorldSession::HandleGuildBankerActivate(WorldPacket& recvPacket)
|
||||
void WorldSession::HandleGuildBankActivate(WorldPackets::Guild::GuildBankActivate& packet)
|
||||
{
|
||||
ObjectGuid guid;
|
||||
bool sendAllSlots;
|
||||
recvPacket >> guid >> sendAllSlots;
|
||||
TC_LOG_DEBUG("guild", "CMSG_GUILD_BANK_ACTIVATE [%s]: [%s] AllSlots: %u"
|
||||
, GetPlayerInfo().c_str(), packet.Banker.ToString().c_str(), packet.FullUpdate);
|
||||
|
||||
TC_LOG_DEBUG("guild", "CMSG_GUILD_BANKER_ACTIVATE [%s]: [%s] AllSlots: %u"
|
||||
, GetPlayerInfo().c_str(), guid.ToString().c_str(), sendAllSlots);
|
||||
|
||||
GameObject const* const go = GetPlayer()->GetGameObjectIfCanInteractWith(guid, GAMEOBJECT_TYPE_GUILD_BANK);
|
||||
GameObject const* const go = GetPlayer()->GetGameObjectIfCanInteractWith(packet.Banker, GAMEOBJECT_TYPE_GUILD_BANK);
|
||||
if (!go)
|
||||
return;
|
||||
|
||||
@@ -415,24 +412,18 @@ void WorldSession::HandleGuildBankerActivate(WorldPacket& recvPacket)
|
||||
return;
|
||||
}
|
||||
|
||||
guild->SendBankList(this, 0, true, true);
|
||||
guild->SendBankList(this, 0, packet.FullUpdate);
|
||||
}
|
||||
|
||||
// Called when opening guild bank tab only (first one)
|
||||
void WorldSession::HandleGuildBankQueryTab(WorldPacket& recvPacket)
|
||||
void WorldSession::HandleGuildBankQueryTab(WorldPackets::Guild::GuildBankQueryTab& packet)
|
||||
{
|
||||
ObjectGuid guid;
|
||||
uint8 tabId;
|
||||
bool full;
|
||||
|
||||
recvPacket >> guid >> tabId >> full;
|
||||
|
||||
TC_LOG_DEBUG("guild", "CMSG_GUILD_BANK_QUERY_TAB [%s]: %s, TabId: %u, ShowTabs: %u"
|
||||
, GetPlayerInfo().c_str(), guid.ToString().c_str(), tabId, full);
|
||||
, GetPlayerInfo().c_str(), packet.Banker.ToString().c_str(), packet.Tab, packet.FullUpdate);
|
||||
|
||||
if (GetPlayer()->GetGameObjectIfCanInteractWith(guid, GAMEOBJECT_TYPE_GUILD_BANK))
|
||||
if (GetPlayer()->GetGameObjectIfCanInteractWith(packet.Banker, GAMEOBJECT_TYPE_GUILD_BANK))
|
||||
if (Guild* guild = GetPlayer()->GetGuild())
|
||||
guild->SendBankList(this, tabId, true, false);
|
||||
guild->SendBankList(this, packet.Tab, packet.FullUpdate);
|
||||
}
|
||||
|
||||
void WorldSession::HandleGuildBankDepositMoney(WorldPacket& recvPacket)
|
||||
@@ -546,35 +537,23 @@ void WorldSession::HandleGuildBankSwapItems(WorldPacket& recvPacket)
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSession::HandleGuildBankBuyTab(WorldPacket& recvPacket)
|
||||
void WorldSession::HandleGuildBankBuyTab(WorldPackets::Guild::GuildBankBuyTab& packet)
|
||||
{
|
||||
ObjectGuid guid;
|
||||
recvPacket >> guid;
|
||||
TC_LOG_DEBUG("guild", "CMSG_GUILD_BANK_BUY_TAB [%s]: [%s[, TabId: %u", GetPlayerInfo().c_str(), packet.Banker.ToString().c_str(), packet.BankTab);
|
||||
|
||||
uint8 tabId;
|
||||
recvPacket >> tabId;
|
||||
|
||||
TC_LOG_DEBUG("guild", "CMSG_GUILD_BANK_BUY_TAB [%s]: [%s[, TabId: %u", GetPlayerInfo().c_str(), guid.ToString().c_str(), tabId);
|
||||
|
||||
if (!guid || GetPlayer()->GetGameObjectIfCanInteractWith(guid, GAMEOBJECT_TYPE_GUILD_BANK))
|
||||
if (!packet.Banker || GetPlayer()->GetGameObjectIfCanInteractWith(packet.Banker, GAMEOBJECT_TYPE_GUILD_BANK))
|
||||
if (Guild* guild = GetPlayer()->GetGuild())
|
||||
guild->HandleBuyBankTab(this, tabId);
|
||||
guild->HandleBuyBankTab(this, packet.BankTab);
|
||||
}
|
||||
|
||||
void WorldSession::HandleGuildBankUpdateTab(WorldPacket& recvPacket)
|
||||
void WorldSession::HandleGuildBankUpdateTab(WorldPackets::Guild::GuildBankUpdateTab& packet)
|
||||
{
|
||||
ObjectGuid guid;
|
||||
uint8 tabId;
|
||||
std::string name, icon;
|
||||
|
||||
recvPacket >> guid >> tabId >> name >> icon;
|
||||
|
||||
TC_LOG_DEBUG("guild", "CMSG_GUILD_BANK_UPDATE_TAB [%s]: [%s], TabId: %u, Name: %s, Icon: %s"
|
||||
, GetPlayerInfo().c_str(), guid.ToString().c_str(), tabId, name.c_str(), icon.c_str());
|
||||
if (!name.empty() && !icon.empty())
|
||||
if (GetPlayer()->GetGameObjectIfCanInteractWith(guid, GAMEOBJECT_TYPE_GUILD_BANK))
|
||||
, GetPlayerInfo().c_str(), packet.Banker.ToString().c_str(), packet.BankTab, packet.Name.c_str(), packet.Icon.c_str());
|
||||
if (!packet.Name.empty() && !packet.Icon.empty())
|
||||
if (GetPlayer()->GetGameObjectIfCanInteractWith(packet.Banker, GAMEOBJECT_TYPE_GUILD_BANK))
|
||||
if (Guild* guild = GetPlayer()->GetGuild())
|
||||
guild->HandleSetBankTabInfo(this, tabId, name, icon);
|
||||
guild->HandleSetBankTabInfo(this, packet.BankTab, packet.Name, packet.Icon);
|
||||
}
|
||||
|
||||
void WorldSession::HandleGuildBankLogQuery(WorldPacket& recvPacket)
|
||||
|
||||
@@ -19,5 +19,6 @@
|
||||
#define AllPackets_h__
|
||||
|
||||
#include "LFGPackets.h"
|
||||
#include "GuildPackets.h"
|
||||
|
||||
#endif // AllPackets_h__
|
||||
|
||||
97
src/server/game/Server/Packets/GuildPackets.cpp
Normal file
97
src/server/game/Server/Packets/GuildPackets.cpp
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2019 TrinityCore <https://www.trinitycore.org/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "GuildPackets.h"
|
||||
|
||||
void WorldPackets::Guild::GuildBankActivate::Read()
|
||||
{
|
||||
_worldPacket >> Banker;
|
||||
_worldPacket >> FullUpdate;
|
||||
}
|
||||
|
||||
void WorldPackets::Guild::GuildBankQueryTab::Read()
|
||||
{
|
||||
_worldPacket >> Banker;
|
||||
_worldPacket >> Tab;
|
||||
_worldPacket >> FullUpdate;
|
||||
}
|
||||
|
||||
void WorldPackets::Guild::GuildBankBuyTab::Read()
|
||||
{
|
||||
_worldPacket >> Banker;
|
||||
_worldPacket >> BankTab;
|
||||
}
|
||||
|
||||
void WorldPackets::Guild::GuildBankUpdateTab::Read()
|
||||
{
|
||||
_worldPacket >> Banker;
|
||||
_worldPacket >> BankTab;
|
||||
_worldPacket >> Name;
|
||||
_worldPacket >> Icon;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::Guild::GuildBankQueryResults::Write()
|
||||
{
|
||||
_worldPacket.WriteBit(FullUpdate);
|
||||
_worldPacket.WriteBits(ItemInfo.size(), 20);
|
||||
_worldPacket.WriteBits(TabInfo.size(), 22);
|
||||
|
||||
for (GuildBankItemInfo const& item : ItemInfo)
|
||||
{
|
||||
_worldPacket.WriteBit(item.Locked);
|
||||
_worldPacket.WriteBits(item.SocketEnchant.size(), 23);
|
||||
}
|
||||
|
||||
for (GuildBankTabInfo const& tab : TabInfo)
|
||||
{
|
||||
_worldPacket.WriteBits(tab.Icon.length(), 9);
|
||||
_worldPacket.WriteBits(tab.Name.length(), 7);
|
||||
}
|
||||
|
||||
_worldPacket.FlushBits();
|
||||
|
||||
for (GuildBankTabInfo const& tab : TabInfo)
|
||||
{
|
||||
_worldPacket.WriteString(tab.Icon);
|
||||
_worldPacket << uint32(tab.TabIndex);
|
||||
_worldPacket.WriteString(tab.Name);
|
||||
}
|
||||
|
||||
_worldPacket << uint64(Money);
|
||||
|
||||
for (GuildBankItemInfo const& item : ItemInfo)
|
||||
{
|
||||
for (Item::ItemGemData const& socketEnchant : item.SocketEnchant)
|
||||
_worldPacket << socketEnchant;
|
||||
|
||||
_worldPacket << uint32(item.EnchantmentID);
|
||||
_worldPacket << uint32(item.ReforgeEnchantmentID);
|
||||
_worldPacket << uint32(item.OnUseEnchantmentID);
|
||||
_worldPacket << int32(item.Count);
|
||||
_worldPacket << int32(item.Slot);
|
||||
_worldPacket << int32(item.Flags);
|
||||
_worldPacket << int32(item.Item.ItemID);
|
||||
_worldPacket << int32(item.RandomPropertiesID);
|
||||
_worldPacket << int32(item.Charges);
|
||||
_worldPacket << int32(item.RandomPropertiesSeed);
|
||||
}
|
||||
|
||||
_worldPacket << uint32(Tab);
|
||||
_worldPacket << uint32(WithdrawalsRemaining);
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
117
src/server/game/Server/Packets/GuildPackets.h
Normal file
117
src/server/game/Server/Packets/GuildPackets.h
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2019 TrinityCore <http://www.trinitycore.org/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GuildPackets_h__
|
||||
#define GuildPackets_h__
|
||||
|
||||
#include "Packet.h"
|
||||
#include "ItemPacketsCommon.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include "Guild.h"
|
||||
|
||||
namespace WorldPackets
|
||||
{
|
||||
namespace Guild
|
||||
{
|
||||
class GuildBankActivate final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
GuildBankActivate(WorldPacket&& packet) : ClientPacket(CMSG_GUILD_BANK_ACTIVATE, std::move(packet)) { }
|
||||
|
||||
void Read() override;
|
||||
|
||||
ObjectGuid Banker;
|
||||
bool FullUpdate = false;
|
||||
};
|
||||
|
||||
class GuildBankQueryTab final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
GuildBankQueryTab(WorldPacket&& packet) : ClientPacket(CMSG_GUILD_BANK_QUERY_TAB, std::move(packet)) { }
|
||||
|
||||
void Read() override;
|
||||
|
||||
ObjectGuid Banker;
|
||||
uint8 Tab = 0;
|
||||
bool FullUpdate = false;
|
||||
};
|
||||
|
||||
class GuildBankBuyTab final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
GuildBankBuyTab(WorldPacket&& packet) : ClientPacket(CMSG_GUILD_BANK_BUY_TAB, std::move(packet)) { }
|
||||
|
||||
void Read() override;
|
||||
|
||||
ObjectGuid Banker;
|
||||
uint8 BankTab = 0;
|
||||
};
|
||||
|
||||
class GuildBankUpdateTab final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
GuildBankUpdateTab(WorldPacket&& packet) : ClientPacket(CMSG_GUILD_BANK_UPDATE_TAB, std::move(packet)) { }
|
||||
|
||||
void Read() override;
|
||||
|
||||
ObjectGuid Banker;
|
||||
uint8 BankTab = 0;
|
||||
std::string Name;
|
||||
std::string Icon;
|
||||
};
|
||||
|
||||
struct GuildBankItemInfo
|
||||
{
|
||||
WorldPackets::Item::ItemInstance Item;
|
||||
int32 Slot = 0;
|
||||
int32 Count = 0;
|
||||
int32 EnchantmentID = 0;
|
||||
int32 Charges = 0;
|
||||
int32 OnUseEnchantmentID = 0;
|
||||
int32 ReforgeEnchantmentID = 0;
|
||||
int32 RandomPropertiesID = 0;
|
||||
int32 RandomPropertiesSeed = 0;
|
||||
int32 Flags = 0;
|
||||
bool Locked = false;
|
||||
std::vector<Item::ItemGemData> SocketEnchant;
|
||||
};
|
||||
|
||||
struct GuildBankTabInfo
|
||||
{
|
||||
int32 TabIndex = 0;
|
||||
std::string Name;
|
||||
std::string Icon;
|
||||
};
|
||||
|
||||
class GuildBankQueryResults final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
GuildBankQueryResults() : ServerPacket(SMSG_GUILD_BANK_QUERY_RESULTS, 25) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
std::vector<GuildBankItemInfo> ItemInfo;
|
||||
std::vector<GuildBankTabInfo> TabInfo;
|
||||
int32 WithdrawalsRemaining = 0;
|
||||
int32 Tab = 0;
|
||||
uint64 Money = 0;
|
||||
bool FullUpdate = false;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // GuildPackets_h__
|
||||
87
src/server/game/Server/Packets/ItemPacketsCommon.cpp
Normal file
87
src/server/game/Server/Packets/ItemPacketsCommon.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2019 TrinityCore <http://www.trinitycore.org/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "ItemPacketsCommon.h"
|
||||
#include "Item.h"
|
||||
#include "Player.h"
|
||||
#include "Loot.h"
|
||||
|
||||
void WorldPackets::Item::ItemInstance::Initialize(::Item const* item)
|
||||
{
|
||||
ItemID = item->GetEntry();
|
||||
RandomPropertiesID = item->GetItemRandomPropertyId();
|
||||
RandomPropertiesSeed = item->GetItemSuffixFactor();
|
||||
}
|
||||
|
||||
bool WorldPackets::Item::ItemInstance::operator==(ItemInstance const& r) const
|
||||
{
|
||||
if (ItemID != r.ItemID || RandomPropertiesID != r.RandomPropertiesID || RandomPropertiesSeed != r.RandomPropertiesSeed)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Item::ItemInstance const& itemInstance)
|
||||
{
|
||||
data << int32(itemInstance.ItemID);
|
||||
data << int32(itemInstance.RandomPropertiesID);
|
||||
data << int32(itemInstance.RandomPropertiesSeed);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
ByteBuffer& operator>>(ByteBuffer& data, WorldPackets::Item::ItemInstance& itemInstance)
|
||||
{
|
||||
data >> itemInstance.ItemID;
|
||||
data >> itemInstance.RandomPropertiesID;
|
||||
data >> itemInstance.RandomPropertiesSeed;
|
||||
return data;
|
||||
}
|
||||
|
||||
ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Item::ItemEnchantData const& itemEnchantData)
|
||||
{
|
||||
data << int32(itemEnchantData.ID);
|
||||
data << uint32(itemEnchantData.Expiration);
|
||||
data << int32(itemEnchantData.Charges);
|
||||
data << uint8(itemEnchantData.Slot);
|
||||
return data;
|
||||
}
|
||||
|
||||
ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Item::ItemGemData const& itemGemData)
|
||||
{
|
||||
data << uint32(itemGemData.Slot);
|
||||
data << uint32(itemGemData.EnchantmentId);
|
||||
return data;
|
||||
}
|
||||
|
||||
ByteBuffer& operator>>(ByteBuffer& data, WorldPackets::Item::ItemGemData& itemGemData)
|
||||
{
|
||||
data >> itemGemData.Slot;
|
||||
data >> itemGemData.EnchantmentId;
|
||||
return data;
|
||||
}
|
||||
|
||||
ByteBuffer& operator>>(ByteBuffer& data, WorldPackets::Item::InvUpdate& invUpdate)
|
||||
{
|
||||
invUpdate.Items.resize(data.ReadBits(2));
|
||||
for (size_t i = 0; i < invUpdate.Items.size(); ++i)
|
||||
{
|
||||
data >> invUpdate.Items[i].ContainerSlot;
|
||||
data >> invUpdate.Items[i].Slot;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
83
src/server/game/Server/Packets/ItemPacketsCommon.h
Normal file
83
src/server/game/Server/Packets/ItemPacketsCommon.h
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2019 TrinityCore <http://www.trinitycore.org/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef ItemPacketsCommon_h__
|
||||
#define ItemPacketsCommon_h__
|
||||
|
||||
#include "Define.h"
|
||||
#include "PacketUtilities.h"
|
||||
#include "Optional.h"
|
||||
#include <vector>
|
||||
|
||||
class ByteBuffer;
|
||||
class Item;
|
||||
|
||||
namespace WorldPackets
|
||||
{
|
||||
namespace Item
|
||||
{
|
||||
struct ItemInstance
|
||||
{
|
||||
void Initialize(::Item const* item);
|
||||
|
||||
uint32 ItemID = 0;
|
||||
uint32 RandomPropertiesSeed = 0;
|
||||
uint32 RandomPropertiesID = 0;
|
||||
|
||||
bool operator==(ItemInstance const& r) const;
|
||||
bool operator!=(ItemInstance const& r) const { return !(*this == r); }
|
||||
};
|
||||
|
||||
struct ItemEnchantData
|
||||
{
|
||||
ItemEnchantData(int32 id, uint32 expiration, int32 charges, uint8 slot) : ID(id), Expiration(expiration), Charges(charges), Slot(slot) { }
|
||||
int32 ID = 0;
|
||||
uint32 Expiration = 0;
|
||||
int32 Charges = 0;
|
||||
uint8 Slot = 0;
|
||||
};
|
||||
|
||||
struct ItemGemData
|
||||
{
|
||||
uint8 Slot;
|
||||
uint32 EnchantmentId;
|
||||
};
|
||||
|
||||
struct InvUpdate
|
||||
{
|
||||
struct InvItem
|
||||
{
|
||||
uint8 ContainerSlot = 0;
|
||||
uint8 Slot = 0;
|
||||
};
|
||||
|
||||
std::vector<InvItem> Items;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Item::ItemInstance const& itemInstance);
|
||||
ByteBuffer& operator>>(ByteBuffer& data, WorldPackets::Item::ItemInstance& itemInstance);
|
||||
|
||||
ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Item::ItemEnchantData const& itemEnchantData);
|
||||
|
||||
ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Item::ItemGemData const& itemGemInstanceData);
|
||||
ByteBuffer& operator>>(ByteBuffer& data, WorldPackets::Item::ItemGemData& itemGemInstanceData);
|
||||
|
||||
ByteBuffer& operator>>(ByteBuffer& data, WorldPackets::Item::InvUpdate& invUpdate);
|
||||
|
||||
#endif // ItemPacketsCommon_h__
|
||||
@@ -319,7 +319,7 @@ void OpcodeTable::Initialize()
|
||||
DEFINE_HANDLER(CMSG_GUILD_ACHIEVEMENT_PROGRESS_QUERY, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleGuildAchievementProgressQuery);
|
||||
DEFINE_HANDLER(CMSG_GUILD_ADD_RANK, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleGuildAddRankOpcode );
|
||||
DEFINE_HANDLER(CMSG_GUILD_ASSIGN_MEMBER_RANK, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleGuildAssignRankOpcode );
|
||||
DEFINE_HANDLER(CMSG_GUILD_BANKER_ACTIVATE, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleGuildBankerActivate );
|
||||
DEFINE_HANDLER(CMSG_GUILD_BANK_ACTIVATE, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleGuildBankActivate );
|
||||
DEFINE_HANDLER(CMSG_GUILD_BANK_BUY_TAB, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleGuildBankBuyTab );
|
||||
DEFINE_HANDLER(CMSG_GUILD_BANK_DEPOSIT_MONEY, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleGuildBankDepositMoney );
|
||||
DEFINE_HANDLER(CMSG_GUILD_BANK_LOG_QUERY, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleGuildBankLogQuery );
|
||||
@@ -922,7 +922,7 @@ void OpcodeTable::Initialize()
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_GUILD_ACHIEVEMENT_DELETED, STATUS_NEVER);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_GUILD_ACHIEVEMENT_EARNED, STATUS_NEVER);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_GUILD_ACHIEVEMENT_MEMBERS, STATUS_NEVER);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_GUILD_BANK_LIST, STATUS_NEVER);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_GUILD_BANK_QUERY_RESULTS, STATUS_NEVER);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_GUILD_BANK_LOG_QUERY_RESULT, STATUS_NEVER);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_GUILD_BANK_MONEY_WITHDRAWN, STATUS_NEVER);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_GUILD_BANK_QUERY_TEXT_RESULT, STATUS_NEVER);
|
||||
|
||||
@@ -234,7 +234,7 @@ enum Opcodes : uint16
|
||||
CMSG_GUILD_ACHIEVEMENT_PROGRESS_QUERY = 0x3235,
|
||||
CMSG_GUILD_ADD_RANK = 0x3030,
|
||||
CMSG_GUILD_ASSIGN_MEMBER_RANK = 0x3032,
|
||||
CMSG_GUILD_BANKER_ACTIVATE = 0x2E37,
|
||||
CMSG_GUILD_BANK_ACTIVATE = 0x2E37,
|
||||
CMSG_GUILD_BANK_BUY_TAB = 0x0C37,
|
||||
CMSG_GUILD_BANK_DEPOSIT_MONEY = 0x0707,
|
||||
CMSG_GUILD_BANK_LOG_QUERY = 0x3224,
|
||||
@@ -893,7 +893,7 @@ enum Opcodes : uint16
|
||||
SMSG_GUILD_ACHIEVEMENT_DELETED = 0x35A0,
|
||||
SMSG_GUILD_ACHIEVEMENT_EARNED = 0x50B5,
|
||||
SMSG_GUILD_ACHIEVEMENT_MEMBERS = 0x38A5,
|
||||
SMSG_GUILD_BANK_LIST = 0x78A5,
|
||||
SMSG_GUILD_BANK_QUERY_RESULTS = 0x78A5,
|
||||
SMSG_GUILD_BANK_LOG_QUERY_RESULT = 0x30B2,
|
||||
SMSG_GUILD_BANK_MONEY_WITHDRAWN = 0x5DB4,
|
||||
SMSG_GUILD_BANK_QUERY_TEXT_RESULT = 0x75A3,
|
||||
|
||||
@@ -96,6 +96,15 @@ namespace WorldPackets
|
||||
class LfgBootPlayer;
|
||||
class LFGOfferContinue;
|
||||
}
|
||||
|
||||
namespace Guild
|
||||
{
|
||||
class GuildBankQueryResults;
|
||||
class GuildBankActivate;
|
||||
class GuildBankQueryTab;
|
||||
class GuildBankBuyTab;
|
||||
class GuildBankUpdateTab;
|
||||
}
|
||||
}
|
||||
|
||||
enum AccountDataType
|
||||
@@ -1022,15 +1031,14 @@ class TC_GAME_API WorldSession
|
||||
// Guild Bank
|
||||
void HandleGuildPermissions(WorldPacket& recvData);
|
||||
void HandleGuildBankMoneyWithdrawn(WorldPacket& recvData);
|
||||
void HandleGuildBankerActivate(WorldPacket& recvData);
|
||||
void HandleGuildBankQueryTab(WorldPacket& recvData);
|
||||
void HandleGuildBankActivate(WorldPackets::Guild::GuildBankActivate& packet);
|
||||
void HandleGuildBankQueryTab(WorldPackets::Guild::GuildBankQueryTab& packet);
|
||||
void HandleGuildBankLogQuery(WorldPacket& recvData);
|
||||
void HandleGuildBankDepositMoney(WorldPacket& recvData);
|
||||
void HandleGuildBankWithdrawMoney(WorldPacket& recvData);
|
||||
void HandleGuildBankSwapItems(WorldPacket& recvData);
|
||||
|
||||
void HandleGuildBankUpdateTab(WorldPacket& recvData);
|
||||
void HandleGuildBankBuyTab(WorldPacket& recvData);
|
||||
void HandleGuildBankUpdateTab(WorldPackets::Guild::GuildBankUpdateTab& packet);
|
||||
void HandleGuildBankBuyTab(WorldPackets::Guild::GuildBankBuyTab& packet);
|
||||
void HandleQueryGuildBankTabText(WorldPacket& recvData);
|
||||
void HandleSetGuildBankTabText(WorldPacket& recvData);
|
||||
void HandleGuildQueryXPOpcode(WorldPacket& recvData);
|
||||
|
||||
Reference in New Issue
Block a user