refactor: in llGetInventoryPermMask use existing GetInventoryItem()

0.7.3-extended
Justin Clark-Casey (justincc) 2012-07-04 21:42:04 +01:00
parent 8c7f511e55
commit 795443cff1
1 changed files with 18 additions and 22 deletions

View File

@ -6486,7 +6486,7 @@ 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);
UUID destId = UUID.Zero; UUID destId = UUID.Zero;
if (!UUID.TryParse(target, out destId)) if (!UUID.TryParse(target, out destId))
@ -8872,31 +8872,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
} }
public LSL_Integer llGetInventoryPermMask(string item, int mask) public LSL_Integer llGetInventoryPermMask(string itemName, int mask)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
lock (m_host.TaskInventory) TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName);
if (item == null)
return -1;
switch (mask)
{ {
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) case 0:
{ return (int)item.BasePermissions;
if (inv.Value.Name == item) case 1:
{ return (int)item.CurrentPermissions;
switch (mask) case 2:
{ return (int)item.GroupPermissions;
case 0: case 3:
return (int)inv.Value.BasePermissions; return (int)item.EveryonePermissions;
case 1: case 4:
return (int)inv.Value.CurrentPermissions; return (int)item.NextPermissions;
case 2:
return (int)inv.Value.GroupPermissions;
case 3:
return (int)inv.Value.EveryonePermissions;
case 4:
return (int)inv.Value.NextPermissions;
}
}
}
} }
return -1; return -1;