diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2023-10-31 22:16:27 +0200 |
---|---|---|
committer | akleshchev <117672381+akleshchev@users.noreply.github.com> | 2023-10-31 23:18:11 +0200 |
commit | 40e568a3180f641fe0feb0e6ddd696c07ed662be (patch) | |
tree | e18ac9b8f7f97e4533556ef79528f36492bd44c1 /indra/newview | |
parent | f72309a17eab1be1979c58a135e061ebffc37e21 (diff) |
SL-20549 Blank no-copy materials are not moved into scripted objects
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/lltooldraganddrop.cpp | 4 | ||||
-rw-r--r-- | indra/newview/llviewerobject.cpp | 69 | ||||
-rw-r--r-- | indra/newview/llviewerobject.h | 3 |
3 files changed, 62 insertions, 14 deletions
diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index 97be78df77..e7f96239fd 100644 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -961,7 +961,9 @@ BOOL LLToolDragAndDrop::handleDropMaterialProtections(LLViewerObject* hit_obj, LLNotificationsUtil::add("ErrorMessage", args); return FALSE; } - if (hit_obj->getInventoryItemByAsset(item->getAssetUUID())) + // Make sure to verify both id and type since 'null' + // is a shared default for some asset types. + if (hit_obj->getInventoryItemByAsset(item->getAssetUUID(), item->getType())) { // if the asset is already in the object's inventory // then it can always be added to a side. diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index a1d068461e..028fea29c2 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -3498,22 +3498,29 @@ void LLViewerObject::removeInventory(const LLUUID& item_id) ++mExpectedInventorySerialNum; } -bool LLViewerObject::isAssetInInventory(LLViewerInventoryItem* item) +bool LLViewerObject::isAssetInInventory(LLViewerInventoryItem* item, LLAssetType::EType type) { - bool result = false; + bool result = false; - if (item) - { - std::list<LLUUID>::iterator begin = mPendingInventoryItemsIDs.begin(); - std::list<LLUUID>::iterator end = mPendingInventoryItemsIDs.end(); + if (item) + { + // For now mPendingInventoryItemsIDs only stores textures and materials + // but if it gets to store more types, it will need to verify type as well + // since null can be a shared default id and it is fine to need a null + // script and a null material simultaneously. + std::list<LLUUID>::iterator begin = mPendingInventoryItemsIDs.begin(); + std::list<LLUUID>::iterator end = mPendingInventoryItemsIDs.end(); - bool is_fetching = std::find(begin, end, item->getAssetUUID()) != end; - bool is_fetched = getInventoryItemByAsset(item->getAssetUUID()) != NULL; + bool is_fetching = std::find(begin, end, item->getAssetUUID()) != end; - result = is_fetched || is_fetching; - } + // null is the default asset for materials and default for scripts + // so need to check type as well + bool is_fetched = getInventoryItemByAsset(item->getAssetUUID(), type) != NULL; - return result; + result = is_fetched || is_fetching; + } + + return result; } void LLViewerObject::updateMaterialInventory(LLViewerInventoryItem* item, U8 key, bool is_new) @@ -3529,7 +3536,7 @@ void LLViewerObject::updateMaterialInventory(LLViewerInventoryItem* item, U8 key return; } - if (isAssetInInventory(item)) + if (isAssetInInventory(item, item->getType())) { // already there return; @@ -3672,6 +3679,44 @@ LLViewerInventoryItem* LLViewerObject::getInventoryItemByAsset(const LLUUID& ass return rv; } +LLViewerInventoryItem* LLViewerObject::getInventoryItemByAsset(const LLUUID& asset_id, LLAssetType::EType type) +{ + if (mInventoryDirty) + LL_WARNS() << "Peforming inventory lookup for object " << mID << " that has dirty inventory!" << LL_ENDL; + + LLViewerInventoryItem* rv = NULL; + if (type == LLAssetType::AT_CATEGORY) + { + // Whatever called this shouldn't be trying to get a folder by asset + // categories don't have assets + llassert(0); + return rv; + } + + if (mInventory) + { + LLViewerInventoryItem* item = NULL; + + LLInventoryObject::object_list_t::iterator it = mInventory->begin(); + LLInventoryObject::object_list_t::iterator end = mInventory->end(); + for (; it != end; ++it) + { + LLInventoryObject* obj = *it; + if (obj->getType() == type) + { + // *FIX: gank-ass down cast! + item = (LLViewerInventoryItem*)obj; + if (item->getAssetUUID() == asset_id) + { + rv = item; + break; + } + } + } + } + return rv; +} + void LLViewerObject::updateViewerInventoryAsset( const LLViewerInventoryItem* item, const LLUUID& new_asset) diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 898b21e1ae..ec7bf36f71 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -500,6 +500,7 @@ public: void getInventoryContents(LLInventoryObject::object_list_t& objects); LLInventoryObject* getInventoryRoot(); LLViewerInventoryItem* getInventoryItemByAsset(const LLUUID& asset_id); + LLViewerInventoryItem* getInventoryItemByAsset(const LLUUID& asset_id, LLAssetType::EType type); S16 getInventorySerial() const { return mInventorySerialNum; } // These functions does viewer-side only object inventory modifications @@ -639,7 +640,7 @@ public: private: void setObjectCostStale(); - bool isAssetInInventory(LLViewerInventoryItem* item); + bool isAssetInInventory(LLViewerInventoryItem* item, LLAssetType::EType type); ExtraParameter* createNewParameterEntry(U16 param_type); ExtraParameter* getExtraParameterEntry(U16 param_type) const; |