From 60d2c703b67bea4fb2de29094fe7b3467f85c509 Mon Sep 17 00:00:00 2001 From: Uleat Date: Sat, 1 Apr 2017 17:40:18 -0400 Subject: [PATCH] Hack fix for an outdated inventory function --- common/inventory_profile.cpp | 37 +++++++++++++++++++++++++++++++++--- common/inventory_profile.h | 2 +- zone/inventory.cpp | 2 +- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/common/inventory_profile.cpp b/common/inventory_profile.cpp index 545788588..4f245ee58 100644 --- a/common/inventory_profile.cpp +++ b/common/inventory_profile.cpp @@ -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 diff --git a/common/inventory_profile.h b/common/inventory_profile.h index d8cf6cf7f..d6d166337 100644 --- a/common/inventory_profile.h +++ b/common/inventory_profile.h @@ -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); diff --git a/zone/inventory.cpp b/zone/inventory.cpp index 38f407570..ceaeb282b 100644 --- a/zone/inventory.cpp +++ b/zone/inventory.cpp @@ -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) {