aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Handlers/ItemHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Handlers/ItemHandler.cpp')
-rw-r--r--src/server/game/Handlers/ItemHandler.cpp78
1 files changed, 34 insertions, 44 deletions
diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp
index 6745299b195..921e883a4e4 100644
--- a/src/server/game/Handlers/ItemHandler.cpp
+++ b/src/server/game/Handlers/ItemHandler.cpp
@@ -343,22 +343,19 @@ void WorldSession::HandleReadItem(WorldPacket& recvData)
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
}
-void WorldSession::HandleSellItemOpcode(WorldPacket& recvData)
+void WorldSession::HandleSellItemOpcode(WorldPackets::Item::SellItem& packet)
{
- TC_LOG_DEBUG("network", "WORLD: Received CMSG_SELL_ITEM");
- ObjectGuid vendorguid, itemguid;
- uint32 count;
+ TC_LOG_DEBUG("network", "WORLD: Received CMSG_SELL_ITEM: Vendor %s, Item %s, Amount: %u",
+ packet.VendorGUID.ToString().c_str(), packet.ItemGUID.ToString().c_str(), packet.Amount);
- recvData >> vendorguid >> itemguid >> count;
-
- if (!itemguid)
+ if (packet.ItemGUID.IsEmpty())
return;
- Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(vendorguid, UNIT_NPC_FLAG_VENDOR);
+ Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(packet.VendorGUID, UNIT_NPC_FLAG_VENDOR);
if (!creature)
{
- TC_LOG_DEBUG("network", "WORLD: HandleSellItemOpcode - %s not found or you can not interact with him.", vendorguid.ToString().c_str());
- _player->SendSellError(SELL_ERR_CANT_FIND_VENDOR, NULL, itemguid);
+ TC_LOG_DEBUG("network", "WORLD: HandleSellItemOpcode - %s not found or you can not interact with him.", packet.VendorGUID.ToString().c_str());
+ _player->SendSellError(SELL_ERR_CANT_FIND_VENDOR, nullptr, packet.ItemGUID);
return;
}
@@ -366,27 +363,27 @@ 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)
{
// prevent sell not owner item
if (_player->GetGUID() != pItem->GetOwnerGUID())
{
- _player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid);
+ _player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGUID);
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);
+ _player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGUID);
return;
}
// prevent sell currently looted item
if (_player->GetLootGUID() == pItem->GetGUID())
{
- _player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid);
+ _player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGUID);
return;
}
@@ -397,14 +394,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.Amount == 0)
+ packet.Amount = pItem->GetCount();
else
{
// prevent sell more items that exist in stack (possible only not from client)
- if (count > pItem->GetCount())
+ if (packet.Amount > pItem->GetCount())
{
- _player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid);
+ _player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGUID);
return;
}
}
@@ -414,18 +411,18 @@ void WorldSession::HandleSellItemOpcode(WorldPacket& recvData)
{
if (pProto->GetSellPrice() > 0)
{
- if (count < pItem->GetCount()) // need split items
+ if (packet.Amount < pItem->GetCount()) // need split items
{
- Item* pNewItem = pItem->CloneItem(count, _player);
+ Item* pNewItem = pItem->CloneItem(packet.Amount, _player);
if (!pNewItem)
{
- TC_LOG_ERROR("network", "WORLD: HandleSellItemOpcode - could not create clone of item %u; count = %u", pItem->GetEntry(), count);
- _player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid);
+ TC_LOG_ERROR("network", "WORLD: HandleSellItemOpcode - could not create clone of item %u; count = %u", pItem->GetEntry(), packet.Amount);
+ _player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGUID);
return;
}
- pItem->SetCount(pItem->GetCount() - count);
- _player->ItemRemovedQuestCheck(pItem->GetEntry(), count);
+ pItem->SetCount(pItem->GetCount() - packet.Amount);
+ _player->ItemRemovedQuestCheck(pItem->GetEntry(), packet.Amount);
if (_player->IsInWorld())
pItem->SendUpdateToPlayer(_player);
pItem->SetState(ITEM_CHANGED, _player);
@@ -442,31 +439,27 @@ void WorldSession::HandleSellItemOpcode(WorldPacket& recvData)
_player->AddItemToBuyBackSlot(pItem);
}
- uint32 money = pProto->GetSellPrice() * count;
+ uint32 money = pProto->GetSellPrice() * packet.Amount;
_player->ModifyMoney(money);
_player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_VENDORS, money);
}
else
- _player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid);
+ _player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGUID);
return;
}
}
- _player->SendSellError(SELL_ERR_CANT_FIND_ITEM, creature, itemguid);
+ _player->SendSellError(SELL_ERR_CANT_FIND_ITEM, creature, packet.ItemGUID);
return;
}
-void WorldSession::HandleBuybackItem(WorldPacket& recvData)
+void WorldSession::HandleBuybackItem(WorldPackets::Item::BuyBackItem& packet)
{
- TC_LOG_DEBUG("network", "WORLD: Received CMSG_BUYBACK_ITEM");
- ObjectGuid vendorguid;
- uint32 slot;
+ TC_LOG_DEBUG("network", "WORLD: Received CMSG_BUYBACK_ITEM: Vendor %s, Slot: %u", packet.VendorGUID.ToString().c_str(), packet.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)
{
- TC_LOG_DEBUG("network", "WORLD: HandleBuybackItem - Unit (%s) not found or you can not interact with him.", vendorguid.ToString().c_str());
+ TC_LOG_DEBUG("network", "WORLD: HandleBuybackItem - Unit (%s) not found or you can not interact with him.", packet.VendorGUID.ToString().c_str());
_player->SendSellError(SELL_ERR_CANT_FIND_VENDOR, NULL, ObjectGuid::Empty);
return;
}
@@ -475,10 +468,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(uint64(price)))
{
_player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, pItem->GetEntry(), 0);
@@ -490,7 +483,7 @@ void WorldSession::HandleBuybackItem(WorldPacket& recvData)
if (msg == EQUIP_ERR_OK)
{
_player->ModifyMoney(-(int32)price);
- _player->RemoveItemFromBuyBackSlot(slot, false);
+ _player->RemoveItemFromBuyBackSlot(packet.Slot, false);
_player->ItemAddedQuestCheck(pItem->GetEntry(), pItem->GetCount());
_player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_RECEIVE_EPIC_ITEM, pItem->GetEntry(), pItem->GetCount());
_player->StoreItem(dest, pItem, true);
@@ -1255,14 +1248,11 @@ void WorldSession::HandleCancelTempEnchantmentOpcode(WorldPacket& recvData)
item->ClearEnchantment(TEMP_ENCHANTMENT_SLOT);
}
-void WorldSession::HandleItemRefundInfoRequest(WorldPacket& recvData)
+void WorldSession::HandleItemRefundInfoRequest(WorldPackets::Item::ItemRefundInfo& packet)
{
- TC_LOG_DEBUG("network", "WORLD: CMSG_ITEM_REFUND_INFO");
+ TC_LOG_DEBUG("network", "WORLD: CMSG_ITEM_REFUND_INFO: Item %s", packet.ItemGUID.ToString().c_str());
- ObjectGuid guid;
- recvData >> guid; // item guid
-
- Item* item = _player->GetItemByGuid(guid);
+ Item* item = _player->GetItemByGuid(packet.ItemGUID);
if (!item)
{
TC_LOG_DEBUG("network", "Item refund: item not found!");