From e98e3d4efa32cea7799214cdfda442f1e03008de Mon Sep 17 00:00:00 2001
From: Kitty Barnett <none@none>
Date: Sat, 4 Sep 2010 03:03:34 +0200
Subject: [PATCH] - internal : moved "canDetach" checks from callers to
 LLVOAvatarSelf::detachAttachmentIntoInventory() instead - internal : changed
 @detachme=force to use LLVOAvatarSelf::detachAttachmentIntoInventory() -
 internal : fix-up for LLAppearanceMgr::removeItemFromAvatar() due to merging
 in Appearance-Misc patch branch

--HG--
branch : RLVa
---
 indra/newview/llappearancemgr.cpp   |  3 +++
 indra/newview/llinventorybridge.cpp | 10 ++--------
 indra/newview/llvoavatarself.cpp    |  5 ++++-
 indra/newview/rlvhandler.cpp        | 13 +++----------
 4 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index 88fee221ad..9d3e5f1267 100644
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -2794,6 +2794,9 @@ void LLAppearanceMgr::removeItemFromAvatar(const LLUUID& id_to_remove)
 //				LLWearableBridge::removeItemFromAvatar(item_to_remove);
 //			}
 // [SL:KB] - Patch: Appearance-RemoveWearableFromAvatar | Checked: 2010-08-13 (Catznip-2.1.2a) | Added: Catznip-2.1.1d
+// [RLVa:KB] - Checked: 2010-09-04 (RLVa-1.2.1c) | Added: RLVa-1.2.1c
+			if ( (!rlv_handler_t::isEnabled()) || (gRlvWearableLocks.canRemove(item_to_remove)) )
+// [/RLVa:KB]
 			{
 				/*const*/ LLWearable* pWearable = gAgentWearables.getWearableFromItemID(item_to_remove->getLinkedUUID());
 				if ( (pWearable) && (LLAssetType::AT_BODYPART != pWearable->getAssetType()) )
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 3683b7eaac..1665286516 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -3985,10 +3985,7 @@ void LLObjectBridge::performAction(LLInventoryModel* model, std::string action)
 	else if (isRemoveAction(action))
 	{
 		LLInventoryItem* item = gInventory.getItem(mUUID);
-//		if(item)
-// [RLVa:KB] - Checked: 2010-03-04 (RLVa-1.2.0a) | Added: RLVa-1.2.0a
-		if ( (item) && ((!rlv_handler_t::isEnabled()) || (gRlvAttachmentLocks.canDetach(item))) )
-// [/RLVa:KB]
+		if(item)
 		{
 			LLVOAvatarSelf::detachAttachmentIntoInventory(item->getLinkedUUID());
 		}
@@ -4408,10 +4405,7 @@ void remove_inventory_category_from_avatar_step2( BOOL proceed, LLUUID category_
 			for(i = 0; i  < obj_count; ++i)
 			{
 				LLViewerInventoryItem *obj_item = obj_item_array.get(i);
-//				if (get_is_item_worn(obj_item->getUUID()))
-// [RLVa:KB] - Checked: 2010-03-16 (RLVa-1.2.0a) | Modified: RLVa-1.0.5a
-				if ((get_is_item_worn(obj_item->getUUID())) && ((!rlv_handler_t::isEnabled()) || (gRlvAttachmentLocks.canDetach(obj_item))))
-// [/RVLa:KB]
+				if (get_is_item_worn(obj_item->getUUID()))
 				{
 					LLVOAvatarSelf::detachAttachmentIntoInventory(obj_item->getLinkedUUID());
 				}
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index 4adb65b2d9..eeb7d3e63b 100644
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -1209,7 +1209,10 @@ BOOL LLVOAvatarSelf::detachObject(LLViewerObject *viewer_object)
 BOOL LLVOAvatarSelf::detachAttachmentIntoInventory(const LLUUID &item_id)
 {
 	LLInventoryItem* item = gInventory.getItem(item_id);
-	if (item)
+//	if (item)
+// [RLVa:KB] - Checked: 2010-09-04 (RLVa-1.2.1c) | Added: RLVa-1.2.1c
+	if ( (item) && ((!rlv_handler_t::isEnabled()) || (gRlvAttachmentLocks.canDetach(item))) )
+// [/RLVa:KB]
 	{
 		gMessageSystem->newMessageFast(_PREHASH_DetachAttachmentIntoInv);
 		gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
diff --git a/indra/newview/rlvhandler.cpp b/indra/newview/rlvhandler.cpp
index d19da6c10c..f939f81f24 100644
--- a/indra/newview/rlvhandler.cpp
+++ b/indra/newview/rlvhandler.cpp
@@ -1357,21 +1357,14 @@ ERlvCmdRet RlvHandler::processForceCommand(const RlvCommand& rlvCmd) const
 				}
 			}
 			break;
-		case RLV_BHVR_DETACHME:		// @detachme=force						- Checked: 2010-04-04 (RLVa-1.2.0c) | Modified: RLVa-1.2.0c
+		case RLV_BHVR_DETACHME:		// @detachme=force						- Checked: 2010-09-04 (RLVa-1.2.1c) | Modified: RLVa-1.2.1c
 			{
 				VERIFY_OPTION(rlvCmd.getOption().empty());
 				// NOTE: @detachme should respect locks but shouldn't respect things like nostrip
 				const LLViewerObject* pAttachObj = gObjectList.findObject(rlvCmd.getObjectID());
-				if ( (pAttachObj) && (pAttachObj->isAttachment()) && (!gRlvAttachmentLocks.isLockedAttachment(pAttachObj)) )
+				if ( (pAttachObj) && (pAttachObj->isAttachment()) )
 				{
-					gMessageSystem->newMessage("ObjectDetach");
-					gMessageSystem->nextBlockFast(_PREHASH_AgentData);
-					gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
-					gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
-
-					gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
-					gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, pAttachObj->getLocalID());
-					gMessageSystem->sendReliable( gAgent.getRegionHost() );
+					LLVOAvatarSelf::detachAttachmentIntoInventory(pAttachObj->getAttachmentItemID());
 				}
 			}
 			break;
-- 
GitLab