diff --git a/indra/newview/rlvactions.cpp b/indra/newview/rlvactions.cpp index 355945dbc0..83c44583d8 100644 --- a/indra/newview/rlvactions.cpp +++ b/indra/newview/rlvactions.cpp @@ -317,22 +317,25 @@ bool RlvActions::canJump() bool RlvActions::canTeleportToLocal(const LLVector3d& posGlobal) { // User can initiate a local teleport if: - // - not restricted from "sit teleporting" (or the destination is within the allowed xy-radius) - // - not restricted from teleporting locally (or the destination is within the allowed xy-radius) // - can stand up (or isn't sitting) + // - not restricted from "sit teleporting" (or the destination is within the allowed xyz-radius) + // - not restricted from teleporting locally (or the destination is within the allowed xy-radius) // NOTE: if we're teleporting due to an active command we should disregard any restrictions from the same object const LLUUID& idRlvObjExcept = gRlvHandler.getCurrentObject(); - bool fCanStand = RlvActions::canStand(idRlvObjExcept); - if ( (fCanStand) && ((gRlvHandler.hasBehaviourExcept(RLV_BHVR_SITTP, idRlvObjExcept)) || (gRlvHandler.hasBehaviourExcept(RLV_BHVR_TPLOCAL, idRlvObjExcept))) ) + bool fCanTeleport = RlvActions::canStand(idRlvObjExcept); + if ( (fCanTeleport) && (gRlvHandler.hasBehaviourExcept(RLV_BHVR_SITTP, idRlvObjExcept)) ) { - // User can stand up but is either @sittp or @tplocal restricted so we need to distance check - const F32 nDistSq = (LLVector2(posGlobal.mdV[0], posGlobal.mdV[1]) - LLVector2(gAgent.getPositionGlobal().mdV[0], gAgent.getPositionGlobal().mdV[1])).lengthSquared(); - F32 nMaxDist = llmin(RlvBehaviourDictionary::instance().getModifier(RLV_MODIFIER_TPLOCALDIST)->getValue(), RLV_MODIFIER_TPLOCAL_DEFAULT); - if (gRlvHandler.hasBehaviourExcept(RLV_BHVR_SITTP, idRlvObjExcept)) - nMaxDist = llmin(nMaxDist, RlvBehaviourDictionary::instance().getModifier(RLV_MODIFIER_SITTPDIST)->getValue()); - return (nDistSq < nMaxDist * nMaxDist); + const F32 nDistSq = (posGlobal - gAgent.getPositionGlobal()).lengthSquared(); + const F32 nSitTpDist = RlvBehaviourDictionary::instance().getModifier(RLV_MODIFIER_SITTPDIST)->getValue(); + fCanTeleport = nDistSq < nSitTpDist * nSitTpDist; } - return fCanStand; + if ( (fCanTeleport) && (gRlvHandler.hasBehaviourExcept(RLV_BHVR_TPLOCAL, idRlvObjExcept)) ) + { + const F32 nDistSq = (LLVector2(posGlobal.mdV[0], posGlobal.mdV[1]) - LLVector2(gAgent.getPositionGlobal().mdV[0], gAgent.getPositionGlobal().mdV[1])).lengthSquared(); + const F32 nTpLocalDist = llmin(RlvBehaviourDictionary::instance().getModifier(RLV_MODIFIER_TPLOCALDIST)->getValue(), RLV_MODIFIER_TPLOCAL_DEFAULT); + fCanTeleport = nDistSq < nTpLocalDist * nTpLocalDist; + } + return fCanTeleport; } bool RlvActions::canTeleportToLocation()