diff options
Diffstat (limited to 'indra/newview/llinventorymodel.cpp')
-rw-r--r-- | indra/newview/llinventorymodel.cpp | 177 |
1 files changed, 78 insertions, 99 deletions
diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index c6192ddf1a..53ea02983a 100644 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -79,7 +79,7 @@ // Increment this if the inventory contents change in a non-backwards-compatible way. // For viewer 2, the addition of link items makes a pre-viewer-2 cache incorrect. const S32 LLInventoryModel::sCurrentInvCacheVersion = 3; -BOOL LLInventoryModel::sFirstTimeInViewer2 = TRUE; +bool LLInventoryModel::sFirstTimeInViewer2 = true; S32 LLInventoryModel::sPendingSystemFolders = 0; @@ -87,7 +87,7 @@ S32 LLInventoryModel::sPendingSystemFolders = 0; /// Local function declarations, constants, enums, and typedefs ///---------------------------------------------------------------------------- -//BOOL decompress_file(const char* src_filename, const char* dst_filename); +//bool decompress_file(const char* src_filename, const char* dst_filename); static const char PRODUCTION_CACHE_FORMAT_STRING[] = "%s.inv.llsd"; static const char GRID_CACHE_FORMAT_STRING[] = "%s.%s.inv.llsd"; static const char * const LOG_INV("Inventory"); @@ -316,7 +316,7 @@ public: if (LLInventoryState::sWearNewClothing) { LLInventoryState::sWearNewClothingTransactionID = tid; - LLInventoryState::sWearNewClothing = FALSE; + LLInventoryState::sWearNewClothing = false; } if (tid.notNull() && tid == LLInventoryState::sWearNewClothingTransactionID) @@ -333,7 +333,7 @@ public: if (LLInventoryState::sWearNewClothing && wearable_ids.size() > 0) { - LLInventoryState::sWearNewClothing = FALSE; + LLInventoryState::sWearNewClothing = false; size_t count = wearable_ids.size(); for (S32 i = 0; i < count; ++i) @@ -441,7 +441,7 @@ LLInventoryModel::LLInventoryModel() mParentChildCategoryTree(), mParentChildItemTree(), mLastItem(NULL), - mIsNotifyObservers(FALSE), + mIsNotifyObservers(false), mModifyMask(LLInventoryObserver::ALL), mChangedItemIDs(), mBulkFecthCallbackSlot(), @@ -493,10 +493,10 @@ void LLInventoryModel::cleanupInventory() // This is a convenience function to check if one object has a parent // chain up to the category specified by UUID. -BOOL LLInventoryModel::isObjectDescendentOf(const LLUUID& obj_id, +bool LLInventoryModel::isObjectDescendentOf(const LLUUID& obj_id, const LLUUID& cat_id) const { - if (obj_id == cat_id) return TRUE; + if (obj_id == cat_id) return true; const LLInventoryObject* obj = getObject(obj_id); while(obj) @@ -504,17 +504,17 @@ BOOL LLInventoryModel::isObjectDescendentOf(const LLUUID& obj_id, const LLUUID& parent_id = obj->getParentUUID(); if( parent_id.isNull() ) { - return FALSE; + return false; } if(parent_id == cat_id) { - return TRUE; + return true; } // Since we're scanning up the parents, we only need to check // in the category list. obj = getCategory(parent_id); } - return FALSE; + return false; } const LLViewerInventoryCategory *LLInventoryModel::getFirstNondefaultParent(const LLUUID& obj_id) const @@ -657,12 +657,12 @@ LLViewerInventoryCategory* LLInventoryModel::getCategory(const LLUUID& id) const S32 LLInventoryModel::getItemCount() const { - return mItemMap.size(); + return static_cast<S32>(mItemMap.size()); } S32 LLInventoryModel::getCategoryCount() const { - return mCategoryMap.size(); + return static_cast<S32>(mCategoryMap.size()); } // Return the direct descendents of the id provided. The array @@ -782,7 +782,7 @@ void LLInventoryModel::consolidateForType(const LLUUID& main_id, LLFolderType::E for (std::vector<LLUUID>::const_iterator it = list_uuids.begin(); it != list_uuids.end(); ++it) { LLViewerInventoryItem* item = getItem(*it); - changeItemParent(item, main_id, TRUE); + changeItemParent(item, main_id, true); } // Move all folders to the main folder @@ -794,7 +794,7 @@ void LLInventoryModel::consolidateForType(const LLUUID& main_id, LLFolderType::E for (std::vector<LLUUID>::const_iterator it = list_uuids.begin(); it != list_uuids.end(); ++it) { LLViewerInventoryCategory* cat = getCategory(*it); - changeCategoryParent(cat, main_id, TRUE); + changeCategoryParent(cat, main_id, true); } // Purge the emptied folder @@ -805,7 +805,7 @@ void LLInventoryModel::consolidateForType(const LLUUID& main_id, LLFolderType::E const LLUUID trash_id = findCategoryUUIDForType(LLFolderType::FT_TRASH); if (trash_id.notNull()) { - changeCategoryParent(cat, trash_id, TRUE); + changeCategoryParent(cat, trash_id, true); } } remove_inventory_category(folder_id, NULL); @@ -822,17 +822,14 @@ void LLInventoryModel::ensureCategoryForTypeExists(LLFolderType::EType preferred } else if (root_id.notNull()) { - cat_array_t* cats = NULL; - cats = get_ptr_in_map(mParentChildCategoryTree, root_id); + cat_array_t* cats = get_ptr_in_map(mParentChildCategoryTree, root_id); if (cats) { - S32 count = cats->size(); - for (S32 i = 0; i < count; ++i) + for (auto& p_cat : *cats) { - LLViewerInventoryCategory* p_cat = cats->at(i); if (p_cat && p_cat->getPreferredType() == preferred_type) { - const LLUUID& folder_id = cats->at(i)->getUUID(); + const LLUUID& folder_id = p_cat->getUUID(); if (rv.isNull() || folder_id < rv) { rv = folder_id; @@ -891,17 +888,14 @@ const LLUUID LLInventoryModel::findCategoryUUIDForTypeInRoot( } else if (root_id.notNull()) { - cat_array_t* cats = NULL; - cats = get_ptr_in_map(mParentChildCategoryTree, root_id); + cat_array_t* cats = get_ptr_in_map(mParentChildCategoryTree, root_id); if(cats) { - S32 count = cats->size(); - for(S32 i = 0; i < count; ++i) + for (auto& p_cat : *cats) { - LLViewerInventoryCategory* p_cat = cats->at(i); if(p_cat && p_cat->getPreferredType() == preferred_type) { - const LLUUID& folder_id = cats->at(i)->getUUID(); + const LLUUID& folder_id = p_cat->getUUID(); if (rv.isNull() || folder_id < rv) { rv = folder_id; @@ -1257,14 +1251,14 @@ public: virtual bool operator()(LLInventoryCategory* cat, LLInventoryItem* item) { - return TRUE; + return true; } }; void LLInventoryModel::collectDescendents(const LLUUID& id, cat_array_t& cats, item_array_t& items, - BOOL include_trash) + bool include_trash) { LLAlwaysCollect always; collectDescendentsIf(id, cats, items, include_trash, always); @@ -1273,7 +1267,7 @@ void LLInventoryModel::collectDescendents(const LLUUID& id, void LLInventoryModel::collectDescendentsIf(const LLUUID& id, cat_array_t& cats, item_array_t& items, - BOOL include_trash, + bool include_trash, LLInventoryCollectFunctor& add) { // Start with categories @@ -1286,10 +1280,8 @@ void LLInventoryModel::collectDescendentsIf(const LLUUID& id, cat_array_t* cat_array = get_ptr_in_map(mParentChildCategoryTree, id); if(cat_array) { - S32 count = cat_array->size(); - for(S32 i = 0; i < count; ++i) + for (auto& cat : *cat_array) { - LLViewerInventoryCategory* cat = cat_array->at(i); if(add(cat,NULL)) { cats.push_back(cat); @@ -1298,16 +1290,13 @@ void LLInventoryModel::collectDescendentsIf(const LLUUID& id, } } - LLViewerInventoryItem* item = NULL; item_array_t* item_array = get_ptr_in_map(mParentChildItemTree, id); // Move onto items if(item_array) { - S32 count = item_array->size(); - for(S32 i = 0; i < count; ++i) + for (auto& item : *item_array) { - item = item_array->at(i); if(add(NULL, item)) { items.push_back(item); @@ -1400,7 +1389,9 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item, U32 mask) return mask; } - if (item->getType() == LLAssetType::AT_MESH) + if (item->getType() == LLAssetType::AT_MESH || + item->getType() == LLAssetType::AT_GLTF || + item->getType() == LLAssetType::AT_GLTF_BIN) { return mask; } @@ -1474,7 +1465,7 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item, U32 mask) { // Parent id at server is null, so update server even if item already is in the same folder old_item->setParent(new_parent_id); - new_item->updateParentOnServer(FALSE); + new_item->updateParentOnServer(false); } mask |= LLInventoryObserver::INTERNAL; } @@ -1495,7 +1486,7 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item, U32 mask) gInventory.accountForUpdate(update); // *FIX: bit of a hack to call update server from here... - new_item->updateParentOnServer(FALSE); + new_item->updateParentOnServer(false); item_array->push_back(new_item); } else @@ -1540,7 +1531,7 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item, U32 mask) gInventory.accountForUpdate(update); // *FIX: bit of a hack to call update server from // here... - new_item->updateParentOnServer(FALSE); + new_item->updateParentOnServer(false); item_array->push_back(new_item); } else @@ -1558,7 +1549,7 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item, U32 mask) // Target ID is stored in the description field of the card. LLUUID id; std::string desc = new_item->getDescription(); - BOOL isId = desc.empty() ? FALSE : id.set(desc, FALSE); + bool isId = desc.empty() ? false : id.set(desc, false); if (isId) { // Valid UUID; set the item UUID and rename it @@ -1593,7 +1584,7 @@ LLInventoryModel::cat_array_t* LLInventoryModel::getUnlockedCatArray(const LLUUI cat_array_t* cat_array = get_ptr_in_map(mParentChildCategoryTree, id); if (cat_array) { - llassert_always(mCategoryLock[id] == false); + llassert_always(!mCategoryLock[id]); } return cat_array; } @@ -1603,7 +1594,7 @@ LLInventoryModel::item_array_t* LLInventoryModel::getUnlockedItemArray(const LLU item_array_t* item_array = get_ptr_in_map(mParentChildItemTree, id); if (item_array) { - llassert_always(mItemLock[id] == false); + llassert_always(!mItemLock[id]); } return item_array; } @@ -1675,8 +1666,8 @@ void LLInventoryModel::updateCategory(const LLViewerInventoryCategory* cat, U32 } // make space in the tree for this category's children. - llassert_always(mCategoryLock[new_cat->getUUID()] == false); - llassert_always(mItemLock[new_cat->getUUID()] == false); + llassert_always(!mCategoryLock[new_cat->getUUID()]); + llassert_always(!mItemLock[new_cat->getUUID()]); cat_array_t* catsp = new cat_array_t; item_array_t* itemsp = new item_array_t; mParentChildCategoryTree[new_cat->getUUID()] = catsp; @@ -1732,7 +1723,7 @@ void LLInventoryModel::moveObject(const LLUUID& object_id, const LLUUID& cat_id) // Migrated from llinventoryfunctions void LLInventoryModel::changeItemParent(LLViewerInventoryItem* item, const LLUUID& new_parent_id, - BOOL restamp) + bool restamp) { if (item->getParentUUID() == new_parent_id) { @@ -1760,7 +1751,7 @@ void LLInventoryModel::changeItemParent(LLViewerInventoryItem* item, // Migrated from llinventoryfunctions void LLInventoryModel::changeCategoryParent(LLViewerInventoryCategory* cat, const LLUUID& new_parent_id, - BOOL restamp) + bool restamp) { if (!cat) { @@ -1906,10 +1897,10 @@ void LLInventoryModel::onDescendentsPurgedFromServer(const LLUUID& object_id, bo categories, items, LLInventoryModel::INCLUDE_TRASH); - S32 count = items.size(); + auto count = items.size(); LLUUID uu_id; - for(S32 i = 0; i < count; ++i) + for(size_t i = 0; i < count; ++i) { uu_id = items.at(i)->getUUID(); @@ -1985,7 +1976,7 @@ void LLInventoryModel::onObjectDeletedFromServer(const LLUUID& object_id, bool f LLViewerInventoryItem *item = getItem(object_id); if (item && (item->getType() != LLAssetType::AT_LSL_TEXT)) { - LLPreview::hide(object_id, TRUE); + LLPreview::hide(object_id, true); } deleteObject(object_id, fix_broken_links, do_notify_observers); } @@ -2104,7 +2095,7 @@ void LLInventoryModel::removeObserver(LLInventoryObserver* observer) mObservers.erase(observer); } -BOOL LLInventoryModel::containsObserver(LLInventoryObserver* observer) const +bool LLInventoryModel::containsObserver(LLInventoryObserver* observer) const { return mObservers.find(observer) != mObservers.end(); } @@ -2147,7 +2138,7 @@ void LLInventoryModel::notifyObservers() return; } - mIsNotifyObservers = TRUE; + mIsNotifyObservers = true; for (observer_list_t::iterator iter = mObservers.begin(); iter != mObservers.end(); ) { @@ -2170,7 +2161,7 @@ void LLInventoryModel::notifyObservers() mChangedItemIDsBacklog.clear(); mAddedItemIDsBacklog.clear(); - mIsNotifyObservers = FALSE; + mIsNotifyObservers = false; } // store flag for change @@ -2689,8 +2680,8 @@ bool LLInventoryModel::loadSkeleton( } } - S32 cached_category_count = 0; - S32 cached_item_count = 0; + size_t cached_category_count = 0; + size_t cached_item_count = 0; if(!temp_cats.empty()) { update_map_t child_counts; @@ -2739,12 +2730,10 @@ bool LLInventoryModel::loadSkeleton( // found to generate a set of categories we should add. We // will go through each category loaded and if the version // does not match, invalidate the version. - S32 count = categories.size(); cat_set_t::iterator not_cached = temp_cats.end(); - std::set<LLUUID> cached_ids; - for(S32 i = 0; i < count; ++i) + uuid_set_t cached_ids; + for (auto& cat : categories) { - LLViewerInventoryCategory* cat = categories[i]; cat_set_t::iterator cit = temp_cats.find(cat); if (cit == temp_cats.end()) { @@ -2965,13 +2954,13 @@ void LLInventoryModel::buildParentChildMap() cats.push_back(cat); if (mParentChildCategoryTree.count(cat->getUUID()) == 0) { - llassert_always(mCategoryLock[cat->getUUID()] == false); + llassert_always(!mCategoryLock[cat->getUUID()]); catsp = new cat_array_t; mParentChildCategoryTree[cat->getUUID()] = catsp; } if (mParentChildItemTree.count(cat->getUUID()) == 0) { - llassert_always(mItemLock[cat->getUUID()] == false); + llassert_always(!mItemLock[cat->getUUID()]); itemsp = new item_array_t; mParentChildItemTree[cat->getUUID()] = itemsp; } @@ -2990,13 +2979,11 @@ void LLInventoryModel::buildParentChildMap() // Now we have a structure with all of the categories that we can // iterate over and insert into the correct place in the child // category tree. - S32 count = cats.size(); S32 i; S32 lost = 0; cat_array_t lost_cats; - for(i = 0; i < count; ++i) + for (auto& cat : cats) { - LLViewerInventoryCategory* cat = cats.at(i); catsp = getUnlockedCatArray(cat->getParentUUID()); if(catsp && // Only the two root folders should be children of null. @@ -3050,10 +3037,10 @@ void LLInventoryModel::buildParentChildMap() // FIXME note that updateServer() fails with protected // types, so this will not work as intended in that case. // UpdateServer uses AIS, AIS cat move is not implemented yet - // cat->updateServer(TRUE); + // cat->updateServer(true); // MoveInventoryFolder message, intentionally per item - cat->updateParentOnServer(FALSE); + cat->updateParentOnServer(false); catsp = getUnlockedCatArray(cat->getParentUUID()); if(catsp) { @@ -3065,7 +3052,7 @@ void LLInventoryModel::buildParentChildMap() } } - const BOOL COF_exists = (findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT) != LLUUID::null); + const bool COF_exists = (findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT) != LLUUID::null); sFirstTimeInViewer2 = !COF_exists || gAgent.isFirstLogin(); @@ -3082,13 +3069,10 @@ void LLInventoryModel::buildParentChildMap() items.push_back(item); } } - count = items.size(); lost = 0; uuid_vec_t lost_item_ids; - for(i = 0; i < count; ++i) + for (auto& item : items) { - LLPointer<LLViewerInventoryItem> item; - item = items.at(i); itemsp = getUnlockedItemArray(item->getParentUUID()); if(itemsp) { @@ -3121,18 +3105,18 @@ void LLInventoryModel::buildParentChildMap() { LL_WARNS(LOG_INV) << "Found " << lost << " lost items." << LL_ENDL; LLMessageSystem* msg = gMessageSystem; - BOOL start_new_message = TRUE; + bool start_new_message = true; const LLUUID lnf = findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND); for(uuid_vec_t::iterator it = lost_item_ids.begin() ; it < lost_item_ids.end(); ++it) { if(start_new_message) { - start_new_message = FALSE; + start_new_message = false; msg->newMessageFast(_PREHASH_MoveInventoryItem); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - msg->addBOOLFast(_PREHASH_Stamp, FALSE); + msg->addBOOLFast(_PREHASH_Stamp, false); } msg->nextBlockFast(_PREHASH_InventoryData); msg->addUUIDFast(_PREHASH_ItemID, (*it)); @@ -3140,7 +3124,7 @@ void LLInventoryModel::buildParentChildMap() msg->addString("NewName", NULL); if(msg->isSendFull(NULL)) { - start_new_message = TRUE; + start_new_message = true; gAgent.sendReliableMessage(); } } @@ -3469,12 +3453,9 @@ bool LLInventoryModel::saveToFile(const std::string& filename, fileXML << LLSDOStreamer<LLSDNotationFormatter>(cache_ver) << std::endl; - S32 count = categories.size(); S32 cat_count = 0; - S32 i; - for (i = 0; i < count; ++i) + for (auto& cat : categories) { - LLViewerInventoryCategory* cat = categories[i]; if (cat->getVersion() != LLViewerInventoryCategory::VERSION_UNKNOWN) { fileXML << LLSDOStreamer<LLSDNotationFormatter>(cat->exportLLSD()) << std::endl; @@ -3488,10 +3469,10 @@ bool LLInventoryModel::saveToFile(const std::string& filename, } } - S32 it_count = items.size(); - for (i = 0; i < it_count; ++i) + auto it_count = items.size(); + for (auto& item : items) { - fileXML << LLSDOStreamer<LLSDNotationFormatter>(items[i]->asLLSD()) << std::endl; + fileXML << LLSDOStreamer<LLSDNotationFormatter>(item->asLLSD()) << std::endl; if (fileXML.fail()) { @@ -3952,16 +3933,14 @@ void LLInventoryModel::processBulkUpdateInventory(LLMessageSystem* msg, void**) if (LLInventoryState::sWearNewClothing) { LLInventoryState::sWearNewClothingTransactionID = tid; - LLInventoryState::sWearNewClothing = FALSE; + LLInventoryState::sWearNewClothing = false; } if (tid.notNull() && tid == LLInventoryState::sWearNewClothingTransactionID) { - count = wearable_ids.size(); - for (i = 0; i < count; ++i) + for (const auto& wearable_id : wearable_ids) { - LLViewerInventoryItem* wearable_item; - wearable_item = gInventory.getItem(wearable_ids[i]); + LLViewerInventoryItem* wearable_item = gInventory.getItem(wearable_id); LLAppearanceMgr::instance().wearItemOnAvatar(wearable_item->getUUID(), true, true); } } @@ -4056,7 +4035,7 @@ void LLInventoryModel::emptyFolderType(const std::string notification, LLFolderT LLInventoryModel::item_array_t items; const LLUUID trash_id = findCategoryUUIDForType(preferred_type); gInventory.collectDescendents(trash_id, cats, items, LLInventoryModel::INCLUDE_TRASH); //All descendants - S32 item_count = items.size() + cats.size(); + S32 item_count = static_cast<S32>(items.size() + cats.size()); args["COUNT"] = item_count; } LLNotificationsUtil::add(notification, args, LLSD(), @@ -4084,7 +4063,7 @@ void LLInventoryModel::removeItem(const LLUUID& item_id) if (new_parent.notNull()) { LL_INFOS("Inventory") << "Moving to Trash (" << new_parent << "):" << LL_ENDL; - changeItemParent(item, new_parent, TRUE); + changeItemParent(item, new_parent, true); } } } @@ -4099,7 +4078,7 @@ void LLInventoryModel::removeCategory(const LLUUID& category_id) // Look for any gestures and deactivate them LLInventoryModel::cat_array_t descendent_categories; LLInventoryModel::item_array_t descendent_items; - collectDescendents(category_id, descendent_categories, descendent_items, FALSE); + collectDescendents(category_id, descendent_categories, descendent_items, false); for (LLInventoryModel::item_array_t::const_iterator iter = descendent_items.begin(); iter != descendent_items.end(); @@ -4120,7 +4099,7 @@ void LLInventoryModel::removeCategory(const LLUUID& category_id) const LLUUID trash_id = findCategoryUUIDForType(LLFolderType::FT_TRASH); if (trash_id.notNull()) { - changeCategoryParent(cat, trash_id, TRUE); + changeCategoryParent(cat, trash_id, true); } } @@ -4178,7 +4157,7 @@ void LLInventoryModel::checkTrashOverflow() LLInventoryModel::item_array_t items; const LLUUID trash_id = findCategoryUUIDForType(LLFolderType::FT_TRASH); gInventory.collectDescendents(trash_id, cats, items, LLInventoryModel::INCLUDE_TRASH); - S32 item_count = items.size() + cats.size(); + auto item_count = items.size() + cats.size(); if (item_count >= trash_max_capacity) { @@ -4226,13 +4205,13 @@ void LLInventoryModel::setLibraryOwnerID(const LLUUID& val) } // static -BOOL LLInventoryModel::getIsFirstTimeInViewer2() +bool LLInventoryModel::getIsFirstTimeInViewer2() { // Do not call this before parentchild map is built. if (!gInventory.mIsAgentInvUsable) { LL_WARNS() << "Parent Child Map not yet built; guessing as first time in viewer2." << LL_ENDL; - return TRUE; + return true; } return sFirstTimeInViewer2; @@ -4851,9 +4830,9 @@ std::string LLInventoryModel::getFullPath(const LLInventoryObject *obj) const #if 0 -BOOL decompress_file(const char* src_filename, const char* dst_filename) +bool decompress_file(const char* src_filename, const char* dst_filename) { - BOOL rv = FALSE; + bool rv = false; gzFile src = NULL; U8* buffer = NULL; LLFILE* dst = NULL; @@ -4881,7 +4860,7 @@ BOOL decompress_file(const char* src_filename, const char* dst_filename) } while(gzeof(src) == 0); // success - rv = TRUE; + rv = true; err_decompress: if(src != NULL) gzclose(src); @@ -4987,7 +4966,7 @@ void LLInventoryModel::FetchItemHttpHandler::processData(LLSD & content, LLCore: LLInventoryModel::update_map_t update; LLUUID folder_id; LLSD content_items(content["items"]); - const S32 count(content_items.size()); + const S32 count(static_cast<S32>(content_items.size())); // Does this loop ever execute more than once? for (S32 i(0); i < count; ++i) |