Hack fix for an outdated inventory function

This commit is contained in:
Uleat 2017-04-01 17:40:18 -04:00
parent de52d2f64a
commit 60d2c703b6
3 changed files with 36 additions and 5 deletions

View File

@ -241,14 +241,45 @@ EQEmu::ItemInstance* EQEmu::InventoryProfile::GetCursorItem()
}
// Swap items in inventory
bool EQEmu::InventoryProfile::SwapItem(int16 slot_a, int16 slot_b)
bool EQEmu::InventoryProfile::SwapItem(int16 slot_a, int16 slot_b, uint16 race_id, uint8 class_id, uint16 deity_id, uint8 level)
{
// Temp holding areas for a and b
ItemInstance* inst_a = GetItem(slot_a);
ItemInstance* inst_b = GetItem(slot_b);
if (inst_a) { if (!inst_a->IsSlotAllowed(slot_b)) { return false; } }
if (inst_b) { if (!inst_b->IsSlotAllowed(slot_a)) { return false; } }
if (inst_a) {
if (!inst_a->IsSlotAllowed(slot_b))
return false;
if ((slot_b >= legacy::EQUIPMENT_BEGIN && slot_b <= legacy::EQUIPMENT_END) || slot_b == inventory::slotPowerSource) {
auto item_a = inst_a->GetItem();
if (!item_a)
return false;
if (race_id && class_id && !item_a->IsEquipable(race_id, class_id))
return false;
if (deity_id && item_a->Deity && !(deity::ConvertDeityTypeToDeityTypeBit((deity::DeityType)deity_id) & item_a->Deity))
return false;
if (level && item_a->ReqLevel && level < item_a->ReqLevel)
return false;
}
}
if (inst_b) {
if (!inst_b->IsSlotAllowed(slot_a))
return false;
if ((slot_a >= legacy::EQUIPMENT_BEGIN && slot_a <= legacy::EQUIPMENT_END) || slot_a == inventory::slotPowerSource) {
auto item_b = inst_b->GetItem();
if (!item_b)
return false;
if (race_id && class_id && !item_b->IsEquipable(race_id, class_id))
return false;
if (deity_id && item_b->Deity && !(deity::ConvertDeityTypeToDeityTypeBit((deity::DeityType)deity_id) & item_b->Deity))
return false;
if (level && item_b->ReqLevel && level < item_b->ReqLevel)
return false;
}
}
_PutItem(slot_a, inst_b); // Copy b->a
_PutItem(slot_b, inst_a); // Copy a->b

View File

@ -127,7 +127,7 @@ namespace EQEmu
ItemInstance* GetCursorItem();
// Swap items in inventory
bool SwapItem(int16 slot_a, int16 slot_b);
bool SwapItem(int16 slot_a, int16 slot_b, uint16 race_id = 0, uint8 class_id = 0, uint16 deity_id = 0, uint8 level = 0);
// Remove item from inventory
bool DeleteItem(int16 slot_id, uint8 quantity = 0);

View File

@ -1823,7 +1823,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
}
SetMaterial(dst_slot_id,src_inst->GetItem()->ID);
}
if(!m_inv.SwapItem(src_slot_id, dst_slot_id)) { return false; }
if(!m_inv.SwapItem(src_slot_id, dst_slot_id, GetRace(), GetClass(), GetDeity(), GetLevel())) { return false; }
Log(Logs::Detail, Logs::Inventory, "Moving entire item from slot %d to slot %d", src_slot_id, dst_slot_id);
if (src_slot_id <= EQEmu::legacy::EQUIPMENT_END || src_slot_id == EQEmu::inventory::slotPowerSource) {