From 0ea708c1339f1da2b9d189b2920d520e008a6491 Mon Sep 17 00:00:00 2001 From: alondria Date: Sat, 2 Feb 2008 18:52:07 +0000 Subject: Added llParseString2List (and a few extra methods to LSL_Types.list). --- .../Region/ScriptEngine/Common/LSL_BaseClass.cs | 4 +- .../ScriptEngine/Common/LSL_BuiltIn_Commands.cs | 50 +++++++++++++++++++++- .../Common/LSL_BuiltIn_Commands_Interface.cs | 2 +- OpenSim/Region/ScriptEngine/Common/LSL_Types.cs | 23 ++++++++++ 4 files changed, 74 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BaseClass.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BaseClass.cs index 96a7dae..c985d6f 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BaseClass.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BaseClass.cs @@ -1244,9 +1244,9 @@ namespace OpenSim.Region.ScriptEngine.Common m_LSL_Functions.llEjectFromLand(pest); } - public void llParseString2List() + public LSL_Types.list llParseString2List(string str, LSL_Types.list separators, LSL_Types.list spacers) { - m_LSL_Functions.llParseString2List(); + return m_LSL_Functions.llParseString2List(str,separators,spacers); } public int llOverMyLand(string id) diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index 4054369..8ef33d7 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs @@ -2039,9 +2039,55 @@ namespace OpenSim.Region.ScriptEngine.Common NotImplemented("llEjectFromLand"); } - public void llParseString2List() + public LSL_Types.list llParseString2List(string str, LSL_Types.list separators, LSL_Types.list spacers) { - NotImplemented("llParseString2List"); + LSL_Types.list ret = new LSL_Types.list(); + object[] delimeters = new object[separators.Length + spacers.Length]; + separators.Data.CopyTo(delimeters, 0); + spacers.Data.CopyTo(delimeters, separators.Length); + bool dfound = false; + do + { + dfound = false; + int cindex = -1; + string cdeli = ""; + for (int i = 0; i < delimeters.Length; i++) + { + int index = str.IndexOf(delimeters[i].ToString()); + bool found = index != -1; + if (found) + { + if ((cindex > index) || (cindex == -1)) + { + cindex = index; + cdeli = (string)delimeters[i]; + } + dfound = dfound || found; + } + } + if (cindex != -1) + { + if (cindex > 0) + { + ret.Add(str.Substring(0, cindex)); + if (spacers.Contains(cdeli)) + { + ret.Add(cdeli); + } + } + if (cindex == 0 && spacers.Contains(cdeli)) + { + ret.Add(cdeli); + } + str = str.Substring(cindex + 1); + } + } + while (dfound); + if (str != "") + { + ret.Add(str); + } + return ret; } public int llOverMyLand(string id) diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs index dbeeaf5..f6ccca3 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs @@ -409,7 +409,7 @@ namespace OpenSim.Region.ScriptEngine.Common //wiki: llEjectFromLand(key pest) void llEjectFromLand(string pest); - void llParseString2List(); + LSL_Types.list llParseString2List(string str, LSL_Types.list separators, LSL_Types.list spacers); //wiki: integer llOverMyLand(key id) int llOverMyLand(string id); //wiki: key llGetLandOwnerAt(vector pos) diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs index e48f667..bbdd4ee 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs @@ -354,6 +354,29 @@ namespace OpenSim.Region.ScriptEngine.Common return new list(tmp); } + public void Add(object o) + { + object[] tmp; + tmp = new object[m_data.Length + 1]; + m_data.CopyTo(tmp, 0); + tmp[m_data.Length] = o; + m_data = tmp; + } + + public bool Contains(object o) + { + bool ret = false; + foreach (object i in Data) + { + if (i == o) + { + ret = true; + break; + } + } + return ret; + } + public list GetSublist(int start, int end) { Console.WriteLine("GetSublist(" + start.ToString() + "," + end.ToString() + ")"); -- cgit v1.1