From 54d1669a5e08db2f5b7222a63085a197dc481eb7 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Mon, 13 Jun 2011 19:20:52 +0200 Subject: [PATCH] - added : "RLVaWearReplaceUnlocked" to not block replace when at least one attachment on the target attachment point is non-detachable -> locked (cuff) attachment on left and right lower leg -> ankle boots with attachments on left and right lower leg -> FALSE: "Wear" on a new set of ankle boots will fail (can not replace the non-detachable ankle cuffs) TRUE : "Wear" on a new set of ankle boots will replace the existing boots (ankle cuffs are not affected) --HG-- branch : RLVa --- indra/newview/app_settings/settings.xml | 11 +++++++++ indra/newview/rlvdefines.h | 1 + indra/newview/rlvlocks.cpp | 33 ++++++++++++++++--------- indra/newview/rlvlocks.h | 3 ++- 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 1100b59fdc..2d4887bbfc 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -167,6 +167,17 @@ Value 0 + RLVaWearReplaceUnlocked + + Comment + Don't block wear replace when at least one attachment on the target attachment point is non-detachable + Persist + 1 + Type + Boolean + Value + 0 + WarnFirstRLVGiveToRLV Comment diff --git a/indra/newview/rlvdefines.h b/indra/newview/rlvdefines.h index c342fea9f5..03a9d9b0c1 100644 --- a/indra/newview/rlvdefines.h +++ b/indra/newview/rlvdefines.h @@ -308,6 +308,7 @@ enum ERlvAttachGroupType #define RLV_SETTING_LOGINLASTLOCATION "RLVaLoginLastLocation" #define RLV_SETTING_SHAREDINVAUTORENAME "RLVaSharedInvAutoRename" #define RLV_SETTING_SHOWNAMETAGS "RLVaShowNameTags" +#define RLV_SETTING_WEARREPLACEUNLOCKED "RLVaWearReplaceUnlocked" #define RLV_SETTING_FIRSTUSE_PREFIX "FirstRLV" #define RLV_SETTING_FIRSTUSE_GIVETORLV RLV_SETTING_FIRSTUSE_PREFIX"GiveToRLV" diff --git a/indra/newview/rlvlocks.cpp b/indra/newview/rlvlocks.cpp index e7b4645239..8b5a36b4c7 100644 --- a/indra/newview/rlvlocks.cpp +++ b/indra/newview/rlvlocks.cpp @@ -519,11 +519,10 @@ void RlvAttachmentLockWatchdog::detach(const LLViewerObject* pAttachObj) } } -// Checked: 2010-07-28 (RLVa-1.2.0i) | Added: RLVa-1.2.0i -void RlvAttachmentLockWatchdog::detach(S32 idxAttachPt, const LLViewerObject* pAttachObjExcept /*=NULL*/) +// Checked: 2011-06-13 (RLVa-1.3.1b) | Modified: RLVa-1.3.1b +void RlvAttachmentLockWatchdog::detach(S32 idxAttachPt, const uuid_vec_t& idsAttachObjExcept) { - const LLViewerJointAttachment* pAttachPt = - (isAgentAvatarValid()) ? get_if_there(gAgentAvatarp->mAttachmentPoints, (S32)idxAttachPt, (LLViewerJointAttachment*)NULL) : NULL; + const LLViewerJointAttachment* pAttachPt = RlvAttachPtLookup::getAttachPoint(idxAttachPt); if (!pAttachPt) return; @@ -532,7 +531,7 @@ void RlvAttachmentLockWatchdog::detach(S32 idxAttachPt, const LLViewerObject* pA itAttachObj != pAttachPt->mAttachedObjects.end(); ++itAttachObj) { const LLViewerObject* pAttachObj = *itAttachObj; - if (pAttachObj != pAttachObjExcept) + if (idsAttachObjExcept.end() == std::find(idsAttachObjExcept.begin(), idsAttachObjExcept.end(), pAttachObj->getID())) attachObjs.push_back(pAttachObj); } @@ -548,7 +547,7 @@ void RlvAttachmentLockWatchdog::detach(S32 idxAttachPt, const LLViewerObject* pA const LLViewerObject* pAttachObj = *itAttachObj; gMessageSystem->nextBlockFast(_PREHASH_ObjectData); gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, pAttachObj->getLocalID()); - if (std::find(m_PendingDetach.begin(), m_PendingDetach.end(), pAttachObj->getAttachmentItemID()) == m_PendingDetach.end()) + if (m_PendingDetach.end() == std::find(m_PendingDetach.begin(), m_PendingDetach.end(), pAttachObj->getAttachmentItemID())) m_PendingDetach.push_back(pAttachObj->getAttachmentItemID()); } @@ -649,18 +648,30 @@ void RlvAttachmentLockWatchdog::onAttach(const LLViewerObject* pAttachObj, const } else if (RLV_WEAR_REPLACE == itWear->second.eWearAction) { - // Now that we know where this attaches to check if we can actually perform a "replace" + // Now that we know where this attaches to, check if we can actually perform a "replace" + uuid_vec_t idsAttachObjExcept; for (LLViewerJointAttachment::attachedobjs_vec_t::const_iterator itAttachObj = pAttachPt->mAttachedObjects.begin(); ((itAttachObj != pAttachPt->mAttachedObjects.end()) && (fAttachAllowed)); ++itAttachObj) { - if (pAttachObj != *itAttachObj) - fAttachAllowed &= !gRlvAttachmentLocks.isLockedAttachment(*itAttachObj); + if ( (pAttachObj != *itAttachObj) && (gRlvAttachmentLocks.isLockedAttachment(*itAttachObj)) ) + { + // Fail if we encounter a non-detachable attachment (unless we're only replacing detachable attachments) + if (gSavedSettings.getBOOL("RLVaWearReplaceUnlocked")) + idsAttachObjExcept.push_back((*itAttachObj)->getID()); + else + fAttachAllowed = false; + } } if (fAttachAllowed) - detach(idxAttachPt, pAttachObj); // Replace == allowed: detach everything except the new attachment + { + idsAttachObjExcept.push_back(pAttachObj->getID()); // Replace == allowed: detach everything except the new attachment + detach(idxAttachPt, idsAttachObjExcept); // or detach all *unlocked* attachments except the new attachment + } else - detach(pAttachObj); // Replace != allowed: detach the new attachment + { + detach(pAttachObj); // Replace != allowed: detach the new attachment + } } m_PendingWear.erase(itWear); // No need to start the timer since it should be running already if '!m_PendingWear.empty()' } diff --git a/indra/newview/rlvlocks.h b/indra/newview/rlvlocks.h index 97e4f6e2bf..b1c7e12862 100644 --- a/indra/newview/rlvlocks.h +++ b/indra/newview/rlvlocks.h @@ -151,7 +151,8 @@ protected: protected: // NOTE: detach does *not* respect attachment locks so use with care void detach(const LLViewerObject* pAttachObj); - void detach(S32 idxAttachPt, const LLViewerObject* pAttachObjExcept = NULL); + void detach(S32 idxAttachPt) { uuid_vec_t idsAttachObjExcept; detach(idxAttachPt, idsAttachObjExcept); } + void detach(S32 idxAttachPt, const uuid_vec_t& idsAttachObjExcept); void startTimer() { if (!m_pTimer) m_pTimer = new RlvAttachmentLockWatchdogTimer(this); }