diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 6a85c90507..93ac79bd12 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -5150,31 +5150,41 @@ namespace OpenSim.Region.Framework.Scenes if (engines.Length == 0) // No engine at all return 0.0f; - float time = 0.0f; - - // get all the scripts in all parts - SceneObjectPart[] parts = m_parts.GetArray(); - List scripts = new(); - for (int i = 0; i < parts.Length; i++) + try { - scripts.AddRange(parts[i].Inventory.GetInventoryItems(InventoryType.LSL)); - } - // extract the UUIDs - HashSet unique = new(); - foreach (TaskInventoryItem script in scripts) - unique.Add(script.ItemID); + float time = 0.0f; - List ids = unique.ToList(); - - // Offer the list of script UUIDs to each engine found and accumulate the time - foreach (IScriptModule e in engines) - { - if (e is not null) + // get all the scripts in all parts + SceneObjectPart[] parts = m_parts.GetArray(); + List scripts = new(); + for (int i = 0; i < parts.Length; i++) { - time += e.GetScriptExecutionTime(ids); + IEntityInventory inv = parts[i].Inventory; + if (inv is not null) + scripts.AddRange(parts[i].Inventory.GetInventoryItems(InventoryType.LSL)); } + + // extract the UUIDs + HashSet unique = new(); + foreach (TaskInventoryItem script in scripts) + unique.Add(script.ItemID); + + List ids = unique.ToList(); + + // Offer the list of script UUIDs to each engine found and accumulate the time + foreach (IScriptModule e in engines) + { + if (e is not null) + { + time += e.GetScriptExecutionTime(ids); + } + } + return time; + } + catch + { + return 0.0f; } - return time; } public bool ScriptsMemory(out int memory) @@ -5184,32 +5194,42 @@ namespace OpenSim.Region.Framework.Scenes if (engines.Length == 0) // No engine at all return false; - // get all the scripts in all parts - SceneObjectPart[] parts = m_parts.GetArray(); - List scripts = new(); - for (int i = 0; i < parts.Length; i++) + try { - scripts.AddRange(parts[i].Inventory.GetInventoryItems(InventoryType.LSL)); - } - - if (scripts.Count == 0) - return false; - - // extract the UUIDs - HashSet unique = new(); - foreach (TaskInventoryItem script in scripts) - unique.Add(script.ItemID); - - List ids = unique.ToList(); - // Offer the list of script UUIDs to each engine found and accumulate the memory - foreach (IScriptModule e in engines) - { - if (e is not null) + // get all the scripts in all parts + SceneObjectPart[] parts = m_parts.GetArray(); + List scripts = new(); + for (int i = 0; i < parts.Length; i++) { - memory += e.GetScriptsMemory(ids); + IEntityInventory inv = parts[i].Inventory; + if(inv is not null) + scripts.AddRange(inv.GetInventoryItems(InventoryType.LSL)); } + + if (scripts.Count == 0) + return false; + + // extract the UUIDs + HashSet unique = new(); + foreach (TaskInventoryItem script in scripts) + unique.Add(script.ItemID); + + List ids = unique.ToList(); + // Offer the list of script UUIDs to each engine found and accumulate the memory + foreach (IScriptModule e in engines) + { + if (e is not null) + { + memory += e.GetScriptsMemory(ids); + } + } + return true; } - return true; + catch + { + return false; + } + } ///