From 227f80bfd7f1e5222eff8403ac962efd35299a47 Mon Sep 17 00:00:00 2001
From: XenHat <commits@xenh.at>
Date: Wed, 27 Jan 2021 13:46:20 -0500
Subject: [PATCH] Expand Rez Under Land Group to general item rezz

---
 indra/newview/alchatcommand.cpp     | 12 +-----------
 indra/newview/llagent.cpp           | 15 +++++++++++++++
 indra/newview/llagent.h             |  1 +
 indra/newview/llselectmgr.cpp       |  2 +-
 indra/newview/lltooldraganddrop.cpp |  2 +-
 indra/newview/lltoolplacer.cpp      |  2 +-
 6 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/indra/newview/alchatcommand.cpp b/indra/newview/alchatcommand.cpp
index 41dfa26d5d9..cfcf726fb4e 100644
--- a/indra/newview/alchatcommand.cpp
+++ b/indra/newview/alchatcommand.cpp
@@ -135,17 +135,7 @@ bool ALChatCommand::parseCommand(std::string data)
 			msg->nextBlockFast(_PREHASH_AgentData);
 			msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
 			msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
-			LLUUID group_id = gAgent.getGroupID();
-			if (gSavedSettings.getBOOL("AlchemyRezUnderLandGroup"))
-			{
-				LLParcel* land_parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
-				// Is the agent in the land group
-				if (gAgent.isInGroup(land_parcel->getGroupID()))
-					group_id = land_parcel->getGroupID();
-				// Is the agent in the land group (the group owns the land)
-				else if (gAgent.isInGroup(land_parcel->getOwnerID()))
-					group_id = land_parcel->getOwnerID();
-			}
+			LLUUID group_id = gAgent.getGroupForRezzing();
 			msg->addUUIDFast(_PREHASH_GroupID, group_id);
 			msg->nextBlockFast(_PREHASH_ObjectData);
 			msg->addU8Fast(_PREHASH_PCode, LL_PCODE_VOLUME);
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 26edbec4ea3..f7e50950cec 100644
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -5195,4 +5195,19 @@ void LLTeleportRequestViaLocationLookAt::restartTeleport()
 //    gAgent.doTeleportViaLocationLookAt(getPosGlobal());
 }
 
+LLUUID LLAgent::getGroupForRezzing()
+{
+	if (gSavedSettings.getBOOL("AlchemyRezUnderLandGroup"))
+	{
+		LLParcel* land_parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
+		// Is the agent in the land group
+		if (gAgent.isInGroup(land_parcel->getGroupID()))
+			return land_parcel->getGroupID();
+		// Is the agent in the land group (the group owns the land)
+		else if (gAgent.isInGroup(land_parcel->getOwnerID()))
+			return land_parcel->getOwnerID();
+	}
+	return LLUUID::null;
+}
+
 // EOF
diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h
index fb5ef12c659..77ff3507fbf 100644
--- a/indra/newview/llagent.h
+++ b/indra/newview/llagent.h
@@ -905,6 +905,7 @@ class LLAgent : public LLOldEvents::LLObservable
 public:
 	void			setHideGroupTitle(BOOL hide)	{ mHideGroupTitle = hide; }
 	BOOL			isGroupTitleHidden() const 		{ return mHideGroupTitle; }
+	LLUUID			getGroupForRezzing();
 private:
 	std::string		mGroupTitle; 					// Honorific, like "Sir"
 	BOOL			mHideGroupTitle;
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 1a327a3778a..86c31e22a88 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -4077,7 +4077,7 @@ void LLSelectMgr::packDuplicateOnRayHead(void *user_data)
 	msg->nextBlockFast(_PREHASH_AgentData);
 	msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
 	msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() );
-	msg->addUUIDFast(_PREHASH_GroupID, gAgent.getGroupID() );
+	msg->addUUIDFast(_PREHASH_GroupID, gAgent.getGroupForRezzing() );
 	msg->addVector3Fast(_PREHASH_RayStart, data->mRayStartRegion );
 	msg->addVector3Fast(_PREHASH_RayEnd, data->mRayEndRegion );
 	msg->addBOOLFast(_PREHASH_BypassRaycast, data->mBypassRaycast );
diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp
index f65ae6d6378..00703d4fe2d 100644
--- a/indra/newview/lltooldraganddrop.cpp
+++ b/indra/newview/lltooldraganddrop.cpp
@@ -1330,7 +1330,7 @@ void LLToolDragAndDrop::dropObject(LLViewerObject* raycast_target,
 	msg->nextBlockFast(_PREHASH_AgentData);
 	msg->addUUIDFast(_PREHASH_AgentID,  gAgent.getID());
 	msg->addUUIDFast(_PREHASH_SessionID,  gAgent.getSessionID());
-	msg->addUUIDFast(_PREHASH_GroupID, gAgent.getGroupID());
+	msg->addUUIDFast(_PREHASH_GroupID, gAgent.getGroupForRezzing());
 
 	msg->nextBlock("RezData");
 	// if it's being rezzed from task inventory, we need to enable
diff --git a/indra/newview/lltoolplacer.cpp b/indra/newview/lltoolplacer.cpp
index 34d33743b94..b87659ad369 100644
--- a/indra/newview/lltoolplacer.cpp
+++ b/indra/newview/lltoolplacer.cpp
@@ -245,7 +245,7 @@ BOOL LLToolPlacer::addObject( LLPCode pcode, S32 x, S32 y, U8 use_physics )
 	gMessageSystem->nextBlockFast(_PREHASH_AgentData);
 	gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
 	gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
-	gMessageSystem->addUUIDFast(_PREHASH_GroupID, gAgent.getGroupID());
+	gMessageSystem->addUUIDFast(_PREHASH_GroupID, gAgent.getGroupForRezzing());
 	gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
 	gMessageSystem->addU8Fast(_PREHASH_Material,	material);
 
-- 
GitLab