From b721494405d60597ef2bfe981e25751b517ad56a Mon Sep 17 00:00:00 2001 From: Ansariel Date: Wed, 26 Oct 2016 17:42:22 +0200 Subject: [PATCH] Refactor code for rezzing under land group and concentrate it into FSCommon::getGroupForRezzing() --- indra/newview/fscommon.cpp | 22 +++++++++++++++++++++ indra/newview/fscommon.h | 3 +++ indra/newview/fsfloaterimport.cpp | 21 ++++---------------- indra/newview/llselectmgr.cpp | 30 +++-------------------------- indra/newview/lltooldraganddrop.cpp | 15 +-------------- indra/newview/lltoolplacer.cpp | 15 +-------------- 6 files changed, 34 insertions(+), 72 deletions(-) diff --git a/indra/newview/fscommon.cpp b/indra/newview/fscommon.cpp index f8f6072793..222a147d7f 100644 --- a/indra/newview/fscommon.cpp +++ b/indra/newview/fscommon.cpp @@ -37,11 +37,13 @@ #include "lllogchat.h" #include "llmutelist.h" #include "llnotificationmanager.h" +#include "llparcel.h" #include "lltooldraganddrop.h" #include "lltrans.h" #include "llviewerinventory.h" #include "llviewernetwork.h" #include "llviewerobject.h" +#include "llviewerparcelmgr.h" #include "llviewerregion.h" #include "rlvactions.h" #include "rlvhandler.h" @@ -426,3 +428,23 @@ bool FSCommon::isFilterEditorKeyCombo(KEY key, MASK mask) { return (mask == MASK_CONTROL && key == 'F' && gSavedSettings.getBOOL("FSSelectLocalSearchEditorOnShortcut")); } + +LLUUID FSCommon::getGroupForRezzing() +{ + LLUUID group_id = gAgent.getGroupID(); + LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); + + if (parcel && gSavedSettings.getBOOL("RezUnderLandGroup")) + { + // In both cases, group-owned or not, the group ID is the same; + // No need to query the parcel owner ID as it will be either + // the group ID if the parcel is group-owned or the ID of an + // avatar. + if (parcel->getGroupID().notNull() && gAgent.isInGroup(parcel->getGroupID())) + { + group_id = parcel->getGroupID(); + } + } + + return group_id; +} diff --git a/indra/newview/fscommon.h b/indra/newview/fscommon.h index 3fa6b52bdd..5d00a2887c 100644 --- a/indra/newview/fscommon.h +++ b/indra/newview/fscommon.h @@ -32,6 +32,7 @@ class LLAvatarName; class LLViewerObject; +class LLViewerParcelMgr; const F64 AVATAR_UNKNOWN_Z_OFFSET = -1.0; // Const value for avatars at unknown height const F32 AVATAR_UNKNOWN_RANGE = -1.f; @@ -86,6 +87,8 @@ namespace FSCommon bool isLegacySkin(); bool isFilterEditorKeyCombo(KEY key, MASK mask); + + LLUUID getGroupForRezzing(); }; #endif // FS_COMMON_H diff --git a/indra/newview/fsfloaterimport.cpp b/indra/newview/fsfloaterimport.cpp index 1753d31de6..587e83c0b9 100644 --- a/indra/newview/fsfloaterimport.cpp +++ b/indra/newview/fsfloaterimport.cpp @@ -28,6 +28,7 @@ #include "llviewerprecompiledheaders.h" #include "fsfloaterimport.h" +#include "fscommon.h" #include "llagent.h" #include "llappviewer.h" #include "llbuycurrencyhtml.h" @@ -656,23 +657,9 @@ void FSFloaterImport::createPrim() gMessageSystem->newMessageFast(_PREHASH_ObjectAdd); gMessageSystem->nextBlockFast(_PREHASH_AgentData); - gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - - LLUUID group_id = gAgent.getGroupID(); - LLParcel *parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); - if (gSavedSettings.getBOOL("RezUnderLandGroup")) - { - if (gAgent.isInGroup(parcel->getGroupID())) - { - group_id = parcel->getGroupID(); - } - else if (gAgent.isInGroup(parcel->getOwnerID())) - { - group_id = parcel->getOwnerID(); - } - } - gMessageSystem->addUUIDFast(_PREHASH_GroupID, group_id); + gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgentID); + gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgentSessionID); + gMessageSystem->addUUIDFast(_PREHASH_GroupID, FSCommon::getGroupForRezzing()); gMessageSystem->nextBlockFast(_PREHASH_ObjectData); gMessageSystem->addU8Fast(_PREHASH_Material, (U8)prim["material"].asInteger()); diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 8b34cfe3c5..e70d526192 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -107,6 +107,7 @@ // Aurora Sim #include "fsareasearch.h" #include "llglheaders.h" +#include "fscommon.h" LLViewerObject* getSelectedParentObject(LLViewerObject *object) ; // @@ -4088,20 +4089,7 @@ void LLSelectMgr::packDuplicateOnRayHead(void *user_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("RezUnderLandGroup")) - { - LLParcel *parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); - if (gAgent.isInGroup(parcel->getGroupID())) - { - group_id = parcel->getGroupID(); - } - else if (gAgent.isInGroup(parcel->getOwnerID())) - { - group_id = parcel->getOwnerID(); - } - } - msg->addUUIDFast(_PREHASH_GroupID, group_id); + msg->addUUIDFast(_PREHASH_GroupID, FSCommon::getGroupForRezzing()); msg->addVector3Fast(_PREHASH_RayStart, data->mRayStartRegion ); msg->addVector3Fast(_PREHASH_RayEnd, data->mRayEndRegion ); msg->addBOOLFast(_PREHASH_BypassRaycast, data->mBypassRaycast ); @@ -4970,19 +4958,7 @@ void LLSelectMgr::packAgentAndSessionAndGroupID(void* user_data) // static void LLSelectMgr::packDuplicateHeader(void* data) { - LLUUID group_id(gAgent.getGroupID()); - if (gSavedSettings.getBOOL("RezUnderLandGroup")) - { - LLParcel *parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); - if (gAgent.isInGroup(parcel->getGroupID())) - { - group_id = parcel->getGroupID(); - } - else if (gAgent.isInGroup(parcel->getOwnerID())) - { - group_id = parcel->getOwnerID(); - } - } + LLUUID group_id(FSCommon::getGroupForRezzing()); packAgentAndSessionAndGroupID(&group_id); LLDuplicateData* dup_data = (LLDuplicateData*) data; diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index 66c0f433da..9bd97327e6 100644 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -1329,20 +1329,7 @@ void LLToolDragAndDrop::dropObject(LLViewerObject* raycast_target, msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - LLUUID group_id = gAgent.getGroupID(); - if (gSavedSettings.getBOOL("RezUnderLandGroup")) - { - LLParcel *parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); - if (gAgent.isInGroup(parcel->getGroupID())) - { - group_id = parcel->getGroupID(); - } - else if (gAgent.isInGroup(parcel->getOwnerID())) - { - group_id = parcel->getOwnerID(); - } - } - msg->addUUIDFast(_PREHASH_GroupID, group_id); + msg->addUUIDFast(_PREHASH_GroupID, FSCommon::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 0bc5749d0a..65ff61f02a 100644 --- a/indra/newview/lltoolplacer.cpp +++ b/indra/newview/lltoolplacer.cpp @@ -305,20 +305,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()); - LLUUID group_id = gAgent.getGroupID(); - LLParcel *parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); - if (gSavedSettings.getBOOL("RezUnderLandGroup")) - { - if (gAgent.isInGroup(parcel->getGroupID())) - { - group_id = parcel->getGroupID(); - } - else if (gAgent.isInGroup(parcel->getOwnerID())) - { - group_id = parcel->getOwnerID(); - } - } - gMessageSystem->addUUIDFast(_PREHASH_GroupID, group_id); + gMessageSystem->addUUIDFast(_PREHASH_GroupID, FSCommon::getGroupForRezzing()); gMessageSystem->nextBlockFast(_PREHASH_ObjectData); gMessageSystem->addU8Fast(_PREHASH_Material, material);