mirror of
https://github.com/opensim/opensim.git
synced 2026-08-01 06:06:06 +08:00
catch some possible null refs
This commit is contained in:
@@ -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<TaskInventoryItem> scripts = new();
|
||||
for (int i = 0; i < parts.Length; i++)
|
||||
try
|
||||
{
|
||||
scripts.AddRange(parts[i].Inventory.GetInventoryItems(InventoryType.LSL));
|
||||
}
|
||||
// extract the UUIDs
|
||||
HashSet<UUID> unique = new();
|
||||
foreach (TaskInventoryItem script in scripts)
|
||||
unique.Add(script.ItemID);
|
||||
float time = 0.0f;
|
||||
|
||||
List<UUID> 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<TaskInventoryItem> 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<UUID> unique = new();
|
||||
foreach (TaskInventoryItem script in scripts)
|
||||
unique.Add(script.ItemID);
|
||||
|
||||
List<UUID> 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<TaskInventoryItem> 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<UUID> unique = new();
|
||||
foreach (TaskInventoryItem script in scripts)
|
||||
unique.Add(script.ItemID);
|
||||
|
||||
List<UUID> 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<TaskInventoryItem> 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<UUID> unique = new();
|
||||
foreach (TaskInventoryItem script in scripts)
|
||||
unique.Add(script.ItemID);
|
||||
|
||||
List<UUID> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user