diff options
author | Loren Shih <seraph@lindenlab.com> | 2010-03-02 19:56:28 -0500 |
---|---|---|
committer | Loren Shih <seraph@lindenlab.com> | 2010-03-02 19:56:28 -0500 |
commit | 6ebc1d8858e77ed00d3363ce1d8d18be5dc2a3a2 (patch) | |
tree | a6d78ea622d7785107ef4a4af33332f71c79982b /indra/newview/llagentwearables.cpp | |
parent | 06b81466869dc021f7138579580a1939fdfceb89 (diff) |
EXT-5547 : Autopopulation broken due to new web deploy accounts
EXT-5673 : Autopopulation: Created outfits copy subfolder contents as well as immediate folder contents
EXT-5632 : Autopopulation is including subfolders even if those aren't outfits
DEV-46683 : Post-Deployment Cleanup
This is a series of changes to fix autopopulation behavior that was broken due to the new surprise web avatar deploy. That deploy surfaced a number of serious issues with the original AP code. I did not write this code and the person who did is no longer here, so I've done my best to fix those issues up.
This is a fairly comprehensive set of changes, but it's necessary given the poor state of the pre-existing code and how many problems it caused the new web avatar deploy.
This new version of the AP code will:
(1) Look for a Library->Clothing->Initial Outfits folder and use that if it exists
(2) Not create outfits out of folders that aren't complete outfits
(3) No longer string match against "More Outfits" in order to ignore outfits
(4) No longer recursively collect folder contents when creating an outfit (i.e. will only look at direct descendents)
Diffstat (limited to 'indra/newview/llagentwearables.cpp')
-rw-r--r-- | indra/newview/llagentwearables.cpp | 134 |
1 files changed, 89 insertions, 45 deletions
diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp index 11ac103b3a..7b55282ee5 100644 --- a/indra/newview/llagentwearables.cpp +++ b/indra/newview/llagentwearables.cpp @@ -119,9 +119,9 @@ protected: void importedFolderDone(void); void contentsDone(void); enum ELibraryOutfitFetchStep mCurrFetchStep; - typedef std::vector< std::pair< LLUUID, std::string > > cloth_folder_vec_t; - cloth_folder_vec_t mLibraryClothingFolders; - cloth_folder_vec_t mImportedClothingFolders; + typedef std::vector<LLUUID> clothing_folder_vec_t; + clothing_folder_vec_t mLibraryClothingFolders; + clothing_folder_vec_t mImportedClothingFolders; bool mOutfitsPopulated; LLUUID mClothingID; LLUUID mLibraryClothingID; @@ -2240,7 +2240,7 @@ void LLAgentWearables::updateServer() void LLAgentWearables::populateMyOutfitsFolder(void) { - llinfos << "starting outfit populate" << llendl; + llinfos << "starting outfit population" << llendl; LLLibraryOutfitsFetch* outfits = new LLLibraryOutfitsFetch(); @@ -2312,17 +2312,28 @@ void LLLibraryOutfitsFetch::folderDone(void) LLInventoryModel::item_array_t wearable_array; gInventory.collectDescendents(mMyOutfitsID, cat_array, wearable_array, LLInventoryModel::EXCLUDE_TRASH); - // Early out if we already have items in My Outfits. if (cat_array.count() > 0 || wearable_array.count() > 0) { mOutfitsPopulated = true; return; } - + mClothingID = gInventory.findCategoryUUIDForType(LLFolderType::FT_CLOTHING); mLibraryClothingID = gInventory.findCategoryUUIDForType(LLFolderType::FT_CLOTHING, false, true); - + + // If Library->Clothing->Initial Outfits exists, use that. + LLNameCategoryCollector matchFolderFunctor("Initial Outfits"); + gInventory.collectDescendentsIf(mLibraryClothingID, + cat_array, wearable_array, + LLInventoryModel::EXCLUDE_TRASH, + matchFolderFunctor); + if (cat_array.count() > 0) + { + const LLViewerInventoryCategory *cat = cat_array.get(0); + mLibraryClothingID = cat->getUUID(); + } + mCompleteFolders.clear(); // Get the complete information on the items in the inventory. @@ -2353,31 +2364,28 @@ void LLLibraryOutfitsFetch::outfitsDone(void) { const LLViewerInventoryCategory *cat = iter->get(); - // Get the names and id's of every outfit in the library, except for ruth and other "misc" outfits. - if (cat->getName() != "More Outfits" && cat->getName() != "Ruth") + // Get the names and id's of every outfit in the library, skip "Ruth" + // because it's a low quality legacy outfit + if (cat->getName() != "Ruth") { // Get the name of every outfit in the library folders.push_back(cat->getUUID()); - mLibraryClothingFolders.push_back(std::make_pair(cat->getUUID(), cat->getName())); + mLibraryClothingFolders.push_back(cat->getUUID()); } } - - // Collect the contents of your Inventory Clothing folder cat_array.clear(); wearable_array.clear(); - gInventory.collectDescendents(mClothingID, cat_array, wearable_array, - LLInventoryModel::EXCLUDE_TRASH); // Check if you already have an "Imported Library Clothing" folder - for (LLInventoryModel::cat_array_t::const_iterator iter = cat_array.begin(); - iter != cat_array.end(); - ++iter) + LLNameCategoryCollector matchFolderFunctor(mImportedClothingName); + gInventory.collectDescendentsIf(mClothingID, + cat_array, wearable_array, + LLInventoryModel::EXCLUDE_TRASH, + matchFolderFunctor); + if (cat_array.size() > 0) { - const LLViewerInventoryCategory *cat = iter->get(); - if (cat->getName() == mImportedClothingName) - { - mImportedClothingID = cat->getUUID(); - } + const LLViewerInventoryCategory *cat = cat_array.get(0); + mImportedClothingID = cat->getUUID(); } mCompleteFolders.clear(); @@ -2415,31 +2423,59 @@ private: LLLibraryOutfitsFetch * mLibraryOutfitsFetcher; }; +// Copy the clothing folders from the library into the imported clothing folder void LLLibraryOutfitsFetch::libraryDone(void) { - // Copy the clothing folders from the library into the imported clothing folder if necessary. - if (mImportedClothingID == LLUUID::null) + if (mImportedClothingID != LLUUID::null) { - gInventory.removeObserver(this); - LLPointer<LLInventoryCallback> copy_waiter = new LLLibraryOutfitsCopyDone(this); - mImportedClothingID = gInventory.createNewCategory(mClothingID, - LLFolderType::FT_NONE, - mImportedClothingName); + // Skip straight to fetching the contents of the imported folder + importedFolderFetch(); + return; + } + + // Remove observer; next autopopulation step will be triggered externally by LLLibraryOutfitsCopyDone. + gInventory.removeObserver(this); + + LLPointer<LLInventoryCallback> copy_waiter = new LLLibraryOutfitsCopyDone(this); + mImportedClothingID = gInventory.createNewCategory(mClothingID, + LLFolderType::FT_NONE, + mImportedClothingName); + // Copy each folder from library into clothing unless it already exists. + for (clothing_folder_vec_t::const_iterator iter = mLibraryClothingFolders.begin(); + iter != mLibraryClothingFolders.end(); + ++iter) + { + const LLUUID& src_folder_id = (*iter); // Library clothing folder ID + const LLViewerInventoryCategory *cat = gInventory.getCategory(src_folder_id); + if (!cat) + { + llwarns << "Library folder import for uuid:" << src_folder_id << " failed to find folder." << llendl; + continue; + } - for (cloth_folder_vec_t::const_iterator iter = mLibraryClothingFolders.begin(); - iter != mLibraryClothingFolders.end(); - ++iter) + if (!LLAppearanceManager::getInstance()->getCanMakeFolderIntoOutfit(src_folder_id)) { - LLUUID folder_id = gInventory.createNewCategory(mImportedClothingID, - LLFolderType::FT_NONE, - iter->second); - LLAppearanceManager::getInstance()->shallowCopyCategoryContents(iter->first, folder_id, copy_waiter); + llinfos << "Skipping non-outfit folder name:" << cat->getName() << llendl; + continue; } - } - else - { - // Skip straight to fetching the contents of the imported folder - importedFolderFetch(); + + // Don't copy the category if it already exists. + LLNameCategoryCollector matchFolderFunctor(cat->getName()); + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t wearable_array; + gInventory.collectDescendentsIf(mImportedClothingID, + cat_array, wearable_array, + LLInventoryModel::EXCLUDE_TRASH, + matchFolderFunctor); + if (cat_array.size() > 0) + { + continue; + } + + LLUUID dst_folder_id = gInventory.createNewCategory(mImportedClothingID, + LLFolderType::FT_NONE, + cat->getName()); + LLAppearanceManager::getInstance()->shallowCopyCategoryContents(src_folder_id, dst_folder_id, copy_waiter); } } @@ -2476,7 +2512,7 @@ void LLLibraryOutfitsFetch::importedFolderDone(void) // Get the name of every imported outfit folders.push_back(cat->getUUID()); - mImportedClothingFolders.push_back(std::make_pair(cat->getUUID(), cat->getName())); + mImportedClothingFolders.push_back(cat->getUUID()); } mCompleteFolders.clear(); @@ -2492,17 +2528,25 @@ void LLLibraryOutfitsFetch::contentsDone(void) LLInventoryModel::cat_array_t cat_array; LLInventoryModel::item_array_t wearable_array; - for (cloth_folder_vec_t::const_iterator folder_iter = mImportedClothingFolders.begin(); + for (clothing_folder_vec_t::const_iterator folder_iter = mImportedClothingFolders.begin(); folder_iter != mImportedClothingFolders.end(); ++folder_iter) { + const LLUUID &folder_id = (*folder_iter); + const LLViewerInventoryCategory *cat = gInventory.getCategory(folder_id); + if (!cat) + { + llwarns << "Library folder import for uuid:" << folder_id << " failed to find folder." << llendl; + continue; + } + // First, make a folder in the My Outfits directory. - LLUUID new_outfit_folder_id = gInventory.createNewCategory(mMyOutfitsID, LLFolderType::FT_OUTFIT, folder_iter->second); + LLUUID new_outfit_folder_id = gInventory.createNewCategory(mMyOutfitsID, LLFolderType::FT_OUTFIT, cat->getName()); cat_array.clear(); wearable_array.clear(); // Collect the contents of each imported clothing folder, so we can create new outfit links for it - gInventory.collectDescendents(folder_iter->first, cat_array, wearable_array, + gInventory.collectDescendents(folder_id, cat_array, wearable_array, LLInventoryModel::EXCLUDE_TRASH); for (LLInventoryModel::item_array_t::const_iterator wearable_iter = wearable_array.begin(); |