mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-30 13:47:23 +01:00
Core/PacketIO: OpenItem for 6.1
You can test it with http://www.wowhead.com/item=41426/
This commit is contained in:
@@ -129,42 +129,35 @@ void WorldSession::HandleUseItemOpcode(WorldPackets::Spells::UseItem& packet)
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
|
||||
void WorldSession::HandleOpenItemOpcode(WorldPackets::Spells::OpenItem& packet)
|
||||
{
|
||||
TC_LOG_DEBUG("network", "WORLD: CMSG_OPEN_ITEM packet, data length = %i", (uint32)recvPacket.size());
|
||||
|
||||
Player* pUser = _player;
|
||||
Player* player = _player;
|
||||
|
||||
// ignore for remote control state
|
||||
if (pUser->m_mover != pUser)
|
||||
if (player->m_mover != player)
|
||||
return;
|
||||
TC_LOG_INFO("network", "bagIndex: %u, slot: %u", packet.Slot, packet.PackSlot);
|
||||
|
||||
uint8 bagIndex, slot;
|
||||
|
||||
recvPacket >> bagIndex >> slot;
|
||||
|
||||
TC_LOG_INFO("network", "bagIndex: %u, slot: %u", bagIndex, slot);
|
||||
|
||||
Item* item = pUser->GetItemByPos(bagIndex, slot);
|
||||
Item* item = player->GetItemByPos(packet.Slot, packet.PackSlot);
|
||||
if (!item)
|
||||
{
|
||||
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
|
||||
player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
ItemTemplate const* proto = item->GetTemplate();
|
||||
if (!proto)
|
||||
{
|
||||
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, item, NULL);
|
||||
player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, item, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
// Verify that the bag is an actual bag or wrapped item that can be used "normally"
|
||||
if (!(proto->GetFlags() & ITEM_PROTO_FLAG_OPENABLE) && !item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED))
|
||||
{
|
||||
pUser->SendEquipError(EQUIP_ERR_CLIENT_LOCKED_OUT, item, NULL);
|
||||
player->SendEquipError(EQUIP_ERR_CLIENT_LOCKED_OUT, item, NULL);
|
||||
TC_LOG_ERROR("network", "Possible hacking attempt: Player %s [%s] tried to open item [%s, entry: %u] which is not openable!",
|
||||
pUser->GetName().c_str(), pUser->GetGUID().ToString().c_str(), item->GetGUID().ToString().c_str(), proto->GetId());
|
||||
player->GetName().c_str(), player->GetGUID().ToString().c_str(), item->GetGUID().ToString().c_str(), proto->GetId());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -176,7 +169,7 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
|
||||
|
||||
if (!lockInfo)
|
||||
{
|
||||
pUser->SendEquipError(EQUIP_ERR_ITEM_LOCKED, item, NULL);
|
||||
player->SendEquipError(EQUIP_ERR_ITEM_LOCKED, item, NULL);
|
||||
TC_LOG_ERROR("network", "WORLD::OpenItem: item [%s] has an unknown lockId: %u!", item->GetGUID().ToString().c_str(), lockId);
|
||||
return;
|
||||
}
|
||||
@@ -184,7 +177,7 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
|
||||
// was not unlocked yet
|
||||
if (item->IsLocked())
|
||||
{
|
||||
pUser->SendEquipError(EQUIP_ERR_ITEM_LOCKED, item, NULL);
|
||||
player->SendEquipError(EQUIP_ERR_ITEM_LOCKED, item, NULL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -206,12 +199,12 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
|
||||
item->SetGuidValue(ITEM_FIELD_GIFTCREATOR, ObjectGuid::Empty);
|
||||
item->SetEntry(entry);
|
||||
item->SetUInt32Value(ITEM_FIELD_FLAGS, flags);
|
||||
item->SetState(ITEM_CHANGED, pUser);
|
||||
item->SetState(ITEM_CHANGED, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
TC_LOG_ERROR("network", "Wrapped item %s don't have record in character_gifts table and will deleted", item->GetGUID().ToString().c_str());
|
||||
pUser->DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
|
||||
player->DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -222,7 +215,7 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
else
|
||||
pUser->SendLoot(item->GetGUID(), LOOT_CORPSE);
|
||||
player->SendLoot(item->GetGUID(), LOOT_CORPSE);
|
||||
}
|
||||
|
||||
void WorldSession::HandleGameObjectUseOpcode(WorldPackets::GameObject::GameObjectUse& packet)
|
||||
|
||||
Reference in New Issue
Block a user