Merged with forgotten RLVa-1.4 code review branch

--HG--
branch : RLVa
master
Kitty Barnett 2011-09-09 16:59:46 +02:00
commit 410ee7cbd3
9 changed files with 77 additions and 95 deletions

View File

@ -41,7 +41,7 @@
#include "llviewerregion.h"
#include "llversioninfo.h"
#include "llweb.h"
// [RLVa:KB] - Checked: 2010-04-18 (RLVa-1.2.0e)
// [RLVa:KB] - Checked: 2010-04-18 (RLVa-1.4.0a)
#include "rlvhandler.h"
// [/RLVa:KB]
@ -257,11 +257,8 @@ LLSD LLFloaterAbout::getInfo()
}
#endif
// [RLVa:KB] - Checked: 2010-04-18 (RLVa-1.2.0e) | Added: RLVa-1.2.0e
if (rlv_handler_t::isEnabled())
info["RLV_VERSION"] = RlvStrings::getVersionAbout();
else
info["RLV_VERSION"] = "(disabled)";
// [RLVa:KB] - Checked: 2010-04-18 (RLVa-1.4.0a) | Added: RLVa-1.2.0e
info["RLV_VERSION"] = (rlv_handler_t::isEnabled()) ? RlvStrings::getVersionAbout() : "(disabled)";
// [/RLVa:KB]
info["OPENGL_VERSION"] = (const char*)(glGetString(GL_VERSION));
info["LIBCURL_VERSION"] = LLCurl::getVersionString();

View File

@ -652,7 +652,7 @@ bool LLSelectMgr::enableLinkObjects()
{
// Allow only if the avie isn't sitting on any of the selected objects
LLObjectSelectionHandle hSel = LLSelectMgr::getInstance()->getSelection();
RlvSelectIsSittingOn f(gAgentAvatarp->getRoot());
RlvSelectIsSittingOn f(gAgentAvatarp);
if (hSel->getFirstRootNode(&f, TRUE) != NULL)
new_value = false;
}
@ -672,7 +672,7 @@ bool LLSelectMgr::enableUnlinkObjects()
{
// Allow only if the avie isn't sitting on any of the selected objects
LLObjectSelectionHandle hSel = LLSelectMgr::getInstance()->getSelection();
RlvSelectIsSittingOn f(gAgentAvatarp->getRoot());
RlvSelectIsSittingOn f(gAgentAvatarp);
if (hSel->getFirstRootNode(&f, TRUE) != NULL)
new_value = false;
}

View File

@ -4269,7 +4269,7 @@ void handle_take_copy()
{
// Allow only if the avie isn't sitting on any of the selected objects
LLObjectSelectionHandle hSel = LLSelectMgr::getInstance()->getSelection();
RlvSelectIsSittingOn f(gAgentAvatarp->getRoot());
RlvSelectIsSittingOn f(gAgentAvatarp);
if ( (hSel.notNull()) && (hSel->getFirstRootNode(&f, TRUE) != NULL) )
return;
}
@ -4285,7 +4285,7 @@ class LLObjectReturn : public view_listener_t
bool handleEvent(const LLSD& userdata)
{
if (LLSelectMgr::getInstance()->getSelection()->isEmpty()) return true;
// [RLVa:KB] - Checked: 2010-03-24 (RLVa-1.2.0e) | Modified: RLVa-1.0.0b
// [RLVa:KB] - Checked: 2010-03-24 (RLVa-1.4.0a) | Modified: RLVa-1.0.0b
if ( (rlv_handler_t::isEnabled()) && (!rlvCanDeleteOrReturn()) ) return true;
// [/RLVa:KB]
@ -4325,6 +4325,12 @@ class LLObjectEnableReturn : public view_listener_t
// Do not enable if nothing selected
return false;
}
// [RLVa:KB] - Checked: 2011-05-28 (RLVa-1.4.0a) | Modified: RLVa-1.4.0a
if ( (rlv_handler_t::isEnabled()) && (!rlvCanDeleteOrReturn()) )
{
return false;
}
// [/RLVa:KB]
#ifdef HACKED_GODLIKE_VIEWER
bool new_value = true;
#else
@ -4360,9 +4366,6 @@ class LLObjectEnableReturn : public view_listener_t
}
}
#endif
// [RLVa:KB] - Checked: 2010-03-24 (RLVa-1.2.0e) | Modified: RLVa-1.0.0b
new_value &= (!rlv_handler_t::isEnabled()) || (rlvCanDeleteOrReturn());
// [/RLVa:KB]
return new_value;
}
};

