1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
|
#ifndef RLV_HELPER_H
#define RLV_HELPER_H
#include "llboost.h"
#include "llinventorymodel.h"
#include "llselectmgr.h"
#include "llviewercontrol.h"
#include "llviewerobjectlist.h"
#include "llwlparamset.h"
#include "rlvdefines.h"
// ============================================================================
// RlvCommand
//
class RlvCommand
{
public:
explicit RlvCommand(const std::string& strCommand);
/*
* Member functions
*/
public:
std::string asString() const;
const std::string& getBehaviour() const { return m_strBehaviour; }
ERlvBehaviour getBehaviourType() const { return m_eBehaviour; }
const std::string& getOption() const { return m_strOption; }
const std::string& getParam() const { return m_strParam; }
ERlvParamType getParamType() const { return m_eParamType; }
bool isValid() const { return m_fValid; }
static ERlvBehaviour getBehaviourFromString(const std::string& strBhvr);
static const std::string& getStringFromBehaviour(ERlvBehaviour eBhvr);
static void initLookupTable();
protected:
static bool parseCommand(const std::string& strCommand, std::string& strBehaviour, std::string& strOption, std::string& strParam);
/*
* Operators
*/
public:
bool operator ==(const RlvCommand&) const;
/*
* Member variables
*/
protected:
bool m_fValid;
std::string m_strBehaviour;
ERlvBehaviour m_eBehaviour;
std::string m_strOption;
std::string m_strParam;
ERlvParamType m_eParamType;
typedef std::map<std::string, ERlvBehaviour> RlvBhvrTable;
static RlvBhvrTable m_BhvrMap;
friend class RlvHandler;
};
typedef std::list<RlvCommand> rlv_command_list_t;
// ============================================================================
// RlvObject
//
class RlvObject
{
public:
RlvObject(const LLUUID& idObj);
/*
* Member functions
*/
public:
bool addCommand(const RlvCommand& rlvCmd);
bool removeCommand(const RlvCommand& rlvCmd);
std::string getStatusString(const std::string& strMatch) const;
bool hasBehaviour(ERlvBehaviour eBehaviour) const;
bool hasBehaviour(const std::string& strBehaviour) const;
bool hasBehaviour(ERlvBehaviour eBehaviour, const std::string& strOption) const;
bool hasBehaviour(const std::string& strBehaviour, const std::string& strOption) const;
const rlv_command_list_t* getCommandList() const { return &m_Commands; }
/*
* Member variables
*/
protected:
LLUUID m_UUID; // The object's UUID
S32 m_idxAttachPt; // The object's attachment point (or 0 if it's not an attachment)
bool m_fLookup; // TRUE if the object existed in gObjectList at one point in time
S16 m_nLookupMisses; // Count of unsuccessful lookups in gObjectList by the GC
rlv_command_list_t m_Commands; // List of behaviours held by this object (in the order they were received)
friend class RlvHandler;
};
// ============================================================================
// RlvCriteriaCategoryCollector - Criteria based folder matching filter used by @findfolder and @findfolders
//
class RlvCriteriaCategoryCollector : public LLInventoryCollectFunctor
{
public:
RlvCriteriaCategoryCollector(const std::string& strCriteria)
{
std::string::size_type idxIt, idxLast = 0;
while (idxLast < strCriteria.length())
{
idxIt = strCriteria.find("&&", idxLast);
if (std::string::npos == idxIt)
idxIt = strCriteria.length();
if (idxIt != idxLast)
m_Criteria.push_back(strCriteria.substr(idxLast, idxIt - idxLast));
idxLast = idxIt + 2;
}
}
virtual ~RlvCriteriaCategoryCollector() {}
virtual bool operator()(LLInventoryCategory* pFolder, LLInventoryItem* pItem)
{
if ( (!pFolder) || (m_Criteria.empty()) ) // We're only interested in matching folders, we don't care about items
return false; // (if there are no criteria then we don't want to return a match)
std::string strFolderName = pFolder->getName();
LLStringUtil::toLower(strFolderName);
if ( (strFolderName.empty()) || (RLV_FOLDER_PREFIX_HIDDEN == strFolderName[0]) )
return false;
for (std::list<std::string>::const_iterator itCrit = m_Criteria.begin(); itCrit != m_Criteria.end(); ++itCrit)
if (std::string::npos == strFolderName.find(*itCrit)) // Return false on the first mismatch
return false;
return true;
}
protected:
std::list<std::string> m_Criteria;
};
// ============================================================================
// RlvWearableItemCollector - Inventory item filter used by attach/detach/attachall/detachall/getinvworn
//
class RlvWearableItemCollector : public LLInventoryCollectFunctor
{
public:
RlvWearableItemCollector(const LLUUID& idFolder, bool fAttach, bool fMatchAll)
: m_idFolder(idFolder), m_fAttach(fAttach), m_fMatchAll(fMatchAll)
{
m_Wearable.push_back(idFolder);
}
virtual ~RlvWearableItemCollector() {}
virtual bool operator()(LLInventoryCategory* pFolder, LLInventoryItem* pItem);
const LLUUID& getFoldedParent(const LLUUID& idFolder) const;
protected:
bool m_fAttach;
bool m_fMatchAll;
const LLUUID m_idFolder;
bool onCollectFolder(const LLInventoryCategory* pFolder);
bool onCollectItem(const LLInventoryItem* pItem);
std::list<LLUUID> m_Tentative;
std::list<LLUUID> m_Wearable;
std::map<LLUUID, LLUUID> m_Folding;
};
// ============================================================================
// RlvRetainedCommand
//
struct RlvRetainedCommand
{
public:
std::string strObject;
LLUUID idObject;
std::string strCmd;
RlvRetainedCommand(const std::string obj, const LLUUID& uuid, const std::string& cmd) : strObject(obj), idObject(uuid), strCmd(cmd) {}
private:
RlvRetainedCommand();
};
typedef std::list<RlvRetainedCommand> rlv_retained_list_t;
// ============================================================================
// RlvWLSnapshot
//
struct RlvWLSnapshot
{
public:
static void restoreSnapshot(const RlvWLSnapshot* pWLSnapshot);
static RlvWLSnapshot* takeSnapshot();
private:
RlvWLSnapshot() {}
bool fIsRunning;
bool fUseLindenTime;
LLWLParamSet WLParams;
};
// ============================================================================
// RlvSettings
//
inline BOOL rlvGetSettingBOOL(const std::string& strSetting, BOOL fDefault)
{
return (gSavedSettings.controlExists(strSetting)) ? gSavedSettings.getBOOL(strSetting) : fDefault;
}
inline BOOL rlvGetPerUserSettingsBOOL(const std::string& strSetting, BOOL fDefault)
{
return (gSavedPerAccountSettings.controlExists(strSetting)) ? gSavedPerAccountSettings.getBOOL(strSetting) : fDefault;
}
class RlvSettings
{
public:
static BOOL getDebug() { return rlvGetSettingBOOL(RLV_SETTING_DEBUG, FALSE); }
static BOOL getForbidGiveToRLV() { return rlvGetSettingBOOL(RLV_SETTING_FORBIDGIVETORLV, TRUE); }
static BOOL getEnableWear() { return rlvGetSettingBOOL(RLV_SETTING_ENABLEWEAR, FALSE); }
static BOOL getHideLockedLayers() { return rlvGetSettingBOOL(RLV_SETTING_HIDELOCKEDLAYER, FALSE); }
static BOOL getHideLockedAttach() { return rlvGetSettingBOOL(RLV_SETTING_HIDELOCKEDATTACH, FALSE); }
static BOOL getHideLockedInventory() { return rlvGetSettingBOOL(RLV_SETTING_HIDELOCKEDINVENTORY, FALSE); }
static BOOL getShowNameTags() { return fShowNameTags; }
#ifdef RLV_EXTENSION_STARTLOCATION
static BOOL getLoginLastLocation() { return rlvGetPerUserSettingsBOOL(RLV_SETTING_LOGINLASTLOCATION, TRUE); }
static void updateLoginLastLocation();
#endif // RLV_EXTENSION_STARTLOCATION
static BOOL fShowNameTags;
};
// ============================================================================
// State keeping classes/structure
//
// ============================================================================
// Various helper classes/timers/functors
//
class RlvGCTimer : public LLEventTimer
{
public:
RlvGCTimer() : LLEventTimer(30.0) {}
virtual BOOL tick();
};
class RlvCurrentlyWorn : public LLInventoryFetchObserver
{
public:
RlvCurrentlyWorn() {}
~RlvCurrentlyWorn() {}
virtual void done() {}
static void fetchWorn();
void fetchItem(const LLUUID& idItem);
};
struct RlvSelectHasLockedAttach : public LLSelectedNodeFunctor
{
virtual bool apply(LLSelectNode* pNode);
};
struct RlvSelectIsOwnedByOrGroupOwned : public LLSelectedNodeFunctor
{
RlvSelectIsOwnedByOrGroupOwned(const LLUUID& uuid) : m_idAgent(uuid) {}
virtual bool apply(LLSelectNode* pNode);
LLUUID m_idAgent;
};
struct RlvSelectIsSittingOn : public LLSelectedNodeFunctor
{
RlvSelectIsSittingOn(LLXform* pObject) : m_pObject(pObject) {}
virtual bool apply(LLSelectNode* pNode);
LLXform* m_pObject;
};
// ============================================================================
// Various helper functions
//
BOOL rlvAttachToEnabler(void* pParam);
bool rlvCanDeleteOrReturn();
S32 rlvGetDirectDescendentsCount(const LLInventoryCategory* pFolder, LLAssetType::EType type);
bool rlvIsEmote(const std::string& strUTF8Text);
bool rlvIsValidReplyChannel(S32 nChannel);
bool rlvIsWearingItem(const LLInventoryItem* pItem);
void rlvForceDetach(LLViewerJointAttachment* pAttachPt);
void rlvSendBusyMessage(const LLUUID& idTo, const std::string& strMsg, const LLUUID& idSession = LLUUID::null);
bool rlvSendChatReply(const std::string& strChannel, const std::string& strReply);
bool rlvSendChatReply(S32 nChannel, const std::string& strReply);
std::string rlvGetFirstParenthesisedText(const std::string& strText, std::string::size_type* pidxMatch = NULL);
std::string rlvGetLastParenthesisedText(const std::string& strText, std::string::size_type* pidxStart = NULL);
void rlvStringReplace(std::string& strText, std::string strFrom, const std::string& strTo);
#ifdef RLV_ADVANCED_TOGGLE_RLVA
// "Advanced / RLVa / Enable RLV" menu option
void rlvToggleEnabled(void*);
BOOL rlvGetEnabled(void*);
#endif // RLV_ADVANCED_TOGGLE_RLVA
// ============================================================================
// Debug helper functions
//
// ============================================================================
// Inlined class member functions
//
// Checked: 2009-09-19 (RLVa-1.0.3d)
inline std::string RlvCommand::asString() const
{
// NOTE: @clear=<param> should be represented as clear:<param>
return (m_eParamType != RLV_TYPE_CLEAR)
? (!m_strOption.empty()) ? (std::string(m_strBehaviour)).append(":").append(m_strOption) : (std::string(m_strBehaviour))
: (!m_strParam.empty()) ? (std::string(m_strBehaviour)).append(":").append(m_strParam) : (std::string(m_strBehaviour));
}
inline bool RlvCommand::operator ==(const RlvCommand& rhs) const
{
// The specification notes that "@detach=n" is semantically identical to "@detach=add" (same for "y" and "rem"
return (m_strBehaviour == rhs.m_strBehaviour) && (m_strOption == rhs.m_strOption) &&
( (RLV_TYPE_UNKNOWN != m_eParamType) ? (m_eParamType == rhs.m_eParamType) : (m_strParam == rhs.m_strParam) );
}
inline void RlvCurrentlyWorn::fetchItem(const LLUUID& idItem)
{
if (idItem.notNull())
{
LLInventoryFetchObserver::item_ref_t idItems;
idItems.push_back(idItem);
fetchItems(idItems);
}
}
// ============================================================================
// Inlined helper functions
//
inline bool rlvIsEmote(const std::string& strUTF8Text)
{
return (strUTF8Text.length() > 4) && ( (strUTF8Text.compare(0, 4, "/me ") == 0) || (strUTF8Text.compare(0, 4, "/me'") == 0) );
}
// Checked: 2009-09-05 (RLVa-1.0.2a) | Added: RLVa-1.0.2a
inline bool rlvIsValidReplyChannel(S32 nChannel)
{
return (nChannel > 0) && (CHAT_CHANNEL_DEBUG != nChannel);
}
// Checked: 2009-08-05 (RLVa-1.0.1e) | Added: RLVa-1.0.0e
inline bool rlvSendChatReply(const std::string& strChannel, const std::string& strReply)
{
S32 nChannel;
return (LLStringUtil::convertToS32(strChannel, nChannel)) ? rlvSendChatReply(nChannel, strReply) : false;
}
// ============================================================================
#endif // RLV_HELPER_H
|