diff options
author | McCabe Maxsted | 2009-09-14 17:52:41 -0700 |
---|---|---|
committer | McCabe Maxsted | 2009-09-14 17:52:41 -0700 |
commit | 7f090f7bec5264ca9e203c27dfb6b2992bb2bcbd (patch) | |
tree | 0243666021de3ae6ac61a6c6f4e57d42771fe964 /linden/indra/newview/rlvhandler.h | |
parent | Applied BlockClickSit debug setting from Emerald to block sit click action (diff) | |
download | meta-impy-7f090f7bec5264ca9e203c27dfb6b2992bb2bcbd.zip meta-impy-7f090f7bec5264ca9e203c27dfb6b2992bb2bcbd.tar.gz meta-impy-7f090f7bec5264ca9e203c27dfb6b2992bb2bcbd.tar.bz2 meta-impy-7f090f7bec5264ca9e203c27dfb6b2992bb2bcbd.tar.xz |
Merged in jacek/next
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/rlvhandler.h | 462 |
1 files changed, 462 insertions, 0 deletions
diff --git a/linden/indra/newview/rlvhandler.h b/linden/indra/newview/rlvhandler.h new file mode 100644 index 0000000..df3ff9b --- /dev/null +++ b/linden/indra/newview/rlvhandler.h | |||
@@ -0,0 +1,462 @@ | |||
1 | #ifndef RLV_HANDLER_H | ||
2 | #define RLV_HANDLER_H | ||
3 | |||
4 | #include "llagentconstants.h" | ||
5 | #include "llappviewer.h" | ||
6 | #include "llformat.h" | ||
7 | #include "llversionviewer.h" | ||
8 | #include "llviewerjointattachment.h" | ||
9 | #include "llviewerobject.h" | ||
10 | #include "llwearable.h" | ||
11 | |||
12 | #include "rlvhelper.h" | ||
13 | #include "rlvevent.h" | ||
14 | #include "rlvmultistringsearch.h" | ||
15 | |||
16 | // ============================================================================ | ||
17 | /* | ||
18 | * RlvHandler | ||
19 | * ========== | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | typedef std::map<LLUUID, RlvObject> rlv_object_map_t; | ||
24 | typedef std::multimap<S32, LLUUID> rlv_detach_map_t; | ||
25 | typedef std::map<S32, LLUUID> rlv_reattach_map_t; | ||
26 | typedef std::multimap<LLUUID, ERlvBehaviour> rlv_exception_map_t; | ||
27 | typedef std::map<S32, RlvRedirInfo> rlv_redir_map_t; | ||
28 | |||
29 | class RlvHandler | ||
30 | { | ||
31 | public: | ||
32 | RlvHandler(); | ||
33 | ~RlvHandler(); | ||
34 | |||
35 | // -------------------------------- | ||
36 | |||
37 | /* | ||
38 | * Rule checking functions | ||
39 | */ | ||
40 | public: | ||
41 | // Returns a pointer to the attachment point for a supplied parameter | ||
42 | LLViewerJointAttachment* getAttachPoint(const std::string& strText, bool fExact) const; | ||
43 | LLViewerJointAttachment* getAttachPoint(const LLInventoryItem* pItem, bool fStrict) const; | ||
44 | LLViewerJointAttachment* getAttachPoint(const LLInventoryCategory* pFolder, bool fStrict) const; | ||
45 | LLViewerJointAttachment* getAttachPointLegacy(const LLInventoryCategory* pFolder) const; | ||
46 | S32 getAttachPointIndex(std::string strText, bool fExact) const; | ||
47 | S32 getAttachPointIndex(LLViewerObject* pObj) const; | ||
48 | S32 getAttachPointIndex(const LLViewerJointAttachment* pObj) const; | ||
49 | bool hasAttachPointName(const LLInventoryItem* pItem, bool fStrict) const; | ||
50 | |||
51 | // Returns TRUE is at least one object contains the specified behaviour (and optional parameter) | ||
52 | // NOTE: - to check @detach=n -> hasLockedAttachment() / hasLockedHUD() / isDetachable() | ||
53 | // - to check @addoutfit=n -> isWearable() | ||
54 | // - to check @remoutfit=n -> isRemovable() | ||
55 | // - to check exceptions -> isException() | ||
56 | // (You *can* use hasBehaviour(); the specialized ones just don't have to iterate over all the objects) | ||
57 | bool hasBehaviour(ERlvBehaviour eBehaviour) const { return (eBehaviour < RLV_BHVR_COUNT) ? (0 != m_Behaviours[eBehaviour]) : false; } | ||
58 | bool hasBehaviour(const std::string& strBehaviour) const; | ||
59 | bool hasBehaviour(ERlvBehaviour eBehaviour, const std::string& strOption) const; | ||
60 | bool hasBehaviour(const std::string& strBehaviour, const std::string& strOption) const; | ||
61 | |||
62 | // Returns TRUE if at least one object (except the specified one) contains the specified behaviour | ||
63 | bool hasBehaviourExcept(ERlvBehaviour eBehaviour, const LLUUID& idObj) const; | ||
64 | bool hasBehaviourExcept(const std::string& strBehaviour, const LLUUID& uuid) const; | ||
65 | bool hasBehaviourExcept(ERlvBehaviour eBehaviour, const std::string& strOption, const LLUUID& idObj) const; | ||
66 | bool hasBehaviourExcept(const std::string& strBehaviour, const std::string& strOption, const LLUUID& idObj) const; | ||
67 | |||
68 | // Returns TRUE if there is at least 1 undetachable attachment | ||
69 | bool hasLockedAttachment() const { return (0 != m_Attachments.size()); } | ||
70 | // Returns TRUE if there is at least 1 undetachable HUD attachment | ||
71 | bool hasLockedHUD() const; | ||
72 | |||
73 | // Returns TRUE if the specified attachment point is detachable | ||
74 | bool isDetachable(S32 idxAttachPt) const { return (idxAttachPt) && (m_Attachments.find(idxAttachPt) == m_Attachments.end()); } | ||
75 | bool isDetachable(const LLInventoryItem* pItem) const; | ||
76 | bool isDetachable(LLViewerObject* pObj) const; | ||
77 | // Returns TRUE if the specified attachment point is set undetachable by anything other than pObj (or one of its children) | ||
78 | bool isDetachableExcept(S32 idxAttachPt, LLViewerObject* pObj) const; | ||
79 | // Marks the specified attachment point as (un)detachable (return value indicates success ; used by unit tests) | ||
80 | bool setDetachable(S32 idxAttachPt, const LLUUID& idRlvObj, bool fDetachable); | ||
81 | bool setDetachable(LLViewerObject* pObj, const LLUUID& idRlvObj, bool fDetachable); | ||
82 | |||
83 | // Adds or removes an exception for the specified restriction | ||
84 | void addException(ERlvBehaviour eBehaviour, const LLUUID& uuid); | ||
85 | void removeException(ERlvBehaviour eBehaviour, const LLUUID& uuid); | ||
86 | // Returns TRUE is the specified UUID is exempt from a restriction (tplure/sendim/recvim/etc) | ||
87 | bool isException(ERlvBehaviour eBehaviour, const LLUUID& uuid) const; | ||
88 | bool isException(const std::string& strBehaviour, const LLUUID& uuid) const; | ||
89 | |||
90 | // Returns TRUE if the specified layer is removable (use hasBehaviour(RLV_BHVR_REMOUTFIT) for the general case) | ||
91 | bool isRemovable(EWearableType type) const { return (type < WT_COUNT) ? (0 == m_LayersRem[type]) : true; } | ||
92 | // Returns TRUE if the specified layer is not remoutfit blocked by any object (except the one specified by UUID) | ||
93 | bool isRemovableExcept(EWearableType type, const LLUUID& idObj) const; | ||
94 | // Returns TRUE if the inventory item is strippable by @detach or @remoutfit | ||
95 | bool isStrippable(const LLUUID& idItem) const; | ||
96 | // Returns TRUE if the specified layer is wearable (use hasBehaviour(RLV_BHVR_ADDOUTFIT) for the general case) | ||
97 | bool isWearable(EWearableType type) const { return (type < WT_COUNT) ? (0 == m_LayersAdd[type]) : true; } | ||
98 | |||
99 | // Returns TRUE if the composite folder doesn't contain any "locked" items | ||
100 | bool canTakeOffComposite(const LLInventoryCategory* pFolder) const; | ||
101 | // Returns TRUE if the folder is a composite folder and optionally returns the name | ||
102 | bool getCompositeInfo(const LLInventoryCategory* pFolder, std::string* pstrName) const; | ||
103 | // Returns TRUE if the inventory item belongs to a composite folder and optionally returns the name and composite folder | ||
104 | bool getCompositeInfo(const LLUUID& idItem, std::string* pstrName, LLViewerInventoryCategory** ppFolder) const; | ||
105 | // Returns TRUE if the folder is a composite folder | ||
106 | bool isCompositeFolder(const LLInventoryCategory* pFolder) const; | ||
107 | // Returns TRUE if the inventory item belongs to a composite folder | ||
108 | bool isCompositeDescendent(const LLUUID& idItem) const; | ||
109 | // Returns TRUE if the inventory item is part of a folded composite folder and should be hidden from @getoufit or @getattach | ||
110 | bool isHiddenCompositeItem(const LLUUID& idItem, const std::string& strItemType) const; | ||
111 | |||
112 | // -------------------------------- | ||
113 | |||
114 | /* | ||
115 | * Helper functions | ||
116 | */ | ||
117 | public: | ||
118 | // Accessors | ||
119 | bool getCanCancelTp() const { return m_fCanCancelTp; } // @accepttp and @tpto | ||
120 | void setCanCancelTp(bool fAllow) { m_fCanCancelTp = fAllow; } // @accepttp and @tpto | ||
121 | |||
122 | // Command specific helper functions | ||
123 | bool canShowHoverText(LLViewerObject* pObj) const; // @showhovertext* command family | ||
124 | void filterChat(std::string& strUTF8Text, bool fFilterEmote) const; // @sendchat, @recvchat and @redirchat | ||
125 | void filterLocation(std::string& strUTF8Text) const; // @showloc | ||
126 | void filterNames(std::string& strUTF8Text) const; // @shownames | ||
127 | const std::string& getAnonym(const std::string& strName) const; // @shownames | ||
128 | std::string getVersionString() const; // @version | ||
129 | BOOL isAgentNearby(const LLUUID& uuid) const; // @shownames | ||
130 | bool redirectChatOrEmote(const std::string& strUTF8Test) const; // @redirchat and @rediremote | ||
131 | |||
132 | // Command processing helper functions | ||
133 | BOOL processCommand(const LLUUID& idObj, const std::string& strCommand, bool fFromObj); | ||
134 | void processRetainedCommands(); | ||
135 | void retainCommand(const std::string& strObj, const LLUUID& idObj, const std::string& strCmd); | ||
136 | |||
137 | // Returns a pointer to the currently executing command (do *not* save this pointer) | ||
138 | const RlvCommand* getCurrentCommand() const { return m_pCurCommand; } | ||
139 | // Returns the UUID of the object we're currently executing a command for | ||
140 | const LLUUID& getCurrentObject() const { return m_idCurObject; } | ||
141 | |||
142 | // Initialization | ||
143 | static BOOL canDisable(); | ||
144 | static BOOL isEnabled() { return m_fEnabled; } | ||
145 | static void initLookupTables(); | ||
146 | static BOOL setEnabled(BOOL fEnable); | ||
147 | protected: | ||
148 | void clearState(); | ||
149 | |||
150 | // -------------------------------- | ||
151 | |||
152 | /* | ||
153 | * Inventory related functions | ||
154 | */ | ||
155 | public: | ||
156 | // Starts a fetch of everything under the shared root (if there is one) | ||
157 | static void fetchSharedInventory(); | ||
158 | // Returns the path of the supplied folder (relative to the shared root) | ||
159 | std::string getSharedPath(const LLViewerInventoryCategory* pFolder) const; | ||
160 | std::string getSharedPath(const LLUUID& idFolder) const; | ||
161 | // Returns a pointer to the shared root folder (if there is one) | ||
162 | static LLViewerInventoryCategory* getSharedRoot(); | ||
163 | // A "folded folder" is a folder whose items logically belong to the grandparent rather than the parent | ||
164 | bool isFoldedFolder(const LLInventoryCategory* pFolder, bool fAttach) const; | ||
165 | bool isFoldedFolderLegacy(const LLInventoryCategory* pFolder, bool fAttach) const; | ||
166 | protected: | ||
167 | // Find all folders that match a supplied criteria (clears the supplied array) | ||
168 | bool findSharedFolders(const std::string& strCriteria, LLInventoryModel::cat_array_t& folders) const; | ||
169 | |||
170 | // Returns a subfolder of idParent that starts with name (exact match > partial match) | ||
171 | LLViewerInventoryCategory* getSharedFolder(const LLUUID& idParent, const std::string& strName) const; | ||
172 | // Looks up a folder from a path (relative to the shared root) | ||
173 | LLViewerInventoryCategory* getSharedFolder(const std::string& strPath) const; | ||
174 | |||
175 | bool getWornInfo(const LLInventoryCategory* pFolder, U8& wiFolder, U8& wiChildren) const; | ||
176 | |||
177 | // -------------------------------- | ||
178 | |||
179 | /* | ||
180 | * Event handling (forwards to registered observers if we don't handle the command) | ||
181 | */ | ||
182 | public: | ||
183 | BOOL addObserver(RlvObserver* pObserver) { return m_Emitter.addObserver(pObserver); } | ||
184 | BOOL removeObserver(RlvObserver* pObserver) { return m_Emitter.remObserver(pObserver); } | ||
185 | void addBehaviourObserver(RlvBehaviourObserver* pBhvrObserver); | ||
186 | void removeBehaviourObserver(RlvBehaviourObserver* pBhvrObserver); | ||
187 | void notifyBehaviourObservers(const RlvCommand& rlvCmd, bool fInternal); | ||
188 | |||
189 | // Externally invoked event handlers | ||
190 | void onAttach(LLViewerJointAttachment* pAttachPt, bool fFullyLoaded); // LLVOAvatar::attachObject() | ||
191 | void onDetach(LLViewerJointAttachment* pAttachPt); // LLVOAvatar::detachObject() | ||
192 | bool onGC(); // RlvGCTimer::tick() | ||
193 | void onSavedAssetIntoInventory(const LLUUID& idItem); // LLInventoryModel::processSaveAssetIntoInventory() | ||
194 | protected: | ||
195 | BOOL processAddCommand(const LLUUID& uuid, const RlvCommand& rlvCmd); | ||
196 | BOOL processRemoveCommand(const LLUUID& uuid, const RlvCommand& rlvCmd); | ||
197 | BOOL processReplyCommand(const LLUUID& uuid, const RlvCommand& rlvCmd) const; | ||
198 | BOOL processForceCommand(const LLUUID& uuid, const RlvCommand& rlvCmd) const; | ||
199 | |||
200 | // Command handlers (exist for no other reason than to keep the length of the processXXX functions down) | ||
201 | void onForceDetach(const LLUUID& idObj, const std::string& strOption) const; | ||
202 | void onForceRemOutfit(const LLUUID& idObj, const std::string& strOption) const; | ||
203 | bool onForceSit(const LLUUID& uuid, const std::string& strOption) const; | ||
204 | void onForceWear(const std::string& strPath, bool fAttach, bool fMatchAll) const; | ||
205 | bool onGetPath(const LLUUID& uuid, const std::string& strOption, std::string& strReply) const; | ||
206 | void onGetInvWorn(const std::string& strPath, std::string &strReply) const; | ||
207 | |||
208 | // -------------------------------- | ||
209 | |||
210 | /* | ||
211 | * Member variables | ||
212 | */ | ||
213 | public: | ||
214 | static BOOL fNoSetEnv; | ||
215 | static BOOL fLegacyNaming; | ||
216 | |||
217 | static const std::string cstrSharedRoot; // Name of the shared root folder | ||
218 | static const std::string cstrBlockedRecvIM; // Stand-in text for incoming IM when recvim restricted | ||
219 | static const std::string cstrBlockedSendIM; // Stand-in text for outgoing IM when sendim restricted | ||
220 | static const std::string cstrHidden; // General purpose "this was censored" text | ||
221 | static const std::string cstrHiddenParcel; | ||
222 | static const std::string cstrHiddenRegion; | ||
223 | static const std::string cstrMsgRecvIM; // Message sent to IM sender when sendim restricted | ||
224 | static const std::string cstrMsgTpLure; // Message sent to tplure sender when tplure restricted | ||
225 | static const std::string cstrAnonyms[28]; | ||
226 | protected: | ||
227 | rlv_object_map_t m_Objects; // Map of objects that have active restrictions (by UUID) | ||
228 | rlv_exception_map_t m_Exceptions; // Map of UUIDs that are exempt from the associated ERlvBehaviour | ||
229 | rlv_detach_map_t m_Attachments; // Map of locked attachments (attachment point index -> object that issued @detach=n) | ||
230 | S16 m_LayersAdd[WT_COUNT]; // Array of locked layers (reference counted) | ||
231 | S16 m_LayersRem[WT_COUNT]; // Array of locked layers (reference counted) | ||
232 | S16 m_Behaviours[RLV_BHVR_COUNT]; | ||
233 | |||
234 | rlv_retained_list_t m_Retained; | ||
235 | rlv_reattach_map_t m_AttachPending; | ||
236 | rlv_reattach_map_t m_DetachPending; | ||
237 | rlv_redir_map_t m_Redirections; | ||
238 | RlvGCTimer* m_pGCTimer; | ||
239 | RlvWLSnapshot* m_pWLSnapshot; | ||
240 | |||
241 | RlvCommand* m_pCurCommand; // Convenience (see @tpto) | ||
242 | LLUUID m_idCurObject; // Convenience (see @tpto) | ||
243 | |||
244 | mutable RlvEventEmitter<RlvObserver> m_Emitter; | ||
245 | mutable std::list<RlvBehaviourObserver*> m_BhvrObservers; | ||
246 | RlvBehaviourNotifyObserver* m_pBhvrNotify; | ||
247 | |||
248 | static BOOL m_fEnabled; // Use setEnabled() to toggle this | ||
249 | static BOOL m_fFetchStarted; // TRUE if we fired off an inventory fetch | ||
250 | static BOOL m_fFetchComplete; // TRUE if everything was fetched | ||
251 | static RlvMultiStringSearch m_AttachLookup; // Lookup table for attachment names (lower case) | ||
252 | |||
253 | bool m_fCanCancelTp; | ||
254 | |||
255 | friend class RlvSharedRootFetcher; // Fetcher needs access to m_fFetchComplete | ||
256 | friend class RlvGCTimer; // Timer clear its own point at destruction | ||
257 | |||
258 | // -------------------------------- | ||
259 | |||
260 | /* | ||
261 | * Internal access functions used by unit tests | ||
262 | */ | ||
263 | public: | ||
264 | const rlv_object_map_t* getObjectMap() const { return &m_Objects; } | ||
265 | const rlv_exception_map_t* getExceptionMap() const { return &m_Exceptions; } | ||
266 | const rlv_detach_map_t* getDetachMap() const { return &m_Attachments; } | ||
267 | #ifdef RLV_DEBUG_TESTS | ||
268 | const S16* getAddLayers() const { return m_LayersAdd; } | ||
269 | const S16* getRemLayers() const { return m_LayersRem; } | ||
270 | const S16* getBehaviours() const { return m_Behaviours; } | ||
271 | const rlv_retained_list_t* getRetainedList() const { return &m_Retained; } | ||
272 | #endif // RLV_DEBUG_TESTS | ||
273 | }; | ||
274 | |||
275 | typedef RlvHandler rlv_handler_t; | ||
276 | extern rlv_handler_t gRlvHandler; | ||
277 | |||
278 | // ============================================================================ | ||
279 | // Inlined member functions | ||
280 | // | ||
281 | |||
282 | // Checked: 2009-07-09 (RLVa-1.0.0f) | ||
283 | inline void RlvHandler::addException(ERlvBehaviour eBehaviour, const LLUUID& uuid) | ||
284 | { | ||
285 | if (!uuid.isNull()) | ||
286 | m_Exceptions.insert(std::pair<LLUUID, ERlvBehaviour>(uuid, eBehaviour)); | ||
287 | } | ||
288 | |||
289 | // Checked: 2009-07-09 (RLVa-1.0.0f) | Modified: RLVa-1.0.0f | ||
290 | inline bool RlvHandler::canShowHoverText(LLViewerObject *pObj) const | ||
291 | { | ||
292 | return ( (!pObj) || (LL_PCODE_VOLUME != pObj->getPCode()) || | ||
293 | !( (hasBehaviour(RLV_BHVR_SHOWHOVERTEXTALL)) || | ||
294 | ( (hasBehaviour(RLV_BHVR_SHOWHOVERTEXTWORLD)) && (!pObj->isHUDAttachment()) ) || | ||
295 | ( (hasBehaviour(RLV_BHVR_SHOWHOVERTEXTHUD)) && (pObj->isHUDAttachment()) ) || | ||
296 | (isException(RLV_BHVR_SHOWHOVERTEXT, pObj->getID())) ) ); | ||
297 | } | ||
298 | |||
299 | // Checked: 2009-05-23 (RLVa-0.2.0d) | Modified: RLVa-0.2.0d | ||
300 | inline S32 RlvHandler::getAttachPointIndex(std::string strText, bool fExact) const | ||
301 | { | ||
302 | U16 nParam; RlvMultiStringSearchMatch match; | ||
303 | LLStringUtil::toLower(strText); | ||
304 | return (fExact) ? ((m_AttachLookup.getExactMatchParam(strText, nParam)) ? nParam : 0) | ||
305 | : ((m_AttachLookup.findLast(strText, match)) ? match.nParam : 0); | ||
306 | } | ||
307 | |||
308 | // Checked: 2009-05-23 (RLVa-0.2.0d) | Modified: RLVa-0.2.0d | ||
309 | inline S32 RlvHandler::getAttachPointIndex(LLViewerObject* pObj) const | ||
310 | { | ||
311 | return (pObj) ? ATTACHMENT_ID_FROM_STATE(pObj->getState()) : 0; | ||
312 | } | ||
313 | |||
314 | // Checked: 2009-06-02 (RLVa-0.2.0g) | ||
315 | inline std::string RlvHandler::getSharedPath(const LLUUID& idFolder) const | ||
316 | { | ||
317 | return getSharedPath(gInventory.getCategory(idFolder)); // getSharedPath() has a NULL pointer check so this is safe | ||
318 | } | ||
319 | |||
320 | // Checked: 2009-06-07 (RLVa-0.2.1c) | ||
321 | inline std::string RlvHandler::getVersionString() const | ||
322 | { | ||
323 | return llformat("RestrainedLife viewer v%d.%d.%d (%s %d.%d.%d.%d - RLVa %d.%d.%d)", | ||
324 | RLV_VERSION_MAJOR, RLV_VERSION_MINOR, RLV_VERSION_PATCH, | ||
325 | LLAppViewer::instance()->getSecondLifeTitle().c_str(), LL_VERSION_MAJOR, LL_VERSION_MINOR, LL_VERSION_PATCH, LL_VERSION_BUILD, | ||
326 | RLVa_VERSION_MAJOR, RLVa_VERSION_MINOR, RLVa_VERSION_PATCH); | ||
327 | } | ||
328 | |||
329 | // Checked: 2009-05-23 (RLVa-0.2.0d) | Modified: RLVa-0.2.0d | ||
330 | inline bool RlvHandler::hasAttachPointName(const LLInventoryItem *pItem, bool fStrict) const | ||
331 | { | ||
332 | return (getAttachPoint(pItem, fStrict) != NULL); // getAttachPoint() has a NULL pointer check so this is safe | ||
333 | } | ||
334 | |||
335 | // Checked: | ||
336 | inline bool RlvHandler::hasBehaviour(ERlvBehaviour eBehaviour, const std::string& strOption) const | ||
337 | { | ||
338 | return hasBehaviourExcept(eBehaviour, strOption, LLUUID::null); | ||
339 | } | ||
340 | |||
341 | // Checked: | ||
342 | inline bool RlvHandler::hasBehaviour(const std::string& strBehaviour) const | ||
343 | { | ||
344 | return hasBehaviourExcept(strBehaviour, LLUUID::null); | ||
345 | } | ||
346 | |||
347 | // Checked: | ||
348 | inline bool RlvHandler::hasBehaviour(const std::string& strBehaviour, const std::string& strOption) const | ||
349 | { | ||
350 | return hasBehaviourExcept(strBehaviour, strOption, LLUUID::null); | ||
351 | } | ||
352 | |||
353 | // Checked: | ||
354 | inline bool RlvHandler::hasBehaviourExcept(ERlvBehaviour eBehaviour, const LLUUID& idObj) const | ||
355 | { | ||
356 | return hasBehaviourExcept(eBehaviour, std::string(), idObj); | ||
357 | } | ||
358 | |||
359 | #ifdef RLV_EXPERIMENTAL_COMPOSITES | ||
360 | // Checked: | ||
361 | inline bool RlvHandler::isCompositeFolder(const LLInventoryCategory* pFolder) const | ||
362 | { | ||
363 | return getCompositeInfo(pFolder, NULL); | ||
364 | } | ||
365 | |||
366 | // Checked: | ||
367 | inline bool RlvHandler::isCompositeDescendent(const LLUUID& idItem) const | ||
368 | { | ||
369 | return getCompositeInfo(idItem, NULL, NULL); | ||
370 | } | ||
371 | #endif // RLV_EXPERIMENTAL_COMPOSITES | ||
372 | |||
373 | // Checked: 2009-05-23 (RLVa-0.2.0d) | Modified: RLVa-0.2.0d | ||
374 | inline bool RlvHandler::isDetachable(LLViewerObject* pObj) const | ||
375 | { | ||
376 | return (pObj == NULL) || (!pObj->isAttachment()) || (isDetachable(getAttachPointIndex(pObj))); | ||
377 | } | ||
378 | |||
379 | // Checked: | ||
380 | inline bool RlvHandler::isException(ERlvBehaviour eBehaviour, const LLUUID& uuid) const | ||
381 | { | ||
382 | for (rlv_exception_map_t::const_iterator itException = m_Exceptions.lower_bound(uuid), | ||
383 | endException = m_Exceptions.upper_bound(uuid); itException != endException; ++itException) | ||
384 | { | ||
385 | if (itException->second == eBehaviour) | ||
386 | return true; | ||
387 | } | ||
388 | return false; | ||
389 | } | ||
390 | |||
391 | // Checked: | ||
392 | inline bool RlvHandler::isException(const std::string& strBehaviour, const LLUUID& uuid) const | ||
393 | { | ||
394 | return hasBehaviour(strBehaviour, uuid.asString()); | ||
395 | } | ||
396 | |||
397 | // Checked: 2009-07-29 (RLVa-1.0.1b) | Added: RLVa-1.0.1b | ||
398 | inline bool RlvHandler::isFoldedFolder(const LLInventoryCategory* pFolder, bool fAttach) const | ||
399 | { | ||
400 | return | ||
401 | ( | ||
402 | // .(<attachpt>) type folder (on detach we don't care about its children, but on attach there can only be 1 attachment) | ||
403 | ( (gRlvHandler.getAttachPoint(pFolder, true)) && | ||
404 | ( (!fAttach) || (1 == rlvGetDirectDescendentsCount(pFolder, LLAssetType::AT_OBJECT))) ) | ||
405 | #ifdef RLV_EXTENSION_FLAG_NOSTRIP | ||
406 | // .(nostrip) folder | ||
407 | || ( (pFolder) && (".("RLV_FOLDER_FLAG_NOSTRIP")" == pFolder->getName()) ) | ||
408 | #endif // RLV_EXTENSION_FLAG_NOSTRIP | ||
409 | ); | ||
410 | } | ||
411 | |||
412 | // Checked: 2009-05-23 (RLVa-0.2.0d) | Added: RLVa-0.2.0d | ||
413 | inline bool RlvHandler::isRemovableExcept(EWearableType type, const LLUUID& idObj) const | ||
414 | { | ||
415 | // NOTE: mind the bitwise OR rather than the logical OR!! | ||
416 | return (isRemovable(type)) || !( (hasBehaviourExcept(RLV_BHVR_REMOUTFIT, idObj)) | | ||
417 | (hasBehaviourExcept(RLV_BHVR_REMOUTFIT, LLWearable::typeToTypeName(type), idObj)) ); | ||
418 | } | ||
419 | |||
420 | #ifndef RLV_EXTENSION_FLAG_NOSTRIP | ||
421 | // Checked: 2009-05-23 (RLVa-0.2.0d) | Added: RLVa-0.2.0d | ||
422 | bool RlvHandler::isStrippable(const LLUUID& idItem) const | ||
423 | { | ||
424 | return true; | ||
425 | } | ||
426 | #endif // RLV_EXTENSION_FLAG_NOSTRIP | ||
427 | |||
428 | // Checked: 2009-07-09 (RLVa-1.0.0f) | ||
429 | inline void RlvHandler::removeException(ERlvBehaviour eBehaviour, const LLUUID &uuid) | ||
430 | { | ||
431 | if (!uuid.isNull()) | ||
432 | { | ||
433 | for (rlv_exception_map_t::iterator itException = m_Exceptions.lower_bound(uuid), | ||
434 | endException = m_Exceptions.upper_bound(uuid); itException != endException; ++itException) | ||
435 | { | ||
436 | if (itException->second == eBehaviour) | ||
437 | { | ||
438 | m_Exceptions.erase(itException); | ||
439 | break; | ||
440 | } | ||
441 | } | ||
442 | } | ||
443 | } | ||
444 | |||
445 | // Checked: 2009-08-05 (RLVa-1.0.1e) | Modified: RLVa-1.0.1e | ||
446 | inline void RlvHandler::retainCommand(const std::string& strObj, const LLUUID& idObj, const std::string& strCmd) | ||
447 | { | ||
448 | #ifdef RLV_DEBUG | ||
449 | RLV_INFOS << "[" << idObj << "]: " << strCmd << " (retaining)" << LL_ENDL; | ||
450 | #endif // RLV_DEBUG | ||
451 | m_Retained.push_back(RlvRetainedCommand(strObj, idObj, strCmd)); | ||
452 | } | ||
453 | |||
454 | // Checked: 2009-05-23 (RLVa-0.2.0d) | Modified: RLVa-0.2.0d | ||
455 | inline bool RlvHandler::setDetachable(LLViewerObject* pObj, const LLUUID& idRlvObj, bool fDetachable) | ||
456 | { | ||
457 | return setDetachable(getAttachPointIndex(pObj), idRlvObj, fDetachable); // getAttachPointIndex() has a NULL pointer check | ||
458 | } | ||
459 | |||
460 | // ============================================================================ | ||
461 | |||
462 | #endif // RLV_HANDLER_H | ||