View File

@ -2451,10 +2451,10 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
// do nothing -- don't distract newbies in
// Prelude with global IMs
}
// [RLVa:KB] - Checked: 2010-03-27 (RLVa-1.2.0b) | Modified: RLVa-1.2.0b
else if ( (rlv_handler_t::isEnabled()) && (offline == IM_ONLINE) && ("@version" == message) )
// [RLVa:KB] - Checked: 2011-05-28 (RLVa-1.4.0a) | Modified: RLVa-1.4.0a
else if ( (rlv_handler_t::isEnabled()) && (offline == IM_ONLINE) && ("@version" == message) &&
(!is_muted) && ((!accept_im_from_only_friend) || (is_friend)) )
{
// TODO-RLVa: [RLVa-1.2.1] Should we send our version string if the other party is muted?
RlvUtil::sendBusyMessage(from_id, RlvStrings::getVersion(), session_id);
}
// [/RLVa:KB]

View File

@ -529,6 +529,15 @@ bool LLViewerObject::isReturnable()
return false;
}
// [RLVa:KB] - Checked: 2011-05-28 (RLVa-1.4.0a) | Added: RLVa-1.4.0a
// Block if: @rez=n restricted and owned by us or a group *or* @unsit=n restricted and being sat on by us
if ( (rlv_handler_t::isEnabled()) &&
( ((gRlvHandler.hasBehaviour(RLV_BHVR_REZ)) && ((permYouOwner() || permGroupOwner()))) ||
((gRlvHandler.hasBehaviour(RLV_BHVR_UNSIT)) && (isAgentAvatarValid()) && (getRootEdit()->isChild(gAgentAvatarp))) ) )
{
return false;
}
// [/RLVa:KB]
std::vector<LLBBox> boxes;
boxes.push_back(LLBBox(getPositionRegion(), getRotationRegion(), getScale() * -0.5f, getScale() * 0.5f).getAxisAligned());
for (child_list_t::iterator iter = mChildList.begin();
@ -732,7 +741,10 @@ void LLViewerObject::addThisAndNonJointChildren(std::vector<LLViewerObject*>& ob
}
}
BOOL LLViewerObject::isChild(LLViewerObject *childp) const
//BOOL LLViewerObject::isChild(LLViewerObject *childp) const
// [RLVa:KB] - Checked: 2011-05-28 (RLVa-1.4.0a) | Added: RLVa-1.4.0a
BOOL LLViewerObject::isChild(const LLViewerObject *childp) const
// [/RLVa:KB]
{
for (child_list_t::const_iterator iter = mChildList.begin();
iter != mChildList.end(); iter++)

View File

@ -259,7 +259,10 @@ public:
S32 numChildren() const { return mChildList.size(); }
void addThisAndAllChildren(std::vector<LLViewerObject*>& objects);
void addThisAndNonJointChildren(std::vector<LLViewerObject*>& objects);
BOOL isChild(LLViewerObject *childp) const;
// BOOL isChild(LLViewerObject *childp) const;
// [RLVa:KB] - Checked: 2011-05-28 (RLVa-1.4.0a) | Added: RLVa-1.4.0a
BOOL isChild(const LLViewerObject *childp) const;
// [/RLVa:KB]
BOOL isSeat() const;

View File

@ -260,8 +260,8 @@ const char* RlvStrings::getStringFromReturnCode(ERlvCmdRet eRet)
return NULL;
}
// Checked: 2010-03-27 (RLVa-1.2.0b) | Modified: RLVa-1.2.0b
std::string RlvStrings::getVersion(bool fLegacy /*=false*/)
// Checked: 2010-03-27 (RLVa-1.4.0a) | Modified: RLVa-1.2.0b
std::string RlvStrings::getVersion(bool fLegacy)
{
return llformat("%s viewer v%d.%d.%d (%s %d.%d.%d.%d - RLVa %d.%d.%d)",
( (!fLegacy) ? "RestrainedLove" : "RestrainedLife" ),
@ -270,7 +270,7 @@ std::string RlvStrings::getVersion(bool fLegacy /*=false*/)
RLVa_VERSION_MAJOR, RLVa_VERSION_MINOR, RLVa_VERSION_PATCH);
}
// Checked: 2010-04-18 (RLVa-1.2.0e) | Added: RLVa-1.2.0e
// Checked: 2010-04-18 (RLVa-1.4.0a) | Added: RLVa-1.2.0e
std::string RlvStrings::getVersionAbout()
{
return llformat("RLV v%d.%d.%d / RLVa v%d.%d.%d%c" ,
@ -278,9 +278,8 @@ std::string RlvStrings::getVersionAbout()
RLVa_VERSION_MAJOR, RLVa_VERSION_MINOR, RLVa_VERSION_PATCH, 'a' + RLVa_VERSION_BUILD);
}
// Checked: 2010-03-27 (RLVa-1.2.0b) | Modified: RLVa-1.1.0a
std::string RlvStrings::getVersionNum()
// Checked: 2010-03-27 (RLVa-1.4.0a) | Modified: RLVa-1.1.0a
std::string RlvStrings::getVersionNum()
{
return llformat("%d%02d%02d%02d", RLV_VERSION_MAJOR, RLV_VERSION_MINOR, RLV_VERSION_PATCH, RLV_VERSION_BUILD);
}
@ -514,30 +513,19 @@ bool rlvMenuEnableIfNot(const LLSD& sdParam)
// Selection functors
//
// Checked: 2010-04-11 (RLVa-1.2.0b) | Modified: RLVa-0.2.0g
// Checked: 2011-05-28 (RLVa-1.4.0a) | Modified: RLVa-1.4.0a
bool rlvCanDeleteOrReturn()
{
bool fIsAllowed = true;
if (gRlvHandler.hasBehaviour(RLV_BHVR_REZ))
if ( (gRlvHandler.hasBehaviour(RLV_BHVR_REZ)) || (gRlvHandler.hasBehaviour(RLV_BHVR_UNSIT)) )
{
// We'll allow if none of the prims are owned by the avie or group owned
LLObjectSelectionHandle handleSel = LLSelectMgr::getInstance()->getSelection();
RlvSelectIsOwnedByOrGroupOwned f(gAgent.getID());
if ( (handleSel.notNull()) && ((0 == handleSel->getRootObjectCount()) || (NULL != handleSel->getFirstRootNode(&f, FALSE))) )
fIsAllowed = false;
struct RlvCanDeleteOrReturn : public LLSelectedObjectFunctor
{
/*virtual*/ bool apply(LLViewerObject* pObj) { return pObj->isReturnable(); }
} f;
LLObjectSelectionHandle hSel = LLSelectMgr::getInstance()->getSelection();
return (hSel.notNull()) && (0 != hSel->getRootObjectCount()) && (hSel->applyToRootObjects(&f, false));
}
if ( (gRlvHandler.hasBehaviour(RLV_BHVR_UNSIT)) && (isAgentAvatarValid()) )
{
// We'll allow if the avie isn't sitting on any of the selected objects
LLObjectSelectionHandle handleSel = LLSelectMgr::getInstance()->getSelection();
RlvSelectIsSittingOn f(gAgentAvatarp->getRoot());
if ( (handleSel.notNull()) && (handleSel->getFirstRootNode(&f, TRUE)) )
fIsAllowed = false;
}
return fIsAllowed;
return true;
}
// Checked: 2010-04-20 (RLVa-1.2.0f) | Modified: RLVa-0.2.0f
@ -553,16 +541,10 @@ bool RlvSelectIsEditable::apply(LLSelectNode* pNode)
return (pObj) && (!gRlvHandler.canEdit(pObj));
}
// Checked: 2009-07-05 (RLVa-1.0.0b) | Modified: RLVa-0.2.0f
bool RlvSelectIsOwnedByOrGroupOwned::apply(LLSelectNode* pNode)
{
return (pNode->mPermissions->isGroupOwned()) || (pNode->mPermissions->getOwner() == m_idAgent);
}
// Checked: 2010-04-01 (RLVa-1.2.0c) | Modified: RLVa-0.2.0f
// Checked: 2011-05-28 (RLVa-1.4.0a) | Modified: RLVa-1.4.0a
bool RlvSelectIsSittingOn::apply(LLSelectNode* pNode)
{
return (pNode->getObject()) && (pNode->getObject()->getRootEdit() == m_pObject);
return (pNode->getObject()) && (pNode->getObject()->getRootEdit()->isChild(m_pAvatar));
}
// ============================================================================

