From 6c1796c105054bf52f879ab7060a2f53f896d44d Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Thu, 12 Aug 2010 11:00:39 -0400 Subject: DEV-52580 WIP: disallow multiple links to the same attachment in updateAppearanceFromCOF() --- indra/newview/llappearancemgr.cpp | 80 ++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 35 deletions(-) (limited to 'indra/newview/llappearancemgr.cpp') diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index 2729053390..5a076845da 100644 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -1608,46 +1608,56 @@ void item_array_diff(LLInventoryModel::item_array_t& full_list, } } -void LLAppearanceMgr::enforceItemCountLimits() +S32 LLAppearanceMgr::findExcessOrDuplicateItems(const LLUUID& cat_id, + LLAssetType::EType type, + S32 max_items, + LLInventoryModel::item_array_t& items_to_kill) { - S32 purge_count = 0; - - LLInventoryModel::item_array_t body_items; - getDescendentsOfAssetType(getCOF(), body_items, LLAssetType::AT_BODYPART, false); - LLInventoryModel::item_array_t curr_body_items = body_items; - removeDuplicateItems(body_items); - filterWearableItems(body_items, 1); - LLInventoryModel::item_array_t kill_body_items; - item_array_diff(curr_body_items,body_items,kill_body_items); - for (LLInventoryModel::item_array_t::iterator it = kill_body_items.begin(); - it != kill_body_items.end(); - ++it) + S32 to_kill_count = 0; + + LLInventoryModel::item_array_t items; + getDescendentsOfAssetType(cat_id, items, type, false); + LLInventoryModel::item_array_t curr_items = items; + removeDuplicateItems(items); + if (max_items > 0) { - LLViewerInventoryItem *item = *it; - llinfos << "purging dup body part " << item->getName() << llendl; - gInventory.purgeObject(item->getUUID()); - purge_count++; + filterWearableItems(items, max_items); } - - LLInventoryModel::item_array_t wear_items; - getDescendentsOfAssetType(getCOF(), wear_items, LLAssetType::AT_CLOTHING, false); - LLInventoryModel::item_array_t curr_wear_items = wear_items; - removeDuplicateItems(wear_items); - filterWearableItems(wear_items, LLAgentWearables::MAX_CLOTHING_PER_TYPE); - LLInventoryModel::item_array_t kill_wear_items; - item_array_diff(curr_wear_items,wear_items,kill_wear_items); - for (LLInventoryModel::item_array_t::iterator it = kill_wear_items.begin(); - it != kill_wear_items.end(); + LLInventoryModel::item_array_t kill_items; + item_array_diff(curr_items,items,kill_items); + for (LLInventoryModel::item_array_t::iterator it = kill_items.begin(); + it != kill_items.end(); ++it) { - LLViewerInventoryItem *item = *it; - llinfos << "purging excess clothing item " << item->getName() << llendl; - gInventory.purgeObject(item->getUUID()); - purge_count++; + items_to_kill.push_back(*it); + to_kill_count++; } + return to_kill_count; +} + + +void LLAppearanceMgr::enforceItemRestrictions() +{ + S32 purge_count = 0; + LLInventoryModel::item_array_t items_to_kill; - if (purge_count>0) + purge_count += findExcessOrDuplicateItems(getCOF(),LLAssetType::AT_BODYPART, + 1, items_to_kill); + purge_count += findExcessOrDuplicateItems(getCOF(),LLAssetType::AT_CLOTHING, + LLAgentWearables::MAX_CLOTHING_PER_TYPE, items_to_kill); + purge_count += findExcessOrDuplicateItems(getCOF(),LLAssetType::AT_OBJECT, + -1, items_to_kill); + + if (items_to_kill.size()>0) { + for (LLInventoryModel::item_array_t::iterator it = items_to_kill.begin(); + it != items_to_kill.end(); + ++it) + { + LLViewerInventoryItem *item = *it; + llinfos << "purging duplicate or excess item " << item->getName() << llendl; + gInventory.purgeObject(item->getUUID()); + } gInventory.notifyObservers(); } } @@ -1670,7 +1680,7 @@ void LLAppearanceMgr::updateAppearanceFromCOF(bool update_base_outfit_ordering) // Remove duplicate or excess wearables. Should normally be enforced at the UI level, but // this should catch anything that gets through. - enforceItemCountLimits(); + enforceItemRestrictions(); // update dirty flag to see if the state of the COF matches // the saved outfit stored as a folder link @@ -2741,8 +2751,8 @@ bool LLAppearanceMgr::isLinkInCOF(const LLUUID& obj_id) LLInventoryModel::item_array_t items; LLLinkedItemIDMatches find_links(gInventory.getLinkedItemID(obj_id)); gInventory.collectDescendentsIf(LLAppearanceMgr::instance().getCOF(), - cats, - items, + cats, + items, LLInventoryModel::EXCLUDE_TRASH, find_links); -- cgit v1.2.3 From 5881252ab2e9ab31b05c1a54d8ce723013eee15a Mon Sep 17 00:00:00 2001 From: Loren Shih Date: Fri, 13 Aug 2010 11:12:51 -0400 Subject: EXT-8650 Can wear multiple copies of no-copy item via object links * EXT-8688 Automatically detach same object is detected * EXT-8689 Cleanup detachAttachmentIntoInventory code When an object arrives as an attachment, if it's already attached then it's automatically detached. --- indra/newview/llappearancemgr.cpp | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) (limited to 'indra/newview/llappearancemgr.cpp') diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index 6fdd71bfbf..21a635e738 100644 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -2496,29 +2496,17 @@ void LLAppearanceMgr::removeItemFromAvatar(const LLUUID& id_to_remove) switch (item_to_remove->getType()) { - case LLAssetType::AT_CLOTHING: - if (get_is_item_worn(id_to_remove)) - { - //*TODO move here the exact removing code from LLWearableBridge::removeItemFromAvatar in the future - LLWearableBridge::removeItemFromAvatar(item_to_remove); - } - break; - case LLAssetType::AT_OBJECT: - gMessageSystem->newMessageFast(_PREHASH_DetachAttachmentIntoInv); - gMessageSystem->nextBlockFast(_PREHASH_ObjectData); - gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - gMessageSystem->addUUIDFast(_PREHASH_ItemID, item_to_remove->getLinkedUUID()); - gMessageSystem->sendReliable( gAgent.getRegion()->getHost()); - - { - // this object might have been selected, so let the selection manager know it's gone now - LLViewerObject *found_obj = gObjectList.findObject(item_to_remove->getLinkedUUID()); - if (found_obj) + case LLAssetType::AT_CLOTHING: + if (get_is_item_worn(id_to_remove)) { - LLSelectMgr::getInstance()->remove(found_obj); - }; - } - default: break; + //*TODO move here the exact removing code from LLWearableBridge::removeItemFromAvatar in the future + LLWearableBridge::removeItemFromAvatar(item_to_remove); + } + break; + case LLAssetType::AT_OBJECT: + LLVOAvatarSelf::detachAttachmentIntoInventory(item_to_remove->getLinkedUUID()); + default: + break; } // *HACK: Force to remove garbage from COF. -- cgit v1.2.3 From f369ebec244f57205d0a9c835d4184c827e7b50f Mon Sep 17 00:00:00 2001 From: Loren Shih Date: Fri, 13 Aug 2010 11:26:22 -0400 Subject: EXT-8650 Can wear multiple copies of no-copy item via object links * EXT-8661 Take out unused mRegisteredAttachments in LLAppearanceMgr Removed unused mRegisteredAttachments. Not sure what this was used for, but it's no longer used. --- indra/newview/llappearancemgr.cpp | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'indra/newview/llappearancemgr.cpp') diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index 21a635e738..5c713e60f9 100644 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -2646,7 +2646,6 @@ void LLAppearanceMgr::setAttachmentInvLinkEnable(bool val) mAttachmentInvLinkEnabled = val; } -// BAP TODO - mRegisteredAttachments is currently maintained but not used for anything. Consider yanking. void dumpAttachmentSet(const std::set& atts, const std::string& msg) { llinfos << msg << llendl; @@ -2666,7 +2665,6 @@ void dumpAttachmentSet(const std::set& atts, const std::string& msg) void LLAppearanceMgr::registerAttachment(const LLUUID& item_id) { - mRegisteredAttachments.insert(item_id); gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id); if (mAttachmentInvLinkEnabled) @@ -2684,7 +2682,6 @@ void LLAppearanceMgr::registerAttachment(const LLUUID& item_id) void LLAppearanceMgr::unregisterAttachment(const LLUUID& item_id) { - mRegisteredAttachments.erase(item_id); gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id); if (mAttachmentInvLinkEnabled) @@ -2697,18 +2694,6 @@ void LLAppearanceMgr::unregisterAttachment(const LLUUID& item_id) } } -void LLAppearanceMgr::linkRegisteredAttachments() -{ - for (std::set::iterator it = mRegisteredAttachments.begin(); - it != mRegisteredAttachments.end(); - ++it) - { - LLUUID item_id = *it; - addCOFItemLink(item_id, false); - } - mRegisteredAttachments.clear(); -} - BOOL LLAppearanceMgr::getIsInCOF(const LLUUID& obj_id) const { return gInventory.isObjectDescendentOf(obj_id, getCOF()); -- cgit v1.2.3