diff --git a/indra/newview/rlvactions.cpp b/indra/newview/rlvactions.cpp index 9fe3572e4ac8af976e049cfa45e71ce8dde10582..4a3d442821390e9ec201c7ff6a9d5ef17de73ef6 100644 --- a/indra/newview/rlvactions.cpp +++ b/indra/newview/rlvactions.cpp @@ -132,12 +132,20 @@ bool RlvActions::canChangeActiveGroup(const LLUUID& idRlvObject) // Little helper function to check the IM exclusion range for @recvim, @sendim and @startim (returns: min_dist <= (pos user - pos target) <= max_dist) static bool rlvCheckAvatarIMDistance(const LLUUID& idAvatar, ERlvBehaviourModifier eModDistMin, ERlvBehaviourModifier eModDistMax) { - LLVector3d posAgent; + // | no limits | minimum set | min+max set | !fHasMin | !fHasMax = INF | fHasMax + // -------------------------------------------------------------- ------------------------------------ + // dist <= min <= max | block | block | block | F | F | F + // min <= dist <= max | block | allow | allow | F | T | T + // min <= max <= dist | block | allow | block | F | ^ (see above) | F + // off-region | block | allow | block | F | ^ (see above) | F + const RlvBehaviourModifier *pBhvrModDistMin = RlvBehaviourDictionary::instance().getModifier(eModDistMin), *pBhvrModDistMax = RlvBehaviourDictionary::instance().getModifier(eModDistMax); - if ( ((pBhvrModDistMin->hasValue()) || (pBhvrModDistMax->hasValue())) && (LLWorld::getInstance()->getAvatar(idAvatar, posAgent)) ) + if (pBhvrModDistMin->hasValue()) { - float nDist = llabs(dist_vec_squared(gAgent.getPositionGlobal(), posAgent)); - return (nDist >= pBhvrModDistMin->getValue<float>()) && (nDist <= pBhvrModDistMax->getValue<float>()); + LLVector3d posAgent; bool fHasMax = pBhvrModDistMax->hasValue(); + float nMinDist = pBhvrModDistMin->getValue<float>(), nMaxDist = (fHasMax) ? pBhvrModDistMax->getValue<float>() : std::numeric_limits<float>::max(); + float nDist = (LLWorld::getInstance()->getAvatar(idAvatar, posAgent)) ? llabs(dist_vec_squared(gAgent.getPositionGlobal(), posAgent)) : std::numeric_limits<float>::max(); + return (nMinDist < nMaxDist) && (nMinDist <= nDist) && (nDist <= nMaxDist); } return false; } diff --git a/indra/newview/rlvactions.h b/indra/newview/rlvactions.h index 0bdfed2058b8c5c377acd05066e09ff755ee77a5..44baca33db3aff5e6c91220d9f361e1f0c8f0c8d 100644 --- a/indra/newview/rlvactions.h +++ b/indra/newview/rlvactions.h @@ -87,7 +87,6 @@ class RlvActions */ static bool canChangeActiveGroup(const LLUUID& idRlvObject = LLUUID::null); - /* * Returns true if the user is allowed to receive IMs from the specified sender (can be an avatar or a group) */