From eacba4fc0b1e3a34f8bae140c402eacb68ecbb94 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 4 Jul 2012 21:54:30 +0100 Subject: refactor: use existing GetInventoryItem() in GetScriptByName(), itself renamed from ScriptByName() --- .../Shared/Api/Implementation/LSL_Api.cs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index a8a2a50..38f146f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -192,7 +192,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); - if ((item = ScriptByName(name)) != UUID.Zero) + if ((item = GetScriptByName(name)) != UUID.Zero) m_ScriptEngine.ResetScript(item); else ShoutError("llResetOtherScript: script "+name+" not found"); @@ -204,7 +204,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); - if ((item = ScriptByName(name)) != UUID.Zero) + if ((item = GetScriptByName(name)) != UUID.Zero) { return m_ScriptEngine.GetScriptState(item) ?1:0; } @@ -226,7 +226,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // These functions are supposed to be robust, // so get the state one step at a time. - if ((item = ScriptByName(name)) != UUID.Zero) + if ((item = GetScriptByName(name)) != UUID.Zero) { m_ScriptEngine.SetScriptState(item, run == 0 ? false : true); } @@ -10455,18 +10455,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return new LSL_List(); } - internal UUID ScriptByName(string name) + internal UUID GetScriptByName(string name) { - lock (m_host.TaskInventory) - { - foreach (TaskInventoryItem item in m_host.TaskInventory.Values) - { - if (item.Type == 10 && item.Name == name) - return item.ItemID; - } - } + TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name); + + if (item == null || item.Type != 10) + return UUID.Zero; - return UUID.Zero; + return item.ItemID; } internal void ShoutError(string msg) -- cgit v1.1