refactor: make llGiveInventory() use existing GetInventoryItem() method rather than iterate through TaskInventory itself.
parent
07298c8b4f
commit
218fe36f84
|
@ -3788,11 +3788,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
public void llGiveInventory(string destination, string inventory)
|
public void llGiveInventory(string destination, string inventory)
|
||||||
{
|
{
|
||||||
m_host.AddScriptLPS(1);
|
m_host.AddScriptLPS(1);
|
||||||
bool found = false;
|
|
||||||
UUID destId = UUID.Zero;
|
UUID destId = UUID.Zero;
|
||||||
UUID objId = UUID.Zero;
|
|
||||||
int assetType = 0;
|
|
||||||
string objName = String.Empty;
|
|
||||||
|
|
||||||
if (!UUID.TryParse(destination, out destId))
|
if (!UUID.TryParse(destination, out destId))
|
||||||
{
|
{
|
||||||
|
@ -3800,28 +3797,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// move the first object found with this inventory name
|
TaskInventoryItem item = m_host.Inventory.GetInventoryItem(inventory);
|
||||||
lock (m_host.TaskInventory)
|
|
||||||
{
|
|
||||||
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
|
|
||||||
{
|
|
||||||
if (inv.Value.Name == inventory)
|
|
||||||
{
|
|
||||||
found = true;
|
|
||||||
objId = inv.Key;
|
|
||||||
assetType = inv.Value.Type;
|
|
||||||
objName = inv.Value.Name;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found)
|
if (item == null)
|
||||||
{
|
{
|
||||||
llSay(0, String.Format("Could not find object '{0}'", inventory));
|
llSay(0, String.Format("Could not find object '{0}'", inventory));
|
||||||
throw new Exception(String.Format("The inventory object '{0}' could not be found", 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
|
// check if destination is an object
|
||||||
if (World.GetSceneObjectPart(destId) != null)
|
if (World.GetSceneObjectPart(destId) != null)
|
||||||
{
|
{
|
||||||
|
@ -3852,7 +3837,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
return;
|
return;
|
||||||
|
|
||||||
byte[] bucket = new byte[17];
|
byte[] bucket = new byte[17];
|
||||||
bucket[0] = (byte)assetType;
|
bucket[0] = (byte)item.Type;
|
||||||
byte[] objBytes = agentItem.ID.GetBytes();
|
byte[] objBytes = agentItem.ID.GetBytes();
|
||||||
Array.Copy(objBytes, 0, bucket, 1, 16);
|
Array.Copy(objBytes, 0, bucket, 1, 16);
|
||||||
|
|
||||||
|
@ -3860,13 +3845,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
m_host.UUID, m_host.Name + ", an object owned by " +
|
m_host.UUID, m_host.Name + ", an object owned by " +
|
||||||
resolveName(m_host.OwnerID) + ",", destId,
|
resolveName(m_host.OwnerID) + ",", destId,
|
||||||
(byte)InstantMessageDialog.TaskInventoryOffered,
|
(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+" "+
|
World.RegionInfo.RegionName+" "+
|
||||||
m_host.AbsolutePosition.ToString(),
|
m_host.AbsolutePosition.ToString(),
|
||||||
agentItem.ID, true, m_host.AbsolutePosition,
|
agentItem.ID, true, m_host.AbsolutePosition,
|
||||||
bucket);
|
bucket);
|
||||||
|
|
||||||
if (m_TransferModule != null)
|
if (m_TransferModule != null)
|
||||||
m_TransferModule.SendInstantMessage(msg, delegate(bool success) {});
|
m_TransferModule.SendInstantMessage(msg, delegate(bool success) {});
|
||||||
|
|
||||||
ScriptSleep(3000);
|
ScriptSleep(3000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue