refactor: In llRemoteLoadScriptPin() use existing GetInventoryItem()

0.7.3-extended
Justin Clark-Casey (justincc) 2012-07-04 21:36:44 +01:00
parent 0acac2f890
commit 8c7f511e55
1 changed files with 5 additions and 20 deletions

View File

@ -6486,9 +6486,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param) public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
bool found = false;
UUID destId = UUID.Zero; UUID destId = UUID.Zero;
UUID srcId = UUID.Zero;
if (!UUID.TryParse(target, out destId)) if (!UUID.TryParse(target, out destId))
{ {
@ -6503,31 +6502,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
// copy the first script found with this inventory name // copy the first script found with this inventory name
lock (m_host.TaskInventory) TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name);
{
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
{
if (inv.Value.Name == name)
{
// make sure the object is a script
if (10 == inv.Value.Type)
{
found = true;
srcId = inv.Key;
break;
}
}
}
}
if (!found) // make sure the object is a script
if (item == null || item.Type != 10)
{ {
llSay(0, "Could not find script " + name); llSay(0, "Could not find script " + name);
return; return;
} }
// the rest of the permission checks are done in RezScript, so check the pin there as well // the rest of the permission checks are done in RezScript, so check the pin there as well
World.RezScriptFromPrim(srcId, m_host, destId, pin, running, start_param); World.RezScriptFromPrim(item.ItemID, m_host, destId, pin, running, start_param);
// this will cause the delay even if the script pin or permissions were wrong - seems ok // this will cause the delay even if the script pin or permissions were wrong - seems ok
ScriptSleep(3000); ScriptSleep(3000);