Fix(Core/CharacterHandler): Incorrect behavior using an equipment set… (#18253)
* Fix(Core/CharacterHandler): Incorrect behavior using an equipment set if it will result in a full inventory. * Fixing the error message to -Equiment swap failed - inventory is full- like the Blizzlike error message
This commit is contained in:
@@ -771,6 +771,14 @@ struct ItemPosCount
|
|||||||
};
|
};
|
||||||
typedef std::vector<ItemPosCount> ItemPosCountVec;
|
typedef std::vector<ItemPosCount> ItemPosCountVec;
|
||||||
|
|
||||||
|
struct SavedItem
|
||||||
|
{
|
||||||
|
Item* item;
|
||||||
|
uint16 dstpos;
|
||||||
|
|
||||||
|
SavedItem(Item* _item, uint16 dstpos) : item(_item), dstpos(dstpos) {}
|
||||||
|
};
|
||||||
|
|
||||||
enum TransferAbortReason
|
enum TransferAbortReason
|
||||||
{
|
{
|
||||||
TRANSFER_ABORT_NONE = 0x00,
|
TRANSFER_ABORT_NONE = 0x00,
|
||||||
|
|||||||
@@ -1804,6 +1804,8 @@ void WorldSession::HandleEquipmentSetUse(WorldPacket& recvData)
|
|||||||
{
|
{
|
||||||
LOG_DEBUG("network", "CMSG_EQUIPMENT_SET_USE");
|
LOG_DEBUG("network", "CMSG_EQUIPMENT_SET_USE");
|
||||||
|
|
||||||
|
std::vector<std::unique_ptr<SavedItem>> savedItems;
|
||||||
|
uint8 errorId = 0;
|
||||||
for (uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i)
|
for (uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i)
|
||||||
{
|
{
|
||||||
ObjectGuid itemGuid;
|
ObjectGuid itemGuid;
|
||||||
@@ -1829,7 +1831,6 @@ void WorldSession::HandleEquipmentSetUse(WorldPacket& recvData)
|
|||||||
uint16 dstpos = i | (INVENTORY_SLOT_BAG_0 << 8);
|
uint16 dstpos = i | (INVENTORY_SLOT_BAG_0 << 8);
|
||||||
|
|
||||||
InventoryResult msg;
|
InventoryResult msg;
|
||||||
|
|
||||||
Item* uItem = _player->GetItemByPos(INVENTORY_SLOT_BAG_0, i);
|
Item* uItem = _player->GetItemByPos(INVENTORY_SLOT_BAG_0, i);
|
||||||
if (uItem)
|
if (uItem)
|
||||||
{
|
{
|
||||||
@@ -1849,11 +1850,19 @@ void WorldSession::HandleEquipmentSetUse(WorldPacket& recvData)
|
|||||||
msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, sDest, uItem, false);
|
msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, sDest, uItem, false);
|
||||||
if (msg == EQUIP_ERR_OK)
|
if (msg == EQUIP_ERR_OK)
|
||||||
{
|
{
|
||||||
|
savedItems.emplace_back(std::make_unique<SavedItem>(uItem, dstpos));
|
||||||
_player->RemoveItem(INVENTORY_SLOT_BAG_0, i, true);
|
_player->RemoveItem(INVENTORY_SLOT_BAG_0, i, true);
|
||||||
_player->StoreItem(sDest, uItem, true);
|
_player->StoreItem(sDest, uItem, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_player->SendEquipError(msg, uItem, nullptr);
|
{
|
||||||
|
errorId = 4;
|
||||||
|
for (uint8_t j = 0; j < savedItems.size(); ++j)
|
||||||
|
{
|
||||||
|
_player->SwapItem(savedItems[j].get()->item->GetPos(), savedItems[j].get()->dstpos);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1880,7 +1889,7 @@ void WorldSession::HandleEquipmentSetUse(WorldPacket& recvData)
|
|||||||
}
|
}
|
||||||
|
|
||||||
WorldPacket data(SMSG_EQUIPMENT_SET_USE_RESULT, 1);
|
WorldPacket data(SMSG_EQUIPMENT_SET_USE_RESULT, 1);
|
||||||
data << uint8(0); // 4 - equipment swap failed - inventory is full
|
data << uint8(errorId); // 4 - equipment swap failed - inventory is full
|
||||||
SendPacket(&data);
|
SendPacket(&data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user