// Internal Method: Checks an inventory queue type bucket for a particular item sint16 Inventory::_HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity) { iter_queue it; iter_contents itb; uint8 quantity_found = 0; // Read-only iteration of queue for (it=iqueue.begin(); it!=iqueue.end(); it++) { ItemInst* inst = *it; if (inst && inst->IsType(ItemClassCommon) && inst->GetItem()->ItemType == use) { quantity_found += (inst->GetCharges()<=0) ? 1 : inst->GetCharges(); if (quantity_found >= quantity) return SLOT_CURSOR; } // Go through bag, if bag if (inst && inst->IsType(ItemClassContainer)) { for (itb=inst->_begin(); itb!=inst->_end(); itb++) { ItemInst* baginst = itb->second; if (baginst && baginst->IsType(ItemClassCommon) && baginst->GetItem()->ItemType == use) { quantity_found += (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges(); if (quantity_found >= quantity) return Inventory::CalcSlotId(SLOT_CURSOR, itb->first); } } } } // Not found return SLOT_INVALID; }
// Internal Method: Checks an inventory queue type bucket for a particular item int16 Inventory::_HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup) { iter_queue it; iter_contents itb; // Read-only iteration of queue for (it = iqueue.begin(); it != iqueue.end(); ++it) { ItemInst* inst = *it; if (inst) { if (inst->GetItem()->LoreGroup == loregroup) return SLOT_CURSOR; } // Go through bag, if bag if (inst && inst->IsType(ItemClassContainer)) { for (itb = inst->_begin(); itb != inst->_end(); ++itb) { ItemInst* baginst = itb->second; if (baginst && baginst->IsType(ItemClassCommon) && baginst->GetItem()->LoreGroup == loregroup) return Inventory::CalcSlotId(SLOT_CURSOR, itb->first); } } } // Not found return SLOT_INVALID; }
// Internal Method: Checks an inventory queue type bucket for a particular item sint16 Inventory::_HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup) { iter_queue it; iter_contents itb; // Read-only iteration of queue for (it=iqueue.begin(); it!=iqueue.end(); it++) { ItemInst* inst = *it; if (inst) { if (inst->GetItem()->LoreGroup == loregroup) return SLOT_CURSOR; ItemInst* Aug; for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) { Aug = inst->GetAugment(i); if (Aug && Aug->GetItem()->LoreGroup == loregroup) return SLOT_AUGMENT; // Only one augment per slot. } } // Go through bag, if bag if (inst && inst->IsType(ItemClassContainer)) { for (itb=inst->_begin(); itb!=inst->_end(); itb++) { ItemInst* baginst = itb->second; if (baginst && baginst->IsType(ItemClassCommon)&& baginst->GetItem()->LoreGroup == loregroup) return Inventory::CalcSlotId(SLOT_CURSOR, itb->first); ItemInst* Aug2; for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) { Aug2 = baginst->GetAugment(i); if (Aug2 && Aug2->GetItem()->LoreGroup == loregroup) return SLOT_AUGMENT; // Only one augment per slot. } } } } // Not found return SLOT_INVALID; }
// Internal Method: Checks an inventory queue type bucket for a particular item sint16 Inventory::_HasItem(ItemInstQueue& iqueue, uint32 item_id, uint8 quantity) { iter_queue it; iter_contents itb; uint8 quantity_found = 0; // Read-only iteration of queue for (it=iqueue.begin(); it!=iqueue.end(); it++) { ItemInst* inst = *it; if (inst) { if (inst->GetID() == item_id) { quantity_found += (inst->GetCharges()<=0) ? 1 : inst->GetCharges(); if (quantity_found >= quantity) return SLOT_CURSOR; } for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) { if (inst->GetAugmentItemID(i) == item_id && quantity <= 1) return SLOT_AUGMENT; // Only one augment per slot. } } // Go through bag, if bag if (inst && inst->IsType(ItemClassContainer)) { for (itb=inst->_begin(); itb!=inst->_end(); itb++) { ItemInst* baginst = itb->second; if (baginst->GetID() == item_id) { quantity_found += (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges(); if (quantity_found >= quantity) return Inventory::CalcSlotId(SLOT_CURSOR, itb->first); } for(int i = 0; i < MAX_AUGMENT_SLOTS; i++) { if (baginst->GetAugmentItemID(i) == item_id && quantity <= 1) return SLOT_AUGMENT; // Only one augment per slot. } } } } // Not found return SLOT_INVALID; }