View File

@ -215,20 +215,12 @@ struct RlvSelectIsEditable : public LLSelectedNodeFunctor
/*virtual*/ bool apply(LLSelectNode* pNode);
};
struct RlvSelectIsOwnedByOrGroupOwned : public LLSelectedNodeFunctor
{
RlvSelectIsOwnedByOrGroupOwned(const LLUUID& uuid) : m_idAgent(uuid) {}
virtual bool apply(LLSelectNode* pNode);
protected:
LLUUID m_idAgent;
};
struct RlvSelectIsSittingOn : public LLSelectedNodeFunctor
{
RlvSelectIsSittingOn(LLXform* pObject) : m_pObject(pObject) {}
virtual bool apply(LLSelectNode* pNode);
RlvSelectIsSittingOn(const LLVOAvatar* pAvatar) : m_pAvatar(pAvatar) {}
/*virtual*/ bool apply(LLSelectNode* pNode);
protected:
LLXform* m_pObject;
const LLVOAvatar* m_pAvatar;
};
// ============================================================================

View File

@ -1829,12 +1829,12 @@ ERlvCmdRet RlvHandler::processReplyCommand(const RlvCommand& rlvCmd) const
ERlvCmdRet eRet = RLV_RET_SUCCESS; std::string strReply;
switch (rlvCmd.getBehaviourType())
{
case RLV_BHVR_VERSION: // @version=<channel> - Checked: 2010-03-27 (RLVa-1.2.0b)
case RLV_BHVR_VERSIONNEW: // @versionnew=<channel> - Checked: 2010-03-27 (RLVa-1.2.0b) | Added: RLVa-1.2.0b
case RLV_BHVR_VERSION: // @version=<channel> - Checked: 2010-03-27 (RLVa-1.4.0a)
case RLV_BHVR_VERSIONNEW: // @versionnew=<channel> - Checked: 2010-03-27 (RLVa-1.4.0a) | Added: RLVa-1.2.0b
// NOTE: RLV will respond even if there's an option
strReply = RlvStrings::getVersion(RLV_BHVR_VERSION == rlvCmd.getBehaviourType());
break;
case RLV_BHVR_VERSIONNUM: // @versionnum=<channel> - Checked: 2010-03-27 (RLVa-1.2.0b) | Added: RLVa-1.0.4b
case RLV_BHVR_VERSIONNUM: // @versionnum=<channel> - Checked: 2010-03-27 (RLVa-1.4.0a) | Added: RLVa-1.0.4b
// NOTE: RLV will respond even if there's an option
strReply = RlvStrings::getVersionNum();
break;
@ -1974,7 +1974,7 @@ ERlvCmdRet RlvHandler::onFindFolder(const RlvCommand& rlvCmd, std::string& strRe
return RLV_RET_SUCCESS;
}
// Checked: 2010-03-19 (RLVa-1.2.0c) | Modified: RLVa-1.1.0e
// Checked: 2010-03-19 (RLVa-1.4.0a) | Modified: RLVa-1.1.0e
ERlvCmdRet RlvHandler::onGetAttach(const RlvCommand& rlvCmd, std::string& strReply) const
{
RLV_ASSERT(RLV_TYPE_REPLY == rlvCmd.getParamType());
@ -1984,8 +1984,8 @@ ERlvCmdRet RlvHandler::onGetAttach(const RlvCommand& rlvCmd, std::string& strRep
return RLV_RET_FAILED;
// Sanity check - <option> should specify an attachment point or be empty
S32 idxAttachPt = RlvAttachPtLookup::getAttachPointIndex(rlvCmd.getOption());
if ( (idxAttachPt == 0) && (!rlvCmd.getOption().empty()) )
S32 idxAttachPt = 0;
if ( (rlvCmd.hasOption()) && ((idxAttachPt = RlvAttachPtLookup::getAttachPointIndex(rlvCmd.getOption())) == 0) )
return RLV_RET_FAILED_OPTION;
// If we're fetching all worn attachments then the reply should start with 0
@ -1998,7 +1998,7 @@ ERlvCmdRet RlvHandler::onGetAttach(const RlvCommand& rlvCmd, std::string& strRep
const LLViewerJointAttachment* pAttachPt = itAttach->second;
if ( (0 == idxAttachPt) || (itAttach->first == idxAttachPt) )
{
bool fWorn = (pAttachPt->getNumObjects()) &&
bool fWorn = (pAttachPt->getNumObjects() > 0) &&
( (!RlvSettings::getHideLockedAttach()) || (RlvForceWear::isForceDetachable(pAttachPt, true, rlvCmd.getObjectID())) );
strReply.push_back( (fWorn) ? '1' : '0' );
}
@ -2006,7 +2006,7 @@ ERlvCmdRet RlvHandler::onGetAttach(const RlvCommand& rlvCmd, std::string& strRep
return RLV_RET_SUCCESS;
}
// Checked: 2010-03-19 (RLVa-1.2.0a) | Added: RLVa-1.1.0e
// Checked: 2011-05-28 (RLVa-1.4.0a) | Modified: RLVa-1.4.0a
ERlvCmdRet RlvHandler::onGetAttachNames(const RlvCommand& rlvCmd, std::string& strReply) const
{
RLV_ASSERT(RLV_TYPE_REPLY == rlvCmd.getParamType());
@ -2026,18 +2026,14 @@ ERlvCmdRet RlvHandler::onGetAttachNames(const RlvCommand& rlvCmd, std::string& s
bool fAdd = false;
switch (rlvCmd.getBehaviourType())
{
case RLV_BHVR_GETATTACHNAMES: // Every attachment point that has an attached object (locked or unlocked)
fAdd = (pAttachPt->getNumObjects());
case RLV_BHVR_GETATTACHNAMES: // Every attachment point that has an attached object
fAdd = (pAttachPt->getNumObjects() > 0);
break;
/*
case RLV_BHVR_GETADDATTACHNAMES: // Every attachment point that can be worn on (but ignore any locks set by the issuer)
fAdd = (!isLockedAttachmentExcept(itAttach->first, RLV_LOCK_ADD, gObjectList.findObject(idObj))) &&
( (pAttachPt->getObject() == NULL) ||
(!isLockedAttachmentExcept(itAttach->first, RLV_LOCK_REMOVE, gObjectList.findObject(idObj))) );
case RLV_BHVR_GETADDATTACHNAMES: // Every attachment point that can be attached to (wear replace OR wear add)
fAdd = (gRlvAttachmentLocks.canAttach(pAttachPt) & RLV_WEAR);
break;
*/
case RLV_BHVR_GETREMATTACHNAMES: // Every attachment point that can be detached (but ignore any locks set by the issuer)
fAdd = RlvForceWear::isForceDetachable(pAttachPt, true, rlvCmd.getObjectID());
case RLV_BHVR_GETREMATTACHNAMES: // Every attachment point that has at least one attachment that can be force-detached
fAdd = RlvForceWear::isForceDetachable(pAttachPt);
break;
default:
break;
@ -2164,15 +2160,15 @@ ERlvCmdRet RlvHandler::onGetInvWorn(const RlvCommand& rlvCmd, std::string& strRe
return RLV_RET_SUCCESS;
}
// Checked: 2010-03-19 (RLVa-1.2.0c) | Modified: RLVa-1.2.0a
// Checked: 2010-03-19 (RLVa-1.4.0a) | Modified: RLVa-1.2.0a
ERlvCmdRet RlvHandler::onGetOutfit(const RlvCommand& rlvCmd, std::string& strReply) const
{
RLV_ASSERT(RLV_TYPE_REPLY == rlvCmd.getParamType());
RLV_ASSERT(RLV_BHVR_GETOUTFIT == rlvCmd.getBehaviourType());
// (Compatibility: RLV-1.16.1 will execute @getoutfit=<channel> if <layer> is invalid while we just return failure)
LLWearableType::EType wtType = LLWearableType::typeNameToType(rlvCmd.getOption());
if ( (LLWearableType::WT_INVALID == wtType) && (!rlvCmd.getOption().empty()) )
LLWearableType::EType wtType = LLWearableType::WT_INVALID;
if ( (rlvCmd.hasOption()) && ((wtType = LLWearableType::typeNameToType(rlvCmd.getOption())) == LLWearableType::WT_INVALID) )
return RLV_RET_FAILED_OPTION;
const LLWearableType::EType wtRlvTypes[] =
@ -2180,7 +2176,7 @@ ERlvCmdRet RlvHandler::onGetOutfit(const RlvCommand& rlvCmd, std::string& strRep
LLWearableType::WT_GLOVES, LLWearableType::WT_JACKET, LLWearableType::WT_PANTS, LLWearableType::WT_SHIRT,
LLWearableType::WT_SHOES, LLWearableType::WT_SKIRT, LLWearableType::WT_SOCKS, LLWearableType::WT_UNDERPANTS,
LLWearableType::WT_UNDERSHIRT, LLWearableType::WT_SKIN, LLWearableType::WT_EYES, LLWearableType::WT_HAIR,
LLWearableType::WT_SHAPE, LLWearableType::WT_ALPHA, LLWearableType::WT_TATTOO
LLWearableType::WT_SHAPE, LLWearableType::WT_ALPHA, LLWearableType::WT_TATTOO, LLWearableType::WT_PHYSICS
};
for (int idxType = 0, cntType = sizeof(wtRlvTypes) / sizeof(LLWearableType::EType); idxType < cntType; idxType++)
@ -2199,7 +2195,7 @@ ERlvCmdRet RlvHandler::onGetOutfit(const RlvCommand& rlvCmd, std::string& strRep
return RLV_RET_SUCCESS;
}
// Checked: 2009-11-21 (RLVa-1.1.0f) | Added: RLVa-1.1.0e
// Checked: 2011-05-28 (RLVa-1.4.0a) | Modified: RLVa-1.4.0a
ERlvCmdRet RlvHandler::onGetOutfitNames(const RlvCommand& rlvCmd, std::string& strReply) const
{
RLV_ASSERT(RLV_TYPE_REPLY == rlvCmd.getParamType());
@ -2207,24 +2203,21 @@ ERlvCmdRet RlvHandler::onGetOutfitNames(const RlvCommand& rlvCmd, std::string& s
(RLV_BHVR_GETREMOUTFITNAMES == rlvCmd.getBehaviourType()) );
// Sanity check - all these commands are optionless
if (!rlvCmd.getOption().empty())
if (rlvCmd.hasOption())
return RLV_RET_FAILED_OPTION;
// RELEASE-RLVa: [SL-2.0.0] Needs revisiting/rewriting once 'LLAgentWearables::MAX_WEARABLES_PER_TYPE > 1'
for (int idxType = 0; idxType < LLWearableType::WT_COUNT; idxType++)
{
bool fAdd = false; LLWearableType::EType wtType = (LLWearableType::EType)idxType;
switch (rlvCmd.getBehaviourType())
{
case RLV_BHVR_GETOUTFITNAMES: // Every layer that's worn
case RLV_BHVR_GETOUTFITNAMES: // Every layer that has at least one worn wearable
fAdd = (gAgentWearables.getWearableCount(wtType) > 0);
break;
/*
case RLV_BHVR_GETADDOUTFITNAMES: // Every layer that can be worn on (but ignore any locks set by the issuer)
fAdd = (isWearable(wtType)) && ( (gAgent.getWearable(wtType) == NULL) || (isRemovableExcept(wtType, idObj)) );
case RLV_BHVR_GETADDOUTFITNAMES: // Every layer that can be worn on (wear replace OR wear add)
fAdd = (gRlvWearableLocks.canWear(wtType) & RLV_WEAR);
break;
*/
case RLV_BHVR_GETREMOUTFITNAMES: // Every layer that can be removed (but ignore any locks set by the issuer)
case RLV_BHVR_GETREMOUTFITNAMES: // Every layer that has at least one wearable that can be force-removed
fAdd = RlvForceWear::isForceRemovable(wtType);
break;
default:
@ -2235,7 +2228,7 @@ ERlvCmdRet RlvHandler::onGetOutfitNames(const RlvCommand& rlvCmd, std::string& s
{
if (!strReply.empty())
strReply.push_back(',');
strReply.append(LLWearableType::getTypeName((LLWearableType::EType)idxType));
strReply.append(LLWearableType::getTypeName(wtType));
}
}
return RLV_RET_SUCCESS;