From 5a376379b6eeca8ecb709d5415ac130a1a99b4be Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Sat, 7 Nov 2009 16:21:26 -0700 Subject: Applied RLVa-1.0.5e_20091107_Imprudence-1.2.0-diff.patch --- linden/indra/newview/rlvhandler.cpp | 519 +++++++++++++++++++----------------- 1 file changed, 267 insertions(+), 252 deletions(-) (limited to 'linden/indra/newview/rlvhandler.cpp') diff --git a/linden/indra/newview/rlvhandler.cpp b/linden/indra/newview/rlvhandler.cpp index 69e2e2f..88cd174 100644 --- a/linden/indra/newview/rlvhandler.cpp +++ b/linden/indra/newview/rlvhandler.cpp @@ -31,11 +31,6 @@ #include "rlvextensions.h" #include "rlvhandler.h" -// Only defined in llinventorybridge.cpp -#if RLV_TARGET < RLV_MAKE_TARGET(1, 23, 0) // Version: 1.22.11 - #include "llinventorybridge.h" - void confirm_replace_attachment_rez(S32 option, void* user_data); -#endif // Only defined in llinventorymodel.cpp extern const char* NEW_CATEGORY_NAME; @@ -66,8 +61,8 @@ const std::string RlvHandler::cstrMsgTpLure = const std::string RlvHandler::cstrAnonyms[] = { "A resident", "This resident", "That resident", "An individual", "This individual", "That individual", "A person", - "This person", "That person", "A stranger", "This stranger", "That stranger", "A human being", "This human being", - "That human being", "An agent", "This agent", "That agent", "A soul", "This soul", "That soul", "Somebody", + "This person", "That person", "A stranger", "This stranger", "That stranger", "A being", "This being", + "That being", "An agent", "This agent", "That agent", "A soul", "This soul", "That soul", "Somebody", "Some people", "Someone", "Mysterious one", "An unknown being", "Unidentified one", "An unknown person" }; @@ -131,6 +126,7 @@ RlvHandler::~RlvHandler() //delete m_pGCTimer; // <- deletes itself delete m_pWLSnapshot; // <- delete on NULL is harmless delete m_pBhvrNotify; + delete m_pAttachMgr; } // ============================================================================ @@ -246,7 +242,7 @@ bool RlvHandler::hasLockedHUD() const return false; LLViewerJointAttachment* pAttachPt; - for (rlv_detach_map_t::const_iterator itAttachPt = m_Attachments.begin(); itAttachPt != m_Attachments.end(); ++itAttachPt) + for (rlv_attachlock_map_t::const_iterator itAttachPt = m_AttachRem.begin(); itAttachPt != m_AttachRem.end(); ++itAttachPt) { pAttachPt = get_if_there(pAvatar->mAttachmentPoints, (S32)itAttachPt->first, (LLViewerJointAttachment*)NULL); if ( (pAttachPt) && (pAttachPt->getIsHUDAttachment()) ) @@ -255,61 +251,94 @@ bool RlvHandler::hasLockedHUD() const return false; // None of our locked attachments is a HUD } -bool RlvHandler::isDetachable(const LLInventoryItem* pItem) const +// Checked: 2009-10-10 (RLVa-1.0.5a) | Added: RLVa-1.0.5a +bool RlvHandler::isLockedAttachment(const LLInventoryItem* pItem, ERlvLockMask eLock) const { LLVOAvatar* pAvatar = gAgent.getAvatarObject(); - return ( (pItem) && (pAvatar) ) ? isDetachable(pAvatar->getWornAttachment(pItem->getUUID())) : true; + return (pItem) && (pAvatar) && (isLockedAttachment(pAvatar->getWornAttachment(pItem->getUUID()), eLock)); } -// Checked: 2009-08-11 (RLVa-1.0.1h) | Added: RLVa-1.0.1h -bool RlvHandler::isDetachableExcept(S32 idxAttachPt, LLViewerObject *pObj) const +// Checked: 2009-10-13 (RLVa-1.0.5b) | Added: RLVa-1.0.5b +bool RlvHandler::isLockedAttachmentExcept(S32 idxAttachPt, ERlvLockMask eLock, LLViewerObject *pObj) const { - // Loop over every object that marked the specific attachment point undetachable (but ignore pObj and any of its children) - for (rlv_detach_map_t::const_iterator itAttach = m_Attachments.lower_bound(idxAttachPt), - endAttach = m_Attachments.upper_bound(idxAttachPt); itAttach != endAttach; ++itAttach) + // Loop over every object that marked the specific attachment point eLock type locked (but ignore pObj and any of its children) + LLViewerObject* pTempObj; + if (eLock & RLV_LOCK_REMOVE) { - LLViewerObject* pTempObj = gObjectList.findObject(itAttach->second); - if ( (!pTempObj) || (pTempObj->getRootEdit()->getID() != pObj->getID()) ) - return false; + for (rlv_attachlock_map_t::const_iterator itAttach = m_AttachRem.lower_bound(idxAttachPt), + endAttach = m_AttachRem.upper_bound(idxAttachPt); itAttach != endAttach; ++itAttach) + { + if ( ((pTempObj = gObjectList.findObject(itAttach->second)) == NULL) || (pTempObj->getRootEdit()->getID() != pObj->getID()) ) + return true; + } } - return true; + if (eLock & RLV_LOCK_ADD) + { + for (rlv_attachlock_map_t::const_iterator itAttach = m_AttachAdd.lower_bound(idxAttachPt), + endAttach = m_AttachAdd.upper_bound(idxAttachPt); itAttach != endAttach; ++itAttach) + { + if ( ((pTempObj = gObjectList.findObject(itAttach->second)) == NULL) || (pTempObj->getRootEdit()->getID() != pObj->getID()) ) + return true; + } + } + return false; } -// Checked: 2009-09-06 (RLVa-1.0.2b) | Modified: RLVa-1.0.2b -bool RlvHandler::setDetachable(S32 idxAttachPt, const LLUUID& idRlvObj, bool fDetachable) +// Checked: 2009-10-10 (RLVa-1.0.5a) | Added: RLVa-1.0.5a +void RlvHandler::addAttachmentLock(S32 idxAttachPt, const LLUUID &idRlvObj, ERlvLockMask eLock) { // Sanity check - make sure it's an object we know about - rlv_object_map_t::const_iterator itObj = m_Objects.find(idRlvObj); - if ( (itObj == m_Objects.end()) || (!idxAttachPt) ) - return false; // If (idxAttachPt) == 0 then: (pObj == NULL) || (pObj->isAttachment() == FALSE) + if ( (m_Objects.find(idRlvObj) == m_Objects.end()) || (!idxAttachPt) ) + return; // If (idxAttachPt) == 0 then: (pObj == NULL) || (pObj->isAttachment() == FALSE) - if (!fDetachable) + // NOTE: m_AttachXXX can contain duplicate pairs (ie @detach:spine=n,detach=n from an attachment on spine) + if (eLock & RLV_LOCK_REMOVE) { #ifdef RLV_EXPERIMENTAL_FIRSTUSE //LLFirstUse::useRlvDetach(); #endif // RLV_EXPERIMENTAL_FIRSTUSE - // NOTE: m_Attachments can contain duplicate pairs (ie @detach:spine=n,detach=n from an attachment on spine) - m_Attachments.insert(std::pair(idxAttachPt, itObj->second.m_UUID)); - return true; + m_AttachRem.insert(std::pair(idxAttachPt, idRlvObj)); } - else + if (eLock & RLV_LOCK_ADD) { - for (rlv_detach_map_t::iterator itAttach = m_Attachments.lower_bound(idxAttachPt), - endAttach = m_Attachments.upper_bound(idxAttachPt); itAttach != endAttach; ++itAttach) + m_AttachAdd.insert(std::pair(idxAttachPt, idRlvObj)); + } +} + +// Checked: 2009-10-10 (RLVa-1.0.5a) | Added: RLVa-1.0.5a +void RlvHandler::removeAttachmentLock(S32 idxAttachPt, const LLUUID &idRlvObj, ERlvLockMask eLock) +{ + // Sanity check - make sure it's an object we know about + if ( (m_Objects.find(idRlvObj) == m_Objects.end()) || (!idxAttachPt) ) + return; // If (idxAttachPt) == 0 then: (pObj == NULL) || (pObj->isAttachment() == FALSE) + + if (eLock & RLV_LOCK_REMOVE) + { + for (rlv_attachlock_map_t::iterator itAttach = m_AttachRem.lower_bound(idxAttachPt), + endAttach = m_AttachRem.upper_bound(idxAttachPt); itAttach != endAttach; ++itAttach) { - if (itObj->second.m_UUID == itAttach->second) + if (idRlvObj == itAttach->second) { - m_Attachments.erase(itAttach); - return true; + m_AttachRem.erase(itAttach); + break; + } + } + } + if (eLock & RLV_LOCK_ADD) + { + for (rlv_attachlock_map_t::iterator itAttach = m_AttachAdd.lower_bound(idxAttachPt), + endAttach = m_AttachAdd.upper_bound(idxAttachPt); itAttach != endAttach; ++itAttach) + { + if (idRlvObj == itAttach->second) + { + m_AttachAdd.erase(itAttach); + break; } } } - return false; // Fall-through for (fDetachable == TRUE) - if the object wasn't undetachable then we consider it a failure } - - #ifdef RLV_EXTENSION_FLAG_NOSTRIP // Checked: 2009-05-26 (RLVa-0.2.0d) | Modified: RLVa-0.2.0d bool RlvHandler::isStrippable(const LLUUID& idItem) const @@ -413,10 +442,10 @@ void RlvHandler::notifyBehaviourObservers(const RlvCommand& rlvCmd, bool fIntern } // Checked: -BOOL RlvHandler::processCommand(const LLUUID& uuid, const std::string& strCmd, bool fFromObj) +BOOL RlvHandler::processCommand(const LLUUID& idObj, const std::string& strCmd, bool fFromObj) { #ifdef RLV_DEBUG - RLV_INFOS << "[" << uuid << "]: " << strCmd << LL_ENDL; + RLV_INFOS << "[" << idObj << "]: " << strCmd << LL_ENDL; #endif // RLV_DEBUG RlvCommand rlvCmd(strCmd); @@ -427,7 +456,10 @@ BOOL RlvHandler::processCommand(const LLUUID& uuid, const std::string& strCmd, b #endif // RLV_DEBUG return FALSE; } - m_pCurCommand = &rlvCmd; m_idCurObject = uuid; + + // NOTE: if we pass RlvObject::m_UUID for idObj somewhere and process a @clear then it will point to invalid/cleared memory at the end + // so make sure to *always* pass our private copy to other functions + m_pCurCommand = &rlvCmd; m_idCurObject = idObj; BOOL fRet = FALSE; switch (rlvCmd.getParamType()) @@ -444,7 +476,7 @@ BOOL RlvHandler::processCommand(const LLUUID& uuid, const std::string& strCmd, b break; } - rlv_object_map_t::iterator itObj = m_Objects.find(uuid); + rlv_object_map_t::iterator itObj = m_Objects.find(m_idCurObject); if (itObj != m_Objects.end()) { RlvObject& rlvObj = itObj->second; @@ -452,9 +484,9 @@ BOOL RlvHandler::processCommand(const LLUUID& uuid, const std::string& strCmd, b } else { - RlvObject rlvObj(uuid); + RlvObject rlvObj(m_idCurObject); fRet = rlvObj.addCommand(rlvCmd); - m_Objects.insert(std::pair(uuid, rlvObj)); + m_Objects.insert(std::pair(m_idCurObject, rlvObj)); } #ifdef RLV_DEBUG @@ -464,14 +496,14 @@ BOOL RlvHandler::processCommand(const LLUUID& uuid, const std::string& strCmd, b if (fRet) { // If FALSE then this was a duplicate, there's no need to handle those if (!m_pGCTimer) m_pGCTimer = new RlvGCTimer(); - processAddCommand(uuid, rlvCmd); + processAddCommand(m_idCurObject, rlvCmd); notifyBehaviourObservers(rlvCmd, !fFromObj); } } break; case RLV_TYPE_REMOVE: // Checked: { - rlv_object_map_t::iterator itObj = m_Objects.find(uuid); + rlv_object_map_t::iterator itObj = m_Objects.find(m_idCurObject); if (itObj != m_Objects.end()) fRet = itObj->second.removeCommand(rlvCmd); @@ -481,13 +513,13 @@ BOOL RlvHandler::processCommand(const LLUUID& uuid, const std::string& strCmd, b #endif // RLV_DEBUG if (fRet) { // Don't handle non-sensical removes - processRemoveCommand(uuid, rlvCmd); + processRemoveCommand(m_idCurObject, rlvCmd); notifyBehaviourObservers(rlvCmd, !fFromObj); if (0 == itObj->second.m_Commands.size()) { #ifdef RLV_DEBUG - RLV_INFOS << "\t- command list empty => removing " << uuid << LL_ENDL; + RLV_INFOS << "\t- command list empty => removing " << m_idCurObject << LL_ENDL; #endif // RLV_DEBUG m_Objects.erase(itObj); } @@ -495,14 +527,14 @@ BOOL RlvHandler::processCommand(const LLUUID& uuid, const std::string& strCmd, b } break; case RLV_TYPE_CLEAR: - fRet = processClearCommand(uuid, rlvCmd); + fRet = processClearCommand(m_idCurObject, rlvCmd); notifyBehaviourObservers(rlvCmd, !fFromObj); break; case RLV_TYPE_FORCE: // Checked: - fRet = processForceCommand(uuid, rlvCmd); + fRet = processForceCommand(m_idCurObject, rlvCmd); break; case RLV_TYPE_REPLY: // Checked: - fRet = processReplyCommand(uuid, rlvCmd); + fRet = processReplyCommand(m_idCurObject, rlvCmd); break; case RLV_TYPE_UNKNOWN: // Checked: break; @@ -535,35 +567,15 @@ BOOL RlvHandler::processAddCommand(const LLUUID& uuid, const RlvCommand& rlvCmd) m_Behaviours[eBehaviour]++; } + bool fRefCount = false; // Unused for the moment switch (eBehaviour) { - case RLV_BHVR_DETACH: // @detach[: