diff options
3 files changed, 42 insertions, 45 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs index 30ed7d1..4370fcc 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs | |||
@@ -164,6 +164,19 @@ namespace OpenSim.Region.Framework.Interfaces | |||
164 | List<TaskInventoryItem> GetInventoryItems(); | 164 | List<TaskInventoryItem> GetInventoryItems(); |
165 | 165 | ||
166 | /// <summary> | 166 | /// <summary> |
167 | /// Gets an inventory item by name | ||
168 | /// </summary> | ||
169 | /// <remarks> | ||
170 | /// This method returns the first inventory item that matches the given name. In SL this is all you need | ||
171 | /// since each item in a prim inventory must have a unique name. | ||
172 | /// </remarks> | ||
173 | /// <param name='name'></param> | ||
174 | /// <returns> | ||
175 | /// The inventory item. Null if no such item was found. | ||
176 | /// </returns> | ||
177 | TaskInventoryItem GetInventoryItem(string name); | ||
178 | |||
179 | /// <summary> | ||
167 | /// Get inventory items by name. | 180 | /// Get inventory items by name. |
168 | /// </summary> | 181 | /// </summary> |
169 | /// <param name="name"></param> | 182 | /// <param name="name"></param> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index aaf9ffa..8810903 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -582,14 +582,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
582 | return item; | 582 | return item; |
583 | } | 583 | } |
584 | 584 | ||
585 | /// <summary> | 585 | public TaskInventoryItem GetInventoryItem(string name) |
586 | /// Get inventory items by name. | 586 | { |
587 | /// </summary> | 587 | lock (m_items) |
588 | /// <param name="name"></param> | 588 | { |
589 | /// <returns> | 589 | foreach (TaskInventoryItem item in m_items.Values) |
590 | /// A list of inventory items with that name. | 590 | { |
591 | /// If no inventory item has that name then an empty list is returned. | 591 | if (item.Name == name) |
592 | /// </returns> | 592 | return item; |
593 | } | ||
594 | } | ||
595 | |||
596 | return null; | ||
597 | } | ||
598 | |||
593 | public List<TaskInventoryItem> GetInventoryItems(string name) | 599 | public List<TaskInventoryItem> GetInventoryItems(string name) |
594 | { | 600 | { |
595 | List<TaskInventoryItem> items = new List<TaskInventoryItem>(); | 601 | List<TaskInventoryItem> items = new List<TaskInventoryItem>(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 4b28808..9908a39 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -104,9 +104,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
104 | protected int m_scriptConsoleChannel = 0; | 104 | protected int m_scriptConsoleChannel = 0; |
105 | protected bool m_scriptConsoleChannelEnabled = false; | 105 | protected bool m_scriptConsoleChannelEnabled = false; |
106 | protected IUrlModule m_UrlModule = null; | 106 | protected IUrlModule m_UrlModule = null; |
107 | protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = | 107 | protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = new Dictionary<UUID, UserInfoCacheEntry>(); |
108 | new Dictionary<UUID, UserInfoCacheEntry>(); | 108 | protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. |
109 | protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. | ||
110 | 109 | ||
111 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) | 110 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) |
112 | { | 111 | { |
@@ -304,25 +303,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
304 | return UUID.Zero; | 303 | return UUID.Zero; |
305 | } | 304 | } |
306 | 305 | ||
307 | protected UUID InventoryKey(string name) | ||
308 | { | ||
309 | m_host.AddScriptLPS(1); | ||
310 | |||
311 | lock (m_host.TaskInventory) | ||
312 | { | ||
313 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
314 | { | ||
315 | if (inv.Value.Name == name) | ||
316 | { | ||
317 | return inv.Value.AssetID; | ||
318 | } | ||
319 | } | ||
320 | } | ||
321 | |||
322 | return UUID.Zero; | ||
323 | } | ||
324 | |||
325 | |||
326 | /// <summary> | 306 | /// <summary> |
327 | /// accepts a valid UUID, -or- a name of an inventory item. | 307 | /// accepts a valid UUID, -or- a name of an inventory item. |
328 | /// Returns a valid UUID or UUID.Zero if key invalid and item not found | 308 | /// Returns a valid UUID or UUID.Zero if key invalid and item not found |
@@ -332,19 +312,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
332 | /// <returns></returns> | 312 | /// <returns></returns> |
333 | protected UUID KeyOrName(string k) | 313 | protected UUID KeyOrName(string k) |
334 | { | 314 | { |
335 | UUID key = UUID.Zero; | 315 | UUID key; |
336 | 316 | ||
337 | // if we can parse the string as a key, use it. | 317 | // if we can parse the string as a key, use it. |
338 | if (UUID.TryParse(k, out key)) | ||
339 | { | ||
340 | return key; | ||
341 | } | ||
342 | // else try to locate the name in inventory of object. found returns key, | 318 | // else try to locate the name in inventory of object. found returns key, |
343 | // not found returns UUID.Zero which will translate to the default particle texture | 319 | // not found returns UUID.Zero |
344 | else | 320 | if (!UUID.TryParse(k, out key)) |
345 | { | 321 | { |
346 | return InventoryKey(k); | 322 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(k); |
323 | |||
324 | if (item != null) | ||
325 | key = item.AssetID; | ||
326 | else | ||
327 | key = UUID.Zero; | ||
347 | } | 328 | } |
329 | |||
330 | return key; | ||
348 | } | 331 | } |
349 | 332 | ||
350 | // convert a LSL_Rotation to a Quaternion | 333 | // convert a LSL_Rotation to a Quaternion |
@@ -3315,17 +3298,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3315 | 3298 | ||
3316 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0) | 3299 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0) |
3317 | { | 3300 | { |
3318 | UUID animID = new UUID(); | ||
3319 | |||
3320 | if (!UUID.TryParse(anim, out animID)) | ||
3321 | { | ||
3322 | animID = InventoryKey(anim); | ||
3323 | } | ||
3324 | |||
3325 | ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); | 3301 | ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); |
3326 | 3302 | ||
3327 | if (presence != null) | 3303 | if (presence != null) |
3328 | { | 3304 | { |
3305 | UUID animID = KeyOrName(anim); | ||
3306 | |||
3329 | if (animID == UUID.Zero) | 3307 | if (animID == UUID.Zero) |
3330 | presence.Animator.RemoveAnimation(anim); | 3308 | presence.Animator.RemoveAnimation(anim); |
3331 | else | 3309 | else |