mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Packets: rename packet structs to match client names
This commit is contained in:
@@ -13030,18 +13030,30 @@ void Player::RemoveItemFromBuyBackSlot(uint32 slot, bool del)
|
||||
}
|
||||
}
|
||||
|
||||
void Player::SendEquipError(InventoryResult msg, Item* pItem, Item* pItem2, uint32 itemid)
|
||||
void Player::SendEquipError(InventoryResult msg, Item* item1 /*= nullptr*/, Item* item2 /*= nullptr*/, uint32 itemId /*= 0*/)
|
||||
{
|
||||
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_INVENTORY_CHANGE_FAILURE (%u)", msg);
|
||||
|
||||
WorldPackets::Item::EquipError error;
|
||||
error.msg = msg;
|
||||
error.itemGUID1 = pItem ? pItem->GetGUID() : ObjectGuid::Empty;
|
||||
error.itemGUID2 = pItem2 ? pItem2->GetGUID() : ObjectGuid::Empty;
|
||||
WorldPackets::Item::InventoryChangeFailure failure;
|
||||
failure.BagResult = msg;
|
||||
|
||||
error.level = uint32(pItem ? pItem->GetRequiredLevel() : 0);
|
||||
if (item1)
|
||||
{
|
||||
failure.Item[0] = item1->GetGUID();
|
||||
failure.Level = uint32(item1->GetRequiredLevel());
|
||||
}
|
||||
|
||||
GetSession()->SendPacket(error.Write());
|
||||
if (item2)
|
||||
failure.Item[1] = item2->GetGUID();
|
||||
|
||||
/// @todo: fill remaining values:
|
||||
/// ContainerBSlot
|
||||
/// SrcContainer
|
||||
/// DstContainer
|
||||
/// SrcSlot
|
||||
/// LimitCategory
|
||||
|
||||
SendDirectMessage(failure.Write());
|
||||
}
|
||||
|
||||
void Player::SendBuyError(BuyResult msg, Creature* creature, uint32 item, uint32 /*param*/)
|
||||
|
||||
@@ -1515,7 +1515,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
void AddItemToBuyBackSlot(Item* pItem);
|
||||
Item* GetItemFromBuyBackSlot(uint32 slot);
|
||||
void RemoveItemFromBuyBackSlot(uint32 slot, bool del);
|
||||
void SendEquipError(InventoryResult msg, Item* pItem, Item* pItem2 = NULL, uint32 itemid = 0);
|
||||
void SendEquipError(InventoryResult msg, Item* item1 = nullptr, Item* item2 = nullptr, uint32 itemId = 0);
|
||||
void SendBuyError(BuyResult msg, Creature* creature, uint32 item, uint32 param);
|
||||
void SendSellError(SellResult msg, Creature* creature, ObjectGuid guid);
|
||||
void AddWeaponProficiency(uint32 newflag) { m_WeaponProficiency |= newflag; }
|
||||
|
||||
@@ -30,86 +30,84 @@
|
||||
#include "DB2Stores.h"
|
||||
#include "NPCPackets.h"
|
||||
#include "ItemPackets.h"
|
||||
#include <vector>
|
||||
|
||||
void WorldSession::HandleSplitItemOpcode(WorldPackets::Item::SplitItem& splitItem)
|
||||
{
|
||||
if (splitItem.itemCount)
|
||||
if (!splitItem.Inv.Items.empty())
|
||||
{
|
||||
TC_LOG_ERROR("network", "WORLD: HandleSplitItemOpcode - Invalid itemCount (%u)", splitItem.itemCount);
|
||||
TC_LOG_ERROR("network", "HandleSplitItemOpcode - Invalid ItemCount (" SZFMTD ")", splitItem.Inv.Items.size());
|
||||
return;
|
||||
}
|
||||
|
||||
//TC_LOG_DEBUG("network", "WORLD: CMSG_SPLIT_ITEM");
|
||||
TC_LOG_DEBUG("network", "HandleSplitItemOpcode: receive FromPackSlot: %u, FromSlot: %u, ToPackSlot: %u, ToSlot: %u, Quantity: %u",
|
||||
splitItem.FromPackSlot, splitItem.FromSlot, splitItem.ToPackSlot, splitItem.ToSlot, splitItem.Quantity);
|
||||
|
||||
TC_LOG_DEBUG("network", "STORAGE: receive srcbag = %u, srcslot = %u, dstbag = %u, dstslot = %u, count = %u", splitItem.srcbag, splitItem.srcslot, splitItem.dstbag, splitItem.dstslot, splitItem.count);
|
||||
|
||||
uint16 src = ((splitItem.srcbag << 8) | splitItem.srcslot);
|
||||
uint16 dst = ((splitItem.dstbag << 8) | splitItem.dstslot);
|
||||
uint16 src = ((splitItem.FromPackSlot << 8) | splitItem.FromSlot);
|
||||
uint16 dst = ((splitItem.ToPackSlot << 8) | splitItem.ToSlot);
|
||||
|
||||
if (src == dst)
|
||||
return;
|
||||
|
||||
if (splitItem.count == 0)
|
||||
return; //check count - if zero it's fake packet
|
||||
// check count - if zero it's fake packet
|
||||
if (!splitItem.Quantity)
|
||||
return;
|
||||
|
||||
if (!_player->IsValidPos(splitItem.srcbag, splitItem.srcslot, true))
|
||||
if (!_player->IsValidPos(splitItem.FromPackSlot, splitItem.FromSlot, true))
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
|
||||
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_player->IsValidPos(splitItem.dstbag, splitItem.dstslot, false)) // can be autostore pos
|
||||
if (!_player->IsValidPos(splitItem.ToPackSlot, splitItem.ToSlot, false)) // can be autostore pos
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_WRONG_SLOT, NULL, NULL);
|
||||
_player->SendEquipError(EQUIP_ERR_WRONG_SLOT);
|
||||
return;
|
||||
}
|
||||
|
||||
_player->SplitItem(src, dst, splitItem.count);
|
||||
_player->SplitItem(src, dst, splitItem.Quantity);
|
||||
}
|
||||
|
||||
void WorldSession::HandleSwapInvItemOpcode(WorldPackets::Item::SwapInvItem& swapInvItem)
|
||||
{
|
||||
if (swapInvItem.itemCount != 2)
|
||||
if (swapInvItem.Inv.Items.size() != 2)
|
||||
{
|
||||
TC_LOG_ERROR("network", "WORLD: HandleSwapInvItemOpcode - Invalid itemCount (%u)", swapInvItem.itemCount);
|
||||
TC_LOG_ERROR("network", "HandleSwapInvItemOpcode - Invalid itemCount (" SZFMTD ")", swapInvItem.Inv.Items.size());
|
||||
return;
|
||||
}
|
||||
|
||||
//TC_LOG_DEBUG("network", "WORLD: CMSG_SWAP_INV_ITEM");
|
||||
|
||||
TC_LOG_DEBUG("network", "STORAGE: receive srcslot = %u, dstslot = %u", swapInvItem.srcslot, swapInvItem.dstslot);
|
||||
TC_LOG_DEBUG("network", "HandleSwapInvItemOpcode: receive Slot1: %u, Slot2: %u",
|
||||
swapInvItem.Slot1, swapInvItem.Slot2);
|
||||
|
||||
// prevent attempt swap same item to current position generated by client at special checting sequence
|
||||
if (swapInvItem.srcslot == swapInvItem.dstslot)
|
||||
if (swapInvItem.Slot1 == swapInvItem.Slot2)
|
||||
return;
|
||||
|
||||
if (!_player->IsValidPos(INVENTORY_SLOT_BAG_0, swapInvItem.srcslot, true))
|
||||
if (!_player->IsValidPos(INVENTORY_SLOT_BAG_0, swapInvItem.Slot1, true))
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
|
||||
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_player->IsValidPos(INVENTORY_SLOT_BAG_0, swapInvItem.dstslot, true))
|
||||
if (!_player->IsValidPos(INVENTORY_SLOT_BAG_0, swapInvItem.Slot2, true))
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_WRONG_SLOT, NULL, NULL);
|
||||
_player->SendEquipError(EQUIP_ERR_WRONG_SLOT);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_player->IsBankPos(INVENTORY_SLOT_BAG_0, swapInvItem.srcslot) && !CanUseBank())
|
||||
if (_player->IsBankPos(INVENTORY_SLOT_BAG_0, swapInvItem.Slot1) && !CanUseBank())
|
||||
{
|
||||
TC_LOG_DEBUG("network", "WORLD: HandleSwapInvItemOpcode - Unit (%s) not found or you can't interact with him.", m_currentBankerGUID.ToString().c_str());
|
||||
TC_LOG_DEBUG("network", "HandleSwapInvItemOpcode - Unit (%s) not found or you can't interact with him.", m_currentBankerGUID.ToString().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (_player->IsBankPos(INVENTORY_SLOT_BAG_0, swapInvItem.dstslot) && !CanUseBank())
|
||||
if (_player->IsBankPos(INVENTORY_SLOT_BAG_0, swapInvItem.Slot2) && !CanUseBank())
|
||||
{
|
||||
TC_LOG_DEBUG("network", "WORLD: HandleSwapInvItemOpcode - Unit (%s) not found or you can't interact with him.", m_currentBankerGUID.ToString().c_str());
|
||||
TC_LOG_DEBUG("network", "HandleSwapInvItemOpcode - Unit (%s) not found or you can't interact with him.", m_currentBankerGUID.ToString().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
uint16 src = ((INVENTORY_SLOT_BAG_0 << 8) | swapInvItem.srcslot);
|
||||
uint16 dst = ((INVENTORY_SLOT_BAG_0 << 8) | swapInvItem.dstslot);
|
||||
uint16 src = ((INVENTORY_SLOT_BAG_0 << 8) | swapInvItem.Slot1);
|
||||
uint16 dst = ((INVENTORY_SLOT_BAG_0 << 8) | swapInvItem.Slot2);
|
||||
|
||||
_player->SwapItem(src, dst);
|
||||
}
|
||||
@@ -135,44 +133,43 @@ void WorldSession::HandleAutoEquipItemSlotOpcode(WorldPacket& recvData)
|
||||
|
||||
void WorldSession::HandleSwapItem(WorldPackets::Item::SwapItem& swapItem)
|
||||
{
|
||||
if (swapItem.itemCount != 2)
|
||||
if (swapItem.Inv.Items.size() != 2)
|
||||
{
|
||||
TC_LOG_ERROR("network", "WORLD: HandleSwapItem - Invalid itemCount (%u)", swapItem.itemCount);
|
||||
TC_LOG_ERROR("network", "HandleSwapItem - Invalid itemCount (" SZFMTD ")", swapItem.Inv.Items.size());
|
||||
return;
|
||||
}
|
||||
|
||||
//TC_LOG_DEBUG("network", "WORLD: CMSG_SWAP_ITEM");
|
||||
TC_LOG_DEBUG("network", "HandleSwapItem: receive ContainerSlotA: %u, SlotA: %u, ContainerSlotB: %u, SlotB: %u",
|
||||
swapItem.ContainerSlotA, swapItem.SlotA, swapItem.ContainerSlotB, swapItem.SlotB);
|
||||
|
||||
TC_LOG_DEBUG("network", "STORAGE: receive srcbag = %u, srcslot = %u, dstbag = %u, dstslot = %u", swapItem.srcbag, swapItem.srcslot, swapItem.dstbag, swapItem.dstslot);
|
||||
|
||||
uint16 src = ((swapItem.srcbag << 8) | swapItem.srcslot);
|
||||
uint16 dst = ((swapItem.dstbag << 8) | swapItem.dstslot);
|
||||
uint16 src = ((swapItem.ContainerSlotA << 8) | swapItem.SlotA);
|
||||
uint16 dst = ((swapItem.ContainerSlotB << 8) | swapItem.SlotB);
|
||||
|
||||
// prevent attempt swap same item to current position generated by client at special checting sequence
|
||||
if (src == dst)
|
||||
return;
|
||||
|
||||
if (!_player->IsValidPos(swapItem.srcbag, swapItem.srcslot, true))
|
||||
if (!_player->IsValidPos(swapItem.ContainerSlotA, swapItem.SlotA, true))
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
|
||||
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_player->IsValidPos(swapItem.dstbag, swapItem.dstslot, true))
|
||||
if (!_player->IsValidPos(swapItem.ContainerSlotB, swapItem.SlotB, true))
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_WRONG_SLOT, NULL, NULL);
|
||||
_player->SendEquipError(EQUIP_ERR_WRONG_SLOT);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_player->IsBankPos(swapItem.srcbag, swapItem.srcslot) && !CanUseBank())
|
||||
if (_player->IsBankPos(swapItem.ContainerSlotA, swapItem.SlotA) && !CanUseBank())
|
||||
{
|
||||
TC_LOG_DEBUG("network", "WORLD: HandleSwapItem - Unit (%s) not found or you can't interact with him.", m_currentBankerGUID.ToString().c_str());
|
||||
TC_LOG_DEBUG("network", "HandleSwapItem - Unit (%s) not found or you can't interact with him.", m_currentBankerGUID.ToString().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (_player->IsBankPos(swapItem.dstbag, swapItem.dstslot) && !CanUseBank())
|
||||
if (_player->IsBankPos(swapItem.ContainerSlotB, swapItem.SlotB) && !CanUseBank())
|
||||
{
|
||||
TC_LOG_DEBUG("network", "WORLD: HandleSwapItem - Unit (%s) not found or you can't interact with him.", m_currentBankerGUID.ToString().c_str());
|
||||
TC_LOG_DEBUG("network", "HandleSwapItem - Unit (%s) not found or you can't interact with him.", m_currentBankerGUID.ToString().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -181,48 +178,47 @@ void WorldSession::HandleSwapItem(WorldPackets::Item::SwapItem& swapItem)
|
||||
|
||||
void WorldSession::HandleAutoEquipItemOpcode(WorldPackets::Item::AutoEquipItem& autoEquipItem)
|
||||
{
|
||||
if (autoEquipItem.itemCount != 1)
|
||||
if (autoEquipItem.Inv.Items.size() != 1)
|
||||
{
|
||||
TC_LOG_ERROR("network", "WORLD: HandleAutoEquipItemOpcode - Invalid itemCount (%u)", autoEquipItem.itemCount);
|
||||
TC_LOG_ERROR("network", "HandleAutoEquipItemOpcode - Invalid itemCount (" SZFMTD ")", autoEquipItem.Inv.Items.size());
|
||||
return;
|
||||
}
|
||||
|
||||
//TC_LOG_DEBUG("network", "WORLD: CMSG_AUTOEQUIP_ITEM");
|
||||
TC_LOG_DEBUG("network", "HandleAutoEquipItemOpcode: receive PackSlot: %u, Slot: %u",
|
||||
autoEquipItem.PackSlot, autoEquipItem.Slot);
|
||||
|
||||
TC_LOG_DEBUG("network", "STORAGE: receive srcbag = %u, srcslot = %u", autoEquipItem.srcbag, autoEquipItem.srcslot);
|
||||
|
||||
Item* pSrcItem = _player->GetItemByPos(autoEquipItem.srcbag, autoEquipItem.srcslot);
|
||||
if (!pSrcItem)
|
||||
return; // only at cheat
|
||||
Item* srcItem = _player->GetItemByPos(autoEquipItem.PackSlot, autoEquipItem.Slot);
|
||||
if (!srcItem)
|
||||
return; // only at cheat
|
||||
|
||||
uint16 dest;
|
||||
InventoryResult msg = _player->CanEquipItem(NULL_SLOT, dest, pSrcItem, !pSrcItem->IsBag());
|
||||
InventoryResult msg = _player->CanEquipItem(NULL_SLOT, dest, srcItem, !srcItem->IsBag());
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
{
|
||||
_player->SendEquipError(msg, pSrcItem, NULL);
|
||||
_player->SendEquipError(msg, srcItem);
|
||||
return;
|
||||
}
|
||||
|
||||
uint16 src = pSrcItem->GetPos();
|
||||
if (dest == src) // prevent equip in same slot, only at cheat
|
||||
uint16 src = srcItem->GetPos();
|
||||
if (dest == src) // prevent equip in same slot, only at cheat
|
||||
return;
|
||||
|
||||
Item* pDstItem = _player->GetItemByPos(dest);
|
||||
if (!pDstItem) // empty slot, simple case
|
||||
Item* dstItem = _player->GetItemByPos(dest);
|
||||
if (!dstItem) // empty slot, simple case
|
||||
{
|
||||
_player->RemoveItem(autoEquipItem.srcbag, autoEquipItem.srcslot, true);
|
||||
_player->EquipItem(dest, pSrcItem, true);
|
||||
_player->RemoveItem(autoEquipItem.PackSlot, autoEquipItem.Slot, true);
|
||||
_player->EquipItem(dest, srcItem, true);
|
||||
_player->AutoUnequipOffhandIfNeed();
|
||||
}
|
||||
else // have currently equipped item, not simple case
|
||||
{
|
||||
uint8 dstbag = pDstItem->GetBagSlot();
|
||||
uint8 dstslot = pDstItem->GetSlot();
|
||||
uint8 dstbag = dstItem->GetBagSlot();
|
||||
uint8 dstslot = dstItem->GetSlot();
|
||||
|
||||
msg = _player->CanUnequipItem(dest, !pSrcItem->IsBag());
|
||||
msg = _player->CanUnequipItem(dest, !srcItem->IsBag());
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
{
|
||||
_player->SendEquipError(msg, pDstItem, NULL);
|
||||
_player->SendEquipError(msg, dstItem);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -231,47 +227,47 @@ void WorldSession::HandleAutoEquipItemOpcode(WorldPackets::Item::AutoEquipItem&
|
||||
uint16 eSrc = 0;
|
||||
if (_player->IsInventoryPos(src))
|
||||
{
|
||||
msg = _player->CanStoreItem(autoEquipItem.srcbag, autoEquipItem.srcslot, sSrc, pDstItem, true);
|
||||
msg = _player->CanStoreItem(autoEquipItem.PackSlot, autoEquipItem.Slot, sSrc, dstItem, true);
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
msg = _player->CanStoreItem(autoEquipItem.srcbag, NULL_SLOT, sSrc, pDstItem, true);
|
||||
msg = _player->CanStoreItem(autoEquipItem.PackSlot, NULL_SLOT, sSrc, dstItem, true);
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, sSrc, pDstItem, true);
|
||||
msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, sSrc, dstItem, true);
|
||||
}
|
||||
else if (_player->IsBankPos(src))
|
||||
{
|
||||
msg = _player->CanBankItem(autoEquipItem.srcbag, autoEquipItem.srcslot, sSrc, pDstItem, true);
|
||||
msg = _player->CanBankItem(autoEquipItem.PackSlot, autoEquipItem.Slot, sSrc, dstItem, true);
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
msg = _player->CanBankItem(autoEquipItem.srcbag, NULL_SLOT, sSrc, pDstItem, true);
|
||||
msg = _player->CanBankItem(autoEquipItem.PackSlot, NULL_SLOT, sSrc, dstItem, true);
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
msg = _player->CanBankItem(NULL_BAG, NULL_SLOT, sSrc, pDstItem, true);
|
||||
msg = _player->CanBankItem(NULL_BAG, NULL_SLOT, sSrc, dstItem, true);
|
||||
}
|
||||
else if (_player->IsEquipmentPos(src))
|
||||
{
|
||||
msg = _player->CanEquipItem(autoEquipItem.srcslot, eSrc, pDstItem, true);
|
||||
msg = _player->CanEquipItem(autoEquipItem.Slot, eSrc, dstItem, true);
|
||||
if (msg == EQUIP_ERR_OK)
|
||||
msg = _player->CanUnequipItem(eSrc, true);
|
||||
}
|
||||
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
{
|
||||
_player->SendEquipError(msg, pDstItem, pSrcItem);
|
||||
_player->SendEquipError(msg, dstItem, srcItem);
|
||||
return;
|
||||
}
|
||||
|
||||
// now do moves, remove...
|
||||
_player->RemoveItem(dstbag, dstslot, false);
|
||||
_player->RemoveItem(autoEquipItem.srcbag, autoEquipItem.srcslot, false);
|
||||
_player->RemoveItem(autoEquipItem.PackSlot, autoEquipItem.Slot, false);
|
||||
|
||||
// add to dest
|
||||
_player->EquipItem(dest, pSrcItem, true);
|
||||
_player->EquipItem(dest, srcItem, true);
|
||||
|
||||
// add to src
|
||||
if (_player->IsInventoryPos(src))
|
||||
_player->StoreItem(sSrc, pDstItem, true);
|
||||
_player->StoreItem(sSrc, dstItem, true);
|
||||
else if (_player->IsBankPos(src))
|
||||
_player->BankItem(sSrc, pDstItem, true);
|
||||
_player->BankItem(sSrc, dstItem, true);
|
||||
else if (_player->IsEquipmentPos(src))
|
||||
_player->EquipItem(eSrc, pDstItem, true);
|
||||
_player->EquipItem(eSrc, dstItem, true);
|
||||
|
||||
_player->AutoUnequipOffhandIfNeed();
|
||||
}
|
||||
@@ -279,11 +275,10 @@ void WorldSession::HandleAutoEquipItemOpcode(WorldPackets::Item::AutoEquipItem&
|
||||
|
||||
void WorldSession::HandleDestroyItemOpcode(WorldPackets::Item::DestroyItem& destroyItem)
|
||||
{
|
||||
//TC_LOG_DEBUG("network", "WORLD: CMSG_DESTROY_ITEM");
|
||||
TC_LOG_DEBUG("network", "HandleDestroyItemOpcode: receive ContainerId: %u, SlotNum: %u, Count: %u",
|
||||
destroyItem.ContainerId, destroyItem.SlotNum, destroyItem.Count);
|
||||
|
||||
TC_LOG_DEBUG("network", "STORAGE: receive bag = %u, slot = %u, count = %u", destroyItem.bag, destroyItem.slot, destroyItem.count);
|
||||
|
||||
uint16 pos = (destroyItem.bag << 8) | destroyItem.slot;
|
||||
uint16 pos = (destroyItem.ContainerId << 8) | destroyItem.SlotNum;
|
||||
|
||||
// prevent drop unequipable items (in combat, for example) and non-empty bags
|
||||
if (_player->IsEquipmentPos(pos) || _player->IsBagPos(pos))
|
||||
@@ -291,31 +286,31 @@ void WorldSession::HandleDestroyItemOpcode(WorldPackets::Item::DestroyItem& dest
|
||||
InventoryResult msg = _player->CanUnequipItem(pos, false);
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
{
|
||||
_player->SendEquipError(msg, _player->GetItemByPos(pos), NULL);
|
||||
_player->SendEquipError(msg, _player->GetItemByPos(pos));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Item* pItem = _player->GetItemByPos(destroyItem.bag, destroyItem.slot);
|
||||
if (!pItem)
|
||||
Item* item = _player->GetItemByPos(destroyItem.ContainerId, destroyItem.SlotNum);
|
||||
if (!item)
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
|
||||
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pItem->GetTemplate()->GetFlags() & ITEM_PROTO_FLAG_INDESTRUCTIBLE)
|
||||
if (item->GetTemplate()->GetFlags() & ITEM_PROTO_FLAG_INDESTRUCTIBLE)
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_DROP_BOUND_ITEM, NULL, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (destroyItem.count)
|
||||
if (destroyItem.Count)
|
||||
{
|
||||
uint32 i_count = destroyItem.count;
|
||||
_player->DestroyItemCount(pItem, i_count, true);
|
||||
uint32 i_count = destroyItem.Count;
|
||||
_player->DestroyItemCount(item, i_count, true);
|
||||
}
|
||||
else
|
||||
_player->DestroyItem(destroyItem.bag, destroyItem.slot, true);
|
||||
_player->DestroyItem(destroyItem.ContainerId, destroyItem.SlotNum, true);
|
||||
}
|
||||
|
||||
void WorldSession::HandleReadItem(WorldPacket& recvData)
|
||||
|
||||
@@ -58,21 +58,20 @@ ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Item::ItemInstance const&
|
||||
return data;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::Item::EquipError::Write()
|
||||
WorldPacket const* WorldPackets::Item::InventoryChangeFailure::Write()
|
||||
{
|
||||
_worldPacket << uint8(msg);
|
||||
_worldPacket << itemGUID1;
|
||||
_worldPacket << itemGUID2;
|
||||
_worldPacket << uint8(0); // bag type subclass, used with EQUIP_ERR_EVENT_AUTOEQUIP_BIND_CONFIRM and EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG2
|
||||
_worldPacket << int8(BagResult);
|
||||
_worldPacket << Item[0];
|
||||
_worldPacket << Item[1];
|
||||
_worldPacket << uint8(ContainerBSlot); // bag type subclass, used with EQUIP_ERR_EVENT_AUTOEQUIP_BIND_CONFIRM and EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG2
|
||||
|
||||
switch (msg)
|
||||
switch (BagResult)
|
||||
{
|
||||
case EQUIP_ERR_CANT_EQUIP_LEVEL_I:
|
||||
case EQUIP_ERR_PURCHASE_LEVEL_TOO_LOW:
|
||||
{
|
||||
_worldPacket << level;
|
||||
_worldPacket << int32(Level);
|
||||
break;
|
||||
}
|
||||
/// @todo: add more cases
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -82,42 +81,64 @@ WorldPacket const* WorldPackets::Item::EquipError::Write()
|
||||
|
||||
void WorldPackets::Item::SplitItem::Read()
|
||||
{
|
||||
itemCount = _worldPacket.ReadBits(2);
|
||||
_worldPacket >> srcbag >> srcslot >> dstbag >> dstslot >> count;
|
||||
Inv.Items.resize(_worldPacket.ReadBits(2));
|
||||
for (size_t i = 0; i < Inv.Items.size(); ++i)
|
||||
{
|
||||
_worldPacket >> Inv.Items[i].ContainerSlot;
|
||||
_worldPacket >> Inv.Items[i].Slot;
|
||||
}
|
||||
|
||||
_worldPacket >> FromPackSlot
|
||||
>> FromSlot
|
||||
>> ToPackSlot
|
||||
>> ToSlot
|
||||
>> Quantity;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::SwapInvItem::Read()
|
||||
{
|
||||
itemCount = _worldPacket.ReadBits(2);
|
||||
for (uint32 i = 0; i < itemCount; ++i)
|
||||
Inv.Items.resize(_worldPacket.ReadBits(2));
|
||||
for (size_t i = 0; i < Inv.Items.size(); ++i)
|
||||
{
|
||||
_worldPacket.read_skip<uint8>(); // bag
|
||||
_worldPacket.read_skip<uint8>(); // slot
|
||||
_worldPacket >> Inv.Items[i].ContainerSlot;
|
||||
_worldPacket >> Inv.Items[i].Slot;
|
||||
}
|
||||
_worldPacket >> dstslot >> srcslot;
|
||||
|
||||
_worldPacket >> Slot2
|
||||
>> Slot1;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::SwapItem::Read()
|
||||
{
|
||||
itemCount = _worldPacket.ReadBits(2);
|
||||
for (uint32 i = 0; i < itemCount; ++i)
|
||||
Inv.Items.resize(_worldPacket.ReadBits(2));
|
||||
for (size_t i = 0; i < Inv.Items.size(); ++i)
|
||||
{
|
||||
_worldPacket.read_skip<uint8>(); // bag
|
||||
_worldPacket.read_skip<uint8>(); // slot
|
||||
_worldPacket >> Inv.Items[i].ContainerSlot;
|
||||
_worldPacket >> Inv.Items[i].Slot;
|
||||
}
|
||||
_worldPacket >> dstbag >> srcbag >> dstslot >> srcslot;
|
||||
|
||||
_worldPacket >> ContainerSlotB
|
||||
>> ContainerSlotA
|
||||
>> SlotB
|
||||
>> SlotA;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::AutoEquipItem::Read()
|
||||
{
|
||||
itemCount = _worldPacket.ReadBits(2);
|
||||
Inv.Items.resize(_worldPacket.ReadBits(2));
|
||||
for (size_t i = 0; i < Inv.Items.size(); ++i)
|
||||
{
|
||||
_worldPacket >> Inv.Items[i].ContainerSlot;
|
||||
_worldPacket >> Inv.Items[i].Slot;
|
||||
}
|
||||
|
||||
_worldPacket >> srcbag >> srcslot;
|
||||
_worldPacket.read_skip<uint8>();
|
||||
_worldPacket.read_skip<uint8>();
|
||||
_worldPacket >> PackSlot
|
||||
>> Slot;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::DestroyItem::Read()
|
||||
{
|
||||
_worldPacket >> count >> bag >> slot;
|
||||
_worldPacket >> Count
|
||||
>> ContainerId
|
||||
>> SlotNum;
|
||||
}
|
||||
|
||||
@@ -51,17 +51,32 @@ namespace WorldPackets
|
||||
std::vector<int32> Modifications;
|
||||
};
|
||||
|
||||
class EquipError final : public ServerPacket
|
||||
struct InvUpdate
|
||||
{
|
||||
struct InvItem
|
||||
{
|
||||
uint8 ContainerSlot = 0;
|
||||
uint8 Slot = 0;
|
||||
};
|
||||
|
||||
std::vector<InvItem> Items;
|
||||
};
|
||||
|
||||
class InventoryChangeFailure final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
EquipError() : ServerPacket(SMSG_INVENTORY_CHANGE_FAILURE, 22) { }
|
||||
InventoryChangeFailure() : ServerPacket(SMSG_INVENTORY_CHANGE_FAILURE, 22) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
InventoryResult msg;
|
||||
ObjectGuid itemGUID1;
|
||||
ObjectGuid itemGUID2;
|
||||
uint32 level;
|
||||
int8 BagResult = EQUIP_ERR_OK; /// @see enum InventoryResult
|
||||
uint8 ContainerBSlot = 0;
|
||||
ObjectGuid SrcContainer;
|
||||
ObjectGuid DstContainer;
|
||||
int32 SrcSlot = 0;
|
||||
int32 LimitCategory = 0;
|
||||
int32 Level = 0;
|
||||
ObjectGuid Item[2];
|
||||
};
|
||||
|
||||
class SplitItem final : public ClientPacket
|
||||
@@ -71,8 +86,12 @@ namespace WorldPackets
|
||||
|
||||
void Read() override;
|
||||
|
||||
uint8 srcbag, srcslot, dstbag, dstslot;
|
||||
uint32 itemCount, count;
|
||||
uint8 ToSlot = 0;
|
||||
uint8 ToPackSlot = 0;
|
||||
uint8 FromPackSlot = 0;
|
||||
int32 Quantity = 0;
|
||||
InvUpdate Inv;
|
||||
uint8 FromSlot = 0;
|
||||
};
|
||||
|
||||
class SwapInvItem final : public ClientPacket
|
||||
@@ -82,8 +101,9 @@ namespace WorldPackets
|
||||
|
||||
void Read() override;
|
||||
|
||||
uint32 itemCount;
|
||||
uint8 srcslot, dstslot;
|
||||
InvUpdate Inv;
|
||||
uint8 Slot1 = 0; /// Source Slot
|
||||
uint8 Slot2 = 0; /// Destination Slot
|
||||
};
|
||||
|
||||
class SwapItem final : public ClientPacket
|
||||
@@ -93,8 +113,11 @@ namespace WorldPackets
|
||||
|
||||
void Read() override;
|
||||
|
||||
uint32 itemCount;
|
||||
uint8 dstbag, dstslot, srcbag, srcslot;
|
||||
InvUpdate Inv;
|
||||
uint8 SlotA = 0;
|
||||
uint8 ContainerSlotB = 0;
|
||||
uint8 SlotB = 0;
|
||||
uint8 ContainerSlotA = 0;
|
||||
};
|
||||
|
||||
class AutoEquipItem final : public ClientPacket
|
||||
@@ -104,8 +127,9 @@ namespace WorldPackets
|
||||
|
||||
void Read() override;
|
||||
|
||||
uint32 itemCount;
|
||||
uint8 srcbag, srcslot;
|
||||
uint8 Slot = 0;
|
||||
InvUpdate Inv;
|
||||
uint8 PackSlot = 0;
|
||||
};
|
||||
|
||||
class DestroyItem final : public ClientPacket
|
||||
@@ -115,8 +139,9 @@ namespace WorldPackets
|
||||
|
||||
void Read() override;
|
||||
|
||||
uint32 count;
|
||||
uint8 bag, slot;
|
||||
uint32 Count = 0;
|
||||
uint8 SlotNum = 0;
|
||||
uint8 ContainerId = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,14 +94,14 @@ namespace WorldPackets
|
||||
void Read() override;
|
||||
|
||||
ObjectGuid QuestGiver;
|
||||
int32 QuestID;
|
||||
int32 QuestID = 0;
|
||||
};
|
||||
|
||||
struct QuestInfoChoiceItem
|
||||
{
|
||||
int32 ItemID;
|
||||
int32 Quantity;
|
||||
int32 DisplayID;
|
||||
int32 ItemID = 0;
|
||||
int32 Quantity = 0;
|
||||
int32 DisplayID = 0;
|
||||
};
|
||||
|
||||
struct QuestInfo
|
||||
|
||||
@@ -220,7 +220,7 @@ class instance_stonecore : public InstanceMapScript
|
||||
ObjectGuid corborusRockDoorGUID;
|
||||
GuidVector slabhideRockWallGUIDs;
|
||||
|
||||
EncounterState slabhideIntro;
|
||||
EncounterState slabhideIntro = NOT_STARTED;
|
||||
};
|
||||
|
||||
InstanceScript* GetInstanceScript(InstanceMap* map) const override
|
||||
|
||||
Reference in New Issue
Block a user