refactor: replace LSL_Api.InventoryKey(string) largely with SceneObjectPartInventory.GetInventoryItem(string)
Also gets llStopAnimation() to call KeyOrName rather than duplicating logic.0.7.3-extended
parent
2021a8aedb
commit
6b819a9032
|
@ -163,6 +163,19 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
/// </returns>
|
/// </returns>
|
||||||
List<TaskInventoryItem> GetInventoryItems();
|
List<TaskInventoryItem> GetInventoryItems();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets an inventory item by name
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// This method returns the first inventory item that matches the given name. In SL this is all you need
|
||||||
|
/// since each item in a prim inventory must have a unique name.
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name='name'></param>
|
||||||
|
/// <returns>
|
||||||
|
/// The inventory item. Null if no such item was found.
|
||||||
|
/// </returns>
|
||||||
|
TaskInventoryItem GetInventoryItem(string name);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get inventory items by name.
|
/// Get inventory items by name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -582,14 +582,20 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
public TaskInventoryItem GetInventoryItem(string name)
|
||||||
/// Get inventory items by name.
|
{
|
||||||
/// </summary>
|
lock (m_items)
|
||||||
/// <param name="name"></param>
|
{
|
||||||
/// <returns>
|
foreach (TaskInventoryItem item in m_items.Values)
|
||||||
/// A list of inventory items with that name.
|
{
|
||||||
/// If no inventory item has that name then an empty list is returned.
|
if (item.Name == name)
|
||||||
/// </returns>
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public List<TaskInventoryItem> GetInventoryItems(string name)
|
public List<TaskInventoryItem> GetInventoryItems(string name)
|
||||||
{
|
{
|
||||||
List<TaskInventoryItem> items = new List<TaskInventoryItem>();
|
List<TaskInventoryItem> items = new List<TaskInventoryItem>();
|
||||||
|
|
|
@ -104,8 +104,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
protected int m_scriptConsoleChannel = 0;
|
protected int m_scriptConsoleChannel = 0;
|
||||||
protected bool m_scriptConsoleChannelEnabled = false;
|
protected bool m_scriptConsoleChannelEnabled = false;
|
||||||
protected IUrlModule m_UrlModule = null;
|
protected IUrlModule m_UrlModule = null;
|
||||||
protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache =
|
|
||||||
new Dictionary<UUID, UserInfoCacheEntry>();
|
protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = new Dictionary<UUID, UserInfoCacheEntry>();
|
||||||
|
protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp.
|
||||||
|
|
||||||
public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
|
public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
|
||||||
{
|
{
|
||||||
|
@ -291,25 +292,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
return UUID.Zero;
|
return UUID.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected UUID InventoryKey(string name)
|
|
||||||
{
|
|
||||||
m_host.AddScriptLPS(1);
|
|
||||||
|
|
||||||
lock (m_host.TaskInventory)
|
|
||||||
{
|
|
||||||
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
|
|
||||||
{
|
|
||||||
if (inv.Value.Name == name)
|
|
||||||
{
|
|
||||||
return inv.Value.AssetID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return UUID.Zero;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// accepts a valid UUID, -or- a name of an inventory item.
|
/// accepts a valid UUID, -or- a name of an inventory item.
|
||||||
/// Returns a valid UUID or UUID.Zero if key invalid and item not found
|
/// Returns a valid UUID or UUID.Zero if key invalid and item not found
|
||||||
|
@ -319,19 +301,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected UUID KeyOrName(string k)
|
protected UUID KeyOrName(string k)
|
||||||
{
|
{
|
||||||
UUID key = UUID.Zero;
|
UUID key;
|
||||||
|
|
||||||
// if we can parse the string as a key, use it.
|
// if we can parse the string as a key, use it.
|
||||||
if (UUID.TryParse(k, out key))
|
|
||||||
{
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
// 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 which will translate to the default particle texture
|
// not found returns UUID.Zero
|
||||||
else
|
if (!UUID.TryParse(k, out key))
|
||||||
{
|
{
|
||||||
return InventoryKey(k);
|
TaskInventoryItem item = m_host.Inventory.GetInventoryItem(k);
|
||||||
|
|
||||||
|
if (item != null)
|
||||||
|
key = item.AssetID;
|
||||||
|
else
|
||||||
|
key = UUID.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert a LSL_Rotation to a Quaternion
|
// convert a LSL_Rotation to a Quaternion
|
||||||
|
@ -3266,17 +3251,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
|
|
||||||
if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
|
if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
|
||||||
{
|
{
|
||||||
UUID animID = new UUID();
|
|
||||||
|
|
||||||
if (!UUID.TryParse(anim, out animID))
|
|
||||||
{
|
|
||||||
animID = InventoryKey(anim);
|
|
||||||
}
|
|
||||||
|
|
||||||
ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
|
ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
|
||||||
|
|
||||||
if (presence != null)
|
if (presence != null)
|
||||||
{
|
{
|
||||||
|
UUID animID = KeyOrName(anim);
|
||||||
|
|
||||||
if (animID == UUID.Zero)
|
if (animID == UUID.Zero)
|
||||||
presence.Animator.RemoveAnimation(anim);
|
presence.Animator.RemoveAnimation(anim);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue