* Patch from Melanie. Mantis: 1040. Thanks Melanie!

* Implements llDeleteSubList in all it's modes. Corrects type selection in inventory functions. Adds support for INVENTORY_ALL selector
0.6.0-stable
Teravus Ovares 2008-04-24 15:11:19 +00:00
parent 56ef67ec6d
commit 5c660ea0c5
2 changed files with 65 additions and 8 deletions

View File

@ -2269,7 +2269,7 @@ namespace OpenSim.Region.ScriptEngine.Common
int count = 0; int count = 0;
foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory) foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory)
{ {
if (inv.Value.InvType == type) if (inv.Value.Type == type || type == -1)
{ {
count = count + 1; count = count + 1;
} }
@ -2283,7 +2283,7 @@ namespace OpenSim.Region.ScriptEngine.Common
ArrayList keys = new ArrayList(); ArrayList keys = new ArrayList();
foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory) foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory)
{ {
if (inv.Value.InvType == type) if (inv.Value.Type == type || type == -1)
{ {
keys.Add(inv.Value.Name); keys.Add(inv.Value.Name);
} }
@ -2972,12 +2972,7 @@ namespace OpenSim.Region.ScriptEngine.Common
public LSL_Types.list llDeleteSubList(LSL_Types.list src, int start, int end) public LSL_Types.list llDeleteSubList(LSL_Types.list src, int start, int end)
{ {
//LSL_Types.list ret = new LSL_Types.list(src); return src.DeleteSublist(end, start);
//ret.RemoveRange(start, end - start);
//return ret;
// Just a hunch - needs testing
return src.GetSublist(end, start);
} }
public int llGetListEntryType(LSL_Types.list src, int index) public int llGetListEntryType(LSL_Types.list src, int index)

View File

@ -403,6 +403,68 @@ namespace OpenSim.Region.ScriptEngine.Common
return ret; return ret;
} }
public list DeleteSublist(int start, int end)
{
// Not an easy one
// If start <= end, remove that part
// if either is negative, count from the end of the array
// if the resulting start > end, remove all BUT that part
Object[] ret;
if(start < 0)
start=m_data.Length-start;
if(start < 0)
start=0;
if(end < 0)
end=m_data.Length-end;
if(end < 0)
end=0;
if(start > end)
{
if(end >= m_data.Length)
return new list(new Object[0]);
if(start >= m_data.Length)
start=m_data.Length-1;
return GetSublist(end, start);
}
// start >= 0 && end >= 0 here
if(start >= m_data.Length)
{
ret=new Object[m_data.Length];
Array.Copy(m_data, 0, ret, 0, m_data.Length);
return new list(ret);
}
if(end >= m_data.Length)
end=m_data.Length-1;
// now, this makes the math easier
int remove=end+1-start;
ret=new Object[m_data.Length-remove];
if(ret.Length == 0)
return new list(ret);
int src;
int dest=0;
for(src = 0 ; src < m_data.Length ; src++)
{
if(src < start || src > end)
ret[dest++]=m_data[src];
}
return new list(ret);
}
public list GetSublist(int start, int end) public list GetSublist(int start, int end)
{ {