Commits

Vadim Savchuk  committed 6e45e25

STORM-1041 FIXED "Remove all clothes" item of the avatar menu didn't actually remove all clothes.

I haven't investigated what the problem was, I've just rewritten the (ancient?) removal code
in the way we take off items in other places, i.e. by removing them from the Current Outfit forder.

  • Participants
  • Parent commits 87fe210

Comments (0)

Files changed (3)

File indra/newview/llagentwearables.cpp

 	}
 }
 
-// static
-void LLAgentWearables::userRemoveAllClothes()
-{
-	// We have to do this up front to avoid having to deal with the case of multiple wearables being dirty.
-	if (gAgentCamera.cameraCustomizeAvatar())
-	{
-		// switching to outfit editor should automagically save any currently edited wearable
-		LLSideTray::getInstance()->showPanel("sidepanel_appearance", LLSD().with("type", "edit_outfit"));
-	}
-	userRemoveAllClothesStep2(TRUE);
-}
-
-// static
-void LLAgentWearables::userRemoveAllClothesStep2(BOOL proceed)
-{
-	if (proceed)
-	{
-		gAgentWearables.removeWearable(LLWearableType::WT_SHIRT,true,0);
-		gAgentWearables.removeWearable(LLWearableType::WT_PANTS,true,0);
-		gAgentWearables.removeWearable(LLWearableType::WT_SHOES,true,0);
-		gAgentWearables.removeWearable(LLWearableType::WT_SOCKS,true,0);
-		gAgentWearables.removeWearable(LLWearableType::WT_JACKET,true,0);
-		gAgentWearables.removeWearable(LLWearableType::WT_GLOVES,true,0);
-		gAgentWearables.removeWearable(LLWearableType::WT_UNDERSHIRT,true,0);
-		gAgentWearables.removeWearable(LLWearableType::WT_UNDERPANTS,true,0);
-		gAgentWearables.removeWearable(LLWearableType::WT_SKIRT,true,0);
-		gAgentWearables.removeWearable(LLWearableType::WT_ALPHA,true,0);
-		gAgentWearables.removeWearable(LLWearableType::WT_TATTOO,true,0);
-	}
-}
-
 // Combines userRemoveAllAttachments() and userAttachMultipleAttachments() logic to
 // get attachments into desired state with minimal number of adds/removes.
 void LLAgentWearables::userUpdateAttachments(LLInventoryModel::item_array_t& obj_item_array)

File indra/newview/llagentwearables.h

 	void			removeWearableFinal(const LLWearableType::EType type, bool do_remove_all /*= false*/, U32 index /*= 0*/);
 protected:
 	static bool		onRemoveWearableDialog(const LLSD& notification, const LLSD& response);
-	static void		userRemoveAllClothesStep2(BOOL proceed); // userdata is NULL
 	
 	//--------------------------------------------------------------------
 	// Server Communication
 public:
 	static void		userRemoveWearable(const LLWearableType::EType &type, const U32 &index);
 	static void		userRemoveWearablesOfType(const LLWearableType::EType &type);
-	static void		userRemoveAllClothes();	
 	
 	typedef std::vector<LLViewerObject*> llvo_vec_t;
 

File indra/newview/llinventorybridge.cpp

 // static
 void LLWearableBridge::removeAllClothesFromAvatar()
 {
-	// Remove COF links.
-	for (S32 itype = LLWearableType::WT_SHAPE; itype < LLWearableType::WT_COUNT; ++itype)
-	{
-		if (itype == LLWearableType::WT_SHAPE || itype == LLWearableType::WT_SKIN || itype == LLWearableType::WT_HAIR || itype == LLWearableType::WT_EYES)
-			continue;
-
-		for (S32 index = gAgentWearables.getWearableCount(itype)-1; index >= 0 ; --index)
-		{
-			LLViewerInventoryItem *item = dynamic_cast<LLViewerInventoryItem*>(
-				gAgentWearables.getWearableInventoryItem((LLWearableType::EType)itype, index));
-			if (!item)
-				continue;
-			const LLUUID &item_id = item->getUUID();
-			const LLWearable *wearable = gAgentWearables.getWearableFromItemID(item_id);
-			if (!wearable)
-				continue;
-	
-			// Find and remove this item from the COF.
-			LLAppearanceMgr::instance().removeCOFItemLinks(item_id,false);
-		}
-	}
-	gInventory.notifyObservers();
-
-	// Remove wearables from gAgentWearables
-	LLAgentWearables::userRemoveAllClothes();
+	// Fetch worn clothes (i.e. the ones in COF).
+	LLInventoryModel::item_array_t clothing_items;
+	LLInventoryModel::cat_array_t dummy;
+	LLIsType is_clothing(LLAssetType::AT_CLOTHING);
+	gInventory.collectDescendentsIf(LLAppearanceMgr::instance().getCOF(),
+									dummy,
+									clothing_items,
+									LLInventoryModel::EXCLUDE_TRASH,
+									is_clothing,
+									false);
+
+	// Take them off by removing from COF.
+	for (LLInventoryModel::item_array_t::const_iterator it = clothing_items.begin(); it != clothing_items.end(); ++it)
+	{
+		LLAppearanceMgr::instance().removeItemFromAvatar((*it)->getUUID());
+	}
 }
 
 // static