search a prim inventory matching both name and asset type, on some LSL and OSSL

This commit is contained in:
UbitUmarov
2022-10-24 01:37:01 +01:00
parent 0289011442
commit ff0422cbd7
3 changed files with 26 additions and 9 deletions

View File

@@ -217,6 +217,7 @@ namespace OpenSim.Region.Framework.Interfaces
/// The inventory item. Null if no such item was found.
/// </returns>
TaskInventoryItem GetInventoryItem(string name);
TaskInventoryItem GetInventoryItem(string name, int assetType);
/// <summary>
/// Get inventory items by name.

View File

@@ -1095,6 +1095,22 @@ namespace OpenSim.Region.Framework.Scenes
return null;
}
public TaskInventoryItem GetInventoryItem(string name, int type)
{
m_items.LockItemsForRead(true);
foreach (TaskInventoryItem item in m_items.Values)
{
if (item.Type == type && item.Name == name)
{
m_items.LockItemsForRead(false);
return item;
}
}
m_items.LockItemsForRead(false);
return null;
}
public List<TaskInventoryItem> GetInventoryItems(string name)
{
List<TaskInventoryItem> items = new List<TaskInventoryItem>();

View File

@@ -96,10 +96,10 @@ namespace OpenSim.Region.Framework.Scenes.Scripting
if (UUID.TryParse(identifier, out UUID key))
return key;
if (part.Inventory != null)
if (part.Inventory is not null)
{
TaskInventoryItem item = part.Inventory.GetInventoryItem(identifier);
if (item != null && item.Type == (int)type)
TaskInventoryItem item = part.Inventory.GetInventoryItem(identifier, (int)type);
if (item is not null)
return item.AssetID;
}
@@ -112,17 +112,17 @@ namespace OpenSim.Region.Framework.Scenes.Scripting
return key;
TaskInventoryItem item;
if (part.Inventory != null)
if (part.Inventory is not null)
{
item = part.Inventory.GetInventoryItem(identifier);
if (item != null && item.Type == (int)type)
item = part.Inventory.GetInventoryItem(identifier, (int)type);
if (item is not null)
return item.AssetID;
}
if (part.LocalId != host.LocalId && host.Inventory != null)
if (part.LocalId != host.LocalId && host.Inventory is not null)
{
item = host.Inventory.GetInventoryItem(identifier);
if (item != null && item.Type == (int)type)
item = host.Inventory.GetInventoryItem(identifier, (int)type);
if (item is not null)
return item.AssetID;
}
return UUID.Zero;