Improved equip manager, anti-abuse system

This commit is contained in:
Yehonal
2017-11-09 10:50:01 +00:00
parent 798e1acfc5
commit fe0c66bf70
+37 -17
View File
@@ -1980,29 +1980,49 @@ void WorldSession::HandleEquipmentSetUse(WorldPacket &recvData)
uint16 dstpos = i | (INVENTORY_SLOT_BAG_0 << 8); uint16 dstpos = i | (INVENTORY_SLOT_BAG_0 << 8);
if (!item) InventoryResult msg;
{
Item* uItem = _player->GetItemByPos(INVENTORY_SLOT_BAG_0, i);
if (!uItem)
continue;
ItemPosCountVec sDest; Item* uItem = _player->GetItemByPos(INVENTORY_SLOT_BAG_0, i);
InventoryResult msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, sDest, uItem, false); if (uItem) {
if (msg == EQUIP_ERR_OK) if (uItem->IsEquipped()) {
{ msg = _player->CanUnequipItem(dstpos, true);
_player->RemoveItem(INVENTORY_SLOT_BAG_0, i, true); if (msg != EQUIP_ERR_OK) {
_player->StoreItem(sDest, uItem, true); _player->SendEquipError(msg, uItem, NULL);
continue;
}
} }
else
_player->SendEquipError(msg, uItem, NULL);
continue; if (!item)
{
ItemPosCountVec sDest;
msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, sDest, uItem, false);
if (msg == EQUIP_ERR_OK)
{
_player->RemoveItem(INVENTORY_SLOT_BAG_0, i, true);
_player->StoreItem(sDest, uItem, true);
}
else
_player->SendEquipError(msg, uItem, NULL);
continue;
}
} }
if (item->GetPos() == dstpos) if (item) {
continue; if (item->GetPos() == dstpos)
continue;
_player->SwapItem(item->GetPos(), dstpos); 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);
}
} }
WorldPacket data(SMSG_EQUIPMENT_SET_USE_RESULT, 1); WorldPacket data(SMSG_EQUIPMENT_SET_USE_RESULT, 1);