mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 01:08:35 +00:00
refactor(Core/Packets): Rewrite various item packets to modern class. (#22758)
This commit is contained in:
@@ -29,91 +29,82 @@
|
||||
#include "WorldSession.h"
|
||||
#include <cmath>
|
||||
|
||||
void WorldSession::HandleSplitItemOpcode(WorldPacket& recvData)
|
||||
#include "ItemPackets.h"
|
||||
|
||||
void WorldSession::HandleSplitItemOpcode(WorldPackets::Item::SplitItem& packet)
|
||||
{
|
||||
//LOG_DEBUG("network.opcode", "WORLD: CMSG_SPLIT_ITEM");
|
||||
uint8 srcbag, srcslot, dstbag, dstslot;
|
||||
uint32 count;
|
||||
|
||||
recvData >> srcbag >> srcslot >> dstbag >> dstslot >> count;
|
||||
|
||||
uint16 src = ((srcbag << 8) | srcslot);
|
||||
uint16 dst = ((dstbag << 8) | dstslot);
|
||||
uint16 src = ((packet.SourceBag << 8) | packet.SourceSlot);
|
||||
uint16 dst = ((packet.DestinationBag << 8) | packet.DestinationSlot);
|
||||
|
||||
if (src == dst)
|
||||
return;
|
||||
|
||||
if (count == 0)
|
||||
return; //check count - if zero it's fake packet
|
||||
if (packet.Count == 0)
|
||||
return; //check count - if zero it's fake packet
|
||||
|
||||
if (!_player->IsValidPos(srcbag, srcslot, true))
|
||||
if (!_player->IsValidPos(packet.SourceBag, packet.SourceSlot, true))
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, nullptr, nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_player->IsValidPos(dstbag, dstslot, false)) // can be autostore pos
|
||||
if (!_player->IsValidPos(packet.DestinationBag, packet.DestinationSlot, false)) // can be autostore pos
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT, nullptr, nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
_player->SplitItem(src, dst, count);
|
||||
_player->SplitItem(src, dst, packet.Count);
|
||||
}
|
||||
|
||||
void WorldSession::HandleSwapInvItemOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleSwapInvItemOpcode(WorldPackets::Item::SwapInventoryItem& packet)
|
||||
{
|
||||
//LOG_DEBUG("network.opcode", "WORLD: CMSG_SWAP_INV_ITEM");
|
||||
uint8 srcslot, dstslot;
|
||||
|
||||
recvData >> dstslot >> srcslot;
|
||||
|
||||
// prevent attempt swap same item to current position generated by client at special checting sequence
|
||||
if (srcslot == dstslot)
|
||||
// prevent attempt swap same item to current position generated by client at special cheating sequence
|
||||
if (packet.SourceSlot == packet.DestinationSlot)
|
||||
return;
|
||||
|
||||
if (!_player->IsValidPos(INVENTORY_SLOT_BAG_0, srcslot, true))
|
||||
if (!_player->IsValidPos(INVENTORY_SLOT_BAG_0, packet.SourceSlot, true))
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, nullptr, nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_player->IsValidPos(INVENTORY_SLOT_BAG_0, dstslot, true))
|
||||
if (!_player->IsValidPos(INVENTORY_SLOT_BAG_0, packet.DestinationSlot, true))
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT, nullptr, nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_player->IsBankPos(INVENTORY_SLOT_BAG_0, srcslot) && !CanUseBank())
|
||||
if (_player->IsBankPos(INVENTORY_SLOT_BAG_0, packet.SourceSlot) && !CanUseBank())
|
||||
{
|
||||
//LOG_DEBUG("network", "WORLD: HandleSwapInvItemOpcode - Unit ({}) not found or you can't interact with him.", m_currentBankerGUID.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
if (_player->IsBankPos(INVENTORY_SLOT_BAG_0, dstslot) && !CanUseBank())
|
||||
if (_player->IsBankPos(INVENTORY_SLOT_BAG_0, packet.DestinationSlot) && !CanUseBank())
|
||||
{
|
||||
//LOG_DEBUG("network", "WORLD: HandleSwapInvItemOpcode - Unit ({}) not found or you can't interact with him.", m_currentBankerGUID.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
uint16 src = ((INVENTORY_SLOT_BAG_0 << 8) | srcslot);
|
||||
uint16 dst = ((INVENTORY_SLOT_BAG_0 << 8) | dstslot);
|
||||
uint16 src = ((INVENTORY_SLOT_BAG_0 << 8) | packet.SourceSlot);
|
||||
uint16 dst = ((INVENTORY_SLOT_BAG_0 << 8) | packet.DestinationSlot);
|
||||
|
||||
_player->SwapItem(src, dst);
|
||||
}
|
||||
|
||||
void WorldSession::HandleAutoEquipItemSlotOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleAutoEquipItemSlotOpcode(WorldPackets::Item::AutoEquipItemSlot& packet)
|
||||
{
|
||||
ObjectGuid itemguid;
|
||||
uint8 dstslot;
|
||||
recvData >> itemguid >> dstslot;
|
||||
|
||||
// cheating attempt, client should never send opcode in that case
|
||||
if (!Player::IsEquipmentPos(INVENTORY_SLOT_BAG_0, dstslot))
|
||||
if (!Player::IsEquipmentPos(INVENTORY_SLOT_BAG_0, packet.DestinationSlot))
|
||||
return;
|
||||
|
||||
Item* item = _player->GetItemByGuid(itemguid);
|
||||
uint16 dstpos = dstslot | (INVENTORY_SLOT_BAG_0 << 8);
|
||||
Item* item = _player->GetItemByGuid(packet.ItemGuid);
|
||||
uint16 dstpos = packet.DestinationSlot | (INVENTORY_SLOT_BAG_0 << 8);
|
||||
|
||||
if (!item || item->GetPos() == dstpos)
|
||||
return;
|
||||
@@ -121,39 +112,36 @@ void WorldSession::HandleAutoEquipItemSlotOpcode(WorldPacket& recvData)
|
||||
_player->SwapItem(item->GetPos(), dstpos);
|
||||
}
|
||||
|
||||
void WorldSession::HandleSwapItem(WorldPacket& recvData)
|
||||
void WorldSession::HandleSwapItem(WorldPackets::Item::SwapItem& packet)
|
||||
{
|
||||
//LOG_DEBUG("network.opcode", "WORLD: CMSG_SWAP_ITEM");
|
||||
uint8 dstbag, dstslot, srcbag, srcslot;
|
||||
|
||||
recvData >> dstbag >> dstslot >> srcbag >> srcslot;
|
||||
uint16 src = ((packet.SourceBag << 8) | packet.SourceSlot);
|
||||
uint16 dst = ((packet.DestinationBag << 8) | packet.DestinationSlot);
|
||||
|
||||
uint16 src = ((srcbag << 8) | srcslot);
|
||||
uint16 dst = ((dstbag << 8) | dstslot);
|
||||
|
||||
// prevent attempt swap same item to current position generated by client at special checting sequence
|
||||
// prevent attempt swap same item to current position generated by client at special cheating sequence
|
||||
if (src == dst)
|
||||
return;
|
||||
|
||||
if (!_player->IsValidPos(srcbag, srcslot, true))
|
||||
if (!_player->IsValidPos(packet.SourceBag, packet.SourceSlot, true))
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, nullptr, nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_player->IsValidPos(dstbag, dstslot, true))
|
||||
if (!_player->IsValidPos(packet.DestinationBag, packet.DestinationSlot, true))
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT, nullptr, nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_player->IsBankPos(srcbag, srcslot) && !CanUseBank())
|
||||
if (_player->IsBankPos(packet.SourceBag, packet.SourceSlot) && !CanUseBank())
|
||||
{
|
||||
//LOG_DEBUG("network", "WORLD: HandleSwapItem - Unit ({}) not found or you can't interact with him.", m_currentBankerGUID.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
if (_player->IsBankPos(dstbag, dstslot) && !CanUseBank())
|
||||
if (_player->IsBankPos(packet.DestinationBag, packet.DestinationSlot) && !CanUseBank())
|
||||
{
|
||||
//LOG_DEBUG("network", "WORLD: HandleSwapItem - Unit ({}) not found or you can't interact with him.", m_currentBankerGUID.ToString());
|
||||
return;
|
||||
@@ -162,14 +150,11 @@ void WorldSession::HandleSwapItem(WorldPacket& recvData)
|
||||
_player->SwapItem(src, dst);
|
||||
}
|
||||
|
||||
void WorldSession::HandleAutoEquipItemOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleAutoEquipItemOpcode(WorldPackets::Item::AutoEquipItem& packet)
|
||||
{
|
||||
//LOG_DEBUG("network.opcode", "WORLD: CMSG_AUTOEQUIP_ITEM");
|
||||
uint8 srcbag, srcslot;
|
||||
|
||||
recvData >> srcbag >> srcslot;
|
||||
|
||||
Item* pSrcItem = _player->GetItemByPos(srcbag, srcslot);
|
||||
Item* pSrcItem = _player->GetItemByPos(packet.SourceBag, packet.SourceSlot);
|
||||
if (!pSrcItem)
|
||||
return; // only at cheat
|
||||
|
||||
@@ -219,7 +204,7 @@ void WorldSession::HandleAutoEquipItemOpcode(WorldPacket& recvData)
|
||||
|
||||
if (!pDstItem) // empty slot, simple case
|
||||
{
|
||||
_player->RemoveItem(srcbag, srcslot, true);
|
||||
_player->RemoveItem(packet.SourceBag, packet.SourceSlot, true);
|
||||
_player->EquipItem(dest, pSrcItem, true);
|
||||
_player->AutoUnequipOffhandIfNeed();
|
||||
}
|
||||
@@ -243,23 +228,23 @@ void WorldSession::HandleAutoEquipItemOpcode(WorldPacket& recvData)
|
||||
uint16 eSrc = 0;
|
||||
if (_player->IsInventoryPos(src))
|
||||
{
|
||||
msg = _player->CanStoreItem(srcbag, srcslot, sSrc, pDstItem, true);
|
||||
msg = _player->CanStoreItem(packet.SourceBag, packet.SourceSlot, sSrc, pDstItem, true);
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
msg = _player->CanStoreItem(srcbag, NULL_SLOT, sSrc, pDstItem, true);
|
||||
msg = _player->CanStoreItem(packet.SourceBag, NULL_SLOT, sSrc, pDstItem, true);
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, sSrc, pDstItem, true);
|
||||
}
|
||||
else if (_player->IsBankPos(src))
|
||||
{
|
||||
msg = _player->CanBankItem(srcbag, srcslot, sSrc, pDstItem, true);
|
||||
msg = _player->CanBankItem(packet.SourceBag, packet.SourceSlot, sSrc, pDstItem, true);
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
msg = _player->CanBankItem(srcbag, NULL_SLOT, sSrc, pDstItem, true);
|
||||
msg = _player->CanBankItem(packet.SourceBag, NULL_SLOT, sSrc, pDstItem, true);
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
msg = _player->CanBankItem(NULL_BAG, NULL_SLOT, sSrc, pDstItem, true);
|
||||
}
|
||||
else if (_player->IsEquipmentPos(src))
|
||||
{
|
||||
msg = _player->CanEquipItem(srcslot, eSrc, pDstItem, true);
|
||||
msg = _player->CanEquipItem(packet.SourceSlot, eSrc, pDstItem, true);
|
||||
if (msg == EQUIP_ERR_OK)
|
||||
msg = _player->CanUnequipItem(eSrc, true);
|
||||
}
|
||||
@@ -272,7 +257,7 @@ void WorldSession::HandleAutoEquipItemOpcode(WorldPacket& recvData)
|
||||
|
||||
// now do moves, remove...
|
||||
_player->RemoveItem(dstbag, dstslot, true, true);
|
||||
_player->RemoveItem(srcbag, srcslot, true, true);
|
||||
_player->RemoveItem(packet.SourceBag, packet.SourceSlot, true, true);
|
||||
|
||||
// add to dest
|
||||
_player->EquipItem(dest, pSrcItem, true);
|
||||
@@ -292,14 +277,11 @@ void WorldSession::HandleAutoEquipItemOpcode(WorldPacket& recvData)
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSession::HandleDestroyItemOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleDestroyItemOpcode(WorldPackets::Item::DestroyItem& packet)
|
||||
{
|
||||
//LOG_DEBUG("network.opcode", "WORLD: CMSG_DESTROYITEM");
|
||||
uint8 bag, slot, count, data1, data2, data3;
|
||||
|
||||
recvData >> bag >> slot >> count >> data1 >> data2 >> data3;
|
||||
|
||||
uint16 pos = (bag << 8) | slot;
|
||||
uint16 pos = (packet.Bag << 8) | packet.Slot;
|
||||
|
||||
// prevent drop unequipable items (in combat, for example) and non-empty bags
|
||||
if (_player->IsEquipmentPos(pos) || _player->IsBagPos(pos))
|
||||
@@ -312,7 +294,7 @@ void WorldSession::HandleDestroyItemOpcode(WorldPacket& recvData)
|
||||
}
|
||||
}
|
||||
|
||||
Item* pItem = _player->GetItemByPos(bag, slot);
|
||||
Item* pItem = _player->GetItemByPos(packet.Bag, packet.Slot);
|
||||
if (!pItem)
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, nullptr, nullptr);
|
||||
@@ -327,14 +309,14 @@ void WorldSession::HandleDestroyItemOpcode(WorldPacket& recvData)
|
||||
|
||||
recoveryItem(pItem);
|
||||
|
||||
if (count)
|
||||
if (packet.Count)
|
||||
{
|
||||
uint32 i_count = count;
|
||||
uint32 i_count = packet.Count;
|
||||
_player->DestroyItemCount(pItem, i_count, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_player->DestroyItem(bag, slot, true);
|
||||
_player->DestroyItem(packet.Bag, packet.Slot, true);
|
||||
}
|
||||
_player->SendQuestGiverStatusMultiple();
|
||||
}
|
||||
@@ -692,15 +674,12 @@ void WorldSession::HandleItemQuerySingleOpcode(WorldPacket& recvData)
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSession::HandleReadItem(WorldPacket& recvData)
|
||||
void WorldSession::HandleReadItem(WorldPackets::Item::ReadItem& packet)
|
||||
{
|
||||
//LOG_DEBUG("network.opcode", "WORLD: CMSG_READ_ITEM");
|
||||
|
||||
uint8 bag, slot;
|
||||
recvData >> bag >> slot;
|
||||
|
||||
//LOG_DEBUG("network.opcode", "STORAGE: Read bag = {}, slot = {}", bag, slot);
|
||||
Item* pItem = _player->GetItemByPos(bag, slot);
|
||||
Item* pItem = _player->GetItemByPos(packet.Bag, packet.Slot);
|
||||
|
||||
if (pItem && pItem->GetTemplate()->PageText)
|
||||
{
|
||||
@@ -725,27 +704,22 @@ void WorldSession::HandleReadItem(WorldPacket& recvData)
|
||||
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, nullptr, nullptr);
|
||||
}
|
||||
|
||||
void WorldSession::HandleSellItemOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleSellItemOpcode(WorldPackets::Item::SellItem& packet)
|
||||
{
|
||||
ObjectGuid vendorguid, itemguid;
|
||||
uint32 count;
|
||||
|
||||
recvData >> vendorguid >> itemguid >> count;
|
||||
|
||||
if (!itemguid)
|
||||
if (!packet.ItemGuid)
|
||||
return;
|
||||
|
||||
Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(vendorguid, UNIT_NPC_FLAG_VENDOR);
|
||||
Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(packet.VendorGuid, UNIT_NPC_FLAG_VENDOR);
|
||||
if (!creature)
|
||||
{
|
||||
LOG_DEBUG("network", "WORLD: HandleSellItemOpcode - Unit ({}) not found or you can not interact with him.", vendorguid.ToString());
|
||||
_player->SendSellError(SELL_ERR_CANT_FIND_VENDOR, nullptr, itemguid, 0);
|
||||
LOG_DEBUG("network", "WORLD: HandleSellItemOpcode - Unit ({}) not found or you can not interact with him.", packet.VendorGuid.ToString());
|
||||
_player->SendSellError(SELL_ERR_CANT_FIND_VENDOR, nullptr, packet.ItemGuid, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (creature->HasFlagsExtra(CREATURE_FLAG_EXTRA_NO_SELL_VENDOR))
|
||||
{
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_TO_THIS_MERCHANT, creature, itemguid, 0);
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_TO_THIS_MERCHANT, creature, packet.ItemGuid, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -753,7 +727,7 @@ void WorldSession::HandleSellItemOpcode(WorldPacket& recvData)
|
||||
if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
|
||||
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
|
||||
|
||||
Item* pItem = _player->GetItemByGuid(itemguid);
|
||||
Item* pItem = _player->GetItemByGuid(packet.ItemGuid);
|
||||
if (pItem)
|
||||
{
|
||||
if (!sScriptMgr->OnPlayerCanSellItem(_player, pItem, creature))
|
||||
@@ -762,21 +736,21 @@ void WorldSession::HandleSellItemOpcode(WorldPacket& recvData)
|
||||
// prevent sell not owner item
|
||||
if (_player->GetGUID() != pItem->GetOwnerGUID())
|
||||
{
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid, 0);
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGuid, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
// prevent sell non empty bag by drag-and-drop at vendor's item list
|
||||
if (pItem->IsNotEmptyBag())
|
||||
{
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid, 0);
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGuid, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
// prevent sell currently looted item
|
||||
if (_player->GetLootGUID() == pItem->GetGUID())
|
||||
{
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid, 0);
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGuid, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -787,16 +761,14 @@ void WorldSession::HandleSellItemOpcode(WorldPacket& recvData)
|
||||
return; // Therefore, no feedback to client
|
||||
|
||||
// special case at auto sell (sell all)
|
||||
if (count == 0)
|
||||
{
|
||||
count = pItem->GetCount();
|
||||
}
|
||||
if (packet.Count == 0)
|
||||
packet.Count = pItem->GetCount();
|
||||
else
|
||||
{
|
||||
// prevent sell more items that exist in stack (possible only not from client)
|
||||
if (count > pItem->GetCount())
|
||||
if (packet.Count > pItem->GetCount())
|
||||
{
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid, 0);
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGuid, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -806,11 +778,11 @@ void WorldSession::HandleSellItemOpcode(WorldPacket& recvData)
|
||||
{
|
||||
if (pProto->SellPrice > 0)
|
||||
{
|
||||
uint32 money = pProto->SellPrice * count;
|
||||
uint32 money = pProto->SellPrice * packet.Count;
|
||||
if (_player->GetMoney() >= MAX_MONEY_AMOUNT - money) // prevent exceeding gold limit
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD, nullptr, nullptr);
|
||||
_player->SendSellError(SELL_ERR_UNK, creature, itemguid, 0);
|
||||
_player->SendSellError(SELL_ERR_UNK, creature, packet.ItemGuid, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -828,8 +800,8 @@ void WorldSession::HandleSellItemOpcode(WorldPacket& recvData)
|
||||
DurabilityCostsEntry const* dcost = sDurabilityCostsStore.LookupEntry(pProto->ItemLevel);
|
||||
if (!dcost)
|
||||
{
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid, 0);
|
||||
LOG_ERROR("network.opcode", "WORLD: HandleSellItemOpcode - Wrong item lvl {} for item {} count = {}", pProto->ItemLevel, pItem->GetEntry(), count);
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGuid, 0);
|
||||
LOG_ERROR("network.opcode", "WORLD: HandleSellItemOpcode - Wrong item lvl {} for item {} count = {}", pProto->ItemLevel, pItem->GetEntry(), packet.Count);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -837,8 +809,8 @@ void WorldSession::HandleSellItemOpcode(WorldPacket& recvData)
|
||||
DurabilityQualityEntry const* dQualitymodEntry = sDurabilityQualityStore.LookupEntry(dQualitymodEntryId);
|
||||
if (!dQualitymodEntry)
|
||||
{
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid, 0);
|
||||
LOG_ERROR("network.opcode", "WORLD: HandleSellItemOpcode - Wrong dQualityModEntry {} for item {} count = {}", dQualitymodEntryId, pItem->GetEntry(), count);
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGuid, 0);
|
||||
LOG_ERROR("network.opcode", "WORLD: HandleSellItemOpcode - Wrong dQualityModEntry {} for item {} count = {}", dQualitymodEntryId, pItem->GetEntry(), packet.Count);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -846,36 +818,30 @@ void WorldSession::HandleSellItemOpcode(WorldPacket& recvData)
|
||||
uint32 refund = uint32(std::ceil(LostDurability * dmultiplier * double(dQualitymodEntry->quality_mod)));
|
||||
|
||||
if (!refund)
|
||||
{
|
||||
refund = 1;
|
||||
}
|
||||
|
||||
//starter items can cost more to refund than vendorprice
|
||||
if (refund > money)
|
||||
{
|
||||
money = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
money -= refund;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count < pItem->GetCount()) // need split items
|
||||
if (packet.Count < pItem->GetCount()) // need split items
|
||||
{
|
||||
Item* pNewItem = pItem->CloneItem(count, _player);
|
||||
Item* pNewItem = pItem->CloneItem(packet.Count, _player);
|
||||
if (!pNewItem)
|
||||
{
|
||||
LOG_ERROR("network.opcode", "WORLD: HandleSellItemOpcode - could not create clone of item {}; count = {}", pItem->GetEntry(), count);
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid, 0);
|
||||
LOG_ERROR("network.opcode", "WORLD: HandleSellItemOpcode - could not create clone of item {}; count = {}", pItem->GetEntry(), packet.Count);
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGuid, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
pNewItem->SetUInt32Value(ITEM_FIELD_DURABILITY, pItem->GetUInt32Value(ITEM_FIELD_DURABILITY));
|
||||
|
||||
pItem->SetCount(pItem->GetCount() - count);
|
||||
_player->ItemRemovedQuestCheck(pItem->GetEntry(), count);
|
||||
pItem->SetCount(pItem->GetCount() - packet.Count);
|
||||
_player->ItemRemovedQuestCheck(pItem->GetEntry(), packet.Count);
|
||||
if (_player->IsInWorld())
|
||||
pItem->SendUpdateToPlayer(_player);
|
||||
pItem->SetState(ITEM_CHANGED, _player);
|
||||
@@ -897,25 +863,20 @@ void WorldSession::HandleSellItemOpcode(WorldPacket& recvData)
|
||||
_player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_VENDORS, money);
|
||||
}
|
||||
else
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid, 0);
|
||||
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGuid, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
_player->SendSellError(SELL_ERR_CANT_FIND_ITEM, creature, itemguid, 0);
|
||||
_player->SendSellError(SELL_ERR_CANT_FIND_ITEM, creature, packet.ItemGuid, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
void WorldSession::HandleBuybackItem(WorldPacket& recvData)
|
||||
void WorldSession::HandleBuybackItem(WorldPackets::Item::BuybackItem& packet)
|
||||
{
|
||||
ObjectGuid vendorguid;
|
||||
uint32 slot;
|
||||
|
||||
recvData >> vendorguid >> slot;
|
||||
|
||||
Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(vendorguid, UNIT_NPC_FLAG_VENDOR);
|
||||
Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(packet.VendorGuid, UNIT_NPC_FLAG_VENDOR);
|
||||
if (!creature)
|
||||
{
|
||||
LOG_DEBUG("network", "WORLD: HandleBuybackItem - Unit ({}) not found or you can not interact with him.", vendorguid.ToString());
|
||||
LOG_DEBUG("network", "WORLD: HandleBuybackItem - Unit ({}) not found or you can not interact with him.", packet.VendorGuid.ToString());
|
||||
_player->SendSellError(SELL_ERR_CANT_FIND_VENDOR, nullptr, ObjectGuid::Empty, 0);
|
||||
return;
|
||||
}
|
||||
@@ -924,10 +885,10 @@ void WorldSession::HandleBuybackItem(WorldPacket& recvData)
|
||||
if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
|
||||
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
|
||||
|
||||
Item* pItem = _player->GetItemFromBuyBackSlot(slot);
|
||||
Item* pItem = _player->GetItemFromBuyBackSlot(packet.Slot);
|
||||
if (pItem)
|
||||
{
|
||||
uint32 price = _player->GetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + slot - BUYBACK_SLOT_START);
|
||||
uint32 price = _player->GetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + packet.Slot - BUYBACK_SLOT_START);
|
||||
if (!_player->HasEnoughMoney(price))
|
||||
{
|
||||
_player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, pItem->GetEntry(), 0);
|
||||
@@ -948,7 +909,7 @@ void WorldSession::HandleBuybackItem(WorldPacket& recvData)
|
||||
}
|
||||
|
||||
_player->ModifyMoney(-(int32)price);
|
||||
_player->RemoveItemFromBuyBackSlot(slot, false);
|
||||
_player->RemoveItemFromBuyBackSlot(packet.Slot, false);
|
||||
_player->ItemAddedQuestCheck(pItem->GetEntry(), pItem->GetCount());
|
||||
_player->StoreItem(dest, pItem, true);
|
||||
}
|
||||
@@ -960,24 +921,18 @@ void WorldSession::HandleBuybackItem(WorldPacket& recvData)
|
||||
_player->SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, 0, 0);
|
||||
}
|
||||
|
||||
void WorldSession::HandleBuyItemInSlotOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleBuyItemInSlotOpcode(WorldPackets::Item::BuyItemInSlot& packet)
|
||||
{
|
||||
ObjectGuid vendorguid, bagguid;
|
||||
uint32 item, slot, count;
|
||||
uint8 bagslot;
|
||||
|
||||
recvData >> vendorguid >> item >> slot >> bagguid >> bagslot >> count;
|
||||
|
||||
// client expects count starting at 1, and we send vendorslot+1 to client already
|
||||
if (slot > 0)
|
||||
--slot;
|
||||
if (packet.Slot > 0)
|
||||
--packet.Slot;
|
||||
else
|
||||
return; // cheating
|
||||
return; // cheating
|
||||
|
||||
uint8 bag = NULL_BAG; // init for case invalid bagGUID
|
||||
uint8 bag = NULL_BAG; // init for case invalid bagGUID
|
||||
|
||||
// find bag slot by bag guid
|
||||
if (bagguid == _player->GetGUID())
|
||||
if (packet.BagGuid == _player->GetGUID())
|
||||
bag = INVENTORY_SLOT_BAG_0;
|
||||
else
|
||||
{
|
||||
@@ -985,7 +940,7 @@ void WorldSession::HandleBuyItemInSlotOpcode(WorldPacket& recvData)
|
||||
{
|
||||
if (Bag* pBag = _player->GetBagByPos(i))
|
||||
{
|
||||
if (bagguid == pBag->GetGUID())
|
||||
if (packet.BagGuid == pBag->GetGUID())
|
||||
{
|
||||
bag = i;
|
||||
break;
|
||||
@@ -998,38 +953,28 @@ void WorldSession::HandleBuyItemInSlotOpcode(WorldPacket& recvData)
|
||||
if (bag == NULL_BAG)
|
||||
return;
|
||||
|
||||
GetPlayer()->BuyItemFromVendorSlot(vendorguid, slot, item, count, bag, bagslot);
|
||||
GetPlayer()->BuyItemFromVendorSlot(packet.VendorGuid, packet.Slot, packet.Item, packet.Count, bag, packet.BagSlot);
|
||||
}
|
||||
|
||||
void WorldSession::HandleBuyItemOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleBuyItemOpcode(WorldPackets::Item::BuyItem& packet)
|
||||
{
|
||||
ObjectGuid vendorguid;
|
||||
uint32 item, slot, count;
|
||||
uint8 unk1;
|
||||
|
||||
recvData >> vendorguid >> item >> slot >> count >> unk1;
|
||||
|
||||
// client expects count starting at 1, and we send vendorslot+1 to client already
|
||||
if (slot > 0)
|
||||
--slot;
|
||||
if (packet.Slot > 0)
|
||||
--packet.Slot;
|
||||
else
|
||||
return; // cheating
|
||||
|
||||
GetPlayer()->BuyItemFromVendorSlot(vendorguid, slot, item, count, NULL_BAG, NULL_SLOT);
|
||||
GetPlayer()->BuyItemFromVendorSlot(packet.VendorGuid, packet.Slot, packet.Item, packet.Count, NULL_BAG, NULL_SLOT);
|
||||
}
|
||||
|
||||
void WorldSession::HandleListInventoryOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleListInventoryOpcode(WorldPackets::Item::ListInventory& packet)
|
||||
{
|
||||
ObjectGuid guid;
|
||||
|
||||
recvData >> guid;
|
||||
|
||||
if (!GetPlayer()->IsAlive())
|
||||
return;
|
||||
|
||||
LOG_DEBUG("network", "WORLD: Recvd CMSG_LIST_INVENTORY");
|
||||
|
||||
SendListInventory(guid);
|
||||
SendListInventory(packet.VendorGuid);
|
||||
}
|
||||
|
||||
void WorldSession::SendListInventory(ObjectGuid vendorGuid, uint32 vendorEntry)
|
||||
@@ -1143,18 +1088,14 @@ void WorldSession::SendListInventory(ObjectGuid vendorGuid, uint32 vendorEntry)
|
||||
SendPacket(&data);
|
||||
}
|
||||
|
||||
void WorldSession::HandleAutoStoreBagItemOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleAutoStoreBagItemOpcode(WorldPackets::Item::AutoStoreBagItem& packet)
|
||||
{
|
||||
//LOG_DEBUG("network.opcode", "WORLD: CMSG_AUTOSTORE_BAG_ITEM");
|
||||
uint8 srcbag, srcslot, dstbag;
|
||||
|
||||
recvData >> srcbag >> srcslot >> dstbag;
|
||||
|
||||
Item* pItem = _player->GetItemByPos(srcbag, srcslot);
|
||||
Item* pItem = _player->GetItemByPos(packet.SourceBag, packet.SourceSlot);
|
||||
if (!pItem)
|
||||
return;
|
||||
|
||||
if (!_player->IsValidPos(dstbag, NULL_SLOT, false)) // can be autostore pos
|
||||
if (!_player->IsValidPos(packet.DestinationBag, NULL_SLOT, false)) // can be autostore pos
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT, nullptr, nullptr);
|
||||
return;
|
||||
@@ -1174,7 +1115,7 @@ void WorldSession::HandleAutoStoreBagItemOpcode(WorldPacket& recvData)
|
||||
}
|
||||
|
||||
ItemPosCountVec dest;
|
||||
InventoryResult msg = _player->CanStoreItem(dstbag, NULL_SLOT, dest, pItem, false);
|
||||
InventoryResult msg = _player->CanStoreItem(packet.DestinationBag, NULL_SLOT, dest, pItem, false);
|
||||
if (msg != EQUIP_ERR_OK)
|
||||
{
|
||||
_player->SendEquipError(msg, pItem, nullptr);
|
||||
@@ -1189,7 +1130,7 @@ void WorldSession::HandleAutoStoreBagItemOpcode(WorldPacket& recvData)
|
||||
return;
|
||||
}
|
||||
|
||||
_player->RemoveItem(srcbag, srcslot, true);
|
||||
_player->RemoveItem(packet.SourceBag, packet.SourceSlot, true);
|
||||
_player->StoreItem(dest, pItem, true);
|
||||
_player->UpdateTitansGrip();
|
||||
}
|
||||
@@ -1223,23 +1164,22 @@ void WorldSession::HandleSetAmmoOpcode(WorldPacket& recvData)
|
||||
|
||||
void WorldSession::SendEnchantmentLog(ObjectGuid target, ObjectGuid caster, uint32 itemId, uint32 enchantId)
|
||||
{
|
||||
WorldPacket data(SMSG_ENCHANTMENTLOG, (8 + 8 + 4 + 4)); // last check 2.0.10
|
||||
data << target.WriteAsPacked();
|
||||
data << caster.WriteAsPacked();
|
||||
data << uint32(itemId);
|
||||
data << uint32(enchantId);
|
||||
GetPlayer()->SendMessageToSet(&data, true);
|
||||
WorldPackets::Item::EnchantmentLog enchantmentLog;
|
||||
enchantmentLog.Target = target.WriteAsPacked();
|
||||
enchantmentLog.Caster = caster.WriteAsPacked();
|
||||
enchantmentLog.ItemId = itemId;
|
||||
enchantmentLog.EnchantId = enchantId;
|
||||
GetPlayer()->SendMessageToSet(enchantmentLog.Write(), true);
|
||||
}
|
||||
|
||||
void WorldSession::SendItemEnchantTimeUpdate(ObjectGuid Playerguid, ObjectGuid Itemguid, uint32 slot, uint32 Duration)
|
||||
{
|
||||
// last check 2.0.10
|
||||
WorldPacket data(SMSG_ITEM_ENCHANT_TIME_UPDATE, (8 + 4 + 4 + 8));
|
||||
data << Itemguid;
|
||||
data << uint32(slot);
|
||||
data << uint32(Duration);
|
||||
data << Playerguid;
|
||||
SendPacket(&data);
|
||||
WorldPackets::Item::ItemEnchantTimeUpdate itemEnchantTimeUpdate;
|
||||
itemEnchantTimeUpdate.ItemGuid = Itemguid;
|
||||
itemEnchantTimeUpdate.Slot = slot;
|
||||
itemEnchantTimeUpdate.Duration = Duration;
|
||||
itemEnchantTimeUpdate.PlayerGuid = Playerguid;
|
||||
SendPacket(itemEnchantTimeUpdate.Write());
|
||||
}
|
||||
|
||||
void WorldSession::HandleItemNameQueryOpcode(WorldPacket& recvData)
|
||||
@@ -1266,18 +1206,13 @@ void WorldSession::HandleItemNameQueryOpcode(WorldPacket& recvData)
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSession::HandleWrapItemOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleWrapItemOpcode(WorldPackets::Item::WrapItem& packet)
|
||||
{
|
||||
LOG_DEBUG("network", "Received opcode CMSG_WRAP_ITEM");
|
||||
|
||||
uint8 gift_bag, gift_slot, item_bag, item_slot;
|
||||
LOG_DEBUG("network", "WRAP: receive GiftBag = {}, GiftSlot = {}, ItemBag = {}, ItemSlot = {}", packet.GiftBag, packet.GiftSlot, packet.ItemBag, packet.ItemSlot);
|
||||
|
||||
recvData >> gift_bag >> gift_slot; // paper
|
||||
recvData >> item_bag >> item_slot; // item
|
||||
|
||||
LOG_DEBUG("network", "WRAP: receive gift_bag = {}, gift_slot = {}, item_bag = {}, item_slot = {}", gift_bag, gift_slot, item_bag, item_slot);
|
||||
|
||||
Item* gift = _player->GetItemByPos(gift_bag, gift_slot);
|
||||
Item* gift = _player->GetItemByPos(packet.GiftBag, packet.GiftSlot);
|
||||
if (!gift)
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, gift, nullptr);
|
||||
@@ -1290,7 +1225,7 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recvData)
|
||||
return;
|
||||
}
|
||||
|
||||
Item* item = _player->GetItemByPos(item_bag, item_slot);
|
||||
Item* item = _player->GetItemByPos(packet.ItemBag, packet.ItemSlot);
|
||||
|
||||
if (!item)
|
||||
{
|
||||
@@ -1305,7 +1240,7 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recvData)
|
||||
return;
|
||||
}
|
||||
|
||||
if (item == gift) // not possable with pacjket from real client
|
||||
if (item == gift) // not possible with packet from real client
|
||||
{
|
||||
_player->SendEquipError(EQUIP_ERR_WRAPPED_CANT_BE_WRAPPED, item, nullptr);
|
||||
return;
|
||||
@@ -1399,26 +1334,19 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recvData)
|
||||
_player->DestroyItemCount(gift, count, true);
|
||||
}
|
||||
|
||||
void WorldSession::HandleSocketOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleSocketOpcode(WorldPackets::Item::SocketGems& packet)
|
||||
{
|
||||
LOG_DEBUG("network", "WORLD: CMSG_SOCKET_GEMS");
|
||||
|
||||
ObjectGuid item_guid;
|
||||
ObjectGuid gem_guids[MAX_GEM_SOCKETS];
|
||||
|
||||
recvData >> item_guid;
|
||||
if (!item_guid)
|
||||
if (!packet.ItemGuid)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < MAX_GEM_SOCKETS; ++i)
|
||||
recvData >> gem_guids[i];
|
||||
|
||||
//cheat -> tried to socket same gem multiple times
|
||||
if ((gem_guids[0] && (gem_guids[0] == gem_guids[1] || gem_guids[0] == gem_guids[2])) ||
|
||||
(gem_guids[1] && (gem_guids[1] == gem_guids[2])))
|
||||
if ((packet.GemGuids[0] && (packet.GemGuids[0] == packet.GemGuids[1] || packet.GemGuids[0] == packet.GemGuids[2])) ||
|
||||
(packet.GemGuids[1] && (packet.GemGuids[1] == packet.GemGuids[2])))
|
||||
return;
|
||||
|
||||
Item* itemTarget = _player->GetItemByGuid(item_guid);
|
||||
Item* itemTarget = _player->GetItemByGuid(packet.ItemGuid);
|
||||
if (!itemTarget) //missing item to socket
|
||||
return;
|
||||
|
||||
@@ -1431,7 +1359,7 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recvData)
|
||||
|
||||
Item* Gems[MAX_GEM_SOCKETS];
|
||||
for (int i = 0; i < MAX_GEM_SOCKETS; ++i)
|
||||
Gems[i] = gem_guids[i] ? _player->GetItemByGuid(gem_guids[i]) : nullptr;
|
||||
Gems[i] = packet.GemGuids[i] ? _player->GetItemByGuid(packet.GemGuids[i]) : nullptr;
|
||||
|
||||
GemPropertiesEntry const* GemProps[MAX_GEM_SOCKETS];
|
||||
for (int i = 0; i < MAX_GEM_SOCKETS; ++i) //get geminfo from dbc storage
|
||||
@@ -1572,7 +1500,7 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recvData)
|
||||
if (GemEnchants[i])
|
||||
{
|
||||
itemTarget->SetEnchantment(EnchantmentSlot(SOCK_ENCHANTMENT_SLOT + i), GemEnchants[i], 0, 0, _player->GetGUID());
|
||||
if (Item* guidItem = _player->GetItemByGuid(gem_guids[i]))
|
||||
if (Item* guidItem = _player->GetItemByGuid(packet.GemGuids[i]))
|
||||
_player->DestroyItem(guidItem->GetBagSlot(), guidItem->GetSlot(), true);
|
||||
}
|
||||
}
|
||||
@@ -1597,19 +1525,15 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recvData)
|
||||
itemTarget->SendUpdateSockets();
|
||||
}
|
||||
|
||||
void WorldSession::HandleCancelTempEnchantmentOpcode(WorldPacket& recvData)
|
||||
void WorldSession::HandleCancelTempEnchantmentOpcode(WorldPackets::Item::CancelTempEnchantment& packet)
|
||||
{
|
||||
LOG_DEBUG("network", "WORLD: CMSG_CANCEL_TEMP_ENCHANTMENT");
|
||||
|
||||
uint32 eslot;
|
||||
|
||||
recvData >> eslot;
|
||||
|
||||
// apply only to equipped item
|
||||
if (!Player::IsEquipmentPos(INVENTORY_SLOT_BAG_0, eslot))
|
||||
if (!Player::IsEquipmentPos(INVENTORY_SLOT_BAG_0, packet.EquipmentSlot))
|
||||
return;
|
||||
|
||||
Item* item = GetPlayer()->GetItemByPos(INVENTORY_SLOT_BAG_0, eslot);
|
||||
Item* item = GetPlayer()->GetItemByPos(INVENTORY_SLOT_BAG_0, packet.EquipmentSlot);
|
||||
|
||||
if (!item)
|
||||
return;
|
||||
@@ -1621,14 +1545,11 @@ void WorldSession::HandleCancelTempEnchantmentOpcode(WorldPacket& recvData)
|
||||
item->ClearEnchantment(TEMP_ENCHANTMENT_SLOT);
|
||||
}
|
||||
|
||||
void WorldSession::HandleItemRefundInfoRequest(WorldPacket& recvData)
|
||||
void WorldSession::HandleItemRefundInfoRequest(WorldPackets::Item::ItemRefundInfo& packet)
|
||||
{
|
||||
LOG_DEBUG("network", "WORLD: CMSG_ITEM_REFUND_INFO");
|
||||
|
||||
ObjectGuid guid;
|
||||
recvData >> guid; // item guid
|
||||
|
||||
Item* item = _player->GetItemByGuid(guid);
|
||||
Item* item = _player->GetItemByGuid(packet.ItemGuid);
|
||||
if (!item)
|
||||
{
|
||||
LOG_DEBUG("network", "Item refund: item not found!");
|
||||
@@ -1638,13 +1559,11 @@ void WorldSession::HandleItemRefundInfoRequest(WorldPacket& recvData)
|
||||
GetPlayer()->SendRefundInfo(item);
|
||||
}
|
||||
|
||||
void WorldSession::HandleItemRefund(WorldPacket& recvData)
|
||||
void WorldSession::HandleItemRefund(WorldPackets::Item::ItemRefund& packet)
|
||||
{
|
||||
LOG_DEBUG("network", "WORLD: CMSG_ITEM_REFUND");
|
||||
ObjectGuid guid;
|
||||
recvData >> guid; // item guid
|
||||
|
||||
Item* item = _player->GetItemByGuid(guid);
|
||||
Item* item = _player->GetItemByGuid(packet.ItemGuid);
|
||||
if (!item)
|
||||
{
|
||||
LOG_DEBUG("network", "Item refund: item not found!");
|
||||
@@ -1652,7 +1571,7 @@ void WorldSession::HandleItemRefund(WorldPacket& recvData)
|
||||
}
|
||||
|
||||
// Don't try to refund item currently being disenchanted
|
||||
if (_player->GetLootGUID() == guid)
|
||||
if (_player->GetLootGUID() == packet.ItemGuid)
|
||||
return;
|
||||
|
||||
GetPlayer()->RefundItem(item);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "CombatLogPackets.h"
|
||||
#include "CombatPackets.h"
|
||||
#include "GuildPackets.h"
|
||||
#include "ItemPackets.h"
|
||||
#include "LFGPackets.h"
|
||||
#include "MiscPackets.h"
|
||||
#include "PetPackets.h"
|
||||
|
||||
163
src/server/game/Server/Packets/ItemPackets.cpp
Normal file
163
src/server/game/Server/Packets/ItemPackets.cpp
Normal file
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by the
|
||||
* Free Software Foundation; either version 3 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 Affero 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 "ItemPackets.h"
|
||||
|
||||
void WorldPackets::Item::SplitItem::Read()
|
||||
{
|
||||
_worldPacket >> SourceBag;
|
||||
_worldPacket >> SourceSlot;
|
||||
_worldPacket >> DestinationBag;
|
||||
_worldPacket >> DestinationSlot;
|
||||
_worldPacket >> Count;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::SwapInventoryItem::Read()
|
||||
{
|
||||
_worldPacket >> DestinationSlot;
|
||||
_worldPacket >> SourceSlot;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::AutoEquipItemSlot::Read()
|
||||
{
|
||||
_worldPacket >> ItemGuid;
|
||||
_worldPacket >> DestinationSlot;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::SwapItem::Read()
|
||||
{
|
||||
_worldPacket >> DestinationBag;
|
||||
_worldPacket >> DestinationSlot;
|
||||
_worldPacket >> SourceBag;
|
||||
_worldPacket >> SourceSlot;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::AutoEquipItem::Read()
|
||||
{
|
||||
_worldPacket >> SourceBag;
|
||||
_worldPacket >> SourceSlot;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::DestroyItem::Read()
|
||||
{
|
||||
_worldPacket >> Bag;
|
||||
_worldPacket >> Slot;
|
||||
_worldPacket >> Count;
|
||||
_worldPacket >> Data1;
|
||||
_worldPacket >> Data2;
|
||||
_worldPacket >> Data3;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::ReadItem::Read()
|
||||
{
|
||||
_worldPacket >> Bag;
|
||||
_worldPacket >> Slot;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::SellItem::Read()
|
||||
{
|
||||
_worldPacket >> VendorGuid;
|
||||
_worldPacket >> ItemGuid;
|
||||
_worldPacket >> Count;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::BuybackItem::Read()
|
||||
{
|
||||
_worldPacket >> VendorGuid;
|
||||
_worldPacket >> Slot;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::BuyItemInSlot::Read()
|
||||
{
|
||||
_worldPacket >> VendorGuid;
|
||||
_worldPacket >> Item;
|
||||
_worldPacket >> Slot;
|
||||
_worldPacket >> BagGuid;
|
||||
_worldPacket >> BagSlot;
|
||||
_worldPacket >> Count;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::BuyItem::Read()
|
||||
{
|
||||
_worldPacket >> VendorGuid;
|
||||
_worldPacket >> Item;
|
||||
_worldPacket >> Slot;
|
||||
_worldPacket >> Count;
|
||||
_worldPacket >> Unk;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::ListInventory::Read()
|
||||
{
|
||||
_worldPacket >> VendorGuid;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::AutoStoreBagItem::Read()
|
||||
{
|
||||
_worldPacket >> SourceBag;
|
||||
_worldPacket >> SourceSlot;
|
||||
_worldPacket >> DestinationBag;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::Item::EnchantmentLog::Write()
|
||||
{
|
||||
_worldPacket << Target;
|
||||
_worldPacket << Caster;
|
||||
_worldPacket << ItemId;
|
||||
_worldPacket << EnchantId;
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::Item::ItemEnchantTimeUpdate::Write()
|
||||
{
|
||||
_worldPacket << ItemGuid;
|
||||
_worldPacket << Slot;
|
||||
_worldPacket << Duration;
|
||||
_worldPacket << PlayerGuid;
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::WrapItem::Read()
|
||||
{
|
||||
_worldPacket >> GiftBag;
|
||||
_worldPacket >> GiftSlot;
|
||||
_worldPacket >> ItemBag;
|
||||
_worldPacket >> ItemSlot;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::SocketGems::Read()
|
||||
{
|
||||
_worldPacket >> ItemGuid;
|
||||
for (int i = 0; i < MAX_GEM_SOCKETS; ++i)
|
||||
_worldPacket >> GemGuids[i];
|
||||
}
|
||||
|
||||
void WorldPackets::Item::CancelTempEnchantment::Read()
|
||||
{
|
||||
_worldPacket >> EquipmentSlot;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::ItemRefundInfo::Read()
|
||||
{
|
||||
_worldPacket >> ItemGuid;
|
||||
}
|
||||
|
||||
void WorldPackets::Item::ItemRefund::Read()
|
||||
{
|
||||
_worldPacket >> ItemGuid;
|
||||
}
|
||||
272
src/server/game/Server/Packets/ItemPackets.h
Normal file
272
src/server/game/Server/Packets/ItemPackets.h
Normal file
@@ -0,0 +1,272 @@
|
||||
/*
|
||||
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by the
|
||||
* Free Software Foundation; either version 3 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 Affero 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 ItemPackets_h__
|
||||
#define ItemPackets_h__
|
||||
|
||||
#include "Item.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include "Packet.h"
|
||||
|
||||
namespace WorldPackets
|
||||
{
|
||||
namespace Item
|
||||
{
|
||||
class SplitItem final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
SplitItem(WorldPacket&& packet) : ClientPacket(CMSG_SPLIT_ITEM, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
uint8 SourceBag = 0;
|
||||
uint8 SourceSlot = 0;
|
||||
uint8 DestinationBag = 0;
|
||||
uint8 DestinationSlot = 0;
|
||||
uint32 Count = 0;
|
||||
};
|
||||
|
||||
class SwapInventoryItem final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
SwapInventoryItem(WorldPacket&& packet) : ClientPacket(CMSG_SWAP_INV_ITEM, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
uint8 DestinationSlot = 0;
|
||||
uint8 SourceSlot = 0;
|
||||
};
|
||||
|
||||
class AutoEquipItemSlot final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
AutoEquipItemSlot(WorldPacket&& packet) : ClientPacket(CMSG_AUTOEQUIP_ITEM_SLOT, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
ObjectGuid ItemGuid;
|
||||
uint8 DestinationSlot = 0;
|
||||
};
|
||||
|
||||
class SwapItem final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
SwapItem(WorldPacket&& packet) : ClientPacket(CMSG_SWAP_ITEM, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
uint8 DestinationBag = 0;
|
||||
uint8 DestinationSlot = 0;
|
||||
uint8 SourceBag = 0;
|
||||
uint8 SourceSlot = 0;
|
||||
};
|
||||
|
||||
class AutoEquipItem final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
AutoEquipItem(WorldPacket&& packet) : ClientPacket(CMSG_AUTOEQUIP_ITEM, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
uint8 SourceBag = 0;
|
||||
uint8 SourceSlot = 0;
|
||||
};
|
||||
|
||||
class DestroyItem final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
DestroyItem(WorldPacket&& packet) : ClientPacket(CMSG_DESTROYITEM, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
uint8 Bag = 0;
|
||||
uint8 Slot = 0;
|
||||
uint8 Count = 0;
|
||||
uint8 Data1 = 0;
|
||||
uint8 Data2 = 0;
|
||||
uint8 Data3 = 0;
|
||||
};
|
||||
|
||||
class ReadItem final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
ReadItem(WorldPacket&& packet) : ClientPacket(CMSG_READ_ITEM, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
uint8 Bag = 0;
|
||||
uint8 Slot = 0;
|
||||
};
|
||||
|
||||
class SellItem final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
SellItem(WorldPacket&& packet) : ClientPacket(CMSG_SELL_ITEM, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
ObjectGuid VendorGuid;
|
||||
ObjectGuid ItemGuid;
|
||||
uint32 Count = 0;
|
||||
};
|
||||
|
||||
class BuybackItem final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
BuybackItem(WorldPacket&& packet) : ClientPacket(CMSG_BUYBACK_ITEM, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
ObjectGuid VendorGuid;
|
||||
uint32 Slot = 0;
|
||||
};
|
||||
|
||||
class BuyItemInSlot final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
BuyItemInSlot(WorldPacket&& packet) : ClientPacket(CMSG_BUY_ITEM_IN_SLOT, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
ObjectGuid VendorGuid;
|
||||
uint32 Item = 0;
|
||||
uint32 Slot = 0;
|
||||
ObjectGuid BagGuid;
|
||||
uint8 BagSlot = 0;
|
||||
uint32 Count = 0;
|
||||
};
|
||||
|
||||
class BuyItem final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
BuyItem(WorldPacket&& packet) : ClientPacket(CMSG_BUY_ITEM, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
ObjectGuid VendorGuid;
|
||||
uint32 Item = 0;
|
||||
uint32 Slot = 0;
|
||||
uint32 Count = 0;
|
||||
uint8 Unk = 0;
|
||||
};
|
||||
|
||||
class ListInventory final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
ListInventory(WorldPacket&& packet) : ClientPacket(CMSG_LIST_INVENTORY, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
ObjectGuid VendorGuid;
|
||||
};
|
||||
|
||||
class AutoStoreBagItem final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
AutoStoreBagItem(WorldPacket&& packet) : ClientPacket(CMSG_AUTOSTORE_BAG_ITEM, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
uint8 SourceBag = 0;
|
||||
uint8 SourceSlot = 0;
|
||||
uint8 DestinationBag = 0;
|
||||
};
|
||||
|
||||
class EnchantmentLog final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
EnchantmentLog() : ServerPacket(SMSG_ENCHANTMENTLOG, 8 + 8 + 4 + 4) {}
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
PackedGuid Target;
|
||||
PackedGuid Caster;
|
||||
uint32 ItemId = 0;
|
||||
uint32 EnchantId = 0;
|
||||
};
|
||||
|
||||
class ItemEnchantTimeUpdate final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
ItemEnchantTimeUpdate() : ServerPacket(SMSG_ITEM_ENCHANT_TIME_UPDATE, 8 + 4 + 4 + 8) {}
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
// last check 2.0.10
|
||||
ObjectGuid ItemGuid;
|
||||
uint32 Slot = 0;
|
||||
uint32 Duration = 0;
|
||||
ObjectGuid PlayerGuid;
|
||||
};
|
||||
|
||||
class WrapItem final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
WrapItem(WorldPacket&& packet) : ClientPacket(CMSG_WRAP_ITEM, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
uint8 GiftBag = 0;
|
||||
uint8 GiftSlot = 0;
|
||||
uint8 ItemBag = 0;
|
||||
uint8 ItemSlot = 0;
|
||||
};
|
||||
|
||||
class SocketGems final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
SocketGems(WorldPacket&& packet) : ClientPacket(CMSG_SOCKET_GEMS, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
ObjectGuid ItemGuid;
|
||||
ObjectGuid GemGuids[MAX_GEM_SOCKETS];
|
||||
};
|
||||
|
||||
class CancelTempEnchantment final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
CancelTempEnchantment(WorldPacket&& packet) : ClientPacket(CMSG_CANCEL_TEMP_ENCHANTMENT, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
uint32 EquipmentSlot = 0;
|
||||
};
|
||||
|
||||
class ItemRefundInfo final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
ItemRefundInfo(WorldPacket&& packet) : ClientPacket(CMSG_ITEM_REFUND_INFO, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
ObjectGuid ItemGuid;
|
||||
};
|
||||
|
||||
class ItemRefund final : public ClientPacket
|
||||
{
|
||||
public:
|
||||
ItemRefund(WorldPacket&& packet) : ClientPacket(CMSG_ITEM_REFUND, std::move(packet)) {}
|
||||
|
||||
void Read() override;
|
||||
|
||||
ObjectGuid ItemGuid;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ItemPackets_h__
|
||||
@@ -167,6 +167,28 @@ namespace WorldPackets
|
||||
class TimeQuery;
|
||||
class CorpseMapPositionQuery;
|
||||
}
|
||||
|
||||
namespace Item
|
||||
{
|
||||
class SplitItem;
|
||||
class SwapInventoryItem;
|
||||
class AutoEquipItemSlot;
|
||||
class SwapItem;
|
||||
class AutoEquipItem;
|
||||
class DestroyItem;
|
||||
class ReadItem;
|
||||
class SellItem;
|
||||
class BuybackItem;
|
||||
class BuyItemInSlot;
|
||||
class BuyItem;
|
||||
class ListInventory;
|
||||
class AutoStoreBagItem;
|
||||
class WrapItem;
|
||||
class SocketGems;
|
||||
class CancelTempEnchantment;
|
||||
class ItemRefundInfo;
|
||||
class ItemRefund;
|
||||
}
|
||||
}
|
||||
|
||||
enum AccountDataType
|
||||
@@ -810,21 +832,21 @@ public: // opcodes handlers
|
||||
void HandleQueryNextMailTime(WorldPacket& recvData);
|
||||
void HandleCancelChanneling(WorldPacket& recvData);
|
||||
|
||||
void HandleSplitItemOpcode(WorldPacket& recvPacket);
|
||||
void HandleSwapInvItemOpcode(WorldPacket& recvPacket);
|
||||
void HandleDestroyItemOpcode(WorldPacket& recvPacket);
|
||||
void HandleAutoEquipItemOpcode(WorldPacket& recvPacket);
|
||||
void HandleSplitItemOpcode(WorldPackets::Item::SplitItem& packet);
|
||||
void HandleSwapInvItemOpcode(WorldPackets::Item::SwapInventoryItem& packet);
|
||||
void HandleDestroyItemOpcode(WorldPackets::Item::DestroyItem& packet);
|
||||
void HandleAutoEquipItemOpcode(WorldPackets::Item::AutoEquipItem& packet);
|
||||
void HandleItemQuerySingleOpcode(WorldPacket& recvPacket);
|
||||
void HandleSellItemOpcode(WorldPacket& recvPacket);
|
||||
void HandleBuyItemInSlotOpcode(WorldPacket& recvPacket);
|
||||
void HandleBuyItemOpcode(WorldPacket& recvPacket);
|
||||
void HandleListInventoryOpcode(WorldPacket& recvPacket);
|
||||
void HandleAutoStoreBagItemOpcode(WorldPacket& recvPacket);
|
||||
void HandleReadItem(WorldPacket& recvPacket);
|
||||
void HandleAutoEquipItemSlotOpcode(WorldPacket& recvPacket);
|
||||
void HandleSwapItem(WorldPacket& recvPacket);
|
||||
void HandleBuybackItem(WorldPacket& recvPacket);
|
||||
void HandleWrapItemOpcode(WorldPacket& recvPacket);
|
||||
void HandleSellItemOpcode(WorldPackets::Item::SellItem& packet);
|
||||
void HandleBuyItemInSlotOpcode(WorldPackets::Item::BuyItemInSlot& packet);
|
||||
void HandleBuyItemOpcode(WorldPackets::Item::BuyItem& packet);
|
||||
void HandleListInventoryOpcode(WorldPackets::Item::ListInventory& packet);
|
||||
void HandleAutoStoreBagItemOpcode(WorldPackets::Item::AutoStoreBagItem& packet);
|
||||
void HandleReadItem(WorldPackets::Item::ReadItem& packet);
|
||||
void HandleAutoEquipItemSlotOpcode(WorldPackets::Item::AutoEquipItemSlot& packet);
|
||||
void HandleSwapItem(WorldPackets::Item::SwapItem& packet);
|
||||
void HandleBuybackItem(WorldPackets::Item::BuybackItem& packet);
|
||||
void HandleWrapItemOpcode(WorldPackets::Item::WrapItem& packet);
|
||||
|
||||
void HandleAttackSwingOpcode(WorldPacket& recvPacket);
|
||||
void HandleAttackStopOpcode(WorldPacket& recvPacket);
|
||||
@@ -1014,12 +1036,12 @@ public: // opcodes handlers
|
||||
void HandleRequestPetInfo(WorldPackets::Pet::RequestPetInfo& packet);
|
||||
|
||||
// Socket gem
|
||||
void HandleSocketOpcode(WorldPacket& recvData);
|
||||
void HandleSocketOpcode(WorldPackets::Item::SocketGems& packet);
|
||||
|
||||
void HandleCancelTempEnchantmentOpcode(WorldPacket& recvData);
|
||||
void HandleCancelTempEnchantmentOpcode(WorldPackets::Item::CancelTempEnchantment& packet);
|
||||
|
||||
void HandleItemRefundInfoRequest(WorldPacket& recvData);
|
||||
void HandleItemRefund(WorldPacket& recvData);
|
||||
void HandleItemRefundInfoRequest(WorldPackets::Item::ItemRefundInfo& packet);
|
||||
void HandleItemRefund(WorldPackets::Item::ItemRefund& packet);
|
||||
|
||||
void HandleChannelVoiceOnOpcode(WorldPacket& recvData);
|
||||
void HandleVoiceSessionEnableOpcode(WorldPacket& recvData);
|
||||
|
||||
Reference in New Issue
Block a user