summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/newview/llappearancemgr.cpp71
-rw-r--r--indra/newview/llappearancemgr.h1
2 files changed, 68 insertions, 4 deletions
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index ce022ac840..8a3b4cb028 100644
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -1537,16 +1537,79 @@ bool sort_by_description(const LLInventoryItem* item1, const LLInventoryItem* it
return item1->LLInventoryItem::getDescription() < item2->LLInventoryItem::getDescription();
}
-void LLAppearanceMgr::updateAppearanceFromCOF()
+void item_array_diff(LLInventoryModel::item_array_t& full_list,
+ LLInventoryModel::item_array_t& keep_list,
+ LLInventoryModel::item_array_t& kill_list)
+
{
- //checking integrity of the COF in terms of ordering of wearables,
- //checking and updating links' descriptions of wearables in the COF (before analyzed for "dirty" state)
- updateClothingOrderingInfo();
+ for (LLInventoryModel::item_array_t::iterator it = full_list.begin();
+ it != full_list.end();
+ ++it)
+ {
+ LLViewerInventoryItem *item = *it;
+ if (keep_list.find(item) < 0) // Why on earth does LLDynamicArray need to redefine find()?
+ {
+ kill_list.push_back(item);
+ }
+ }
+}
+void LLAppearanceMgr::enforceItemCountLimits()
+{
+ 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)
+ {
+ LLViewerInventoryItem *item = *it;
+ llinfos << "purging dup body part " << item->getName() << llendl;
+ gInventory.purgeObject(item->getUUID());
+ purge_count++;
+ }
+
+ 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();
+ ++it)
+ {
+ LLViewerInventoryItem *item = *it;
+ llinfos << "purging excess clothing item " << item->getName() << llendl;
+ gInventory.purgeObject(item->getUUID());
+ purge_count++;
+ }
+
+ if (purge_count>0)
+ {
+ gInventory.notifyObservers();
+ }
+}
+
+void LLAppearanceMgr::updateAppearanceFromCOF()
+{
// update dirty flag to see if the state of the COF matches
// the saved outfit stored as a folder link
llinfos << "starting" << llendl;
+ //checking integrity of the COF in terms of ordering of wearables,
+ //checking and updating links' descriptions of wearables in the COF (before analyzed for "dirty" state)
+ updateClothingOrderingInfo();
+
+ enforceItemCountLimits();
+
updateIsDirty();
dumpCat(getCOF(),"COF, start");
diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h
index 61779d5c0e..15383381f8 100644
--- a/indra/newview/llappearancemgr.h
+++ b/indra/newview/llappearancemgr.h
@@ -66,6 +66,7 @@ public:
void renameOutfit(const LLUUID& outfit_id);
void takeOffOutfit(const LLUUID& cat_id);
void addCategoryToCurrentOutfit(const LLUUID& cat_id);
+ void enforceItemCountLimits();
// Copy all items and the src category itself.
void shallowCopyCategory(const LLUUID& src_id, const LLUUID& dst_id,