From 5c660ea0c59a15000e40fd7be7421c5f99bbe96c Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Thu, 24 Apr 2008 15:11:19 +0000 Subject: * 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 --- .../ScriptEngine/Common/LSL_BuiltIn_Commands.cs | 11 ++-- OpenSim/Region/ScriptEngine/Common/LSL_Types.cs | 62 ++++++++++++++++++++++ 2 files changed, 65 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index 3273023..35f8ee0 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs @@ -2269,7 +2269,7 @@ namespace OpenSim.Region.ScriptEngine.Common int count = 0; foreach (KeyValuePair inv in m_host.TaskInventory) { - if (inv.Value.InvType == type) + if (inv.Value.Type == type || type == -1) { count = count + 1; } @@ -2283,7 +2283,7 @@ namespace OpenSim.Region.ScriptEngine.Common ArrayList keys = new ArrayList(); foreach (KeyValuePair inv in m_host.TaskInventory) { - if (inv.Value.InvType == type) + if (inv.Value.Type == type || type == -1) { 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) { - //LSL_Types.list ret = new LSL_Types.list(src); - //ret.RemoveRange(start, end - start); - //return ret; - - // Just a hunch - needs testing - return src.GetSublist(end, start); + return src.DeleteSublist(end, start); } public int llGetListEntryType(LSL_Types.list src, int index) diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs index 7a8b4ca..ec10157 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs @@ -403,6 +403,68 @@ namespace OpenSim.Region.ScriptEngine.Common 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) { -- cgit v1.1