avoid null refs on part inventory, that can happen if only using default animations names for example
parent
9b09bd255c
commit
fde3727453
|
@ -64,22 +64,20 @@ namespace OpenSim.Region.Framework.Scenes.Scripting
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static UUID GetAssetIdFromKeyOrItemName(SceneObjectPart part, string identifier)
|
public static UUID GetAssetIdFromKeyOrItemName(SceneObjectPart part, string identifier)
|
||||||
{
|
{
|
||||||
UUID key;
|
|
||||||
|
|
||||||
// if we can parse the string as a key, use it.
|
// if we can parse the string as a key, use it.
|
||||||
// else try to locate the name in inventory of object. found returns key,
|
// else try to locate the name in inventory of object. found returns key,
|
||||||
// not found returns UUID.Zero
|
// not found returns UUID.Zero
|
||||||
if (!UUID.TryParse(identifier, out key))
|
if (UUID.TryParse(identifier, out UUID key))
|
||||||
|
return key;
|
||||||
|
|
||||||
|
if (part.Inventory != null)
|
||||||
{
|
{
|
||||||
TaskInventoryItem item = part.Inventory.GetInventoryItem(identifier);
|
TaskInventoryItem item = part.Inventory.GetInventoryItem(identifier);
|
||||||
|
|
||||||
if (item != null)
|
if (item != null)
|
||||||
key = item.AssetID;
|
return item.AssetID;
|
||||||
else
|
|
||||||
key = UUID.Zero;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return key;
|
return UUID.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -92,28 +90,33 @@ namespace OpenSim.Region.Framework.Scenes.Scripting
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static UUID GetAssetIdFromKeyOrItemName(SceneObjectPart part, string identifier, AssetType type)
|
public static UUID GetAssetIdFromKeyOrItemName(SceneObjectPart part, string identifier, AssetType type)
|
||||||
{
|
{
|
||||||
UUID key;
|
if (UUID.TryParse(identifier, out UUID key))
|
||||||
if (UUID.TryParse(identifier, out key))
|
|
||||||
return key;
|
return key;
|
||||||
|
|
||||||
TaskInventoryItem item = part.Inventory.GetInventoryItem(identifier);
|
if (part.Inventory != null)
|
||||||
if (item != null && item.Type == (int)type)
|
{
|
||||||
return item.AssetID;
|
TaskInventoryItem item = part.Inventory.GetInventoryItem(identifier);
|
||||||
|
if (item != null && item.Type == (int)type)
|
||||||
|
return item.AssetID;
|
||||||
|
}
|
||||||
|
|
||||||
return UUID.Zero;
|
return UUID.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UUID GetAssetIdFromKeyOrItemName(SceneObjectPart part, SceneObjectPart host, string identifier, AssetType type)
|
public static UUID GetAssetIdFromKeyOrItemName(SceneObjectPart part, SceneObjectPart host, string identifier, AssetType type)
|
||||||
{
|
{
|
||||||
UUID key;
|
if (UUID.TryParse(identifier, out UUID key))
|
||||||
if (UUID.TryParse(identifier, out key))
|
|
||||||
return key;
|
return key;
|
||||||
|
|
||||||
TaskInventoryItem item = part.Inventory.GetInventoryItem(identifier);
|
TaskInventoryItem item;
|
||||||
if (item != null && item.Type == (int)type)
|
if (part.Inventory != null)
|
||||||
return item.AssetID;
|
{
|
||||||
|
item = part.Inventory.GetInventoryItem(identifier);
|
||||||
|
if (item != null && item.Type == (int)type)
|
||||||
|
return item.AssetID;
|
||||||
|
}
|
||||||
|
|
||||||
if (part.LocalId != host.LocalId)
|
if (part.LocalId != host.LocalId && host.Inventory != null)
|
||||||
{
|
{
|
||||||
item = host.Inventory.GetInventoryItem(identifier);
|
item = host.Inventory.GetInventoryItem(identifier);
|
||||||
if (item != null && item.Type == (int)type)
|
if (item != null && item.Type == (int)type)
|
||||||
|
|
Loading…
Reference in New Issue