From 58b13d51a7eddb442e38e6dc6790a9e7cf68bad7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 4 Jul 2012 20:57:48 +0100 Subject: refactor: make llGiveInventory() use existing GetInventoryItem() method rather than iterate through TaskInventory itself. --- .../Shared/Api/Implementation/LSL_Api.cs | 35 +++++++--------------- 1 file changed, 11 insertions(+), 24 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 12eb098..8a3efa7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3860,11 +3860,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llGiveInventory(string destination, string inventory) { m_host.AddScriptLPS(1); - bool found = false; + UUID destId = UUID.Zero; - UUID objId = UUID.Zero; - int assetType = 0; - string objName = String.Empty; if (!UUID.TryParse(destination, out destId)) { @@ -3872,28 +3869,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; } - // move the first object found with this inventory name - lock (m_host.TaskInventory) - { - foreach (KeyValuePair inv in m_host.TaskInventory) - { - if (inv.Value.Name == inventory) - { - found = true; - objId = inv.Key; - assetType = inv.Value.Type; - objName = inv.Value.Name; - break; - } - } - } + TaskInventoryItem item = m_host.Inventory.GetInventoryItem(inventory); - if (!found) + if (item == null) { llSay(0, String.Format("Could not find object '{0}'", inventory)); throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); } + UUID objId = item.ItemID; + // check if destination is an object if (World.GetSceneObjectPart(destId) != null) { @@ -3924,21 +3909,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; byte[] bucket = new byte[17]; - bucket[0] = (byte)assetType; + bucket[0] = (byte)item.Type; byte[] objBytes = agentItem.ID.GetBytes(); Array.Copy(objBytes, 0, bucket, 1, 16); GridInstantMessage msg = new GridInstantMessage(World, - m_host.UUID, m_host.Name+", an object owned by "+ - resolveName(m_host.OwnerID)+",", destId, + m_host.UUID, m_host.Name + ", an object owned by " + + resolveName(m_host.OwnerID) + ",", destId, (byte)InstantMessageDialog.TaskInventoryOffered, - false, objName+"\n"+m_host.Name+" is located at "+ + false, item.Name + "\n" + m_host.Name + " is located at " + World.RegionInfo.RegionName+" "+ m_host.AbsolutePosition.ToString(), agentItem.ID, true, m_host.AbsolutePosition, bucket); + if (m_TransferModule != null) m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); + ScriptSleep(3000); } } -- cgit v1.1