// Checked: 2010-08-30 (RLVa-1.2.1c) | Modified: RLVa-1.2.1c void RlvForceWear::remAttachment(const LLViewerObject* pAttachObj) { // Remove it from 'm_addAttachments' if it's queued for attaching const LLViewerInventoryItem* pItem = (pAttachObj->isAttachment()) ? gInventory.getItem(pAttachObj->getAttachmentItemID()) : NULL; if (pItem) { addattachments_map_t::iterator itAddAttachments = m_addAttachments.begin(); while (itAddAttachments != m_addAttachments.end()) { LLInventoryModel::item_array_t& wearItems = itAddAttachments->second; if (std::find_if(wearItems.begin(), wearItems.end(), RlvPredIsEqualOrLinkedItem(pItem)) != wearItems.end()) wearItems.erase(std::remove_if(wearItems.begin(), wearItems.end(), RlvPredIsEqualOrLinkedItem(pItem)), wearItems.end()); if (wearItems.empty()) m_addAttachments.erase(itAddAttachments++); else ++itAddAttachments; } } // Add it to 'm_remAttachments' if it's not already there if (!isRemAttachment(pAttachObj)) { m_remAttachments.push_back(const_cast<LLViewerObject*>(pAttachObj)); } }
// Checked: 2010-08-30 (RLVa-1.1.3b) | Modified: RLVa-1.2.1c void RlvForceWear::addAttachment(const LLViewerInventoryItem* pItem, EWearAction eAction) { // Remove it from 'm_remAttachments' if it's queued for detaching const LLViewerObject* pAttachObj = (gAgent.getAvatarObject()) ? gAgent.getAvatarObject()->getWornAttachment(pItem->getLinkedUUID()) : NULL; if ( (pAttachObj) && (isRemAttachment(pAttachObj)) ) m_remAttachments.erase(std::remove(m_remAttachments.begin(), m_remAttachments.end(), pAttachObj), m_remAttachments.end()); S32 idxAttachPt = RlvAttachPtLookup::getAttachPointIndex(pItem, true); if (ACTION_WEAR_ADD == eAction) { // Insert it at the back if it's not already there idxAttachPt |= ATTACHMENT_ADD; if (!isAddAttachment(pItem)) { addattachments_map_t::iterator itAddAttachments = m_addAttachments.find(idxAttachPt); if (itAddAttachments == m_addAttachments.end()) { m_addAttachments.insert(addattachment_pair_t(idxAttachPt, LLInventoryModel::item_array_t())); itAddAttachments = m_addAttachments.find(idxAttachPt); } itAddAttachments->second.push_back((LLViewerInventoryItem*)pItem); } } else if (ACTION_WEAR_REPLACE == eAction) { // Replace all pending attachments on this attachment point with the specified item (don't clear if it's the default attach point) addattachments_map_t::iterator itAddAttachments = m_addAttachments.find(idxAttachPt | ATTACHMENT_ADD); if ( (0 != idxAttachPt) && (itAddAttachments != m_addAttachments.end()) ) itAddAttachments->second.clear(); itAddAttachments = m_addAttachments.find(idxAttachPt); if (itAddAttachments == m_addAttachments.end()) { m_addAttachments.insert(addattachment_pair_t(idxAttachPt, LLInventoryModel::item_array_t())); itAddAttachments = m_addAttachments.find(idxAttachPt); } if (0 != idxAttachPt) itAddAttachments->second.clear(); itAddAttachments->second.push_back((LLViewerInventoryItem*)pItem); } }
// Checked: 2010-03-19 (RLVa-1.2.0a) | Added: RLVa-1.1.0i void RlvForceWear::forceDetach(const LLViewerObject* pAttachObj) { // Sanity check - no need to process duplicate removes if ( (!pAttachObj) || (isRemAttachment(pAttachObj)) ) return; if (isForceDetachable(pAttachObj)) { #ifdef RLV_EXPERIMENTAL_COMPOSITEFOLDERS LLViewerInventoryCategory* pFolder = NULL; if ( (RlvSettings::getEnableComposites()) && (gRlvHandler.getCompositeInfo(pAttachPt->getItemID(), NULL, &pFolder)) ) { // Attachment belongs to a composite folder so detach the entire folder (if we can take it off) if (gRlvHandler.canTakeOffComposite(pFolder)) forceFolder(pFolder, ACTION_DETACH, FLAG_DEFAULT); } else #endif // RLV_EXPERIMENTAL_COMPOSITEFOLDERS { remAttachment(pAttachObj); } } }