From 6f389ba4cf54d7e964b98430f7a6601d3ec0c73b Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Tue, 18 Dec 2007 02:41:34 +0000 Subject: Many Thanks to Alondria for adding: The list type and a bunch of support functions to LSL Added/ReImplmented: llGetListLength(), llList2Integer(), osList2Double() (note rename), llList2Float(), llList2String(), llList2Key(), llList2Vector(), llList2Rot(), llList2List(), llDeleteSubList(), llGetListEntryType(), llList2CSV(), llCSV2List(), llListInsertList(), llDumpList2String(), Borked Still: llListSort(), llListRandomize(), llList2ListStrided(), llListFindList(), Changed: llHTTPRequest() (Made wrapper of LSL_Types.list->List) --- .../Common/LSL_BuiltIn_Commands_Interface.cs | 61 +-- OpenSim/Region/ScriptEngine/Common/LSL_Types.cs | 114 +++++ .../DotNetEngine/Compiler/LSL/LSL2CSConverter.cs | 4 +- .../DotNetEngine/Compiler/LSL/LSL_BaseClass.cs | 64 +-- .../Compiler/Server_API/LSL_BuiltIn_Commands.cs | 465 +++++++++++++-------- 5 files changed, 464 insertions(+), 244 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs index 60e2a0e..34bac59 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs @@ -345,41 +345,41 @@ namespace OpenSim.Region.ScriptEngine.Common //wiki: vector llGetCenterOfMass() LSL_Types.Vector3 llGetCenterOfMass(); //wiki: list llListSort(list src, integer stride, integer ascending) - List llListSort(List src, int stride, int ascending); + LSL_Types.list llListSort(LSL_Types.list src, int stride, int ascending); //integer llGetListLength(list src) - int llGetListLength(List src); + int llGetListLength(LSL_Types.list src); //wiki: integer llList2Integer(list src, integer index) - int llList2Integer(List src, int index); + int llList2Integer(LSL_Types.list src, int index); //wiki: double llList2double(list src, integer index) - double llList2double(List src, int index); + double osList2Double(LSL_Types.list src, int index); //wiki: string llList2String(list src, integer index) - string llList2String(List src, int index); + string llList2String(LSL_Types.list src, int index); //wiki: key llList2Key(list src, integer index) - string llList2Key(List src, int index); + string llList2Key(LSL_Types.list src, int index); //wiki: vector llList2Vector(list src, integer index) - LSL_Types.Vector3 llList2Vector(List src, int index); + LSL_Types.Vector3 llList2Vector(LSL_Types.list src, int index); //wiki rotation llList2Rot(list src, integer index) - LSL_Types.Quaternion llList2Rot(List src, int index); + LSL_Types.Quaternion llList2Rot(LSL_Types.list src, int index); //wiki: list llList2List(list src, integer start, integer end) - List llList2List(List src, int start, int end); + LSL_Types.list llList2List(LSL_Types.list src, int start, int end); //wiki: llDeleteSubList(list src, integer start, integer end) - List llDeleteSubList(List src, int start, int end); + LSL_Types.list llDeleteSubList(LSL_Types.list src, int start, int end); //wiki: integer llGetListEntryType( list src, integer index ) - int llGetListEntryType(List src, int index); + int llGetListEntryType(LSL_Types.list src, int index); //wiki: string llList2CSV( list src ) - string llList2CSV(List src); + string llList2CSV(LSL_Types.list src); //wiki: list llCSV2List( string src ) - List llCSV2List(string src); + LSL_Types.list llCSV2List(string src); //wiki: list llListRandomize( list src, integer stride ) - List llListRandomize(List src, int stride); + LSL_Types.list llListRandomize(LSL_Types.list src, int stride); //wiki: list llList2ListStrided( list src, integer start, integer end, integer stride ) - List llList2ListStrided(List src, int start, int end, int stride); + LSL_Types.list llList2ListStrided(LSL_Types.list src, int start, int end, int stride); //wiki: vector llGetRegionCorner( ) LSL_Types.Vector3 llGetRegionCorner(); //wiki: list llListInsertList( list dest, list src, integer start ) - List llListInsertList(List dest, List src, int start); + LSL_Types.list llListInsertList(LSL_Types.list dest, LSL_Types.list src, int start); //wiki: integer llListFindList( list src, list test ) - int llListFindList(List src, List test); + int llListFindList(LSL_Types.list src, LSL_Types.list test); //wiki: string llGetObjectName() string llGetObjectName(); //wiki: llSetObjectName(string name) @@ -466,11 +466,12 @@ namespace OpenSim.Region.ScriptEngine.Common void llSetCameraEyeOffset(LSL_Types.Vector3 offset); //wiki: llSeteCameraAtOffset(vector offset) void llSetCameraAtOffset(LSL_Types.Vector3 offset); - void llDumpList2String(); + // + string llDumpList2String(LSL_Types.list src, string seperator); //wiki: integer llScriptDanger(vector pos) void llScriptDanger(LSL_Types.Vector3 pos); //wiki: llDialog( key avatar, string message, list buttons, integer chat_channel ) - void llDialog(string avatar, string message, List buttons, int chat_channel); + void llDialog(string avatar, string message, LSL_Types.list buttons, int chat_channel); //wiki: llVolumeDetect(integer detect) void llVolumeDetect(int detect); //wiki: llResetOtherScript(string name) @@ -494,7 +495,7 @@ namespace OpenSim.Region.ScriptEngine.Common //wiki: string llMD5String(string src, integer nonce) string llMD5String(string src, int nonce); //wiki: llSetPrimitiveParams( list rules ) - void llSetPrimitiveParams(List rules); + void llSetPrimitiveParams(LSL_Types.list rules); //wiki: string llStringToBase64(string str) string llStringToBase64(string str); //wiki: string llBase64ToString(string str) @@ -508,7 +509,7 @@ namespace OpenSim.Region.ScriptEngine.Common //wiki: double llLog(double val) double llLog(double val); //wiki: list llGetAnimationList( key id ) - List llGetAnimationList(string id); + LSL_Types.list llGetAnimationList(string id); //wiki: llSetParcelMusicURL(string url) void llSetParcelMusicURL(string url); //wiki: vector llGetRootPosition() @@ -530,7 +531,7 @@ namespace OpenSim.Region.ScriptEngine.Common //wiki: key llGetNumberOfNotecardLines(string name) string llGetNumberOfNotecardLines(string name); //wiki: list llGetBoundingBox( key object ) - List llGetBoundingBox(string obj); + LSL_Types.list llGetBoundingBox(string obj); //wiki: vector llGetGeometricCenter() LSL_Types.Vector3 llGetGeometricCenter(); void llGetPrimitiveParams(); @@ -545,7 +546,7 @@ namespace OpenSim.Region.ScriptEngine.Common //llSetLocalRot(rotation rot) void llSetLocalRot(LSL_Types.Quaternion rot); //wiki: list llParseStringKeepNulls( string src, list separators, list spacers ) - List llParseStringKeepNulls(string src, List seperators, List spacers); + LSL_Types.list llParseStringKeepNulls(string src, LSL_Types.list seperators, LSL_Types.list spacers); //wiki: llRezAtRoot(string inventory, vector position, vector velocity, rotation rot, integer param) void llRezAtRoot(string inventory, LSL_Types.Vector3 position, LSL_Types.Vector3 velocity, LSL_Types.Quaternion rot, int param); @@ -572,14 +573,14 @@ namespace OpenSim.Region.ScriptEngine.Common //wiki: llLoadURL(key avatar_id, string message, string url) void llLoadURL(string avatar_id, string message, string url); //wiki: llParcelMediaCommandList( list commandList ) - void llParcelMediaCommandList(List commandList); + void llParcelMediaCommandList(LSL_Types.list commandList); void llParcelMediaQuery(); //wiki integer llModPow(integer a, integer b, integer c) int llModPow(int a, int b, int c); //wiki: integer llGetInventoryType(string name) int llGetInventoryType(string name); //wiki: llSetPayPrice( integer price, list quick_pay_buttons ) - void llSetPayPrice(int price, List quick_pay_buttons); + void llSetPayPrice(int price, LSL_Types.list quick_pay_buttons); //wiki: vector llGetCameraPos() LSL_Types.Vector3 llGetCameraPos(); //wiki rotation llGetCameraRot() @@ -601,11 +602,11 @@ namespace OpenSim.Region.ScriptEngine.Common //wiki: llRemoveFromLandBanList(key avatar) void llRemoveFromLandBanList(string avatar); //wiki: llSetCameraParams( list rules ) - void llSetCameraParams(List rules); + void llSetCameraParams(LSL_Types.list rules); //wiki: llClearCameraParams() void llClearCameraParams(); //wiki: double llListStatistics( integer operation, list src ) - double llListStatistics(int operation, List src); + double llListStatistics(int operation, LSL_Types.list src); //wiki: integer llGetUnixTime() int llGetUnixTime(); //wiki: integer llGetParcelFlags(vector pos) @@ -614,7 +615,7 @@ namespace OpenSim.Region.ScriptEngine.Common int llGetRegionFlags(); //wiki: string llXorBase64StringsCorrect(string str1, string str2) string llXorBase64StringsCorrect(string str1, string str2); - string llHTTPRequest(string url, List parameters, string body); + string llHTTPRequest(string url, LSL_Types.list parameters, string body); //wiki: llResetLandBanList() void llResetLandBanList(); //wiki: llResetLandPassList() @@ -622,13 +623,13 @@ namespace OpenSim.Region.ScriptEngine.Common //wiki integer llGetParcelPrimCount(vector pos, integer category, integer sim_wide) int llGetParcelPrimCount(LSL_Types.Vector3 pos, int category, int sim_wide); //wiki: list llGetParcelPrimOwners( vector pos ) - List llGetParcelPrimOwners(LSL_Types.Vector3 pos); + LSL_Types.list llGetParcelPrimOwners(LSL_Types.Vector3 pos); //wiki: integer llGetObjectPrimCount(key object_id) int llGetObjectPrimCount(string object_id); //wiki: integer llGetParcelMaxPrims( vector pos, integer sim_wide ) int llGetParcelMaxPrims(LSL_Types.Vector3 pos, int sim_wide); //wiki list llGetParcelDetails(vector pos, list params) - List llGetParcelDetails(LSL_Types.Vector3 pos, List param); + LSL_Types.list llGetParcelDetails(LSL_Types.Vector3 pos, LSL_Types.list param); //OpenSim functions string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, int timer); diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs index e0cf1e5..136b613 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs @@ -252,5 +252,119 @@ namespace OpenSim.Region.ScriptEngine.Common return c; } } + + [Serializable] + public class list + { + private object[] m_data; + public list(params object[] args) + { + m_data = new object[args.Length]; + m_data = args; + } + public int Length + { + get { return m_data.Length; } + } + public object[] Data + { + get { return m_data; } + } + public static list operator +(list a, list b) + { + object[] tmp; + tmp = new object[a.Length + b.Length]; + a.Data.CopyTo(tmp, 0); + b.Data.CopyTo(tmp, a.Length); + return new list(tmp); + } + public list GetSublist(int start, int end) + { + Console.WriteLine("GetSublist(" + start.ToString() + "," + end.ToString() + ")"); + object[] ret; + // Take care of neg start or end's + if (start < 0) + { + start = m_data.Length + start; + } + if (end < 0) + { + end = m_data.Length + end; + } + + // Case start < end + + if (start <= end) + { + if (start >= m_data.Length) + { + return new list(); + } + if (end >= m_data.Length) + { + end = m_data.Length - 1; + } + ret = new object[end - start + 1]; + Array.Copy(m_data, start, ret, 0, end - start + 1); + return new list(ret); + } + else + { + if (start >= m_data.Length) + { + return this.GetSublist(0, end); + } + if (end >= m_data.Length) + { + return new list(); + } + // end < start + //ret = new object[m_data.Length - Math.Abs(end - start + 1)]; + //Array.Copy(m_data, 0, ret, m_data.Length - start, end + 1); + //Array.Copy(m_data, start, ret, 0, m_data.Length - start); + return this.GetSublist(0, end) + this.GetSublist(start, this.Data.Length - 1); + //return new list(ret); + } + } + + public string ToPrettyString() + { + string output; + if (m_data.Length == 0) + { + return "[]"; + } + output = "["; + foreach (object o in m_data) + { + if (o.GetType().ToString() == "System.String") + { + output = output + "\"" + o + "\", "; + } + else + { + output = output + o.ToString() + ", "; + } + } + output = output.Substring(0, output.Length - 2); + output = output + "]"; + return output; + } + public override string ToString() + { + string output; + output = ""; + if (m_data.Length == 0) + { + return ""; + } + foreach (object o in m_data) + { + output = output + o.ToString(); + } + return output; + } + } } + } diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs index 00ddbba..4063647 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs @@ -47,7 +47,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL dataTypes.Add("key", "string"); dataTypes.Add("vector", "LSL_Types.Vector3"); dataTypes.Add("rotation", "LSL_Types.Quaternion"); - dataTypes.Add("list", "List"); + dataTypes.Add("list", "LSL_Types.list"); dataTypes.Add("null", "null"); } @@ -259,7 +259,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL // Replace List []'s Script = - Regex.Replace(Script, @"\[([^\]]*)\]", @"List.Parse($1)", + Regex.Replace(Script, @"\[([^\]]*)\]", @"new LSL_Types.list($1)", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs index d669c15..1657b74 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs @@ -1061,12 +1061,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL return m_LSL_Functions.llGetCenterOfMass(); } - public List llListSort(List src, int stride, int ascending) + public LSL_Types.list llListSort(LSL_Types.list src, int stride, int ascending) { return m_LSL_Functions.llListSort(src, stride, ascending); } - public int llGetListLength(List src) + public int llGetListLength(LSL_Types.list src) { return m_LSL_Functions.llGetListLength(src); } @@ -1074,67 +1074,67 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL // // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs // - public int llList2Integer(List src, int index) + public int llList2Integer(LSL_Types.list src, int index) { return m_LSL_Functions.llList2Integer(src, index); } - public double llList2double(List src, int index) + public double osList2Double(LSL_Types.list src, int index) { - return m_LSL_Functions.llList2double(src, index); + return m_LSL_Functions.osList2Double(src, index); } - public string llList2String(List src, int index) + public string llList2String(LSL_Types.list src, int index) { return m_LSL_Functions.llList2String(src, index); } - public string llList2Key(List src, int index) + public string llList2Key(LSL_Types.list src, int index) { return m_LSL_Functions.llList2Key(src, index); } - public vector llList2Vector(List src, int index) + public vector llList2Vector(LSL_Types.list src, int index) { return m_LSL_Functions.llList2Vector(src, index); } - public rotation llList2Rot(List src, int index) + public rotation llList2Rot(LSL_Types.list src, int index) { return m_LSL_Functions.llList2Rot(src, index); } - public List llList2List(List src, int start, int end) + public LSL_Types.list llList2List(LSL_Types.list src, int start, int end) { return m_LSL_Functions.llList2List(src, start, end); } - public List llDeleteSubList(List src, int start, int end) + public LSL_Types.list llDeleteSubList(LSL_Types.list src, int start, int end) { return m_LSL_Functions.llDeleteSubList(src, start, end); } - public int llGetListEntryType(List src, int index) + public int llGetListEntryType(LSL_Types.list src, int index) { return m_LSL_Functions.llGetListEntryType(src, index); } - public string llList2CSV(List src) + public string llList2CSV(LSL_Types.list src) { return m_LSL_Functions.llList2CSV(src); } - public List llCSV2List(string src) + public LSL_Types.list llCSV2List(string src) { return m_LSL_Functions.llCSV2List(src); } - public List llListRandomize(List src, int stride) + public LSL_Types.list llListRandomize(LSL_Types.list src, int stride) { return m_LSL_Functions.llListRandomize(src, stride); } - public List llList2ListStrided(List src, int start, int end, int stride) + public LSL_Types.list llList2ListStrided(LSL_Types.list src, int start, int end, int stride) { return m_LSL_Functions.llList2ListStrided(src, start, end, stride); } @@ -1144,12 +1144,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL return m_LSL_Functions.llGetRegionCorner(); } - public List llListInsertList(List dest, List src, int start) + public LSL_Types.list llListInsertList(LSL_Types.list dest, LSL_Types.list src, int start) { return m_LSL_Functions.llListInsertList(dest, src, start); } - public int llListFindList(List src, List test) + public int llListFindList(LSL_Types.list src, LSL_Types.list test) { return m_LSL_Functions.llListFindList(src, test); } @@ -1375,9 +1375,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL m_LSL_Functions.llSetCameraAtOffset(offset); } - public void llDumpList2String() + public string llDumpList2String(LSL_Types.list src, string seperator) { - m_LSL_Functions.llDumpList2String(); + return m_LSL_Functions.llDumpList2String(src, seperator); } public void llScriptDanger(vector pos) @@ -1385,7 +1385,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL m_LSL_Functions.llScriptDanger(pos); } - public void llDialog(string avatar, string message, List buttons, int chat_channel) + public void llDialog(string avatar, string message, LSL_Types.list buttons, int chat_channel) { m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel); } @@ -1448,7 +1448,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL return m_LSL_Functions.llMD5String(src, nonce); } - public void llSetPrimitiveParams(List rules) + public void llSetPrimitiveParams(LSL_Types.list rules) { m_LSL_Functions.llSetPrimitiveParams(rules); } @@ -1483,7 +1483,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL return m_LSL_Functions.llLog(val); } - public List llGetAnimationList(string id) + public LSL_Types.list llGetAnimationList(string id) { return m_LSL_Functions.llGetAnimationList(id); } @@ -1538,7 +1538,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL return m_LSL_Functions.llGetNumberOfNotecardLines(name); } - public List llGetBoundingBox(string obj) + public LSL_Types.list llGetBoundingBox(string obj) { return m_LSL_Functions.llGetBoundingBox(obj); } @@ -1581,7 +1581,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL m_LSL_Functions.llSetLocalRot(rot); } - public List llParseStringKeepNulls(string src, List seperators, List spacers) + public LSL_Types.list llParseStringKeepNulls(string src, LSL_Types.list seperators, LSL_Types.list spacers) { return m_LSL_Functions.llParseStringKeepNulls(src, seperators, spacers); } @@ -1646,7 +1646,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL m_LSL_Functions.llLoadURL(avatar_id, message, url); } - public void llParcelMediaCommandList(List commandList) + public void llParcelMediaCommandList(LSL_Types.list commandList) { m_LSL_Functions.llParcelMediaCommandList(commandList); } @@ -1669,7 +1669,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL return m_LSL_Functions.llGetInventoryType(name); } - public void llSetPayPrice(int price, List quick_pay_buttons) + public void llSetPayPrice(int price, LSL_Types.list quick_pay_buttons) { m_LSL_Functions.llSetPayPrice(price, quick_pay_buttons); } @@ -1724,7 +1724,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL m_LSL_Functions.llRemoveFromLandBanList(avatar); } - public void llSetCameraParams(List rules) + public void llSetCameraParams(LSL_Types.list rules) { m_LSL_Functions.llSetCameraParams(rules); } @@ -1734,7 +1734,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL m_LSL_Functions.llClearCameraParams(); } - public double llListStatistics(int operation, List src) + public double llListStatistics(int operation, LSL_Types.list src) { return m_LSL_Functions.llListStatistics(operation, src); } @@ -1759,7 +1759,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL return m_LSL_Functions.llXorBase64StringsCorrect(str1, str2); } - public string llHTTPRequest(string url, List parameters, string body) + public string llHTTPRequest(string url, LSL_Types.list parameters, string body) { return m_LSL_Functions.llHTTPRequest(url, parameters, body); } @@ -1779,7 +1779,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL return m_LSL_Functions.llGetParcelPrimCount(pos, category, sim_wide); } - public List llGetParcelPrimOwners(vector pos) + public LSL_Types.list llGetParcelPrimOwners(vector pos) { return m_LSL_Functions.llGetParcelPrimOwners(pos); } @@ -1797,7 +1797,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL return m_LSL_Functions.llGetParcelMaxPrims(pos, sim_wide); } - public List llGetParcelDetails(vector pos, List param) + public LSL_Types.list llGetParcelDetails(vector pos, LSL_Types.list param) { return m_LSL_Functions.llGetParcelDetails(pos, param); } diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs index 61c4b10..ef31ecc 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Generic; +using System.Collections; using System.Runtime.Remoting.Lifetime; using System.Text; using System.Threading; @@ -102,6 +103,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler //starting out, we use the System.Math library for trig functions. - ckrinke 8-14-07 public double llSin(double f) { + return (double) Math.Sin(f); } @@ -1430,205 +1432,299 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler return new LSL_Types.Vector3(); } - public List llListSort(List src, int stride, int ascending) + public LSL_Types.list llListSort(LSL_Types.list src, int stride, int ascending) { - SortedList> sorted = new SortedList>(); + // SortedList sorted = new SortedList(); // Add chunks to an array - int s = stride; - if (s < 1) - s = 1; - int c = 0; - List chunk = new List(); - string chunkString = ""; - foreach (string element in src) + //int s = stride; + //if (s < 1) + // s = 1; + //int c = 0; + //LSL_Types.list chunk = new LSL_Types.list(); + //string chunkString = ""; + //foreach (string element in src) + //{ + // c++; + // if (c > s) + // { + // sorted.Add(chunkString, chunk); + // chunkString = ""; + // chunk = new LSL_Types.list(); + // c = 0; + // } + // chunk.Add(element); + // chunkString += element.ToString(); + //} + //if (chunk.Count > 0) + // sorted.Add(chunkString, chunk); + + //LSL_Types.list ret = new LSL_Types.list(); + //foreach (LSL_Types.list ls in sorted.Values) + //{ + // ret.AddRange(ls); + //} + + //if (ascending == LSL_BaseClass.TRUE) + // return ret; + //ret.Reverse(); + //return ret; + NotImplemented("llListSort"); + return new LSL_Types.list(); + } + + public int llGetListLength(LSL_Types.list src) + { + return src.Length; + } + + public int llList2Integer(LSL_Types.list src, int index) + { + if (index < 0) { - c++; - if (c > s) - { - sorted.Add(chunkString, chunk); - chunkString = ""; - chunk = new List(); - c = 0; - } - chunk.Add(element); - chunkString += element.ToString(); + index = src.Length + index; } - if (chunk.Count > 0) - sorted.Add(chunkString, chunk); - - List ret = new List(); - foreach (List ls in sorted.Values) + if (index >= src.Length) { - ret.AddRange(ls); + return 0; } - - if (ascending == LSL_BaseClass.TRUE) - return ret; - ret.Reverse(); - return ret; - } - - public int llGetListLength(List src) - { - return src.Count; - } - - public int llList2Integer(List src, int index) - { - return Convert.ToInt32(src[index]); + return Convert.ToInt32(src.Data[index]); } - public double llList2double(List src, int index) + public double osList2Double(LSL_Types.list src, int index) { - return Convert.ToDouble(src[index]); + if (index < 0) + { + index = src.Length + index; + } + if (index >= src.Length) + { + return 0.0; + } + return Convert.ToDouble(src.Data[index]); } - public float llList2Float(List src, int index) + public double llList2Float(LSL_Types.list src, int index) { - return Convert.ToSingle(src[index]); + if (index < 0) + { + index = src.Length + index; + } + if (index >= src.Length) + { + return 0.0; + } + return Convert.ToSingle(src.Data[index]); } - public string llList2String(List src, int index) + public string llList2String(LSL_Types.list src, int index) { - return src[index]; + if (index < 0) + { + index = src.Length + index; + } + if (index >= src.Length) + { + return ""; + } + return src.Data[index].ToString(); } - public string llList2Key(List src, int index) + public string llList2Key(LSL_Types.list src, int index) { + if (index < 0) + { + index = src.Length + index; + } + if (index >= src.Length) + { + return "00000000-0000-0000-0000-000000000000"; + } //return OpenSim.Framework.ToStringHyphenated(src[index]); - return src[index].ToString(); - } - - public LSL_Types.Vector3 llList2Vector(List src, int index) - { - return - new LSL_Types.Vector3(double.Parse(src[index]), double.Parse(src[index + 1]), - double.Parse(src[index + 2])); + LLUUID tmpkey; + if (LLUUID.TryParse(src.Data[index].ToString(), out tmpkey)) + { + return tmpkey.ToStringHyphenated(); + } + else + { + return "00000000-0000-0000-0000-000000000000"; + } } - public LSL_Types.Quaternion llList2Rot(List src, int index) + public LSL_Types.Vector3 llList2Vector(LSL_Types.list src, int index) { - return - new LSL_Types.Quaternion(double.Parse(src[index]), double.Parse(src[index + 1]), - double.Parse(src[index + 2]), double.Parse(src[index + 3])); + if (index < 0) + { + index = src.Length + index; + } + if (index >= src.Length) + { + return new LSL_Types.Vector3(0, 0, 0); + } + if (src.Data[index].GetType().ToString() == "OpenSim.Region.ScriptEngine.Common.LSL_Types+Vector3") + { + return (LSL_Types.Vector3)src.Data[index]; + } + else + { + return new LSL_Types.Vector3(0,0,0); + } } - public List llList2List(List src, int start, int end) + public LSL_Types.Quaternion llList2Rot(LSL_Types.list src, int index) { - if (end > start) + if (index < 0) + { + index = src.Length + index; + } + if (index >= src.Length) { - // Simple straight forward chunk - return src.GetRange(start, end - start); + return new LSL_Types.Quaternion(0, 0, 0, 1); + } + if (src.Data[index].GetType().ToString() == "OpenSim.Region.ScriptEngine.Common.LSL_Types+Quaternion") + { + return (LSL_Types.Quaternion)src.Data[index]; } else { - // Some of the end + some of the beginning - // First chunk - List ret = new List(); - ret.AddRange(src.GetRange(start, src.Count - start)); - ret.AddRange(src.GetRange(0, end)); - return ret; + return new LSL_Types.Quaternion(0, 0, 0, 1); } } - public List llDeleteSubList(List src, int start, int end) + public LSL_Types.list llList2List(LSL_Types.list src, int start, int end) { - List ret = new List(src); - ret.RemoveRange(start, end - start); - return ret; + return src.GetSublist(start, end); } - public int llGetListEntryType(List src, int index) + public LSL_Types.list llDeleteSubList(LSL_Types.list src, int start, int end) { - NotImplemented("llGetListEntryType"); - return 0; + //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); } - public string llList2CSV(List src) + public int llGetListEntryType(LSL_Types.list src, int index) { - string ret = ""; - foreach (string s in src) + if (index < 0) { - if (s.Length > 0) - ret += ","; - ret += s; + index = src.Length + index; + } + if (index >= src.Length) + { + return 0; + } + switch (src.Data[index].GetType().ToString()) + { + case "System.Int32": + return 1; + case "System.Double": + return 2; + case "System.String": + LLUUID tuuid; + if (LLUUID.TryParse(src.Data[index].ToString(),out tuuid)) + { + return 3; + } + else + { + return 4; + } + case "OpenSim.Region.ScriptEngine.Common.LSL_Types+Vector3": + return 5; + case "OpenSim.Region.ScriptEngine.Common.LSL_Types+Quaternion": + return 6; + case "OpenSim.Region.ScriptEngine.Common.LSL_Types+list": + return 7; + default: + return 0; } - return ret; } - public List llCSV2List(string src) + public string llList2CSV(LSL_Types.list src) { - List ret = new List(); - foreach (string s in src.Split(",".ToCharArray())) + string ret = ""; + foreach (object o in src.Data) { - ret.Add(s); + ret = ret + o.ToString() + ","; } + ret = ret.Substring(0, ret.Length - 2); return ret; } - public List llListRandomize(List src, int stride) + public LSL_Types.list llCSV2List(string src) { - int s = stride; - if (s < 1) - s = 1; + return new LSL_Types.list(src.Split(",".ToCharArray())); + } + + public LSL_Types.list llListRandomize(LSL_Types.list src, int stride) + { + //int s = stride; + //if (s < 1) + // s = 1; // This is a cowardly way of doing it ;) // TODO: Instead, randomize and check if random is mod stride or if it can not be, then array.removerange - List> tmp = new List>(); + //List tmp = new List(); // Add chunks to an array - int c = 0; - List chunk = new List(); - foreach (string element in src) - { - c++; - if (c > s) - { - tmp.Add(chunk); - chunk = new List(); - c = 0; - } - chunk.Add(element); - } - if (chunk.Count > 0) - tmp.Add(chunk); + //int c = 0; + //LSL_Types.list chunk = new LSL_Types.list(); + //foreach (string element in src) + //{ + // c++; + // if (c > s) + // { + // tmp.Add(chunk); + // chunk = new LSL_Types.list(); + // c = 0; + // } + // chunk.Add(element); + //} + //if (chunk.Count > 0) + // tmp.Add(chunk); // Decreate (<- what kind of word is that? :D ) array back into a list - int rnd; - List ret = new List(); - while (tmp.Count > 0) - { - rnd = Util.RandomClass.Next(tmp.Count); - foreach (string str in tmp[rnd]) - { - ret.Add(str); - } - tmp.RemoveAt(rnd); - } - - return ret; - } - - public List llList2ListStrided(List src, int start, int end, int stride) - { - List ret = new List(); - int s = stride; - if (s < 1) - s = 1; - - int sc = s; - for (int i = start; i < src.Count; i++) - { - sc--; - if (sc == 0) - { - sc = s; - // Addthis - ret.Add(src[i]); - } - if (i == end) - break; - } + //int rnd; + //LSL_Types.list ret = new LSL_Types.list(); + //while (tmp.Count > 0) + //{ + // rnd = Util.RandomClass.Next(tmp.Count); + // foreach (string str in tmp[rnd]) + // { + // ret.Add(str); + // } + // tmp.RemoveAt(rnd); + //} + + //return ret; + NotImplemented("llListRandomize"); + return new LSL_Types.list(); + } + + public LSL_Types.list llList2ListStrided(LSL_Types.list src, int start, int end, int stride) + { + LSL_Types.list ret = new LSL_Types.list(); + //int s = stride; + //if (s < 1) + // s = 1; + + //int sc = s; + //for (int i = start; i < src.Count; i++) + //{ + // sc--; + // if (sc == 0) + // { + // sc = s; + // // Addthis + // ret.Add(src[i]); + // } + // if (i == end) + // break; + //} + NotImplemented("llList2ListStrided"); return ret; } @@ -1637,27 +1733,22 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler return new LSL_Types.Vector3(World.RegionInfo.RegionLocX*256, World.RegionInfo.RegionLocY*256, 0); } - public List llListInsertList(List dest, List src, int start) + public LSL_Types.list llListInsertList(LSL_Types.list dest, LSL_Types.list src, int start) { - List ret = new List(dest); - //foreach (string s in src.Reverse()) - for (int ci = src.Count - 1; ci > -1; ci--) - { - ret.Insert(start, src[ci]); - } - return ret; + return dest.GetSublist(0, start - 1) + src + dest.GetSublist(start, -1); } - public int llListFindList(List src, List test) + public int llListFindList(LSL_Types.list src, LSL_Types.list test) { - foreach (string s in test) - { - for (int ci = 0; ci < src.Count; ci++) - { - if (s == src[ci]) - return ci; - } - } + //foreach (string s in test) + //{ + // for (int ci = 0; ci < src.Count; ci++) + // { + // if (s == src[ci]) + // return ci; + // } + //} + NotImplemented("llListFindList"); return -1; } @@ -2018,9 +2109,19 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler NotImplemented("llSetCameraAtOffset"); } - public void llDumpList2String() + public string llDumpList2String(LSL_Types.list src, string seperator) { - NotImplemented("llDumpList2String"); + if (src.Length == 0) + { + return ""; + } + string ret = ""; + foreach (object o in src.Data) + { + ret = ret + o.ToString() + seperator; + } + ret = ret.Substring(0, ret.Length - seperator.Length); + return ret; } public void llScriptDanger(LSL_Types.Vector3 pos) @@ -2028,7 +2129,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler NotImplemented("llScriptDanger"); } - public void llDialog(string avatar, string message, List buttons, int chat_channel) + public void llDialog(string avatar, string message, LSL_Types.list buttons, int chat_channel) { NotImplemented("llDialog"); } @@ -2103,7 +2204,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler return Util.Md5Hash(src + ":" + nonce.ToString()); } - public void llSetPrimitiveParams(List rules) + public void llSetPrimitiveParams(LSL_Types.list rules) { NotImplemented("llSetPrimitiveParams"); } @@ -2162,10 +2263,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler return (double) Math.Log(val); } - public List llGetAnimationList(string id) + public LSL_Types.list llGetAnimationList(string id) { NotImplemented("llGetAnimationList"); - return new List(); + return new LSL_Types.list(); } public void llSetParcelMusicURL(string url) @@ -2221,10 +2322,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler return ""; } - public List llGetBoundingBox(string obj) + public LSL_Types.list llGetBoundingBox(string obj) { NotImplemented("llGetBoundingBox"); - return new List(); + return new LSL_Types.list(); } public LSL_Types.Vector3 llGetGeometricCenter() @@ -2265,10 +2366,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler NotImplemented("llSetLocalRot"); } - public List llParseStringKeepNulls(string src, List seperators, List spacers) + public LSL_Types.list llParseStringKeepNulls(string src, LSL_Types.list seperators, LSL_Types.list spacers) { NotImplemented("llParseStringKeepNulls"); - return new List(); + return new LSL_Types.list(); } public void llRezAtRoot(string inventory, LSL_Types.Vector3 position, LSL_Types.Vector3 velocity, @@ -2337,7 +2438,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler url); } - public void llParcelMediaCommandList(List commandList) + public void llParcelMediaCommandList(LSL_Types.list commandList) { NotImplemented("llParcelMediaCommandList"); } @@ -2360,7 +2461,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler return 0; } - public void llSetPayPrice(int price, List quick_pay_buttons) + public void llSetPayPrice(int price, LSL_Types.list quick_pay_buttons) { NotImplemented("llSetPayPrice"); } @@ -2431,7 +2532,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler NotImplemented("llRemoveFromLandBanList"); } - public void llSetCameraParams(List rules) + public void llSetCameraParams(LSL_Types.list rules) { NotImplemented("llSetCameraParams"); } @@ -2441,7 +2542,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler NotImplemented("llClearCameraParams"); } - public double llListStatistics(int operation, List src) + public double llListStatistics(int operation, LSL_Types.list src) { NotImplemented("llListStatistics"); return 0; @@ -2481,13 +2582,17 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler return llStringToBase64(ret); } - public string llHTTPRequest(string url, List parameters, string body) + public string llHTTPRequest(string url, LSL_Types.list parameters, string body) { IHttpRequests httpScriptMod = m_ScriptEngine.World.RequestModuleInterface(); - + List param = new List(); + foreach (object o in parameters.Data) + { + param.Add(o.ToString()); + } LLUUID reqID = httpScriptMod. - StartHttpRequest(m_localID, m_itemID, url, parameters, body); + StartHttpRequest(m_localID, m_itemID, url, param, body); if( reqID != null ) return reqID.ToString(); @@ -2511,10 +2616,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler return 0; } - public List llGetParcelPrimOwners(LSL_Types.Vector3 pos) + public LSL_Types.list llGetParcelPrimOwners(LSL_Types.Vector3 pos) { NotImplemented("llGetParcelPrimOwners"); - return new List(); + return new LSL_Types.list(); } public int llGetObjectPrimCount(string object_id) @@ -2529,10 +2634,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler return 0; } - public List llGetParcelDetails(LSL_Types.Vector3 pos, List param) + public LSL_Types.list llGetParcelDetails(LSL_Types.Vector3 pos, LSL_Types.list param) { NotImplemented("llGetParcelDetails"); - return new List(); + return new LSL_Types.list(); } // -- cgit v1.1