From 78e17b0bf87a41fd8c5e4443f2fa9b2e4b089d3a Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Sun, 22 May 2011 03:21:14 +0200 Subject: [PATCH] - fixed : "Wear" and "Add" aren't grayed out on context menus when @addttach=n restricted -> RlvAttachmentLocks::canAttach() would return RLV_WEAR and allow the attach -> RlvAttachmentLockWatchdog would detach the attachment as soon as it attached due to the @remattach=n --HG-- branch : RLVa --- indra/newview/rlvlocks.cpp | 15 +++++++++++++++ indra/newview/rlvlocks.h | 8 +++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/indra/newview/rlvlocks.cpp b/indra/newview/rlvlocks.cpp index 0ca9105071..51b2395787 100644 --- a/indra/newview/rlvlocks.cpp +++ b/indra/newview/rlvlocks.cpp @@ -204,6 +204,21 @@ void RlvAttachmentLocks::addAttachmentPointLock(S32 idxAttachPt, const LLUUID& i m_AttachPtAdd.insert(std::pair(idxAttachPt, idRlvObj)); } +// Checked: 2011-05-22 (RLVa-1.3.1b) | Added: RLVa-1.3.1b +bool RlvAttachmentLocks::canAttach() const +{ + if (isAgentAvatarValid()) + { + for (LLVOAvatar::attachment_map_t::const_iterator itAttachPt = gAgentAvatarp->mAttachmentPoints.begin(); + itAttachPt != gAgentAvatarp->mAttachmentPoints.end(); ++itAttachPt) + { + if (!isLockedAttachmentPoint(itAttachPt->first, RLV_LOCK_ADD)) + return true; + } + } + return false; +} + // Checked: 2010-08-07 (RLVa-1.2.0i) | Modified: RLVa-1.2.0i bool RlvAttachmentLocks::canDetach(const LLViewerJointAttachment* pAttachPt, bool fDetachAll /*=false*/) const { diff --git a/indra/newview/rlvlocks.h b/indra/newview/rlvlocks.h index 31cfb0c1fa..e5034cd4c2 100644 --- a/indra/newview/rlvlocks.h +++ b/indra/newview/rlvlocks.h @@ -116,6 +116,8 @@ protected: * canAttach/canDetach trivial helper functions (note that a more approriate name might be userCanAttach/userCanDetach) */ public: + // Returns TRUE if there is at least one attachment point that can be attached to + bool canAttach() const; // Returns TRUE if the inventory item can be attached by the user (and optionally provides the attachment point - which may be NULL) ERlvWearMask canAttach(const LLInventoryItem* pItem, LLViewerJointAttachment** ppAttachPtOut = NULL) const; // Returns TRUE if the attachment point can be attached to by the user @@ -430,16 +432,16 @@ inline S32 RlvAttachPtLookup::getAttachPointIndex(const LLViewerObject* pObj) // RlvAttachmentLocks inlined member functions // -// Checked: 2011-03-27 (RLVa-1.3.0g) | Modified: RLVa-1.3.0g +// Checked: 2011-05-22 (RLVa-1.3.1b) | Modified: RLVa-1.3.1b inline ERlvWearMask RlvAttachmentLocks::canAttach(const LLInventoryItem* pItem, LLViewerJointAttachment** ppAttachPtOut /*=NULL*/) const { // The specified item can be attached if: - // - it doesn't specify an attachment point + // - it doesn't specify an attachment point and there is at least one attachment point that can be attached to // - the attachment point it specifies can be attached to LLViewerJointAttachment* pAttachPt = RlvAttachPtLookup::getAttachPoint(pItem); if (ppAttachPtOut) *ppAttachPtOut = pAttachPt; - return ((pItem) && (!RlvFolderLocks::instance().isLockedFolder(pItem->getParentUUID(), RLV_LOCK_ADD))) + return ((canAttach()) && (pItem) && (!RlvFolderLocks::instance().isLockedFolder(pItem->getParentUUID(), RLV_LOCK_ADD))) ? ((!pAttachPt) ? RLV_WEAR : canAttach(pAttachPt)) : RLV_WEAR_LOCKED; }