Refactoring carousel: combine all the different force-wear commands into one virtual RLV_CMD_FORCEWEAR command

--HG--
branch : RLVa
meow-7.2.2
Kitty Barnett 2016-03-28 20:00:15 +02:00
parent ee951f8fc7
commit c372dd36a8
5 changed files with 118 additions and 136 deletions

View File

@ -117,7 +117,6 @@ const S32 RLVa_VERSION_BUILD = 0;
// NOTE: any changes to this enumeration should be reflected in the RlvBehaviourDictionary constructor
enum ERlvBehaviour {
RLV_BHVR_DETACH = 0, // "detach"
RLV_BHVR_ATTACH, // "attach"
RLV_BHVR_ADDATTACH, // "addattach"
RLV_BHVR_REMATTACH, // "remattach"
RLV_BHVR_ADDOUTFIT, // "addoutfit"
@ -190,20 +189,10 @@ enum ERlvBehaviour {
RLV_BHVR_ALWAYSRUN, // "alwaysrun"
RLV_BHVR_TEMPRUN, // "temprun"
RLV_BHVR_DETACHME, // "detachme"
RLV_BHVR_ATTACHOVER, // "attachover"
RLV_BHVR_ATTACHTHIS, // "attachthis"
RLV_BHVR_ATTACHTHISOVER, // "attachthisover"
RLV_BHVR_ATTACHTHISEXCEPT, // "attachthis_except"
RLV_BHVR_DETACHTHIS, // "detachthis"
RLV_BHVR_DETACHTHISEXCEPT, // "detachthis_except"
RLV_BHVR_ATTACHALL, // "attachall"
RLV_BHVR_ATTACHALLOVER, // "attachallover"
RLV_BHVR_DETACHALL, // "detachall"
RLV_BHVR_ATTACHALLTHIS, // "attachallthis"
RLV_BHVR_ATTACHALLTHISEXCEPT, // "attachallthis_except"
RLV_BHVR_ATTACHALLTHISOVER, // "attachallthisover"
RLV_BHVR_DETACHALLTHIS, // "detachallthis"
RLV_BHVR_DETACHALLTHISEXCEPT, // "detachallthis_except"
RLV_BHVR_ADJUSTHEIGHT, // "adjustheight"
RLV_BHVR_TPTO, // "tpto"
RLV_BHVR_VERSION, // "version"
@ -228,6 +217,7 @@ enum ERlvBehaviour {
RLV_BHVR_GETCOMMAND, // "getcommand"
RLV_BHVR_GETSTATUS, // "getstatus"
RLV_BHVR_GETSTATUSALL, // "getstatusall"
RLV_CMD_FORCEWEAR, // Internal representation of all force wear commands
RLV_BHVR_COUNT,
RLV_BHVR_UNKNOWN

View File

@ -1155,14 +1155,10 @@ ERlvCmdRet RlvHandler::processAddRemCommand(const RlvCommand& rlvCmd)
break;
case RLV_BHVR_ATTACHTHIS: // @attachthis[:<option>]=n|y
case RLV_BHVR_DETACHTHIS: // @detachthis[:<option>]=n|y
case RLV_BHVR_ATTACHALLTHIS: // @attachtallhis[:<option>]=n|y
case RLV_BHVR_DETACHALLTHIS: // @detachallthis[:<option>]=n|y
eRet = onAddRemFolderLock(rlvCmd, fRefCount);
break;
case RLV_BHVR_ATTACHTHISEXCEPT: // @attachthisexcept[:<option>]=n|y
case RLV_BHVR_DETACHTHISEXCEPT: // @detachthisexcept[:<option>]=n|y
case RLV_BHVR_ATTACHALLTHISEXCEPT: // @attachallthisexcept[:<option>]=n|y
case RLV_BHVR_DETACHALLTHISEXCEPT: // @detachallthisexcept[:<option>]=n|y
eRet = onAddRemFolderLockException(rlvCmd, fRefCount);
break;
case RLV_BHVR_SETENV: // @setenv=n|y - Checked: 2011-09-04 (RLVa-1.4.1a) | Modified: RLVa-1.4.1a
@ -1530,15 +1526,12 @@ ERlvCmdRet RlvHandler::onAddRemFolderLock(const RlvCommand& rlvCmd, bool& fRefCo
return RLV_RET_FAILED_OPTION;
}
ERlvBehaviour eBhvr = rlvCmd.getBehaviourType();
// Determine the lock type
ERlvLockMask eLockType = ((RLV_BHVR_ATTACHTHIS == eBhvr) || (RLV_BHVR_ATTACHALLTHIS == eBhvr)) ? RLV_LOCK_ADD : RLV_LOCK_REMOVE;
ERlvLockMask eLockType = (RLV_BHVR_ATTACHTHIS == rlvCmd.getBehaviourType()) ? RLV_LOCK_ADD : RLV_LOCK_REMOVE;
// Determine the folder lock options from the issued behaviour
RlvFolderLocks::ELockPermission eLockPermission = RlvFolderLocks::PERM_DENY;
RlvFolderLocks::ELockScope eLockScope =
((RLV_BHVR_ATTACHALLTHIS == eBhvr) || (RLV_BHVR_DETACHALLTHIS == eBhvr)) ? RlvFolderLocks::SCOPE_SUBTREE : RlvFolderLocks::SCOPE_NODE;
RlvFolderLocks::ELockScope eLockScope = (RlvBehaviourInfo::FORCEWEAR_SUBTREE & rlvCmd.getBehaviourFlags()) ? RlvFolderLocks::SCOPE_SUBTREE : RlvFolderLocks::SCOPE_NODE;
if (RLV_TYPE_ADD == rlvCmd.getParamType())
RlvFolderLocks::instance().addFolderLock(lockSource, eLockPermission, eLockScope, rlvCmd.getObjectID(), eLockType);
@ -1560,13 +1553,11 @@ ERlvCmdRet RlvHandler::onAddRemFolderLockException(const RlvCommand& rlvCmd, boo
ERlvBehaviour eBhvr = rlvCmd.getBehaviourType();
// Determine the lock type
ERlvLockMask eLockType =
((RLV_BHVR_ATTACHTHISEXCEPT == eBhvr) || (RLV_BHVR_ATTACHALLTHISEXCEPT == eBhvr)) ? RLV_LOCK_ADD : RLV_LOCK_REMOVE;
ERlvLockMask eLockType = (RLV_BHVR_ATTACHTHISEXCEPT == eBhvr) ? RLV_LOCK_ADD : RLV_LOCK_REMOVE;
// Determine the folder lock options from the issued behaviour
RlvFolderLocks::ELockPermission eLockPermission = RlvFolderLocks::PERM_ALLOW;
RlvFolderLocks::ELockScope eLockScope =
((RLV_BHVR_ATTACHALLTHISEXCEPT == eBhvr) || (RLV_BHVR_DETACHALLTHISEXCEPT == eBhvr)) ? RlvFolderLocks::SCOPE_SUBTREE : RlvFolderLocks::SCOPE_NODE;
RlvFolderLocks::ELockScope eLockScope = (RlvBehaviourInfo::FORCEWEAR_SUBTREE & rlvCmd.getBehaviourFlags()) ? RlvFolderLocks::SCOPE_SUBTREE : RlvFolderLocks::SCOPE_NODE;
RlvFolderLocks::folderlock_source_t lockSource(RlvFolderLocks::ST_SHAREDPATH, rlvCmd.getOption());
if (RLV_TYPE_ADD == rlvCmd.getParamType())
@ -1595,7 +1586,7 @@ ERlvCmdRet RlvHandler::processForceCommand(const RlvCommand& rlvCmd) const
{
RlvCommandOptionGeneric rlvCmdOption(rlvCmd.getOption());
if (rlvCmdOption.isSharedFolder())
eRet = onForceWear(rlvCmdOption.getSharedFolder(), RLV_BHVR_DETACH);
eRet = onForceWear(rlvCmdOption.getSharedFolder(), rlvCmd.getBehaviourFlags());
else
eRet = onForceRemAttach(rlvCmd);
}
@ -1604,7 +1595,7 @@ ERlvCmdRet RlvHandler::processForceCommand(const RlvCommand& rlvCmd) const
{
RlvCommandOptionGeneric rlvCmdOption(rlvCmd.getOption());
if (rlvCmdOption.isSharedFolder())
eRet = onForceWear(rlvCmdOption.getSharedFolder(), RLV_BHVR_DETACH);
eRet = onForceWear(rlvCmdOption.getSharedFolder(), rlvCmd.getBehaviourFlags());
else
eRet = onForceRemOutfit(rlvCmd);
}
@ -1653,30 +1644,6 @@ ERlvCmdRet RlvHandler::processForceCommand(const RlvCommand& rlvCmd) const
gAgent.teleportViaLocation(rlvCmdOption.m_posGlobal);
}
break;
case RLV_BHVR_ATTACH:
case RLV_BHVR_ATTACHOVER:
case RLV_BHVR_ATTACHALL:
case RLV_BHVR_ATTACHALLOVER:
case RLV_BHVR_DETACHALL:
{
RlvCommandOptionGeneric rlvCmdOption(rlvCmd.getOption());
VERIFY_OPTION(rlvCmdOption.isSharedFolder());
eRet = onForceWear(rlvCmdOption.getSharedFolder(), rlvCmd.getBehaviourType());
}
break;
case RLV_BHVR_ATTACHTHIS:
case RLV_BHVR_ATTACHTHISOVER:
case RLV_BHVR_DETACHTHIS:
case RLV_BHVR_ATTACHALLTHIS:
case RLV_BHVR_ATTACHALLTHISOVER:
case RLV_BHVR_DETACHALLTHIS:
{
RlvCommandOptionGetPath rlvGetPathOption(rlvCmd, boost::bind(&RlvHandler::onForceWearCallback, this, _1, rlvCmd.getBehaviourType()));
VERIFY_OPTION(rlvGetPathOption.isValid());
eRet = (!rlvGetPathOption.isCallback()) ? RLV_RET_SUCCESS : RLV_RET_SUCCESS_DELAYED;
}
break;
case RLV_BHVR_DETACHME: // @detachme=force - Checked: 2010-09-04 (RLVa-1.2.1c) | Modified: RLVa-1.2.1c
{
VERIFY_OPTION(rlvCmd.getOption().empty());
@ -1688,6 +1655,22 @@ ERlvCmdRet RlvHandler::processForceCommand(const RlvCommand& rlvCmd) const
}
}
break;
case RLV_CMD_FORCEWEAR: // @forcewear[:<options>]=force - Checked: 2011-09-12 (RLVa-1.5.0)
{
if (RlvBehaviourInfo::FORCEWEAR_CONTEXT_NONE & rlvCmd.getBehaviourFlags())
{
RlvCommandOptionGeneric rlvCmdOption(rlvCmd.getOption());
VERIFY_OPTION(rlvCmdOption.isSharedFolder());
eRet = onForceWear(rlvCmdOption.getSharedFolder(), rlvCmd.getBehaviourFlags());
}
else if (RlvBehaviourInfo::FORCEWEAR_CONTEXT_OBJECT & rlvCmd.getBehaviourFlags())
{
RlvCommandOptionGetPath rlvGetPathOption(rlvCmd, boost::bind(&RlvHandler::onForceWearCallback, this, _1, rlvCmd.getBehaviourFlags()));
VERIFY_OPTION(rlvGetPathOption.isValid());
eRet = (!rlvGetPathOption.isCallback()) ? RLV_RET_SUCCESS : RLV_RET_SUCCESS_DELAYED;
}
}
break;
case RLV_BHVR_UNKNOWN:
// Pass unknown commands on to registered command handlers
return (notifyCommandHandlers(&RlvCommandHandler::onForceCommand, rlvCmd, eRet, false)) ? eRet : RLV_RET_FAILED_UNKNOWN;
@ -1812,41 +1795,27 @@ ERlvCmdRet RlvHandler::onForceSit(const RlvCommand& rlvCmd) const
}
// Checked: 2010-08-30 (RLVa-1.2.1c) | Modified: RLVa-1.2.1c
ERlvCmdRet RlvHandler::onForceWear(const LLViewerInventoryCategory* pFolder, ERlvBehaviour eBhvr) const
ERlvCmdRet RlvHandler::onForceWear(const LLViewerInventoryCategory* pFolder, U32 nFlags) const
{
if ( (pFolder) && (!RlvInventory::instance().isSharedFolder(pFolder->getUUID())) )
if ( (!pFolder) || (!RlvInventory::instance().isSharedFolder(pFolder->getUUID())) )
return RLV_RET_FAILED_OPTION;
RlvForceWear::EWearAction eAction = RlvForceWear::ACTION_WEAR_REPLACE;
if ( (RLV_BHVR_ATTACHOVER == eBhvr) || (RLV_BHVR_ATTACHTHISOVER == eBhvr) ||
(RLV_BHVR_ATTACHALLOVER == eBhvr) || (RLV_BHVR_ATTACHALLTHISOVER == eBhvr) )
{
eAction = RlvForceWear::ACTION_WEAR_ADD;
}
else if ( (RLV_BHVR_DETACH == eBhvr) || (RLV_BHVR_DETACHTHIS == eBhvr) ||
(RLV_BHVR_DETACHALL == eBhvr) || (RLV_BHVR_DETACHALLTHIS == eBhvr) )
{
eAction = RlvForceWear::ACTION_REMOVE;
}
RlvForceWear::EWearFlags eFlags = RlvForceWear::FLAG_DEFAULT;
if ( (RLV_BHVR_ATTACHALL == eBhvr) || (RLV_BHVR_ATTACHALLOVER == eBhvr) || (RLV_BHVR_DETACHALL == eBhvr) ||
(RLV_BHVR_ATTACHALLTHIS == eBhvr) || (RLV_BHVR_ATTACHALLTHISOVER == eBhvr) || (RLV_BHVR_DETACHALLTHIS == eBhvr) )
{
eFlags = (RlvForceWear::EWearFlags)(eFlags | RlvForceWear::FLAG_MATCHALL);
}
RlvForceWear::EWearAction eAction = (RlvBehaviourInfo::FORCEWEAR_WEAR_REMOVE & nFlags) ? RlvForceWear::ACTION_REMOVE
: ((RlvBehaviourInfo::FORCEWEAR_WEAR_ADD & nFlags) ? RlvForceWear::ACTION_WEAR_ADD
: RlvForceWear::ACTION_WEAR_REPLACE);
RlvForceWear::EWearFlags eFlags = (RlvBehaviourInfo::FORCEWEAR_SUBTREE & nFlags) ? RlvForceWear::FLAG_MATCHALL : RlvForceWear::FLAG_DEFAULT;
RlvForceWear::instance().forceFolder(pFolder, eAction, eFlags);
return RLV_RET_SUCCESS;
}
void RlvHandler::onForceWearCallback(const uuid_vec_t& idItems, ERlvBehaviour eBhvr) const
void RlvHandler::onForceWearCallback(const uuid_vec_t& idItems, U32 nFlags) const
{
LLInventoryModel::cat_array_t folders;
if (RlvInventory::instance().getPath(idItems, folders))
{
for (S32 idxFolder = 0, cntFolder = folders.size(); idxFolder < cntFolder; idxFolder++)
onForceWear(folders.at(idxFolder), eBhvr);
onForceWear(folders.at(idxFolder), nFlags);
// If we're not executing a command then we're a delayed callback and need to manually call done()
if ( (!getCurrentCommand()) && (RlvForceWear::instanceExists()) )

View File

@ -168,8 +168,8 @@ protected:
ERlvCmdRet onForceRemOutfit(const RlvCommand& rlvCmd) const;
ERlvCmdRet onForceGroup(const RlvCommand& rlvCmd) const;
ERlvCmdRet onForceSit(const RlvCommand& rlvCmd) const;
ERlvCmdRet onForceWear(const LLViewerInventoryCategory* pFolder, ERlvBehaviour eBhvr) const;
void onForceWearCallback(const uuid_vec_t& idItems, ERlvBehaviour eBhvr) const;
ERlvCmdRet onForceWear(const LLViewerInventoryCategory* pFolder, U32 nFlags) const;
void onForceWearCallback(const uuid_vec_t& idItems, U32 nFlags) const;
// Command handlers (RLV_TYPE_REPLY)
ERlvCmdRet processReplyCommand(const RlvCommand& rlvCmd) const;
ERlvCmdRet onFindFolder(const RlvCommand& rlvCmd, std::string& strReply) const;

View File

@ -35,20 +35,27 @@
RlvBehaviourDictionary::RlvBehaviourDictionary()
{
//
// "Restrictions"
// Restrictions
//
addEntry(new RlvBehaviourInfo("acceptpermission", RLV_BHVR_ACCEPTPERMISSION, RLV_TYPE_ADDREM));
addEntry(new RlvBehaviourInfo("accepttp", RLV_BHVR_ACCEPTTP, RLV_TYPE_ADDREM, RlvBehaviourInfo::BHVR_STRICT));
addEntry(new RlvBehaviourInfo("accepttprequest", RLV_BHVR_ACCEPTTPREQUEST, RLV_TYPE_ADDREM, RlvBehaviourInfo::BHVR_EXTENDED | RlvBehaviourInfo::BHVR_STRICT));
addEntry(new RlvBehaviourInfo("addattach", RLV_BHVR_ADDATTACH, RLV_TYPE_ADDREM));
addEntry(new RlvBehaviourInfo("addoutfit", RLV_BHVR_ADDOUTFIT, RLV_TYPE_ADDREM));
addEntry(new RlvBehaviourInfo("allowidle", RLV_BHVR_ALLOWIDLE, RLV_TYPE_ADDREM, RlvBehaviourInfo::BHVR_EXPERIMENTAL));
addEntry(new RlvBehaviourInfo("alwaysrun", RLV_BHVR_ALWAYSRUN, RLV_TYPE_ADDREM));
addEntry(new RlvBehaviourInfo("attachallthis_except", RLV_BHVR_ATTACHALLTHISEXCEPT, RLV_TYPE_ADDREM));
addEntry(new RlvBehaviourInfo("attachthis_except", RLV_BHVR_ATTACHTHISEXCEPT, RLV_TYPE_ADDREM));
addEntry(new RlvBehaviourInfo("attachthis", RLV_BHVR_ATTACHTHIS, RLV_TYPE_ADDREM, RlvBehaviourInfo::FORCEWEAR_NODE));
addEntry(new RlvBehaviourInfo("attachallthis", RLV_BHVR_ATTACHTHIS, RLV_TYPE_ADDREM, RlvBehaviourInfo::FORCEWEAR_SUBTREE));
addEntry(new RlvBehaviourInfo("attachthis_except", RLV_BHVR_ATTACHTHISEXCEPT, RLV_TYPE_ADDREM, RlvBehaviourInfo::FORCEWEAR_NODE));
addEntry(new RlvBehaviourInfo("attachallthis_except", RLV_BHVR_ATTACHTHISEXCEPT, RLV_TYPE_ADDREM, RlvBehaviourInfo::FORCEWEAR_SUBTREE));
addEntry(new RlvBehaviourInfo("chatwhisper", RLV_BHVR_CHATWHISPER, RLV_TYPE_ADDREM));
addEntry(new RlvBehaviourInfo("chatnormal", RLV_BHVR_CHATNORMAL, RLV_TYPE_ADDREM));
addEntry(new RlvBehaviourInfo("chatshout", RLV_BHVR_CHATSHOUT, RLV_TYPE_ADDREM));
addEntry(new RlvBehaviourInfo("detachallthis_except", RLV_BHVR_DETACHALLTHISEXCEPT, RLV_TYPE_ADDREM));
addEntry(new RlvBehaviourInfo("detachthis_except", RLV_BHVR_DETACHTHISEXCEPT, RLV_TYPE_ADDREM));
addEntry(new RlvBehaviourInfo("detach", RLV_BHVR_DETACH, RLV_TYPE_ADDREM));
addEntry(new RlvBehaviourInfo("detachthis", RLV_BHVR_DETACHTHIS, RLV_TYPE_ADDREM, RlvBehaviourInfo::FORCEWEAR_NODE));
addEntry(new RlvBehaviourInfo("detachallthis", RLV_BHVR_DETACHTHIS, RLV_TYPE_ADDREM, RlvBehaviourInfo::FORCEWEAR_SUBTREE));
addEntry(new RlvBehaviourInfo("detachthis_except", RLV_BHVR_DETACHTHISEXCEPT, RLV_TYPE_ADDREM, RlvBehaviourInfo::FORCEWEAR_NODE));
addEntry(new RlvBehaviourInfo("detachallthis_except", RLV_BHVR_DETACHTHISEXCEPT, RLV_TYPE_ADDREM, RlvBehaviourInfo::FORCEWEAR_SUBTREE));
addEntry(new RlvBehaviourInfo("edit", RLV_BHVR_EDIT, RLV_TYPE_ADDREM));
addEntry(new RlvBehaviourInfo("editobj", RLV_BHVR_EDITOBJ, RLV_TYPE_ADDREM));
addEntry(new RlvBehaviourInfo("emote", RLV_BHVR_EMOTE, RLV_TYPE_ADDREM));
@ -65,6 +72,8 @@ RlvBehaviourDictionary::RlvBehaviourDictionary()
addEntry(new RlvBehaviourInfo("recvimfrom", RLV_BHVR_RECVIMFROM, RLV_TYPE_ADDREM, RlvBehaviourInfo::BHVR_STRICT));
addEntry(new RlvBehaviourInfo("redirchat", RLV_BHVR_REDIRCHAT, RLV_TYPE_ADDREM));
addEntry(new RlvBehaviourInfo("rediremote", RLV_BHVR_REDIREMOTE, RLV_TYPE_ADDREM));
addEntry(new RlvBehaviourInfo("remattach", RLV_BHVR_REMATTACH, RLV_TYPE_ADDREM));
addEntry(new RlvBehaviourInfo("remoutfit", RLV_BHVR_REMOUTFIT, RLV_TYPE_ADDREM));
addEntry(new RlvBehaviourInfo("rez", RLV_BHVR_REZ, RLV_TYPE_ADDREM));
addEntry(new RlvBehaviourInfo("sendchannel", RLV_BHVR_SENDCHANNEL, RLV_TYPE_ADDREM, RlvBehaviourInfo::BHVR_STRICT));
addEntry(new RlvBehaviourInfo("sendchat", RLV_BHVR_SENDCHAT, RLV_TYPE_ADDREM));
@ -107,40 +116,48 @@ RlvBehaviourDictionary::RlvBehaviourDictionary()
addEntry(new RlvBehaviourInfo("viewscript", RLV_BHVR_VIEWSCRIPT, RLV_TYPE_ADDREM));
addEntry(new RlvBehaviourInfo("viewtexture", RLV_BHVR_VIEWTEXTURE, RLV_TYPE_ADDREM));
//
// Force-wear
//
addEntry(new RlvBehaviourInfo("attach", RLV_CMD_FORCEWEAR, RLV_TYPE_FORCE, RlvBehaviourInfo::FORCEWEAR_WEAR_REPLACE | RlvBehaviourInfo::FORCEWEAR_NODE | RlvBehaviourInfo::FORCEWEAR_CONTEXT_NONE));
addEntry(new RlvBehaviourInfo("attachall", RLV_CMD_FORCEWEAR, RLV_TYPE_FORCE, RlvBehaviourInfo::FORCEWEAR_WEAR_REPLACE | RlvBehaviourInfo::FORCEWEAR_SUBTREE | RlvBehaviourInfo::FORCEWEAR_CONTEXT_NONE));
addEntry(new RlvBehaviourInfo("attachover", RLV_CMD_FORCEWEAR, RLV_TYPE_FORCE, RlvBehaviourInfo::FORCEWEAR_WEAR_ADD | RlvBehaviourInfo::FORCEWEAR_NODE | RlvBehaviourInfo::FORCEWEAR_CONTEXT_NONE));
addEntry(new RlvBehaviourInfo("attachallover", RLV_CMD_FORCEWEAR, RLV_TYPE_FORCE, RlvBehaviourInfo::FORCEWEAR_WEAR_ADD | RlvBehaviourInfo::FORCEWEAR_SUBTREE | RlvBehaviourInfo::FORCEWEAR_CONTEXT_NONE));
addEntry(new RlvBehaviourInfo("attachthis", RLV_CMD_FORCEWEAR, RLV_TYPE_FORCE, RlvBehaviourInfo::FORCEWEAR_WEAR_REPLACE | RlvBehaviourInfo::FORCEWEAR_NODE | RlvBehaviourInfo::FORCEWEAR_CONTEXT_OBJECT));
addEntry(new RlvBehaviourInfo("attachallthis", RLV_CMD_FORCEWEAR, RLV_TYPE_FORCE, RlvBehaviourInfo::FORCEWEAR_WEAR_REPLACE | RlvBehaviourInfo::FORCEWEAR_SUBTREE | RlvBehaviourInfo::FORCEWEAR_CONTEXT_OBJECT));
addEntry(new RlvBehaviourInfo("attachthisover", RLV_CMD_FORCEWEAR, RLV_TYPE_FORCE, RlvBehaviourInfo::FORCEWEAR_WEAR_ADD | RlvBehaviourInfo::FORCEWEAR_NODE | RlvBehaviourInfo::FORCEWEAR_CONTEXT_OBJECT));
addEntry(new RlvBehaviourInfo("attachallthisover", RLV_CMD_FORCEWEAR, RLV_TYPE_FORCE, RlvBehaviourInfo::FORCEWEAR_WEAR_ADD | RlvBehaviourInfo::FORCEWEAR_SUBTREE | RlvBehaviourInfo::FORCEWEAR_CONTEXT_OBJECT));
addEntry(new RlvBehaviourInfo("detach", RLV_BHVR_DETACH, RLV_TYPE_FORCE, RlvBehaviourInfo::FORCEWEAR_WEAR_REMOVE | RlvBehaviourInfo::FORCEWEAR_NODE | RlvBehaviourInfo::FORCEWEAR_CONTEXT_NONE));
addEntry(new RlvBehaviourInfo("detachall", RLV_CMD_FORCEWEAR, RLV_TYPE_FORCE, RlvBehaviourInfo::FORCEWEAR_WEAR_REMOVE | RlvBehaviourInfo::FORCEWEAR_SUBTREE | RlvBehaviourInfo::FORCEWEAR_CONTEXT_NONE));
addEntry(new RlvBehaviourInfo("detachthis", RLV_CMD_FORCEWEAR, RLV_TYPE_FORCE, RlvBehaviourInfo::FORCEWEAR_WEAR_REMOVE | RlvBehaviourInfo::FORCEWEAR_NODE | RlvBehaviourInfo::FORCEWEAR_CONTEXT_OBJECT));
addEntry(new RlvBehaviourInfo("detachallthis", RLV_CMD_FORCEWEAR, RLV_TYPE_FORCE, RlvBehaviourInfo::FORCEWEAR_WEAR_REMOVE | RlvBehaviourInfo::FORCEWEAR_SUBTREE | RlvBehaviourInfo::FORCEWEAR_CONTEXT_OBJECT));
addEntry(new RlvBehaviourInfo("remattach", RLV_BHVR_REMATTACH, RLV_TYPE_FORCE, RlvBehaviourInfo::FORCEWEAR_WEAR_REMOVE | RlvBehaviourInfo::FORCEWEAR_NODE | RlvBehaviourInfo::FORCEWEAR_CONTEXT_NONE));
addEntry(new RlvBehaviourInfo("remoutfit", RLV_BHVR_REMOUTFIT, RLV_TYPE_FORCE, RlvBehaviourInfo::FORCEWEAR_WEAR_REMOVE | RlvBehaviourInfo::FORCEWEAR_NODE | RlvBehaviourInfo::FORCEWEAR_CONTEXT_NONE));
// Synonyms (addoutfit* -> attach*)
addEntry(new RlvBehaviourInfo("addoutfit", RLV_CMD_FORCEWEAR, RLV_TYPE_FORCE, RlvBehaviourInfo::FORCEWEAR_WEAR_REPLACE | RlvBehaviourInfo::FORCEWEAR_NODE | RlvBehaviourInfo::FORCEWEAR_CONTEXT_NONE | RlvBehaviourInfo::BHVR_SYNONYM));
addEntry(new RlvBehaviourInfo("addoutfitall", RLV_CMD_FORCEWEAR, RLV_TYPE_FORCE, RlvBehaviourInfo::FORCEWEAR_WEAR_REPLACE | RlvBehaviourInfo::FORCEWEAR_SUBTREE | RlvBehaviourInfo::FORCEWEAR_CONTEXT_NONE | RlvBehaviourInfo::BHVR_SYNONYM));
addEntry(new RlvBehaviourInfo("addoutfitover", RLV_CMD_FORCEWEAR, RLV_TYPE_FORCE, RlvBehaviourInfo::FORCEWEAR_WEAR_ADD | RlvBehaviourInfo::FORCEWEAR_NODE | RlvBehaviourInfo::FORCEWEAR_CONTEXT_NONE | RlvBehaviourInfo::BHVR_SYNONYM));
addEntry(new RlvBehaviourInfo("addoutfitallover", RLV_CMD_FORCEWEAR, RLV_TYPE_FORCE, RlvBehaviourInfo::FORCEWEAR_WEAR_ADD | RlvBehaviourInfo::FORCEWEAR_SUBTREE | RlvBehaviourInfo::FORCEWEAR_CONTEXT_NONE | RlvBehaviourInfo::BHVR_SYNONYM));
addEntry(new RlvBehaviourInfo("addoutfitthis", RLV_CMD_FORCEWEAR, RLV_TYPE_FORCE, RlvBehaviourInfo::FORCEWEAR_WEAR_REPLACE | RlvBehaviourInfo::FORCEWEAR_NODE | RlvBehaviourInfo::FORCEWEAR_CONTEXT_OBJECT | RlvBehaviourInfo::BHVR_SYNONYM));
addEntry(new RlvBehaviourInfo("addoutfitallthis", RLV_CMD_FORCEWEAR, RLV_TYPE_FORCE, RlvBehaviourInfo::FORCEWEAR_WEAR_REPLACE | RlvBehaviourInfo::FORCEWEAR_SUBTREE | RlvBehaviourInfo::FORCEWEAR_CONTEXT_OBJECT | RlvBehaviourInfo::BHVR_SYNONYM));
addEntry(new RlvBehaviourInfo("addoutfitthisover", RLV_CMD_FORCEWEAR, RLV_TYPE_FORCE, RlvBehaviourInfo::FORCEWEAR_WEAR_ADD | RlvBehaviourInfo::FORCEWEAR_NODE | RlvBehaviourInfo::FORCEWEAR_CONTEXT_OBJECT | RlvBehaviourInfo::BHVR_SYNONYM));
addEntry(new RlvBehaviourInfo("addoutfitallthisover", RLV_CMD_FORCEWEAR, RLV_TYPE_FORCE, RlvBehaviourInfo::FORCEWEAR_WEAR_ADD | RlvBehaviourInfo::FORCEWEAR_SUBTREE | RlvBehaviourInfo::FORCEWEAR_CONTEXT_OBJECT | RlvBehaviourInfo::BHVR_SYNONYM));
// Synonyms (attach*overorreplace -> attach*)
addEntry(new RlvBehaviourInfo("attachoverorreplace", RLV_CMD_FORCEWEAR, RLV_TYPE_FORCE, RlvBehaviourInfo::FORCEWEAR_WEAR_REPLACE | RlvBehaviourInfo::FORCEWEAR_NODE | RlvBehaviourInfo::FORCEWEAR_CONTEXT_NONE | RlvBehaviourInfo::BHVR_SYNONYM));
addEntry(new RlvBehaviourInfo("attachalloverorreplace", RLV_CMD_FORCEWEAR, RLV_TYPE_FORCE, RlvBehaviourInfo::FORCEWEAR_WEAR_REPLACE | RlvBehaviourInfo::FORCEWEAR_SUBTREE | RlvBehaviourInfo::FORCEWEAR_CONTEXT_NONE | RlvBehaviourInfo::BHVR_SYNONYM));
addEntry(new RlvBehaviourInfo("attachthisoverorreplace",RLV_CMD_FORCEWEAR, RLV_TYPE_FORCE, RlvBehaviourInfo::FORCEWEAR_WEAR_REPLACE | RlvBehaviourInfo::FORCEWEAR_NODE | RlvBehaviourInfo::FORCEWEAR_CONTEXT_OBJECT | RlvBehaviourInfo::BHVR_SYNONYM));
addEntry(new RlvBehaviourInfo("attachallthisoverorreplace",RLV_CMD_FORCEWEAR,RLV_TYPE_FORCE,RlvBehaviourInfo::FORCEWEAR_WEAR_REPLACE | RlvBehaviourInfo::FORCEWEAR_SUBTREE | RlvBehaviourInfo::FORCEWEAR_CONTEXT_OBJECT | RlvBehaviourInfo::BHVR_SYNONYM));
//
// Force-only
//
addEntry(new RlvBehaviourInfo("adjustheight", RLV_BHVR_ADJUSTHEIGHT, RLV_TYPE_FORCE));
addEntry(new RlvBehaviourInfo("attachall", RLV_BHVR_ATTACHALL, RLV_TYPE_FORCE));
addEntry(new RlvBehaviourInfo("attachallover", RLV_BHVR_ATTACHALLOVER, RLV_TYPE_FORCE));
addEntry(new RlvBehaviourInfo("attachallthisover", RLV_BHVR_ATTACHALLTHISOVER, RLV_TYPE_FORCE));
addEntry(new RlvBehaviourInfo("attachover", RLV_BHVR_ATTACHOVER, RLV_TYPE_FORCE));
addEntry(new RlvBehaviourInfo("attachthisover", RLV_BHVR_ATTACHTHISOVER, RLV_TYPE_FORCE));
addEntry(new RlvBehaviourInfo("detachall", RLV_BHVR_DETACHALL, RLV_TYPE_FORCE));
addEntry(new RlvBehaviourInfo("detachme", RLV_BHVR_DETACHME, RLV_TYPE_FORCE));
addEntry(new RlvBehaviourInfo("tpto", RLV_BHVR_TPTO, RLV_TYPE_FORCE));
// Synonyms (addoutfit* -> attach*)
addEntry(new RlvBehaviourInfo("addoutfitall", RLV_BHVR_ATTACHALL, RLV_TYPE_FORCE, RlvBehaviourInfo::BHVR_SYNONYM));
addEntry(new RlvBehaviourInfo("addoutfitallthis", RLV_BHVR_ATTACHALLTHIS, RLV_TYPE_FORCE, RlvBehaviourInfo::BHVR_SYNONYM));
addEntry(new RlvBehaviourInfo("addoutfitallover", RLV_BHVR_ATTACHALLOVER, RLV_TYPE_FORCE, RlvBehaviourInfo::BHVR_SYNONYM));
addEntry(new RlvBehaviourInfo("addoutfitallthisover", RLV_BHVR_ATTACHALLTHISOVER, RLV_TYPE_FORCE, RlvBehaviourInfo::BHVR_SYNONYM));
addEntry(new RlvBehaviourInfo("addoutfitover", RLV_BHVR_ATTACHOVER, RLV_TYPE_FORCE, RlvBehaviourInfo::BHVR_SYNONYM));
addEntry(new RlvBehaviourInfo("addoutfitthis", RLV_BHVR_ATTACHTHIS, RLV_TYPE_FORCE, RlvBehaviourInfo::BHVR_SYNONYM));
addEntry(new RlvBehaviourInfo("addoutfitthisover", RLV_BHVR_ATTACHTHISOVER, RLV_TYPE_FORCE, RlvBehaviourInfo::BHVR_SYNONYM));
//
// Mixed
//
addEntry(new RlvBehaviourInfo("addattach", RLV_BHVR_ADDATTACH, RLV_TYPE_ADDREM));
addEntry(new RlvBehaviourInfo("addoutfit", RLV_BHVR_ADDOUTFIT, RLV_TYPE_ADDREM));
addEntry(new RlvBehaviourInfo("attach", RLV_BHVR_ATTACH, RLV_TYPE_FORCE));
addEntry(new RlvBehaviourInfo("attachallthis", RLV_BHVR_ATTACHALLTHIS, RLV_TYPE_ADDREM | RLV_TYPE_FORCE));
addEntry(new RlvBehaviourInfo("attachthis", RLV_BHVR_ATTACHTHIS, RLV_TYPE_ADDREM | RLV_TYPE_FORCE));
addEntry(new RlvBehaviourInfo("detach", RLV_BHVR_DETACH, RLV_TYPE_ADDREM | RLV_TYPE_FORCE));
addEntry(new RlvBehaviourInfo("detachallthis", RLV_BHVR_DETACHALLTHIS, RLV_TYPE_ADDREM | RLV_TYPE_FORCE));
addEntry(new RlvBehaviourInfo("detachthis", RLV_BHVR_DETACHTHIS, RLV_TYPE_ADDREM | RLV_TYPE_FORCE));
addEntry(new RlvBehaviourInfo("remattach", RLV_BHVR_REMATTACH, RLV_TYPE_ADDREM | RLV_TYPE_FORCE));
addEntry(new RlvBehaviourInfo("remoutfit", RLV_BHVR_REMOUTFIT, RLV_TYPE_ADDREM | RLV_TYPE_FORCE));
addEntry(new RlvBehaviourInfo("setgroup", RLV_BHVR_SETGROUP, RLV_TYPE_ADDREM | RLV_TYPE_FORCE));
addEntry(new RlvBehaviourInfo("sit", RLV_BHVR_SIT, RLV_TYPE_ADDREM | RLV_TYPE_FORCE));
addEntry(new RlvBehaviourInfo("unsit", RLV_BHVR_UNSIT, RLV_TYPE_ADDREM | RLV_TYPE_FORCE));
@ -177,13 +194,14 @@ RlvBehaviourDictionary::RlvBehaviourDictionary()
m_String2InfoMap.insert(std::make_pair(pBhvrInfo->strBhvr, pBhvrInfo));
}
// Populate m_Bhvr2InfoMap (but skip synonyms)
// Populate m_Bhvr2InfoMap (but only with non-synonym *restrictions*)
for (const RlvBehaviourInfo* pBhvrInfo : m_BhvrInfoList)
{
RLV_ASSERT_DBG( (pBhvrInfo->isSynonym()) || (m_Bhvr2InfoMap.end() == m_Bhvr2InfoMap.find(pBhvrInfo->eBhvr)) );
if (!pBhvrInfo->isSynonym())
m_Bhvr2InfoMap.insert(std::make_pair(pBhvrInfo->eBhvr, pBhvrInfo));
if ( (pBhvrInfo->maskParamType & RLV_TYPE_ADDREM) && (!pBhvrInfo->isSynonym()) )
{
RLV_ASSERT_DBG(m_Bhvr2InfoMap.end() == m_Bhvr2InfoMap.find(pBhvrInfo->eBhvr));
m_Bhvr2InfoMap.insert(std::pair<ERlvBehaviour, const RlvBehaviourInfo*>(pBhvrInfo->eBhvr, pBhvrInfo));
}
}
}
@ -250,7 +268,7 @@ bool RlvBehaviourDictionary::getHasStrict(ERlvBehaviour eBhvr) const
// Checked: 2009-12-27 (RLVa-1.1.0k) | Modified: RLVa-1.1.0k
RlvCommand::RlvCommand(const LLUUID& idObj, const std::string& strCommand)
: m_fValid(false), m_idObj(idObj), m_eBehaviour(RLV_BHVR_UNKNOWN), m_fStrict(false), m_eParamType(RLV_TYPE_UNKNOWN), m_eRet(RLV_RET_UNKNOWN)
: m_fValid(false), m_idObj(idObj), m_eBehaviour(RLV_BHVR_UNKNOWN), m_nBehaviourFlags(0), m_fStrict(false), m_eParamType(RLV_TYPE_UNKNOWN), m_eRet(RLV_RET_UNKNOWN)
{
if ((m_fValid = parseCommand(strCommand, m_strBehaviour, m_strOption, m_strParam)))
{
@ -278,26 +296,17 @@ RlvCommand::RlvCommand(const LLUUID& idObj, const std::string& strCommand)
return;
}
// HACK: all those @*overorreplace synonyms are rather tedious (and error-prone) to deal with so replace them their equivalent
if ( (RLV_TYPE_FORCE == m_eParamType) && (boost::algorithm::ends_with(m_strBehaviour, "overorreplace")) )
{
m_strBehaviour.erase(m_strBehaviour.length() - 13, 13);
}
const RlvBehaviourInfo* pBhvrInfo = RlvBehaviourDictionary::instance().getBehaviourInfo(m_strBehaviour, m_eParamType, &m_fStrict);
if (pBhvrInfo)
{
m_eBehaviour = pBhvrInfo->eBhvr;
// Filter experimental commands (if disabled)
// Filter experimental and/or extended commands (if disabled)
static LLCachedControl<bool> sEnableExperimental(gSavedSettings, "RLVaExperimentalCommands");
if ( (!sEnableExperimental) && (pBhvrInfo->isExperimental()) )
m_eBehaviour = RLV_BHVR_UNKNOWN;
// Filter extended commands (if disabled)
static LLCachedControl<bool> sEnableExtended(gSavedSettings, "RLVaExtendedCommands");
if ( (!sEnableExtended) && (pBhvrInfo->isExtended()) )
m_eBehaviour = RLV_BHVR_UNKNOWN;
if ( ((sEnableExperimental) || (!pBhvrInfo->isExperimental())) && ((sEnableExtended) || (!pBhvrInfo->isExtended())) )
{
m_eBehaviour = pBhvrInfo->eBhvr;
m_nBehaviourFlags = pBhvrInfo->nBhvrFlags;
}
}
}

View File

@ -31,26 +31,38 @@
struct RlvBehaviourInfo
{
enum EBehaviourOptionMask
enum EBehaviourFlags
{
BHVR_STRICT = 0x1,
BHVR_SYNONYM = 0x2,
BHVR_EXTENDED = 0x4,
BHVR_EXPERIMENTAL = 0x8,
// General behaviour flags
BHVR_STRICT = 0x0001,
BHVR_SYNONYM = 0x0002,
BHVR_EXTENDED = 0x0004,
BHVR_EXPERIMENTAL = 0x0008,
BHVR_GENERAL_MASK = 0xFFFF,
// Force-wear specific flags
FORCEWEAR_WEAR_REPLACE = 0x0001 << 16,
FORCEWEAR_WEAR_ADD = 0x0002 << 16,
FORCEWEAR_WEAR_REMOVE = 0x0004 << 16,
FORCEWEAR_NODE = 0x0010 << 16,
FORCEWEAR_SUBTREE = 0x0020 << 16,
FORCEWEAR_CONTEXT_NONE = 0x0100 << 16,
FORCEWEAR_CONTEXT_OBJECT = 0x0200 << 16,
FORCEWEAR_MASK = 0xFFFF << 16
};
std::string strBhvr;
ERlvBehaviour eBhvr;
U32 nBhvrFlags;
U32 maskParamType;
U32 maskBhvrOptions;
bool hasStrict() const { return maskBhvrOptions & BHVR_STRICT; }
bool isExperimental() const { return maskBhvrOptions & BHVR_EXPERIMENTAL; }
bool isExtended() const { return maskBhvrOptions & BHVR_EXTENDED; }
bool isSynonym() const { return maskBhvrOptions & BHVR_SYNONYM; }
bool hasStrict() const { return nBhvrFlags & BHVR_STRICT; }
bool isExperimental() const { return nBhvrFlags & BHVR_EXPERIMENTAL; }
bool isExtended() const { return nBhvrFlags & BHVR_EXTENDED; }
bool isSynonym() const { return nBhvrFlags & BHVR_SYNONYM; }
RlvBehaviourInfo(std::string bhvr_str, ERlvBehaviour bhvr, U32 paramtype_mask, U32 bhvroption_mask = 0)
: strBhvr(bhvr_str), eBhvr(bhvr), maskParamType(paramtype_mask), maskBhvrOptions(bhvroption_mask) {}
RlvBehaviourInfo(std::string bhvr_str, ERlvBehaviour bhvr, U32 paramtype_mask, U32 bhvr_flags = 0)
: strBhvr(bhvr_str), eBhvr(bhvr), maskParamType(paramtype_mask), nBhvrFlags(bhvr_flags) {}
};
class RlvBehaviourDictionary : public LLSingleton<RlvBehaviourDictionary>
@ -101,6 +113,7 @@ public:
std::string asString() const;
const std::string& getBehaviour() const { return m_strBehaviour; }
ERlvBehaviour getBehaviourType() const { return m_eBehaviour; }
U32 getBehaviourFlags() const{ return m_nBehaviourFlags; }
const LLUUID& getObjectID() const { return m_idObj; }
const std::string& getOption() const { return m_strOption; }
const std::string& getParam() const { return m_strParam; }
@ -129,6 +142,7 @@ protected:
LLUUID m_idObj;
std::string m_strBehaviour;
ERlvBehaviour m_eBehaviour;
U32 m_nBehaviourFlags;
bool m_fStrict;
std::string m_strOption;
std::string m_strParam;