Core/PacketIO: Updated and enabled CMSG_WRAP_ITEM for WoD

This commit is contained in:
Vincent-Michael
2015-04-18 23:50:51 +02:00
parent 94215132c1
commit 9c7914524a
5 changed files with 57 additions and 20 deletions
+39 -18
View File
@@ -760,18 +760,27 @@ void WorldSession::SendItemEnchantTimeUpdate(ObjectGuid Playerguid, ObjectGuid I
SendPacket(&data);
}
void WorldSession::HandleWrapItemOpcode(WorldPacket& recvData)
void WorldSession::HandleWrapItem(WorldPackets::Item::WrapItem& packet)
{
TC_LOG_DEBUG("network", "Received opcode CMSG_WRAP_ITEM");
uint8 gift_bag, gift_slot, item_bag, item_slot;
if (packet.Inv.Items.size() != 2)
{
TC_LOG_ERROR("network", "HandleWrapItem - Invalid itemCount (" SZFMTD ")", packet.Inv.Items.size());
return;
}
recvData >> gift_bag >> gift_slot; // paper
recvData >> item_bag >> item_slot; // item
/// @todo: 6.x find better way for read
// Gift
uint8 giftContainerSlot = packet.Inv.Items[0].ContainerSlot;
uint8 giftSlot = packet.Inv.Items[0].Slot;
// Item
uint8 itemContainerSlot = packet.Inv.Items[1].ContainerSlot;
uint8 itemSlot = packet.Inv.Items[1].Slot;
TC_LOG_DEBUG("network", "WRAP: receive gift_bag = %u, gift_slot = %u, item_bag = %u, item_slot = %u", gift_bag, gift_slot, item_bag, item_slot);
TC_LOG_DEBUG("network", "HandleWrapItem - Receive giftContainerSlot = %u, giftSlot = %u, itemContainerSlot = %u, itemSlot = %u", giftContainerSlot, giftSlot, itemContainerSlot, itemSlot);
Item* gift = _player->GetItemByPos(gift_bag, gift_slot);
Item* gift = _player->GetItemByPos(giftContainerSlot, giftSlot);
if (!gift)
{
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, gift, NULL);
@@ -784,15 +793,14 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recvData)
return;
}
Item* item = _player->GetItemByPos(item_bag, item_slot);
Item* item = _player->GetItemByPos(itemContainerSlot, itemSlot);
if (!item)
{
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, item, NULL);
return;
}
if (item == gift) // not possable with pacjket from real client
if (item == gift) // not possable with pacjket from real client
{
_player->SendEquipError(EQUIP_ERR_CANT_WRAP_WRAPPED, item, NULL);
return;
@@ -804,7 +812,7 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recvData)
return;
}
if (!item->GetGuidValue(ITEM_FIELD_GIFTCREATOR).IsEmpty()) // HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED);
if (!item->GetGuidValue(ITEM_FIELD_GIFTCREATOR).IsEmpty()) // HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED);
{
_player->SendEquipError(EQUIP_ERR_CANT_WRAP_WRAPPED, item, NULL);
return;
@@ -848,22 +856,35 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recvData)
switch (item->GetEntry())
{
case 5042: item->SetEntry(5043); break;
case 5048: item->SetEntry(5044); break;
case 17303: item->SetEntry(17302); break;
case 17304: item->SetEntry(17305); break;
case 17307: item->SetEntry(17308); break;
case 21830: item->SetEntry(21831); break;
case 5042:
item->SetEntry(5043);
break;
case 5048:
item->SetEntry(5044);
break;
case 17303:
item->SetEntry(17302);
break;
case 17304:
item->SetEntry(17305);
break;
case 17307:
item->SetEntry(17308);
break;
case 21830:
item->SetEntry(21831);
break;
}
item->SetGuidValue(ITEM_FIELD_GIFTCREATOR, _player->GetGUID());
item->SetUInt32Value(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED);
item->SetState(ITEM_CHANGED, _player);
if (item->GetState() == ITEM_NEW) // save new item, to have alway for `character_gifts` record in `item_instance`
if (item->GetState() == ITEM_NEW) // save new item, to have alway for `character_gifts` record in `item_instance`
{
// after save it will be impossible to remove the item from the queue
item->RemoveFromUpdateQueueOf(_player);
item->SaveToDB(trans); // item gave inventory record unchanged and can be save standalone
item->SaveToDB(trans); // item gave inventory record unchanged and can be save standalone
}
CharacterDatabase.CommitTransaction(trans);
@@ -357,3 +357,8 @@ WorldPacket const* WorldPackets::Item::ReadItemResultOK::Write()
return &_worldPacket;
}
void WorldPackets::Item::WrapItem::Read()
{
_worldPacket >> Inv;
}
@@ -343,6 +343,16 @@ namespace WorldPackets
ObjectGuid Item;
};
class WrapItem final : public ClientPacket
{
public:
WrapItem(WorldPacket&& packet) : ClientPacket(CMSG_WRAP_ITEM, std::move(packet)) { }
void Read() override;
InvUpdate Inv;
};
ByteBuffer& operator>>(ByteBuffer& data, InvUpdate& invUpdate);
}
}
+1 -1
View File
@@ -827,7 +827,7 @@ void OpcodeTable::Initialize()
DEFINE_HANDLER(CMSG_WHO_IS, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Who::WhoIsRequest, &WorldSession::HandleWhoIsOpcode);
DEFINE_HANDLER(CMSG_WORLD_PORT_RESPONSE, STATUS_TRANSFER, PROCESS_THREADUNSAFE, WorldPackets::Movement::WorldPortResponse, &WorldSession::HandleMoveWorldportAckOpcode);
DEFINE_OPCODE_HANDLER_OLD(CMSG_WORLD_TELEPORT, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleWorldTeleportOpcode );
DEFINE_OPCODE_HANDLER_OLD(CMSG_WRAP_ITEM, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleWrapItemOpcode );
DEFINE_HANDLER(CMSG_WRAP_ITEM, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Item::WrapItem, &WorldSession::HandleWrapItem);
#undef DEFINE_OPCODE_HANDLER_OLD
#undef DEFINE_HANDLER
+2 -1
View File
@@ -276,6 +276,7 @@ namespace WorldPackets
class SplitItem;
class SwapInvItem;
class SwapItem;
class WrapItem;
}
namespace Loot
@@ -1185,7 +1186,7 @@ class WorldSession
void HandleAutoEquipItemSlotOpcode(WorldPackets::Item::AutoEquipItemSlot& autoEquipItemSlot);
void HandleSwapItem(WorldPackets::Item::SwapItem& swapItem);
void HandleBuybackItem(WorldPackets::Item::BuyBackItem& packet);
void HandleWrapItemOpcode(WorldPacket& recvPacket);
void HandleWrapItem(WorldPackets::Item::WrapItem& packet);
void HandleAttackSwingOpcode(WorldPackets::Combat::AttackSwing& packet);
void HandleAttackStopOpcode(WorldPackets::Combat::AttackStop& packet);