From 45fdba8fd96ed714cbc0120b0a10a4c5b63ea706 Mon Sep 17 00:00:00 2001
From: Brad Linden <46733234+brad-linden@users.noreply.github.com>
Date: Wed, 19 Apr 2023 09:41:07 -0700
Subject: [PATCH] Implement SL-19605 handling of batched material overrides in
 LargeGenericMessage (#177)

---
 indra/newview/llgltfmateriallist.cpp | 56 +++++++++++++---------------
 1 file changed, 25 insertions(+), 31 deletions(-)

diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp
index 08ce43434f0..151d7fa9694 100644
--- a/indra/newview/llgltfmateriallist.cpp
+++ b/indra/newview/llgltfmateriallist.cpp
@@ -162,49 +162,43 @@ class LLGLTFMaterialOverrideDispatchHandler : public LLDispatchHandler
 
 
         LLSD message;
-
-        sparam_t::const_iterator it = strings.begin();
-        if (it != strings.end())
+        bool success = true;
+        for(const std::string& llsdRaw : strings)
         {
-            const std::string& llsdRaw = *it++;
             std::istringstream llsdData(llsdRaw);
             if (!LLSDSerialize::deserialize(message, llsdData, llsdRaw.length()))
             {
                 LL_WARNS() << "LLGLTFMaterialOverrideDispatchHandler: Attempted to read parameter data into LLSD but failed:" << llsdRaw << LL_ENDL;
+                success = false;
+                continue;
             }
-        }
-        else
-        {
-            // malformed message, nothing we can do to handle it
-            LL_DEBUGS("GLTF") << "Empty message" << LL_ENDL;
-            return false;
-        }
-
-        LLGLTFOverrideCacheEntry object_override;
-        if (!object_override.fromLLSD(message))
-        {
-            // malformed message, nothing we can do to handle it
-            LL_DEBUGS("GLTF") << "Message without id:" << message << LL_ENDL;
-            return false;
-        }
-
-        // Cache the data
-        {
-            LL_DEBUGS("GLTF") << "material overrides cache" << LL_ENDL;
-
-            LLViewerRegion * region = LLWorld::instance().getRegionFromHandle(object_override.mRegionHandle);
 
-            if (region)
+            LLGLTFOverrideCacheEntry object_override;
+            if (!object_override.fromLLSD(message))
             {
-                region->cacheFullUpdateGLTFOverride(object_override);
+                // malformed message, nothing we can do to handle it
+                LL_DEBUGS("GLTF") << "Message without id:" << message << LL_ENDL;
+                success = false;
+                continue;
             }
-            else
+
+            // Cache the data
             {
-                LL_WARNS("GLTF") << "could not access region for material overrides message cache, region_handle: " << LL_ENDL;
+                LLViewerRegion * region = LLWorld::instance().getRegionFromHandle(object_override.mRegionHandle);
+
+                if (region)
+                {
+                    region->cacheFullUpdateGLTFOverride(object_override);
+                }
+                else
+                {
+                    LL_WARNS("GLTF") << "could not access region for material overrides message cache, region_handle: " << LL_ENDL;
+                }
             }
+            applyData(object_override);
         }
-        applyData(object_override);
-        return true;
+
+        return success;
     }
 
     void doSelectionCallbacks(const LLUUID& object_id, S32 side)
-- 
GitLab