Improved equip manager, anti-abuse system

This commit is contained in:
Yehonal
2017-11-09 10:50:01 +00:00
parent 798e1acfc5
commit fe0c66bf70
+25 -5
View File
@@ -1980,14 +1980,22 @@ void WorldSession::HandleEquipmentSetUse(WorldPacket &recvData)
uint16 dstpos = i | (INVENTORY_SLOT_BAG_0 << 8); uint16 dstpos = i | (INVENTORY_SLOT_BAG_0 << 8);
InventoryResult msg;
Item* uItem = _player->GetItemByPos(INVENTORY_SLOT_BAG_0, i);
if (uItem) {
if (uItem->IsEquipped()) {
msg = _player->CanUnequipItem(dstpos, true);
if (msg != EQUIP_ERR_OK) {
_player->SendEquipError(msg, uItem, NULL);
continue;
}
}
if (!item) if (!item)
{ {
Item* uItem = _player->GetItemByPos(INVENTORY_SLOT_BAG_0, i);
if (!uItem)
continue;
ItemPosCountVec sDest; ItemPosCountVec sDest;
InventoryResult 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)
{ {
_player->RemoveItem(INVENTORY_SLOT_BAG_0, i, true); _player->RemoveItem(INVENTORY_SLOT_BAG_0, i, true);
@@ -1998,12 +2006,24 @@ void WorldSession::HandleEquipmentSetUse(WorldPacket &recvData)
continue; continue;
} }
}
if (item) {
if (item->GetPos() == dstpos) if (item->GetPos() == dstpos)
continue; continue;
if (!item->IsEquipped()) {
uint16 _candidatePos;
msg = _player->CanEquipItem(NULL_SLOT, _candidatePos, item, true);
if (msg != EQUIP_ERR_OK) {
_player->SendEquipError(msg, item, NULL);
continue;
}
}
_player->SwapItem(item->GetPos(), dstpos); _player->SwapItem(item->GetPos(), dstpos);
} }
}
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(0); // 4 - equipment swap failed - inventory is full