diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 6c31e3304917a969d05f48f77aad71e0d934d647..6d8b6c6f8d6081ea905a56fcdad35af7fb80a306 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -1187,14 +1187,12 @@ LLVector3d LLAgent::getPosGlobalFromAgent(const LLVector3 &pos_agent) const void LLAgent::sitDown() { -// setControlFlags(AGENT_CONTROL_SIT_ON_GROUND); -// [RLVa:KB] - Checked: 2010-08-28 (RLVa-1.2.1a) | Added: RLVa-1.2.1a - // RELEASE-RLVa: [SL-2.0.0] Check this function's callers since usually they require explicit blocking - if ( (!rlv_handler_t::isEnabled()) || ((RlvActions::canStand()) && (!gRlvHandler.hasBehaviour(RLV_BHVR_SIT))) ) - { - setControlFlags(AGENT_CONTROL_SIT_ON_GROUND); - } +// [RLVa:KB] - Checked: RLVa-1.2.1 + if (!RlvActions::canGroundSit()) + return; // [/RLVa:KB] + + setControlFlags(AGENT_CONTROL_SIT_ON_GROUND); } diff --git a/indra/newview/rlvactions.cpp b/indra/newview/rlvactions.cpp index a11317aa0a8cfaeb6965e4aafb173b7c28a02443..e36c81b2f5f7db5fac70a4267f4454e0c6007e91 100644 --- a/indra/newview/rlvactions.cpp +++ b/indra/newview/rlvactions.cpp @@ -375,6 +375,14 @@ bool RlvActions::canRez() return (!gRlvHandler.hasBehaviour(RLV_BHVR_REZ)); } +bool RlvActions::canGroundSit() +{ + // User can sit on the ground if: + // - not prevented from sitting + // - not prevented from standing up or not currently sitting + return (!hasBehaviour(RLV_BHVR_SIT)) && (canStand()); +} + bool RlvActions::canSit(const LLViewerObject* pObj, const LLVector3& posOffset /*=LLVector3::zero*/) { // User can sit on the specified object if: diff --git a/indra/newview/rlvactions.h b/indra/newview/rlvactions.h index 44baca33db3aff5e6c91220d9f361e1f0c8f0c8d..1e094fd3f1678509e11a9c8e1ecf28d5717e7004 100644 --- a/indra/newview/rlvactions.h +++ b/indra/newview/rlvactions.h @@ -210,6 +210,11 @@ public: */ static bool canEdit(const LLViewerObject* pObj); + /* + * Returns true if the user can sit on the ground + */ + static bool canGroundSit(); + /* * Returns true if the user can interact with the specified object (with an optional relative offset) * (returns true if pObj == nullptr to not short circuit calling code) @@ -237,7 +242,7 @@ public: static bool canShowLocation(); /* - * Returns true if the user can sit up on the specified object + * Returns true if the user can sit on the specified object (see canGroundSit() for sitting on land) */ static bool canSit(const LLViewerObject* pObj, const LLVector3& posOffset = LLVector3::zero); diff --git a/indra/newview/rlvhandler.cpp b/indra/newview/rlvhandler.cpp index 4a0a5a88cc41d5f2da8b49166590307c14f6b4ba..fddc7ff786d38b42a23b8fca5bac7fe2327e620b 100644 --- a/indra/newview/rlvhandler.cpp +++ b/indra/newview/rlvhandler.cpp @@ -2503,30 +2503,43 @@ ERlvCmdRet RlvForceHandler<RLV_BHVR_SETGROUP>::onCommand(const RlvCommand& rlvCm template<> template<> ERlvCmdRet RlvForceHandler<RLV_BHVR_SIT>::onCommand(const RlvCommand& rlvCmd) { - LLViewerObject* pObj = NULL; LLUUID idTarget(rlvCmd.getOption()); - // Sanity checking - we need to know about the object and it should identify a prim/linkset - if ( (idTarget.isNull()) || ((pObj = gObjectList.findObject(idTarget)) == NULL) || (LL_PCODE_VOLUME != pObj->getPCode()) ) + LLUUID idTarget; + if (!RlvCommandOptionHelper::parseOption(rlvCmd.getOption(), idTarget)) return RLV_RET_FAILED_OPTION; - if (!RlvActions::canSit(pObj)) - return RLV_RET_FAILED_LOCK; - else if ( (gRlvHandler.hasBehaviour(RLV_BHVR_STANDTP)) && (isAgentAvatarValid()) ) + LLViewerObject* pObj = NULL; + if (idTarget.isNull()) { - if (gAgentAvatarp->isSitting()) + if (!RlvActions::canGroundSit()) return RLV_RET_FAILED_LOCK; - gRlvHandler.m_posSitSource = gAgent.getPositionGlobal(); + gAgent.sitDown(); } + else if ( ((pObj = gObjectList.findObject(idTarget)) != NULL) && (LL_PCODE_VOLUME == pObj->getPCode())) + { + if (!RlvActions::canSit(pObj)) + return RLV_RET_FAILED_LOCK; - // Copy/paste from handle_sit_or_stand() - gMessageSystem->newMessageFast(_PREHASH_AgentRequestSit); - gMessageSystem->nextBlockFast(_PREHASH_AgentData); - gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - gMessageSystem->nextBlockFast(_PREHASH_TargetObject); - gMessageSystem->addUUIDFast(_PREHASH_TargetID, pObj->mID); - gMessageSystem->addVector3Fast(_PREHASH_Offset, LLVector3::zero); - pObj->getRegion()->sendReliableMessage(); + if ((gRlvHandler.hasBehaviour(RLV_BHVR_STANDTP)) && (isAgentAvatarValid())) + { + if (gAgentAvatarp->isSitting()) + return RLV_RET_FAILED_LOCK; + gRlvHandler.m_posSitSource = gAgent.getPositionGlobal(); + } + // Copy/paste from handle_sit_or_stand() + gMessageSystem->newMessageFast(_PREHASH_AgentRequestSit); + gMessageSystem->nextBlockFast(_PREHASH_AgentData); + gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + gMessageSystem->nextBlockFast(_PREHASH_TargetObject); + gMessageSystem->addUUIDFast(_PREHASH_TargetID, pObj->mID); + gMessageSystem->addVector3Fast(_PREHASH_Offset, LLVector3::zero); + pObj->getRegion()->sendReliableMessage(); + } + else + { + return RLV_RET_FAILED_OPTION; + } return RLV_RET_SUCCESS; } diff --git a/indra/newview/rlvhelper.cpp b/indra/newview/rlvhelper.cpp index 2f0ac47776c96f78e00698fdbd9a9335da4d2cf9..cb56f075bf004b3ac40c18080af898bd1e13726f 100644 --- a/indra/newview/rlvhelper.cpp +++ b/indra/newview/rlvhelper.cpp @@ -606,8 +606,7 @@ bool RlvCommand::parseCommand(const std::string& strCommand, std::string& strBeh template<> bool RlvCommandOptionHelper::parseOption<LLUUID>(const std::string& strOption, LLUUID& idOption) { - idOption.set(strOption); - return idOption.notNull(); + return idOption.set(strOption); } template<>