// Remove augment from item and return it EQEmu::ItemInstance* EQEmu::ItemInstance::RemoveAugment(uint8 index) { if (!m_item || !m_item->IsClassCommon()) return nullptr; return PopItem(index); }
// Remove augment from item and return it ItemInst* ItemInst::RemoveAugment(uint8 index) { if (m_item->ItemClass == ItemClassCommon) return PopItem(index); return nullptr; }
// Remove item from inventory (with memory delete) bool Inventory::DeleteItem(int16 slot_id, uint8 quantity) { // Pop item out of inventory map (or queue) ItemInst* item_to_delete = PopItem(slot_id); // Determine if object should be fully deleted, or // just a quantity of charges of the item can be deleted if (item_to_delete && (quantity > 0)) { item_to_delete->SetCharges(item_to_delete->GetCharges() - quantity); // If there are no charges left on the item, if(item_to_delete->GetCharges() <= 0) { // If the item is stackable (e.g arrows), or // the item is not stackable, and is not a charged item, or is expendable, delete it if(item_to_delete->IsStackable() || (!item_to_delete->IsStackable() && ((item_to_delete->GetItem()->MaxCharges == 0) || item_to_delete->IsExpendable()))) { // Item can now be destroyed Inventory::MarkDirty(item_to_delete); return true; } } // Charges still exist, or it is a charged item that is not expendable. Put back into inventory _PutItem(slot_id, item_to_delete); return false; } Inventory::MarkDirty(item_to_delete); return true; }
// Internal Method: "put" item into bucket, without regard for what is currently in bucket // Assumes item has already been allocated int16 Inventory::_PutItem(int16 slot_id, ItemInst* inst) { // If putting a nullptr into slot, we need to remove slot without memory delete if (inst == nullptr) { //Why do we not delete the poped item here???? PopItem(slot_id); return slot_id; } int16 result = SLOT_INVALID; if (slot_id==SLOT_CURSOR) { // Cursor // Replace current item on cursor, if exists m_cursor.pop(); // no memory delete, clients of this function know what they are doing m_cursor.push_front(inst); result = slot_id; } else if ((slot_id>=0 && slot_id<=21) || (slot_id >= 400 && slot_id<=404) || (slot_id == 9999)) { // Worn slots m_worn[slot_id] = inst; result = slot_id; } else if ((slot_id>=22 && slot_id<=29)) { m_inv[slot_id] = inst; result = slot_id; } else if (slot_id>=2000 && slot_id<=2023) { // Bank slots m_bank[slot_id] = inst; result = slot_id; } else if (slot_id>=2500 && slot_id<=2501) { // Shared bank slots m_shbank[slot_id] = inst; result = slot_id; } else if (slot_id>=3000 && slot_id<=3007) { // Trade window slots m_trade[slot_id] = inst; result = slot_id; } else { // Slot must be within a bag ItemInst* baginst = GetItem(Inventory::CalcSlotId(slot_id)); // Get parent bag if (baginst && baginst->IsType(ItemClassContainer)) { baginst->_PutItem(Inventory::CalcBagIdx(slot_id), inst); result = slot_id; } } if (result == SLOT_INVALID) { LogFile->write(EQEMuLog::Error, "Inventory::_PutItem: Invalid slot_id specified (%i)", slot_id); Inventory::MarkDirty(inst); // Slot not found, clean up } return result; }
// Remove item inside container void EQEmu::ItemInstance::DeleteItem(uint8 index) { ItemInstance* inst = PopItem(index); safe_delete(inst); }
// Remove item inside container void ItemInst::DeleteItem(uint8 index) { ItemInst* inst = PopItem(index); safe_delete(inst); }