summaryrefslogtreecommitdiff
path: root/indra/newview/llappearancemgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llappearancemgr.cpp')
-rw-r--r--indra/newview/llappearancemgr.cpp80
1 files changed, 63 insertions, 17 deletions
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index 43b2f34ecd..1150d84feb 100644
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -364,7 +364,7 @@ LLUUID LLAppearanceManager::getCOF()
}
-const LLViewerInventoryItem* LLAppearanceManager::getCurrentOutfitLink()
+const LLViewerInventoryItem* LLAppearanceManager::getBaseOutfitLink()
{
const LLUUID& current_outfit_cat = getCOF();
LLInventoryModel::cat_array_t cat_array;
@@ -444,6 +444,28 @@ void LLAppearanceManager::shallowCopyCategory(const LLUUID& src_id, const LLUUID
}
}
+void LLAppearanceManager::purgeBaseOutfitLink(const LLUUID& category)
+{
+ LLInventoryModel::cat_array_t cats;
+ LLInventoryModel::item_array_t items;
+ gInventory.collectDescendents(category, cats, items,
+ LLInventoryModel::EXCLUDE_TRASH);
+ for (S32 i = 0; i < items.count(); ++i)
+ {
+ LLViewerInventoryItem *item = items.get(i);
+ if (item->getActualType() != LLAssetType::AT_LINK_FOLDER)
+ continue;
+ if (item->getIsLinkType())
+ {
+ LLViewerInventoryCategory* catp = item->getLinkedCategory();
+ if(catp && catp->getPreferredType() == LLFolderType::FT_OUTFIT)
+ {
+ gInventory.purgeObject(item->getUUID());
+ }
+ }
+ }
+}
+
void LLAppearanceManager::purgeCategory(const LLUUID& category, bool keep_outfit_links)
{
LLInventoryModel::cat_array_t cats;
@@ -578,17 +600,9 @@ void LLAppearanceManager::updateCOF(const LLUUID& category, bool append)
linkAll(cof, gest_items, link_waiter);
// Add link to outfit if category is an outfit.
- LLViewerInventoryCategory* catp = gInventory.getCategory(category);
if (!append)
{
- std::string new_outfit_name = "";
- if (catp && catp->getPreferredType() == LLFolderType::FT_OUTFIT)
- {
- link_inventory_item(gAgent.getID(), category, cof, catp->getName(),
- LLAssetType::AT_LINK_FOLDER, link_waiter);
- new_outfit_name = catp->getName();
- }
- updatePanelOutfitName(new_outfit_name);
+ createBaseOutfitLink(category, link_waiter);
}
}
@@ -602,6 +616,22 @@ void LLAppearanceManager::updatePanelOutfitName(const std::string& name)
}
}
+void LLAppearanceManager::createBaseOutfitLink(const LLUUID& category, LLPointer<LLInventoryCallback> link_waiter)
+{
+ const LLUUID cof = getCOF();
+ LLViewerInventoryCategory* catp = gInventory.getCategory(category);
+ std::string new_outfit_name = "";
+
+ purgeBaseOutfitLink(cof);
+
+ if (catp && catp->getPreferredType() == LLFolderType::FT_OUTFIT)
+ {
+ link_inventory_item(gAgent.getID(), category, cof, catp->getName(),
+ LLAssetType::AT_LINK_FOLDER, link_waiter);
+ new_outfit_name = catp->getName();
+ }
+ updatePanelOutfitName(new_outfit_name);
+}
void LLAppearanceManager::updateAgentWearables(LLWearableHoldingPattern* holder, bool append)
{
@@ -693,14 +723,30 @@ void LLAppearanceManager::updateAppearanceFromCOF()
LLDynamicArray<LLFoundData*> found_container;
for(S32 i = 0; i < wear_items.count(); ++i)
{
- found = new LLFoundData(wear_items.get(i)->getLinkedUUID(), // Wear the base item, not the link
- wear_items.get(i)->getAssetUUID(),
- wear_items.get(i)->getName(),
- wear_items.get(i)->getType());
- holder->mFoundList.push_front(found);
- found_container.put(found);
+ LLViewerInventoryItem *item = wear_items.get(i);
+ LLViewerInventoryItem *linked_item = item ? item->getLinkedItem() : NULL;
+ if (item && linked_item)
+ {
+ found = new LLFoundData(linked_item->getUUID(),
+ linked_item->getAssetUUID(),
+ linked_item->getName(),
+ linked_item->getType());
+ holder->mFoundList.push_front(found);
+ found_container.put(found);
+ }
+ else
+ {
+ if (!item)
+ {
+ llwarns << "attempt to wear a null item " << llendl;
+ }
+ else if (!linked_item)
+ {
+ llwarns << "attempt to wear a broken link " << item->getName() << llendl;
+ }
+ }
}
- for(S32 i = 0; i < wear_items.count(); ++i)
+ for(S32 i = 0; i < found_container.count(); ++i)
{
holder->append = false;
found = found_container.get(i);