aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/rlvhandler.h
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/rlvhandler.h')
-rw-r--r--linden/indra/newview/rlvhandler.h139
1 files changed, 80 insertions, 59 deletions
diff --git a/linden/indra/newview/rlvhandler.h b/linden/indra/newview/rlvhandler.h
index 5295a72..6821149 100644
--- a/linden/indra/newview/rlvhandler.h
+++ b/linden/indra/newview/rlvhandler.h
@@ -16,9 +16,8 @@
16// ============================================================================ 16// ============================================================================
17 17
18typedef std::map<LLUUID, RlvObject> rlv_object_map_t; 18typedef std::map<LLUUID, RlvObject> rlv_object_map_t;
19typedef std::multimap<S32, LLUUID> rlv_detach_map_t;
20typedef std::map<S32, LLUUID> rlv_reattach_map_t;
21typedef std::multimap<ERlvBehaviour, RlvException> rlv_exception_map_t; 19typedef std::multimap<ERlvBehaviour, RlvException> rlv_exception_map_t;
20typedef std::map<S32, LLUUID> rlv_attachlock_map_t;
22 21
23class RlvHandler 22class RlvHandler
24{ 23{
@@ -47,7 +46,9 @@ public:
47 /* 46 /*
48 * Rule checking functions 47 * Rule checking functions
49 */ 48 */
50 // NOTE: - to check @detach=n -> hasLockedAttachment() / hasLockedHUD() / isDetachable() 49 // NOTE: - to check @detach=n -> hasLockedAttachment(RLV_LOCK_REMOVE) / hasLockedHUD() / isLockedAttachment(.., RLV_LOCK_REMOVE)
50 // - to check @addattach=n -> hasLockedAttachment(RLV_LOCK_ADD) / isLockedAttachment(.., RLV_LOCK_ADD)
51 // - to check @remattach=n -> (see @detach=n)
51 // - to check exceptions -> isException() 52 // - to check exceptions -> isException()
52 // - to check @addoutfit=n -> isWearable() 53 // - to check @addoutfit=n -> isWearable()
53 // - to check @remoutfit=n -> isRemovable() 54 // - to check @remoutfit=n -> isRemovable()
@@ -59,20 +60,21 @@ public:
59 bool hasBehaviourExcept(ERlvBehaviour eBehaviour, const LLUUID& idObj) const; 60 bool hasBehaviourExcept(ERlvBehaviour eBehaviour, const LLUUID& idObj) const;
60 bool hasBehaviourExcept(ERlvBehaviour eBehaviour, const std::string& strOption, const LLUUID& idObj) const; 61 bool hasBehaviourExcept(ERlvBehaviour eBehaviour, const std::string& strOption, const LLUUID& idObj) const;
61 62
62 // Returns TRUE if there is at least 1 non-detachable attachment 63 // Adds an eLock type lock (held by idRlvObj) for the specified attachment point
63 bool hasLockedAttachment() const { return (0 != m_Attachments.size()); } 64 void addAttachmentLock(S32 idxAttachPt, const LLUUID& idRlvObj, ERlvLockMask eLock);
65 // Returns TRUE if there is at least 1 eLock type locked attachment (RLV_LOCK_ANY = RLV_LOCK_ADD *or* RLV_LOCK_REMOVE)
66 bool hasLockedAttachment(ERlvLockMask eLock) const;
64 // Returns TRUE if there is at least 1 non-detachable HUD attachment 67 // Returns TRUE if there is at least 1 non-detachable HUD attachment
65 bool hasLockedHUD() const; 68 bool hasLockedHUD() const;
66 // Returns TRUE if the specified attachment point is detachable 69 // Returns TRUE if the specified attachment point is eLock type locked (RLV_LOCK_ANY = RLV_LOCK_ADD *or* RLV_LOCK_REMOVE)
67 bool isDetachable(S32 idxAttachPt) const { return (idxAttachPt) && (m_Attachments.find(idxAttachPt) == m_Attachments.end()); } 70 bool isLockedAttachment(S32 idxAttachPt, ERlvLockMask eLock) const;
68 bool isDetachable(const LLInventoryItem* pItem) const; 71 bool isLockedAttachment(const LLInventoryItem* pItem, ERlvLockMask eLock) const;
69 bool isDetachable(LLViewerJointAttachment* pAttachPt) const; 72 bool isLockedAttachment(LLViewerJointAttachment* pAttachPt, ERlvLockMask eLock) const;
70 bool isDetachable(LLViewerObject* pObj) const; 73 bool isLockedAttachment(LLViewerObject* pObj, ERlvLockMask eLock) const;
71 // Returns TRUE if the specified attachment point is set non-detachable by anything other than pObj (or one of its children) 74 // Returns TRUE if the specified attachment point is eLock type locked by anything other than pObj (or one of its children)
72 bool isDetachableExcept(S32 idxAttachPt, LLViewerObject* pObj) const; 75 bool isLockedAttachmentExcept(S32 idxAttachPt, ERlvLockMask eLock, LLViewerObject* pObj) const;
73 // Marks the specified attachment point as (non-)detachable (return value indicates success ; used by unit tests) 76 // Adds an eLock type lock (held by idRlvObj) for the specified attachment point
74 bool setDetachable(S32 idxAttachPt, const LLUUID& idRlvObj, bool fDetachable); 77 void removeAttachmentLock(S32 idxAttachPt, const LLUUID& idRlovObj, ERlvLockMask eLock);
75 bool setDetachable(LLViewerObject* pObj, const LLUUID& idRlvObj, bool fDetachable);
76 78
77 // Adds or removes an exception for the specified behaviour 79 // Adds or removes an exception for the specified behaviour
78 void addException(const LLUUID& idObj, ERlvBehaviour eBhvr, const RlvExceptionOption& varOption); 80 void addException(const LLUUID& idObj, ERlvBehaviour eBhvr, const RlvExceptionOption& varOption);
@@ -183,19 +185,28 @@ public:
183 void notifyBehaviourObservers(const RlvCommand& rlvCmd, bool fInternal); 185 void notifyBehaviourObservers(const RlvCommand& rlvCmd, bool fInternal);
184 186
185 // Externally invoked event handlers 187 // Externally invoked event handlers
186 void onAttach(LLViewerJointAttachment* pAttachPt, bool fFullyLoaded); // LLVOAvatar::attachObject() 188 void onAttach(LLViewerJointAttachment* pAttachPt); // LLVOAvatar::attachObject()
187 void onDetach(LLViewerJointAttachment* pAttachPt); // LLVOAvatar::detachObject() 189 void onDetach(LLViewerJointAttachment* pAttachPt); // LLVOAvatar::detachObject()
188 bool onGC(); // RlvGCTimer::tick() 190 bool onGC(); // RlvGCTimer::tick()
189 void onSavedAssetIntoInventory(const LLUUID& idItem); // LLInventoryModel::processSaveAssetIntoInventory() 191 void onSavedAssetIntoInventory(const LLUUID& idItem) { if (m_pAttachMgr) m_pAttachMgr->onSavedAssetIntoInventory(idItem); }
192 void onWearAttachment(const LLUUID& idItem) { if (m_pAttachMgr) m_pAttachMgr->onWearAttachment(idItem); }
190protected: 193protected:
191 BOOL processAddCommand(const LLUUID& uuid, const RlvCommand& rlvCmd); 194 BOOL processAddCommand(const LLUUID& uuid, const RlvCommand& rlvCmd);
192 BOOL processRemoveCommand(const LLUUID& uuid, const RlvCommand& rlvCmd); 195 BOOL processRemoveCommand(const LLUUID& uuid, const RlvCommand& rlvCmd);
193 BOOL processClearCommand(const LLUUID& idObj, const RlvCommand& rlvCmd); 196 BOOL processClearCommand(const LLUUID idObj, const RlvCommand& rlvCmd);
194 BOOL processReplyCommand(const LLUUID& uuid, const RlvCommand& rlvCmd) const; 197 BOOL processReplyCommand(const LLUUID& uuid, const RlvCommand& rlvCmd) const;
195 BOOL processForceCommand(const LLUUID& uuid, const RlvCommand& rlvCmd) const; 198 BOOL processForceCommand(const LLUUID& uuid, const RlvCommand& rlvCmd) const;
196 199
197 // Command handlers (exist for no other reason than to keep the length of the processXXX functions down) 200 // Command handlers (exist for no other reason than to keep the length of the processXXX functions down)
198 void onForceDetach(const LLUUID& idObj, const std::string& strOption) const; 201 ERlvCmdRet onAddRemAttach(const LLUUID& idObj, const RlvCommand& rlvCmd, bool& fRefCount);
202 ERlvCmdRet onAddRemDetach(const LLUUID& idObj, const RlvCommand& rlvCmd, bool& fRefCount);
203 ERlvCmdRet onAddRemOutfit(const LLUUID& idObj, const RlvCommand& rlvCmd, bool& fRefCount);
204 ERlvCmdRet onForceDetach(const LLUUID& idObj, const RlvCommand& rlvCmd) const;
205 ERlvCmdRet onForceRemAttach(const LLUUID& idObj, const RlvCommand& rlvCmd) const;
206 ERlvCmdRet onForceRemOutfit(const LLUUID& idObj, const RlvCommand& rlvCmd) const;
207 ERlvCmdRet onGetAttach(const LLUUID& idObj, const RlvCommand& rlvCmd, std::string& strReply);
208 ERlvCmdRet onGetOutfit(const LLUUID& idObj, const RlvCommand& rlvCmd, std::string& strReply);
209 // Old style command handlers (need to be updated to return ERlvCmdRet)
199 void onForceRemOutfit(const LLUUID& idObj, const std::string& strOption) const; 210 void onForceRemOutfit(const LLUUID& idObj, const std::string& strOption) const;
200 bool onForceSit(const LLUUID& uuid, const std::string& strOption) const; 211 bool onForceSit(const LLUUID& uuid, const std::string& strOption) const;
201 void onForceWear(const std::string& strPath, bool fAttach, bool fMatchAll) const; 212 void onForceWear(const std::string& strPath, bool fAttach, bool fMatchAll) const;
@@ -221,29 +232,29 @@ public:
221 static const std::string cstrMsgTpLure; // Message sent to tplure sender when tplure restricted 232 static const std::string cstrMsgTpLure; // Message sent to tplure sender when tplure restricted
222 static const std::string cstrAnonyms[28]; 233 static const std::string cstrAnonyms[28];
223protected: 234protected:
224 rlv_object_map_t m_Objects; // Map of objects that have active restrictions (by UUID) 235 rlv_object_map_t m_Objects; // Map of objects that have active restrictions (idObj -> RlvObject)
225 rlv_exception_map_t m_Exceptions; // Map of UUIDs that are exempt from the associated ERlvBehaviour 236 rlv_exception_map_t m_Exceptions; // Map of currently active restriction exceptions (ERlvBehaviour -> RlvException)
226 rlv_detach_map_t m_Attachments; // Map of locked attachments (attachment point index -> object that issued @detach=n) 237 rlv_attachlock_map_t m_AttachAdd; // Map of attachment points that can't be attached (idxAttachPt -> idObj)
227 S16 m_LayersAdd[WT_COUNT]; // Array of locked layers (reference counted) 238 rlv_attachlock_map_t m_AttachRem; // Map of attachment points that can't be detached (idxAttachPt -> idObj)
228 S16 m_LayersRem[WT_COUNT]; // Array of locked layers (reference counted) 239 S16 m_LayersAdd[WT_COUNT]; // Array of layers that can't be worn (reference counted)
229 S16 m_Behaviours[RLV_BHVR_COUNT]; 240 S16 m_LayersRem[WT_COUNT]; // Array of layers that can't be removed (reference counted)
230 241 S16 m_Behaviours[RLV_BHVR_COUNT];
231 rlv_retained_list_t m_Retained; 242
232 rlv_reattach_map_t m_AttachPending; 243 rlv_retained_list_t m_Retained;
233 rlv_reattach_map_t m_DetachPending; 244 RlvGCTimer* m_pGCTimer;
234 RlvGCTimer* m_pGCTimer; 245 RlvWLSnapshot* m_pWLSnapshot;
235 RlvWLSnapshot* m_pWLSnapshot; 246 RlvAttachmentManager* m_pAttachMgr;
236 247
237 RlvCommand* m_pCurCommand; // Convenience (see @tpto) 248 RlvCommand* m_pCurCommand; // Convenience (see @tpto)
238 LLUUID m_idCurObject; // Convenience (see @tpto) 249 LLUUID m_idCurObject; // Convenience (see @tpto)
239 250
240 mutable RlvEventEmitter<RlvObserver> m_Emitter; 251 mutable RlvEventEmitter<RlvObserver> m_Emitter;
241 mutable std::list<RlvBehaviourObserver*> m_BhvrObservers; 252 mutable std::list<RlvBehaviourObserver*> m_BhvrObservers;
242 RlvBehaviourNotifyObserver* m_pBhvrNotify; 253 RlvBehaviourNotifyObserver* m_pBhvrNotify;
243 254
244 static BOOL m_fEnabled; // Use setEnabled() to toggle this 255 static BOOL m_fEnabled; // Use setEnabled() to toggle this
245 static BOOL m_fFetchStarted; // TRUE if we fired off an inventory fetch 256 static BOOL m_fFetchStarted; // TRUE if we fired off an inventory fetch
246 static BOOL m_fFetchComplete; // TRUE if everything was fetched 257 static BOOL m_fFetchComplete; // TRUE if everything was fetched
247 static RlvMultiStringSearch m_AttachLookup; // Lookup table for attachment names (lower case) 258 static RlvMultiStringSearch m_AttachLookup; // Lookup table for attachment names (lower case)
248 259
249 bool m_fCanCancelTp; 260 bool m_fCanCancelTp;
@@ -258,8 +269,8 @@ protected:
258 */ 269 */
259public: 270public:
260 const rlv_object_map_t* getObjectMap() const { return &m_Objects; } 271 const rlv_object_map_t* getObjectMap() const { return &m_Objects; }
261 const rlv_exception_map_t* getExceptionMap() const { return &m_Exceptions; } 272 //const rlv_exception_map_t* getExceptionMap() const { return &m_Exceptions; }
262 const rlv_detach_map_t* getDetachMap() const { return &m_Attachments; } 273 //const rlv_detach_map_t* getDetachMap() const { return &m_Attachments; }
263 #ifdef RLV_DEBUG_TESTS 274 #ifdef RLV_DEBUG_TESTS
264 const S16* getAddLayers() const { return m_LayersAdd; } 275 const S16* getAddLayers() const { return m_LayersAdd; }
265 const S16* getRemLayers() const { return m_LayersRem; } 276 const S16* getRemLayers() const { return m_LayersRem; }
@@ -345,6 +356,13 @@ inline bool RlvHandler::hasBehaviourExcept(ERlvBehaviour eBehaviour, const LLUUI
345 return hasBehaviourExcept(eBehaviour, std::string(), idObj); 356 return hasBehaviourExcept(eBehaviour, std::string(), idObj);
346} 357}
347 358
359// Checked: 2009-10-10 (RLVa-1.0.5a) | Added: RLVa-1.0.5a
360inline bool RlvHandler::hasLockedAttachment(ERlvLockMask eLock) const
361{
362 // Remove locks are more common so check those first
363 return ( (eLock & RLV_LOCK_REMOVE) && (!m_AttachRem.empty()) ) || ( (eLock & RLV_LOCK_ADD) && (!m_AttachAdd.empty()) );
364}
365
348#ifdef RLV_EXPERIMENTAL_COMPOSITES 366#ifdef RLV_EXPERIMENTAL_COMPOSITES
349 // Checked: 367 // Checked:
350 inline bool RlvHandler::isCompositeFolder(const LLInventoryCategory* pFolder) const 368 inline bool RlvHandler::isCompositeFolder(const LLInventoryCategory* pFolder) const
@@ -359,20 +377,6 @@ inline bool RlvHandler::hasBehaviourExcept(ERlvBehaviour eBehaviour, const LLUUI
359 } 377 }
360#endif // RLV_EXPERIMENTAL_COMPOSITES 378#endif // RLV_EXPERIMENTAL_COMPOSITES
361 379
362// Checked: 2009-09-08 (RLVa-1.0.2c) | Added: RLVa-1.0.2c
363inline bool RlvHandler::isDetachable(LLViewerJointAttachment *pAttachPt) const
364{
365 // If there's an attached object it's faster to just use that; otherwise look up the attachment index because it might be locked empty
366 return (pAttachPt == NULL) ||
367 ( (pAttachPt->getObject() != NULL) && isDetachable(pAttachPt->getObject()) ) || (isDetachable(getAttachPointIndex(pAttachPt)));
368}
369
370// Checked: 2009-05-23 (RLVa-0.2.0d) | Modified: RLVa-0.2.0d
371inline bool RlvHandler::isDetachable(LLViewerObject* pObj) const
372{
373 return (pObj == NULL) || (!pObj->isAttachment()) || (isDetachable(getAttachPointIndex(pObj)));
374}
375
376inline bool RlvHandler::isPermissive(ERlvBehaviour eBhvr) const 380inline bool RlvHandler::isPermissive(ERlvBehaviour eBhvr) const
377{ 381{
378 return (RlvCommand::hasStrictVariant(eBhvr)) 382 return (RlvCommand::hasStrictVariant(eBhvr))
@@ -395,6 +399,29 @@ inline bool RlvHandler::isFoldedFolder(const LLInventoryCategory* pFolder, bool
395 ); 399 );
396} 400}
397 401
402// Checked: 2009-10-10 (RLVa-1.0.5a) | Added: RLVa-1.0.5a
403inline bool RlvHandler::isLockedAttachment(S32 idxAttachPt, ERlvLockMask eLock) const
404{
405 return ( (eLock & RLV_LOCK_REMOVE) && (m_AttachRem.find(idxAttachPt) != m_AttachRem.end()) ) ||
406 ( (eLock & RLV_LOCK_ADD) && (m_AttachAdd.find(idxAttachPt) != m_AttachAdd.end()) );
407}
408
409
410// Checked: 2009-10-10 (RLVa-1.0.5a) | Added: RLVa-1.0.5a
411inline bool RlvHandler::isLockedAttachment(LLViewerJointAttachment *pAttachPt, ERlvLockMask eLock) const
412{
413 // If there's an attached object it's faster to just use that; otherwise look up the attachment index because it might be locked empty
414 return (pAttachPt != NULL) &&
415 ( ( (pAttachPt->getObject() != NULL) && (isLockedAttachment(pAttachPt->getObject(), eLock)) ) ||
416 (isLockedAttachment(getAttachPointIndex(pAttachPt), eLock)) );
417}
418
419// Checked: 2009-10-10 (RLVa-1.0.5a) | Added: RLVa-1.0.5a
420inline bool RlvHandler::isLockedAttachment(LLViewerObject* pObj, ERlvLockMask eLock) const
421{
422 return (pObj != NULL) && (pObj->isAttachment()) && (isLockedAttachment(getAttachPointIndex(pObj), eLock));
423}
424
398// Checked: 2009-05-23 (RLVa-0.2.0d) | Added: RLVa-0.2.0d 425// Checked: 2009-05-23 (RLVa-0.2.0d) | Added: RLVa-0.2.0d
399inline bool RlvHandler::isRemovableExcept(EWearableType type, const LLUUID& idObj) const 426inline bool RlvHandler::isRemovableExcept(EWearableType type, const LLUUID& idObj) const
400{ 427{
@@ -434,12 +461,6 @@ inline void RlvHandler::retainCommand(const std::string& strObj, const LLUUID& i
434 m_Retained.push_back(RlvRetainedCommand(strObj, idObj, strCmd)); 461 m_Retained.push_back(RlvRetainedCommand(strObj, idObj, strCmd));
435} 462}
436 463
437// Checked: 2009-05-23 (RLVa-0.2.0d) | Modified: RLVa-0.2.0d
438inline bool RlvHandler::setDetachable(LLViewerObject* pObj, const LLUUID& idRlvObj, bool fDetachable)
439{
440 return setDetachable(getAttachPointIndex(pObj), idRlvObj, fDetachable); // getAttachPointIndex() has a NULL pointer check
441}
442
443// ============================================================================ 464// ============================================================================
444 465
445#endif // RLV_HANDLER_H 466#endif // RLV_HANDLER_H