From 2aa11e6383381f84a7be1a41344c91c3f0c472ad Mon Sep 17 00:00:00 2001 From: Beq Date: Thu, 23 Nov 2023 18:50:49 +0000 Subject: [PATCH] FIRE-33384 - AO updates. Make pernickety compilers happy. --- indra/newview/aoengine.cpp | 40 ++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/indra/newview/aoengine.cpp b/indra/newview/aoengine.cpp index ac306310af..569f5d3662 100644 --- a/indra/newview/aoengine.cpp +++ b/indra/newview/aoengine.cpp @@ -987,7 +987,7 @@ void AOEngine::addSet(const std::string& name, inventory_func_type callback, boo BOOL wasProtected = gSavedPerAccountSettings.getBOOL("LockAOFolders"); gSavedPerAccountSettings.setBOOL("LockAOFolders", FALSE); LL_DEBUGS("AOEngine") << "adding set folder " << name << LL_ENDL; - gInventory.createNewCategory(mAOFolder, LLFolderType::FT_NONE, name, [callback, wasProtected, reload, this](const LLUUID &new_cat_id) + gInventory.createNewCategory(mAOFolder, LLFolderType::FT_NONE, name, [callback, wasProtected](const LLUUID &new_cat_id) { gSavedPerAccountSettings.setBOOL("LockAOFolders", wasProtected); @@ -2019,20 +2019,12 @@ void AOEngine::parseNotecard(const char* buffer) std::vector lines; LLStringUtil::getTokens(text, lines, "\n"); - S32 found = 0; - std::size_t index = 0; - for (const auto& line : lines) - { - if (line.find("Text length ") == 0) - { - found = index + 1; - break; - } - index++; - } + auto it = std::find_if(lines.begin(), lines.end(), [](const std::string& line) { + return line.find("Text length ") == 0; + }); - if (!found) - { + if (it == lines.end()) { + // Line not found LLNotificationsUtil::add("AOImportNoText", LLSD()); delete mImportSet; mImportSet = nullptr; @@ -2040,6 +2032,9 @@ void AOEngine::parseNotecard(const char* buffer) return; } + // Line found, 'it' points to the found element + std::size_t found = std::distance(lines.begin(), it) + 1; + // mImportSet->getInventoryUUID() right now contains the folder UUID where the notecard is in LLViewerInventoryCategory* importCategory = gInventory.getCategory(mImportSet->getInventoryUUID()); if (!importCategory) @@ -2055,16 +2050,15 @@ void AOEngine::parseNotecard(const char* buffer) LLInventoryModel::cat_array_t* dummy; LLInventoryModel::item_array_t* items; - gInventory.getDirectDescendentsOf(mImportSet->getInventoryUUID(), dummy, items); - for (index = 0; index < items->size(); ++index) - { - animationMap[items->at(index)->getName()] = items->at(index)->getUUID(); - LL_DEBUGS("AOEngine") << "animation " << items->at(index)->getName() << - " has inventory UUID " << animationMap[items->at(index)->getName()] << LL_ENDL; - } + gInventory.getDirectDescendentsOf(mImportSet->getInventoryUUID(), dummy, items); + for (auto& item : *items) + { + animationMap[item->getName()] = item->getUUID(); + LL_DEBUGS("AOEngine") << "animation " << item->getName() << " has inventory UUID " << animationMap[item->getName()] << LL_ENDL; + } // [ State ]Anim1|Anim2|Anim3 - for (index = found; index < lines.size(); ++index) + for (auto index = found; index < lines.size(); ++index) { std::string line = lines[index]; @@ -2159,7 +2153,7 @@ void AOEngine::processImport(bool from_timer) if (mImportSet->getInventoryUUID().isNull()) { // create new inventory folder for this AO set, the next timer tick should pick it up - addSet(mImportSet->getName(), [this, from_timer](const LLUUID& new_cat_id) + addSet(mImportSet->getName(), [this](const LLUUID& new_cat_id) { mImportSet->setInventoryUUID(new_cat_id); }, false);