From 036390f5bd44e002c3a741bede82c6687112c110 Mon Sep 17 00:00:00 2001 From: Kitty Barnett <develop@catznip.com> Date: Sun, 27 Nov 2016 18:07:30 +0100 Subject: [PATCH] @sit[:<null-uuid>]=force will ground-sit the avatar (if permitted) --HG-- branch : RLVa --- indra/newview/llagent.cpp | 12 ++++----- indra/newview/rlvactions.cpp | 8 ++++++ indra/newview/rlvactions.h | 7 +++++- indra/newview/rlvhandler.cpp | 47 +++++++++++++++++++++++------------- indra/newview/rlvhelper.cpp | 3 +-- 5 files changed, 50 insertions(+), 27 deletions(-) diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 6c31e33049..6d8b6c6f8d 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 a11317aa0a..e36c81b2f5 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 44baca33db..1e094fd3f1 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 4a0a5a88cc..fddc7ff786 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 2f0ac47776..cb56f075bf 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<> -- GitLab