From eb00239a0b6b3177acd61a7261251cc2fdd5cb86 Mon Sep 17 00:00:00 2001
From: Todd Stinson <stinson@lindenlab.com>
Date: Thu, 12 Jul 2012 14:47:47 -0700
Subject: [PATCH] PATH-807: Ensuring that the "Show in linksets..." and "Show
 in characters..." right-click menu option does not show for objects outside
 the current region.

---
 indra/newview/llselectmgr.cpp  | 25 +++++++++++++++++++++++++
 indra/newview/llselectmgr.h    |  1 +
 indra/newview/llviewermenu.cpp |  2 +-
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index a5d9db4a004..e711a51fe8f 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -2806,6 +2806,7 @@ BOOL LLSelectMgr::selectGetEditableLinksets()
 			object->flagCharacter() ||
 			object->flagVolumeDetect() ||
 			object->flagAnimSource() ||
+			(object->getRegion() != gAgent.getRegion()) ||
 			(!gAgent.isGodlike() && 
 			!gAgent.canManageEstate() &&
 			!object->permYouOwner() &&
@@ -2817,6 +2818,30 @@ BOOL LLSelectMgr::selectGetEditableLinksets()
 	return TRUE;
 }
 
+//-----------------------------------------------------------------------------
+// selectGetViewableCharacters() - return TRUE if all objects are characters
+//                        viewable within the pathfinding characters floater
+//-----------------------------------------------------------------------------
+BOOL LLSelectMgr::selectGetViewableCharacters()
+{
+	for (LLObjectSelection::iterator iter = getSelection()->begin();
+		 iter != getSelection()->end(); iter++ )
+	{
+		LLSelectNode* node = *iter;
+		LLViewerObject* object = node->getObject();
+		if( !object || !node->mValid )
+		{
+			return FALSE;
+		}
+		if( !object->flagCharacter() ||
+			(object->getRegion() != gAgent.getRegion()))
+		{
+			return FALSE;
+		}
+	}
+	return TRUE;
+}
+
 //-----------------------------------------------------------------------------
 // selectGetRootsTransfer() - return TRUE if current agent can transfer all
 // selected root objects.
diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h
index feab6ebdf89..20d0a23267e 100644
--- a/indra/newview/llselectmgr.h
+++ b/indra/newview/llselectmgr.h
@@ -585,6 +585,7 @@ class LLSelectMgr : public LLEditMenuHandler, public LLSingleton<LLSelectMgr>
 	BOOL selectGetNonCharacter();
 
 	BOOL selectGetEditableLinksets();
+	BOOL selectGetViewableCharacters();
 
 	// returns TRUE if selected objects can be transferred.
 	BOOL selectGetRootsTransfer();
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 3eb05383287..b4ddc6039ab 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -2809,7 +2809,7 @@ bool enable_object_select_in_pathfinding_linksets()
 
 bool enable_object_select_in_pathfinding_characters()
 {
-	return LLPathfindingManager::getInstance()->isPathfindingEnabledForCurrentRegion() &&  LLSelectMgr::getInstance()->selectGetCharacter();
+	return LLPathfindingManager::getInstance()->isPathfindingEnabledForCurrentRegion() &&  LLSelectMgr::getInstance()->selectGetViewableCharacters();
 }
 
 class LLSelfRemoveAllAttachments : public view_listener_t
-- 
GitLab