aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/XEngine
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/AsyncCommandManager.cs268
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Dataserver.cs127
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Eventstream.cs75
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/HttpRequest.cs89
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Listener.cs91
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/SensorRepeat.cs393
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Timer.cs161
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/XmlRequest.cs115
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/Compiler.cs515
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/EventManager.cs99
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/Executor.cs19
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/ExecutorBase.cs16
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/LSL2CSConverter.cs374
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs6593
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/OSSL_ScriptCommands.cs553
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/Script/AssemblyResolver.cs65
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/Script/BuiltIn_Commands_BaseClass.cs2397
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/Script/ILSL_ScriptCommands.cs653
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/Script/IOSSL_ScriptCommands.cs68
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/Script/IScript.cs46
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/Script/LSL_Types.cs1512
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs234
22 files changed, 146 insertions, 14317 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandManager.cs
deleted file mode 100644
index fdad5b0..0000000
--- a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandManager.cs
+++ /dev/null
@@ -1,268 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Threading;
32using libsecondlife;
33using OpenSim.Framework;
34using OpenSim.Region.Environment.Interfaces;
35using OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins;
36using Timer=OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins.Timer;
37using Dataserver=OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins.Dataserver;
38
39namespace OpenSim.Region.ScriptEngine.XEngine
40{
41 /// <summary>
42 /// Handles LSL commands that takes long time and returns an event, for example timers, HTTP requests, etc.
43 /// </summary>
44 public class AsyncCommandManager
45 {
46 private static Thread cmdHandlerThread;
47 private static int cmdHandlerThreadCycleSleepms;
48
49 public XEngine m_ScriptEngine;
50
51 public Dataserver m_Dataserver;
52 public Timer m_Timer;
53 public HttpRequest m_HttpRequest;
54 public Listener m_Listener;
55 public SensorRepeat m_SensorRepeat;
56 public XmlRequest m_XmlRequest;
57
58 public AsyncCommandManager(XEngine _ScriptEngine)
59 {
60 m_ScriptEngine = _ScriptEngine;
61 ReadConfig();
62
63 // Create instances of all plugins
64 m_Dataserver = new Dataserver(this);
65 m_Timer = new Timer(this);
66 m_HttpRequest = new HttpRequest(this);
67 m_Listener = new Listener(this);
68 m_SensorRepeat = new SensorRepeat(this);
69 m_XmlRequest = new XmlRequest(this);
70
71 StartThread();
72 }
73
74 private static void StartThread()
75 {
76 if (cmdHandlerThread == null)
77 {
78 // Start the thread that will be doing the work
79 cmdHandlerThread = new Thread(CmdHandlerThreadLoop);
80 cmdHandlerThread.Name = "AsyncLSLCmdHandlerThread";
81 cmdHandlerThread.Priority = ThreadPriority.BelowNormal;
82 cmdHandlerThread.IsBackground = true;
83 cmdHandlerThread.Start();
84 ThreadTracker.Add(cmdHandlerThread);
85 }
86 }
87
88 public void ReadConfig()
89 {
90 cmdHandlerThreadCycleSleepms = m_ScriptEngine.ScriptConfigSource.GetInt("AsyncLLCommandLoopms", 100);
91 }
92
93 ~AsyncCommandManager()
94 {
95 // Shut down thread
96 try
97 {
98 if (cmdHandlerThread != null)
99 {
100 if (cmdHandlerThread.IsAlive == true)
101 {
102 cmdHandlerThread.Abort();
103 //cmdHandlerThread.Join();
104 }
105 }
106 }
107 catch
108 {
109 }
110 }
111
112 private static void CmdHandlerThreadLoop()
113 {
114 while (true)
115 {
116 try
117 {
118 while (true)
119 {
120 Thread.Sleep(cmdHandlerThreadCycleSleepms);
121
122 foreach (XEngine xe in XEngine.ScriptEngines)
123 {
124 xe.m_ASYNCLSLCommandManager.DoOneCmdHandlerPass();
125 }
126 }
127 }
128 catch
129 {
130 }
131 }
132 }
133
134 internal void DoOneCmdHandlerPass()
135 {
136 // Check timers
137 m_Timer.CheckTimerEvents();
138 // Check HttpRequests
139 m_HttpRequest.CheckHttpRequests();
140 // Check XMLRPCRequests
141 m_XmlRequest.CheckXMLRPCRequests();
142 // Check Listeners
143 m_Listener.CheckListeners();
144 // Check Sensors
145 m_SensorRepeat.CheckSenseRepeaterEvents();
146 // Check dataserver
147 m_Dataserver.ExpireRequests();
148 }
149
150 /// <summary>
151 /// Remove a specific script (and all its pending commands)
152 /// </summary>
153 /// <param name="localID"></param>
154 /// <param name="itemID"></param>
155 public void RemoveScript(uint localID, LLUUID itemID)
156 {
157 // Remove a specific script
158
159 // Remove dataserver events
160 m_Dataserver.RemoveEvents(localID, itemID);
161
162 // Remove from: Timers
163 m_Timer.UnSetTimerEvents(localID, itemID);
164
165 // Remove from: HttpRequest
166 IHttpRequests iHttpReq =
167 m_ScriptEngine.World.RequestModuleInterface<IHttpRequests>();
168 iHttpReq.StopHttpRequest(localID, itemID);
169
170 IWorldComm comms = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
171 comms.DeleteListener(itemID);
172
173 IXMLRPC xmlrpc = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
174 xmlrpc.DeleteChannels(itemID);
175 xmlrpc.CancelSRDRequests(itemID);
176
177 // Remove Sensors
178 m_SensorRepeat.UnSetSenseRepeaterEvents(localID, itemID);
179
180 }
181
182 public Object[] GetSerializationData(LLUUID itemID)
183 {
184 List<Object> data = new List<Object>();
185
186 Object[] listeners=m_Listener.GetSerializationData(itemID);
187 if (listeners.Length > 0)
188 {
189 data.Add("listener");
190 data.Add(listeners.Length);
191 data.AddRange(listeners);
192 }
193
194 Object[] timers=m_Timer.GetSerializationData(itemID);
195 if (timers.Length > 0)
196 {
197 data.Add("timer");
198 data.Add(timers.Length);
199 data.AddRange(timers);
200 }
201
202 Object[] sensors=m_SensorRepeat.GetSerializationData(itemID);
203 if (sensors.Length > 0)
204 {
205 data.Add("sensor");
206 data.Add(sensors.Length);
207 data.AddRange(sensors);
208 }
209
210 return data.ToArray();
211 }
212
213 public void CreateFromData(uint localID, LLUUID itemID, LLUUID hostID,
214 Object[] data)
215 {
216 int idx = 0;
217 int len;
218
219 while (idx < data.Length)
220 {
221 string type = data[idx].ToString();
222 len = (int)data[idx+1];
223 idx+=2;
224
225 if (len > 0)
226 {
227 Object[] item = new Object[len];
228 Array.Copy(data, idx, item, 0, len);
229
230 idx+=len;
231
232 switch (type)
233 {
234 case "listener":
235 m_Listener.CreateFromData(localID, itemID, hostID,
236 item);
237 break;
238 case "timer":
239 m_Timer.CreateFromData(localID, itemID, hostID, item);
240 break;
241 case "sensor":
242 m_SensorRepeat.CreateFromData(localID, itemID, hostID,
243 item);
244 break;
245 }
246 }
247 }
248 }
249
250 #region Check llRemoteData channels
251
252 #endregion
253
254 #region Check llListeners
255
256 #endregion
257
258 /// <summary>
259 /// If set to true then threads and stuff should try to make a graceful exit
260 /// </summary>
261 public bool PleaseShutdown
262 {
263 get { return _PleaseShutdown; }
264 set { _PleaseShutdown = value; }
265 }
266 private bool _PleaseShutdown = false;
267 }
268}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Dataserver.cs b/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Dataserver.cs
deleted file mode 100644
index 47ab420..0000000
--- a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Dataserver.cs
+++ /dev/null
@@ -1,127 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using libsecondlife;
32using OpenSim.Region.ScriptEngine.XEngine.Script;
33
34namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
35{
36 public class Dataserver
37 {
38 public AsyncCommandManager m_CmdManager;
39
40 private Dictionary<string, DataserverRequest> DataserverRequests =
41 new Dictionary<string, DataserverRequest>();
42
43 public Dataserver(AsyncCommandManager CmdManager)
44 {
45 m_CmdManager = CmdManager;
46 }
47
48 private class DataserverRequest
49 {
50 public uint localID;
51 public LLUUID itemID;
52
53 public LLUUID ID;
54 public string handle;
55
56 public DateTime startTime;
57 }
58
59 public LLUUID RegisterRequest(uint localID, LLUUID itemID,
60 string identifier)
61 {
62 lock (DataserverRequests)
63 {
64 if (DataserverRequests.ContainsKey(identifier))
65 return LLUUID.Zero;
66
67 DataserverRequest ds = new DataserverRequest();
68
69 ds.localID = localID;
70 ds.itemID = itemID;
71
72 ds.ID = LLUUID.Random();
73 ds.handle = identifier;
74
75 ds.startTime = DateTime.Now;
76
77 DataserverRequests[identifier]=ds;
78
79 return ds.ID;
80 }
81 }
82
83 public void DataserverReply(string identifier, string reply)
84 {
85 DataserverRequest ds;
86
87 lock (DataserverRequests)
88 {
89 if (!DataserverRequests.ContainsKey(identifier))
90 return;
91
92 ds=DataserverRequests[identifier];
93 DataserverRequests.Remove(identifier);
94 }
95
96 m_CmdManager.m_ScriptEngine.PostObjectEvent(ds.localID,
97 new XEventParams("dataserver", new Object[]
98 { new LSL_Types.LSLString(ds.ID.ToString()),
99 new LSL_Types.LSLString(reply)},
100 new XDetectParams[0]));
101 }
102
103 public void RemoveEvents(uint localID, LLUUID itemID)
104 {
105 lock (DataserverRequests)
106 {
107 foreach (DataserverRequest ds in new List<DataserverRequest>(DataserverRequests.Values))
108 {
109 if (ds.itemID == itemID)
110 DataserverRequests.Remove(ds.handle);
111 }
112 }
113 }
114
115 public void ExpireRequests()
116 {
117 lock (DataserverRequests)
118 {
119 foreach (DataserverRequest ds in new List<DataserverRequest>(DataserverRequests.Values))
120 {
121 if (ds.startTime > DateTime.Now.AddSeconds(30))
122 DataserverRequests.Remove(ds.handle);
123 }
124 }
125 }
126 }
127}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Eventstream.cs b/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Eventstream.cs
deleted file mode 100644
index dab7a0a..0000000
--- a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Eventstream.cs
+++ /dev/null
@@ -1,75 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using libsecondlife;
32using OpenSim.Region.Environment.Scenes;
33
34namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
35{
36 public class Eventstream
37 {
38 public AsyncCommandManager m_CmdManager;
39
40 private class Event
41 {
42 public uint LocalID;
43 public string EventName;
44 public Dictionary<LLUUID, XDetectParams> DetectParams;
45 }
46
47 private Dictionary<uint, Dictionary<string, Event> > m_Events =
48 new Dictionary<uint, Dictionary<string, Event> >();
49
50 public Eventstream(AsyncCommandManager CmdManager)
51 {
52 m_CmdManager = CmdManager;
53 }
54
55 public void AddObjectEvent(uint localID, string eventName, XDetectParams det)
56 {
57 SceneObjectPart part = m_CmdManager.m_ScriptEngine.World.
58 GetSceneObjectPart(localID);
59
60 if (part == null) // Can't register events for non-prims
61 return;
62
63 if (!part.ContainsScripts())
64 return;
65 }
66
67 public void RemoveObjectEvent(uint localID, string eventName, LLUUID id)
68 {
69 }
70
71 public void RemoveObjects(uint localID)
72 {
73 }
74 }
75}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/HttpRequest.cs b/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/HttpRequest.cs
deleted file mode 100644
index 089e016..0000000
--- a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/HttpRequest.cs
+++ /dev/null
@@ -1,89 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using OpenSim.Region.Environment.Interfaces;
30using OpenSim.Region.Environment.Modules.Scripting.HttpRequest;
31using OpenSim.Region.ScriptEngine.XEngine.Script;
32
33namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
34{
35 public class HttpRequest
36 {
37 public AsyncCommandManager m_CmdManager;
38
39 public HttpRequest(AsyncCommandManager CmdManager)
40 {
41 m_CmdManager = CmdManager;
42 }
43
44 public void CheckHttpRequests()
45 {
46 if (m_CmdManager.m_ScriptEngine.World == null)
47 return;
48
49 IHttpRequests iHttpReq =
50 m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IHttpRequests>();
51
52 HttpRequestClass httpInfo = null;
53
54 if (iHttpReq != null)
55 httpInfo = iHttpReq.GetNextCompletedRequest();
56
57 while (httpInfo != null)
58 {
59 //m_ScriptEngine.Log.Info("[AsyncLSL]:" + httpInfo.response_body + httpInfo.status);
60
61 // Deliver data to prim's remote_data handler
62 //
63 // TODO: Returning null for metadata, since the lsl function
64 // only returns the byte for HTTP_BODY_TRUNCATED, which is not
65 // implemented here yet anyway. Should be fixed if/when maxsize
66 // is supported
67
68 iHttpReq.RemoveCompletedRequest(httpInfo.reqID);
69
70 object[] resobj = new object[]
71 {
72 new LSL_Types.LSLString(httpInfo.reqID.ToString()),
73 new LSL_Types.LSLInteger(httpInfo.status),
74 new LSL_Types.list(),
75 new LSL_Types.LSLString(httpInfo.response_body)
76 };
77
78 foreach (XEngine xe in XEngine.ScriptEngines)
79 {
80 if (xe.PostObjectEvent(httpInfo.localID,
81 new XEventParams("http_response",
82 resobj, new XDetectParams[0])))
83 break;
84 }
85 httpInfo = iHttpReq.GetNextCompletedRequest();
86 }
87 }
88 }
89}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Listener.cs b/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Listener.cs
deleted file mode 100644
index 1144c00..0000000
--- a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Listener.cs
+++ /dev/null
@@ -1,91 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using libsecondlife;
30using OpenSim.Region.Environment.Interfaces;
31using OpenSim.Region.Environment.Modules.Scripting.WorldComm;
32using OpenSim.Region.ScriptEngine.XEngine.Script;
33
34namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
35{
36 public class Listener
37 {
38 // private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
39
40 public AsyncCommandManager m_CmdManager;
41
42 public Listener(AsyncCommandManager CmdManager)
43 {
44 m_CmdManager = CmdManager;
45 }
46
47 public void CheckListeners()
48 {
49 if (m_CmdManager.m_ScriptEngine.World == null)
50 return;
51 IWorldComm comms = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
52
53 if (comms != null)
54 {
55 while (comms.HasMessages())
56 {
57 ListenerInfo lInfo = comms.GetNextMessage();
58
59 //Deliver data to prim's listen handler
60 object[] resobj = new object[]
61 {
62 new LSL_Types.LSLInteger(lInfo.GetChannel()),
63 new LSL_Types.LSLString(lInfo.GetName()),
64 new LSL_Types.LSLString(lInfo.GetID().ToString()),
65 new LSL_Types.LSLString(lInfo.GetMessage())
66 };
67
68 m_CmdManager.m_ScriptEngine.PostScriptEvent(
69 lInfo.GetItemID(), new XEventParams(
70 "listen", resobj,
71 new XDetectParams[0]));
72 }
73 }
74 }
75
76 public Object[] GetSerializationData(LLUUID itemID)
77 {
78 IWorldComm comms = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
79
80 return comms.GetSerializationData(itemID);
81 }
82
83 public void CreateFromData(uint localID, LLUUID itemID, LLUUID hostID,
84 Object[] data)
85 {
86 IWorldComm comms = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
87
88 comms.CreateFromData(localID, itemID, hostID, data);
89 }
90 }
91}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/SensorRepeat.cs
deleted file mode 100644
index 8a25098..0000000
--- a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/SensorRepeat.cs
+++ /dev/null
@@ -1,393 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using libsecondlife;
31using OpenSim.Framework;
32using OpenSim.Region.Environment.Scenes;
33using OpenSim.Region.ScriptEngine.XEngine.Script;
34
35namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
36{
37 public class SensorRepeat
38 {
39 public AsyncCommandManager m_CmdManager;
40
41 public SensorRepeat(AsyncCommandManager CmdManager)
42 {
43 m_CmdManager = CmdManager;
44 }
45
46 public Dictionary<uint, Dictionary<LLUUID, LSL_Types.list>> SenseEvents =
47 new Dictionary<uint, Dictionary<LLUUID, LSL_Types.list>>();
48 private Object SenseLock = new Object();
49
50 //
51 // SenseRepeater and Sensors
52 //
53 private class SenseRepeatClass
54 {
55 public uint localID;
56 public LLUUID itemID;
57 public double interval;
58 public DateTime next;
59
60 public string name;
61 public LLUUID keyID;
62 public int type;
63 public double range;
64 public double arc;
65 public SceneObjectPart host;
66 }
67
68 private List<SenseRepeatClass> SenseRepeaters = new List<SenseRepeatClass>();
69 private object SenseRepeatListLock = new object();
70
71 public void SetSenseRepeatEvent(uint m_localID, LLUUID m_itemID,
72 string name, LLUUID keyID, int type, double range,
73 double arc, double sec, SceneObjectPart host)
74 {
75 Console.WriteLine("SetSensorEvent");
76
77 // Always remove first, in case this is a re-set
78 UnSetSenseRepeaterEvents(m_localID, m_itemID);
79 if (sec == 0) // Disabling timer
80 return;
81
82 // Add to timer
83 SenseRepeatClass ts = new SenseRepeatClass();
84 ts.localID = m_localID;
85 ts.itemID = m_itemID;
86 ts.interval = sec;
87 ts.name = name;
88 ts.keyID = keyID;
89 ts.type = type;
90 ts.range = range;
91 ts.arc = arc;
92 ts.host = host;
93
94 ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
95 lock (SenseRepeatListLock)
96 {
97 SenseRepeaters.Add(ts);
98 }
99 }
100
101 public void UnSetSenseRepeaterEvents(uint m_localID, LLUUID m_itemID)
102 {
103 // Remove from timer
104 lock (SenseRepeatListLock)
105 {
106 List<SenseRepeatClass> NewSensors = new List<SenseRepeatClass>();
107 foreach (SenseRepeatClass ts in SenseRepeaters)
108 {
109 if (ts.localID != m_localID && ts.itemID != m_itemID)
110 {
111 NewSensors.Add(ts);
112 }
113 }
114 SenseRepeaters.Clear();
115 SenseRepeaters = NewSensors;
116 }
117 }
118
119 public void CheckSenseRepeaterEvents()
120 {
121 // Nothing to do here?
122 if (SenseRepeaters.Count == 0)
123 return;
124
125 lock (SenseRepeatListLock)
126 {
127 // Go through all timers
128 foreach (SenseRepeatClass ts in SenseRepeaters)
129 {
130 // Time has passed?
131 if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime())
132 {
133 SensorSweep(ts);
134 // set next interval
135 ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
136 }
137 }
138 } // lock
139 }
140
141 public void SenseOnce(uint m_localID, LLUUID m_itemID,
142 string name, LLUUID keyID, int type,
143 double range, double arc, SceneObjectPart host)
144 {
145 // Add to timer
146 SenseRepeatClass ts = new SenseRepeatClass();
147 ts.localID = m_localID;
148 ts.itemID = m_itemID;
149 ts.interval = 0;
150 ts.name = name;
151 ts.keyID = keyID;
152 ts.type = type;
153 ts.range = range;
154 ts.arc = arc;
155 ts.host = host;
156 SensorSweep(ts);
157 }
158
159 public LSL_Types.list GetSensorList(uint m_localID, LLUUID m_itemID)
160 {
161 lock (SenseLock)
162 {
163 Dictionary<LLUUID, LSL_Types.list> Obj = null;
164 if (!SenseEvents.TryGetValue(m_localID, out Obj))
165 {
166 m_CmdManager.m_ScriptEngine.Log.Info("[AsyncLSL]: GetSensorList missing localID: " + m_localID);
167 return null;
168 }
169 lock (Obj)
170 {
171 // Get script
172 LSL_Types.list SenseList = null;
173 if (!Obj.TryGetValue(m_itemID, out SenseList))
174 {
175 m_CmdManager.m_ScriptEngine.Log.Info("[AsyncLSL]: GetSensorList missing itemID: " + m_itemID);
176 return null;
177 }
178 return SenseList;
179 }
180 }
181 }
182
183 private void SensorSweep(SenseRepeatClass ts)
184 {
185 //m_ScriptEngine.Log.Info("[AsyncLSL]:Enter SensorSweep");
186 SceneObjectPart SensePoint = ts.host;
187
188 if (SensePoint == null)
189 {
190 //m_ScriptEngine.Log.Info("[AsyncLSL]: Enter SensorSweep (SensePoint == null) for "+ts.itemID.ToString());
191 return;
192 }
193 //m_ScriptEngine.Log.Info("[AsyncLSL]: Enter SensorSweep Scan");
194
195 LLVector3 sensorPos = SensePoint.AbsolutePosition;
196 LLVector3 regionPos = new LLVector3(m_CmdManager.m_ScriptEngine.World.RegionInfo.RegionLocX * Constants.RegionSize, m_CmdManager.m_ScriptEngine.World.RegionInfo.RegionLocY * Constants.RegionSize, 0);
197 LLVector3 fromRegionPos = sensorPos + regionPos;
198
199 LLQuaternion q = SensePoint.RotationOffset;
200 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W);
201 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r);
202 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir);
203
204 // Here we should do some smart culling ...
205 // math seems quicker than strings so try that first
206 LSL_Types.list SensedObjects = new LSL_Types.list();
207 LSL_Types.Vector3 ZeroVector = new LSL_Types.Vector3(0, 0, 0);
208
209 foreach (EntityBase ent in m_CmdManager.m_ScriptEngine.World.Entities.Values)
210 {
211 LLVector3 toRegionPos = ent.AbsolutePosition + regionPos;
212 double dis = Math.Abs((double)Util.GetDistanceTo(toRegionPos, fromRegionPos));
213 if (dis <= ts.range)
214 {
215 // In Range, is it the right Type ?
216 int objtype = 0;
217
218 if (m_CmdManager.m_ScriptEngine.World.GetScenePresence(ent.UUID) != null) objtype |= 0x01; // actor
219 if (ent.Velocity.Equals(ZeroVector))
220 objtype |= 0x04; // passive non-moving
221 else
222 objtype |= 0x02; // active moving
223 if (ent is IScript) objtype |= 0x08; // Scripted. It COULD have one hidden ...
224
225 if (((ts.type & objtype) != 0) || ((ts.type & objtype) == ts.type))
226 {
227 // docs claim AGENT|ACTIVE should find agent objects OR active objects
228 // so the bitwise AND with object type should be non-zero
229
230 // Right type too, what about the other params , key and name ?
231 bool keep = true;
232 if (ts.arc < Math.PI)
233 {
234 // not omni-directional. Can you see it ?
235 // vec forward_dir = llRot2Fwd(llGetRot())
236 // vec obj_dir = toRegionPos-fromRegionPos
237 // dot=dot(forward_dir,obj_dir)
238 // mag_fwd = mag(forward_dir)
239 // mag_obj = mag(obj_dir)
240 // ang = acos(dot /(mag_fwd*mag_obj))
241 double ang_obj = 0;
242 try
243 {
244 LLVector3 diff = toRegionPos - fromRegionPos;
245 LSL_Types.Vector3 obj_dir = new LSL_Types.Vector3(diff.X, diff.Y, diff.Z);
246 double dot = LSL_Types.Vector3.Dot(forward_dir, obj_dir);
247 double mag_obj = LSL_Types.Vector3.Mag(obj_dir);
248 ang_obj = Math.Acos(dot / (mag_fwd * mag_obj));
249 }
250 catch
251 {
252 }
253
254 if (ang_obj > ts.arc) keep = false;
255 }
256
257 if (keep && (ts.keyID != LLUUID.Zero) && (ts.keyID != ent.UUID))
258 {
259 keep = false;
260 }
261
262 if (keep && (ts.name.Length > 0))
263 {
264 string avatarname=null;
265 string objectname=null;
266 string entname =ent.Name;
267
268 // try avatar username surname
269 UserProfileData profile = m_CmdManager.m_ScriptEngine.World.CommsManager.UserService.GetUserProfile(ent.UUID);
270 if (profile != null)
271 {
272 avatarname = profile.FirstName + " " + profile.SurName;
273 }
274 // try an scene object
275 SceneObjectPart SOP = m_CmdManager.m_ScriptEngine.World.GetSceneObjectPart(ent.UUID);
276 if (SOP != null)
277 {
278 objectname = SOP.Name;
279 }
280
281 if ((ts.name != entname) && (ts.name != avatarname) && (ts.name != objectname))
282 {
283 keep = false;
284 }
285 }
286
287 if (keep == true) SensedObjects.Add(ent.UUID);
288 }
289 }
290 }
291 //m_ScriptEngine.Log.Info("[AsyncLSL]: Enter SensorSweep SenseLock");
292
293 lock (SenseLock)
294 {
295 // Create object if it doesn't exist
296 if (SenseEvents.ContainsKey(ts.localID) == false)
297 {
298 SenseEvents.Add(ts.localID, new Dictionary<LLUUID, LSL_Types.list>());
299 }
300 // clear if previous traces exist
301 Dictionary<LLUUID, LSL_Types.list> Obj;
302 SenseEvents.TryGetValue(ts.localID, out Obj);
303 if (Obj.ContainsKey(ts.itemID) == true)
304 Obj.Remove(ts.itemID);
305
306 // note list may be zero length
307 Obj.Add(ts.itemID, SensedObjects);
308
309 if (SensedObjects.Length == 0)
310 {
311 // send a "no_sensor"
312 // Add it to queue
313 m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID,
314 new XEventParams("no_sensor", new Object[0],
315 new XDetectParams[0]));
316 }
317 else
318 {
319 XDetectParams[] detect =
320 new XDetectParams[SensedObjects.Length];
321
322 int idx;
323 for (idx = 0; idx < SensedObjects.Length; idx++)
324 {
325 detect[idx] = new XDetectParams();
326 detect[idx].Key=(LLUUID)(SensedObjects.Data[idx]);
327 detect[idx].Populate(m_CmdManager.m_ScriptEngine.World);
328 }
329
330 m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID,
331 new XEventParams("sensor",
332 new Object[] {
333 new LSL_Types.LSLInteger(SensedObjects.Length) },
334 detect));
335 }
336 }
337 }
338
339 public Object[] GetSerializationData(LLUUID itemID)
340 {
341 List<Object> data = new List<Object>();
342
343 foreach (SenseRepeatClass ts in SenseRepeaters)
344 {
345 if (ts.itemID == itemID)
346 {
347 data.Add(ts.interval);
348 data.Add(ts.name);
349 data.Add(ts.keyID);
350 data.Add(ts.type);
351 data.Add(ts.range);
352 data.Add(ts.arc);
353 }
354 }
355 return data.ToArray();
356 }
357
358 public void CreateFromData(uint localID, LLUUID itemID, LLUUID objectID,
359 Object[] data)
360 {
361 SceneObjectPart part =
362 m_CmdManager.m_ScriptEngine.World.GetSceneObjectPart(
363 objectID);
364
365 if (part == null)
366 return;
367
368 int idx = 0;
369
370 while (idx < data.Length)
371 {
372 SenseRepeatClass ts = new SenseRepeatClass();
373
374 ts.localID = localID;
375 ts.itemID = itemID;
376
377 ts.interval = (double)data[idx];
378 ts.name = (string)data[idx+1];
379 ts.keyID = (LLUUID)data[idx+2];
380 ts.type = (int)data[idx+3];
381 ts.range = (double)data[idx+4];
382 ts.arc = (double)data[idx+5];
383 ts.host = part;
384
385 ts.next =
386 DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
387
388 SenseRepeaters.Add(ts);
389 idx += 6;
390 }
391 }
392 }
393}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Timer.cs b/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Timer.cs
deleted file mode 100644
index 3dd875a..0000000
--- a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Timer.cs
+++ /dev/null
@@ -1,161 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using libsecondlife;
32
33namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
34{
35 public class Timer
36 {
37 public AsyncCommandManager m_CmdManager;
38
39 public Timer(AsyncCommandManager CmdManager)
40 {
41 m_CmdManager = CmdManager;
42 }
43
44 //
45 // TIMER
46 //
47 private class TimerClass
48 {
49 public uint localID;
50 public LLUUID itemID;
51 //public double interval;
52 public long interval;
53 //public DateTime next;
54 public long next;
55 }
56
57 private List<TimerClass> Timers = new List<TimerClass>();
58 private object TimerListLock = new object();
59
60 public void SetTimerEvent(uint m_localID, LLUUID m_itemID, double sec)
61 {
62 // Always remove first, in case this is a re-set
63 UnSetTimerEvents(m_localID, m_itemID);
64 if (sec == 0) // Disabling timer
65 return;
66
67 // Add to timer
68 TimerClass ts = new TimerClass();
69 ts.localID = m_localID;
70 ts.itemID = m_itemID;
71 ts.interval = Convert.ToInt64(sec * 10000000); // How many 100 nanoseconds (ticks) should we wait
72 // 2193386136332921 ticks
73 // 219338613 seconds
74
75 //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
76 ts.next = DateTime.Now.Ticks + ts.interval;
77 lock (TimerListLock)
78 {
79 Timers.Add(ts);
80 }
81 }
82
83 public void UnSetTimerEvents(uint m_localID, LLUUID m_itemID)
84 {
85 // Remove from timer
86 lock (TimerListLock)
87 {
88 foreach (TimerClass ts in new ArrayList(Timers))
89 {
90 if (ts.localID == m_localID && ts.itemID == m_itemID)
91 Timers.Remove(ts);
92 }
93 }
94 }
95
96 public void CheckTimerEvents()
97 {
98 // Nothing to do here?
99 if (Timers.Count == 0)
100 return;
101
102 lock (TimerListLock)
103 {
104 // Go through all timers
105 foreach (TimerClass ts in Timers)
106 {
107 // Time has passed?
108 if (ts.next < DateTime.Now.Ticks)
109 {
110 // Console.WriteLine("Time has passed: Now: " + DateTime.Now.Ticks + ", Passed: " + ts.next);
111 // Add it to queue
112 m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID,
113 new XEventParams("timer", new Object[0],
114 new XDetectParams[0]));
115 // set next interval
116
117 //ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
118 ts.next = DateTime.Now.Ticks + ts.interval;
119 }
120 }
121 }
122 }
123
124 public Object[] GetSerializationData(LLUUID itemID)
125 {
126 List<Object> data = new List<Object>();
127
128 lock (TimerListLock)
129 {
130 foreach (TimerClass ts in Timers)
131 {
132 if (ts.itemID == itemID)
133 {
134 data.Add(ts.interval);
135 data.Add(ts.next-DateTime.Now.Ticks);
136 }
137 }
138 }
139 return data.ToArray();
140 }
141
142 public void CreateFromData(uint localID, LLUUID itemID, LLUUID objectID,
143 Object[] data)
144 {
145 int idx = 0;
146
147 while (idx < data.Length)
148 {
149 TimerClass ts = new TimerClass();
150
151 ts.localID = localID;
152 ts.itemID = itemID;
153 ts.interval = (long)data[idx];
154 ts.next = DateTime.Now.Ticks + (long)data[idx+1];
155 idx += 2;
156
157 Timers.Add(ts);
158 }
159 }
160 }
161}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/XmlRequest.cs b/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/XmlRequest.cs
deleted file mode 100644
index 288349e..0000000
--- a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/XmlRequest.cs
+++ /dev/null
@@ -1,115 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using OpenSim.Region.Environment.Interfaces;
30using OpenSim.Region.Environment.Modules.Scripting.XMLRPC;
31using OpenSim.Region.ScriptEngine.XEngine.Script;
32
33namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
34{
35 public class XmlRequest
36 {
37 public AsyncCommandManager m_CmdManager;
38
39 public XmlRequest(AsyncCommandManager CmdManager)
40 {
41 m_CmdManager = CmdManager;
42 }
43
44 public void CheckXMLRPCRequests()
45 {
46 if (m_CmdManager.m_ScriptEngine.World == null)
47 return;
48
49 IXMLRPC xmlrpc = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
50
51 if (xmlrpc != null)
52 {
53 RPCRequestInfo rInfo = xmlrpc.GetNextCompletedRequest();
54
55 while (rInfo != null)
56 {
57 xmlrpc.RemoveCompletedRequest(rInfo.GetMessageID());
58
59 //Deliver data to prim's remote_data handler
60 object[] resobj = new object[]
61 {
62 new LSL_Types.LSLInteger(2),
63 new LSL_Types.LSLString(
64 rInfo.GetChannelKey().ToString()),
65 new LSL_Types.LSLString(
66 rInfo.GetMessageID().ToString()),
67 new LSL_Types.LSLString(String.Empty),
68 new LSL_Types.LSLInteger(rInfo.GetIntValue()),
69 new LSL_Types.LSLString(rInfo.GetStrVal())
70 };
71
72 foreach (XEngine xe in XEngine.ScriptEngines)
73 {
74 if (xe.PostScriptEvent(
75 rInfo.GetItemID(), new XEventParams(
76 "remote_data", resobj,
77 new XDetectParams[0])))
78 break;
79 }
80
81 rInfo = xmlrpc.GetNextCompletedRequest();
82 }
83
84 SendRemoteDataRequest srdInfo = xmlrpc.GetNextCompletedSRDRequest();
85
86 while (srdInfo != null)
87 {
88 xmlrpc.RemoveCompletedSRDRequest(srdInfo.GetReqID());
89
90 //Deliver data to prim's remote_data handler
91 object[] resobj = new object[]
92 {
93 new LSL_Types.LSLInteger(3),
94 new LSL_Types.LSLString(srdInfo.channel.ToString()),
95 new LSL_Types.LSLString(srdInfo.GetReqID().ToString()),
96 new LSL_Types.LSLString(String.Empty),
97 new LSL_Types.LSLInteger(srdInfo.idata),
98 new LSL_Types.LSLString(srdInfo.sdata)
99 };
100
101 foreach (XEngine xe in XEngine.ScriptEngines)
102 {
103 if (xe.PostScriptEvent(
104 srdInfo.m_itemID, new XEventParams(
105 "remote_data", resobj,
106 new XDetectParams[0])))
107 break;
108 }
109
110 srdInfo = xmlrpc.GetNextCompletedSRDRequest();
111 }
112 }
113 }
114 }
115}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Compiler.cs b/OpenSim/Region/ScriptEngine/XEngine/Compiler.cs
deleted file mode 100644
index 68fb1dd..0000000
--- a/OpenSim/Region/ScriptEngine/XEngine/Compiler.cs
+++ /dev/null
@@ -1,515 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.CodeDom.Compiler;
30using System.Collections.Generic;
31using System.Globalization;
32using System.IO;
33using Microsoft.CSharp;
34using Microsoft.JScript;
35using Microsoft.VisualBasic;
36using OpenSim.Region.Environment.Interfaces;
37
38namespace OpenSim.Region.ScriptEngine.XEngine
39{
40 public class Compiler
41 {
42 private static readonly log4net.ILog m_log
43 = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
44
45 // * Uses "LSL2Converter" to convert LSL to C# if necessary.
46 // * Compiles C#-code into an assembly
47 // * Returns assembly name ready for AppDomain load.
48 //
49 // Assembly is compiled using LSL_BaseClass as base. Look at debug C# code file created when LSL script is compiled for full details.
50 //
51
52 internal enum enumCompileType
53 {
54 lsl = 0,
55 cs = 1,
56 vb = 2,
57 js = 3
58 }
59
60 /// <summary>
61 /// This contains number of lines WE use for header when compiling script. User will get error in line x-LinesToRemoveOnError when error occurs.
62 /// </summary>
63 public int LinesToRemoveOnError = 3;
64 private enumCompileType DefaultCompileLanguage;
65 private bool WriteScriptSourceToDebugFile;
66 private bool CompileWithDebugInformation;
67 private Dictionary<string, bool> AllowedCompilers = new Dictionary<string, bool>(StringComparer.CurrentCultureIgnoreCase);
68 private Dictionary<string, enumCompileType> LanguageMapping = new Dictionary<string, enumCompileType>(StringComparer.CurrentCultureIgnoreCase);
69
70 private string FilePrefix;
71 private string ScriptEnginesPath = "ScriptEngines";
72
73 private static LSL2CSConverter LSL_Converter = new LSL2CSConverter();
74 private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider();
75 private static VBCodeProvider VBcodeProvider = new VBCodeProvider();
76 private static JScriptCodeProvider JScodeProvider = new JScriptCodeProvider();
77
78 private static int instanceID = new Random().Next(0, int.MaxValue); // Unique number to use on our compiled files
79 private static UInt64 scriptCompileCounter = 0; // And a counter
80
81 public XEngine m_scriptEngine;
82 public Compiler(XEngine scriptEngine)
83 {
84 m_scriptEngine = scriptEngine;
85 ReadConfig();
86 }
87 public bool in_startup = true;
88 public void ReadConfig()
89 {
90
91 // Get some config
92 WriteScriptSourceToDebugFile = m_scriptEngine.ScriptConfigSource.GetBoolean("WriteScriptSourceToDebugFile", true);
93 CompileWithDebugInformation = m_scriptEngine.ScriptConfigSource.GetBoolean("CompileWithDebugInformation", true);
94
95 // Get file prefix from scriptengine name and make it file system safe:
96 FilePrefix = m_scriptEngine.ScriptEngineName;
97 foreach (char c in Path.GetInvalidFileNameChars())
98 {
99 FilePrefix = FilePrefix.Replace(c, '_');
100 }
101
102 // First time we start? Delete old files
103 if (in_startup)
104 {
105 in_startup = false;
106 DeleteOldFiles();
107 }
108
109 // Map name and enum type of our supported languages
110 LanguageMapping.Add(enumCompileType.cs.ToString(), enumCompileType.cs);
111 LanguageMapping.Add(enumCompileType.vb.ToString(), enumCompileType.vb);
112 LanguageMapping.Add(enumCompileType.lsl.ToString(), enumCompileType.lsl);
113 LanguageMapping.Add(enumCompileType.js.ToString(), enumCompileType.js);
114
115 // Allowed compilers
116 string allowComp = m_scriptEngine.ScriptConfigSource.GetString("AllowedCompilers", "lsl,cs,vb,js");
117 AllowedCompilers.Clear();
118
119#if DEBUG
120 m_scriptEngine.Log.Debug("[" + m_scriptEngine.ScriptEngineName + "]: Allowed languages: " + allowComp);
121#endif
122
123
124 foreach (string strl in allowComp.Split(','))
125 {
126 string strlan = strl.Trim(" \t".ToCharArray()).ToLower();
127 if (!LanguageMapping.ContainsKey(strlan))
128 {
129 m_scriptEngine.Log.Error("[" + m_scriptEngine.ScriptEngineName + "]: Config error. Compiler is unable to recognize language type \"" + strlan + "\" specified in \"AllowedCompilers\".");
130 }
131 else
132 {
133#if DEBUG
134 //m_scriptEngine.Log.Debug("[" + m_scriptEngine.ScriptEngineName + "]: Config OK. Compiler recognized language type \"" + strlan + "\" specified in \"AllowedCompilers\".");
135#endif
136 }
137 AllowedCompilers.Add(strlan, true);
138 }
139 if (AllowedCompilers.Count == 0)
140 m_scriptEngine.Log.Error("[" + m_scriptEngine.ScriptEngineName + "]: Config error. Compiler could not recognize any language in \"AllowedCompilers\". Scripts will not be executed!");
141
142 // Default language
143 string defaultCompileLanguage = m_scriptEngine.ScriptConfigSource.GetString("DefaultCompileLanguage", "lsl").ToLower();
144
145 // Is this language recognized at all?
146 if (!LanguageMapping.ContainsKey(defaultCompileLanguage))
147 {
148 m_scriptEngine.Log.Error("[" + m_scriptEngine.ScriptEngineName + "]: " +
149 "Config error. Default language \"" + defaultCompileLanguage + "\" specified in \"DefaultCompileLanguage\" is not recognized as a valid language. Changing default to: \"lsl\".");
150 defaultCompileLanguage = "lsl";
151 }
152
153 // Is this language in allow-list?
154 if (!AllowedCompilers.ContainsKey(defaultCompileLanguage))
155 {
156 m_scriptEngine.Log.Error("[" + m_scriptEngine.ScriptEngineName + "]: " +
157 "Config error. Default language \"" + defaultCompileLanguage + "\"specified in \"DefaultCompileLanguage\" is not in list of \"AllowedCompilers\". Scripts may not be executed!");
158 }
159 else
160 {
161#if DEBUG
162// m_scriptEngine.Log.Debug("[" + m_scriptEngine.ScriptEngineName + "]: " +
163// "Config OK. Default language \"" + defaultCompileLanguage + "\" specified in \"DefaultCompileLanguage\" is recognized as a valid language.");
164#endif
165 // LANGUAGE IS IN ALLOW-LIST
166 DefaultCompileLanguage = LanguageMapping[defaultCompileLanguage];
167 }
168
169 // We now have an allow-list, a mapping list, and a default language
170
171 }
172
173 /// <summary>
174 /// Delete old script files
175 /// </summary>
176 private void DeleteOldFiles()
177 {
178
179 // CREATE FOLDER IF IT DOESNT EXIST
180 if (!Directory.Exists(ScriptEnginesPath))
181 {
182 try
183 {
184 Directory.CreateDirectory(ScriptEnginesPath);
185 }
186 catch (Exception ex)
187 {
188 m_scriptEngine.Log.Error("[" + m_scriptEngine.ScriptEngineName + "]: Exception trying to create ScriptEngine directory \"" + ScriptEnginesPath + "\": " + ex.ToString());
189 }
190 }
191
192 if (!Directory.Exists(Path.Combine(ScriptEnginesPath,
193 m_scriptEngine.World.RegionInfo.RegionID.ToString())))
194 {
195 try
196 {
197 Directory.CreateDirectory(Path.Combine(ScriptEnginesPath,
198 m_scriptEngine.World.RegionInfo.RegionID.ToString()));
199 }
200 catch (Exception ex)
201 {
202 m_scriptEngine.Log.Error("[" + m_scriptEngine.ScriptEngineName + "]: Exception trying to create ScriptEngine directory \"" + Path.Combine(ScriptEnginesPath,
203 m_scriptEngine.World.RegionInfo.RegionID.ToString())+ "\": " + ex.ToString());
204 }
205 }
206
207 foreach (string file in Directory.GetFiles(Path.Combine(ScriptEnginesPath,
208 m_scriptEngine.World.RegionInfo.RegionID.ToString())))
209 {
210 //m_scriptEngine.Log.Error("[" + m_scriptEngine.ScriptEngineName + "]: FILE FOUND: " + file);
211
212 if (file.ToLower().StartsWith(FilePrefix + "_compiled_") ||
213 file.ToLower().StartsWith(FilePrefix + "_source_"))
214 {
215 try
216 {
217 File.Delete(file);
218 }
219 catch (Exception ex)
220 {
221 m_scriptEngine.Log.Error("[" + m_scriptEngine.ScriptEngineName + "]: Exception trying delete old script file \"" + file + "\": " + ex.ToString());
222 }
223
224 }
225 }
226
227 }
228
229 ////private ICodeCompiler icc = codeProvider.CreateCompiler();
230 //public string CompileFromFile(string LSOFileName)
231 //{
232 // switch (Path.GetExtension(LSOFileName).ToLower())
233 // {
234 // case ".txt":
235 // case ".lsl":
236 // Common.ScriptEngineBase.Common.SendToDebug("Source code is LSL, converting to CS");
237 // return CompileFromLSLText(File.ReadAllText(LSOFileName));
238 // case ".cs":
239 // Common.ScriptEngineBase.Common.SendToDebug("Source code is CS");
240 // return CompileFromCSText(File.ReadAllText(LSOFileName));
241 // default:
242 // throw new Exception("Unknown script type.");
243 // }
244 //}
245
246 /// <summary>
247 /// Converts script from LSL to CS and calls CompileFromCSText
248 /// </summary>
249 /// <param name="Script">LSL script</param>
250 /// <returns>Filename to .dll assembly</returns>
251 public string PerformScriptCompile(string Script, string asset)
252 {
253 string OutFile = Path.Combine(ScriptEnginesPath, Path.Combine(
254 m_scriptEngine.World.RegionInfo.RegionID.ToString(),
255 FilePrefix + "_compiled_" + asset + ".dll"));
256// string OutFile = Path.Combine(ScriptEnginesPath,
257// FilePrefix + "_compiled_" + asset + ".dll");
258
259 if (File.Exists(OutFile))
260 {
261 m_scriptEngine.Log.DebugFormat("[XEngine] Returning existing assembly for {0}", asset);
262 return OutFile;
263 }
264
265 if (!Directory.Exists(ScriptEnginesPath))
266 {
267 try
268 {
269 Directory.CreateDirectory(ScriptEnginesPath);
270 }
271 catch (Exception ex)
272 {
273 }
274 }
275
276 if (!Directory.Exists(Path.Combine(ScriptEnginesPath,
277 m_scriptEngine.World.RegionInfo.RegionID.ToString())))
278 {
279 try
280 {
281 Directory.CreateDirectory(ScriptEnginesPath);
282 }
283 catch (Exception ex)
284 {
285 }
286 }
287
288 enumCompileType l = DefaultCompileLanguage;
289
290 if (Script.StartsWith("//c#", true, CultureInfo.InvariantCulture))
291 l = enumCompileType.cs;
292 if (Script.StartsWith("//vb", true, CultureInfo.InvariantCulture))
293 {
294 l = enumCompileType.vb;
295 // We need to remove //vb, it won't compile with that
296
297 Script = Script.Substring(4, Script.Length - 4);
298 }
299 if (Script.StartsWith("//lsl", true, CultureInfo.InvariantCulture))
300 l = enumCompileType.lsl;
301
302 if (Script.StartsWith("//js", true, CultureInfo.InvariantCulture))
303 l = enumCompileType.js;
304
305 if (!AllowedCompilers.ContainsKey(l.ToString()))
306 {
307 // Not allowed to compile to this language!
308 string errtext = String.Empty;
309 errtext += "The compiler for language \"" + l.ToString() + "\" is not in list of allowed compilers. Script will not be executed!";
310 throw new Exception(errtext);
311 }
312
313 string compileScript = Script;
314
315 if (l == enumCompileType.lsl)
316 {
317 // Its LSL, convert it to C#
318 compileScript = LSL_Converter.Convert(Script);
319 l = enumCompileType.cs;
320 }
321
322 // Insert additional assemblies here
323
324 //ADAM: Disabled for the moment until it's working right.
325 bool enableCommanderLSL = false;
326
327 if (enableCommanderLSL == true && l == enumCompileType.cs)
328 {
329 foreach (KeyValuePair<string,
330 ICommander> com
331 in m_scriptEngine.World.GetCommanders())
332 {
333 compileScript = com.Value.GenerateRuntimeAPI() + compileScript;
334 }
335 }
336
337 // End of insert
338
339 switch (l)
340 {
341 case enumCompileType.cs:
342 compileScript = CreateCSCompilerScript(compileScript);
343 break;
344 case enumCompileType.vb:
345 compileScript = CreateVBCompilerScript(compileScript);
346 break;
347 case enumCompileType.js:
348 compileScript = CreateJSCompilerScript(compileScript);
349 break;
350 }
351
352// m_log.Debug("[ScriptEngine.DotNetEngine]: Preparing to compile the following LSL to C# translated code");
353// m_log.Debug("");
354// m_log.Debug(compileScript);
355
356 return CompileFromDotNetText(compileScript, l, asset);
357 }
358
359 private static string CreateJSCompilerScript(string compileScript)
360 {
361 compileScript = String.Empty +
362 "import OpenSim.Region.ScriptEngine.XEngine.Script; import System.Collections.Generic;\r\n" +
363 "package SecondLife {\r\n" +
364 "class Script extends OpenSim.Region.ScriptEngine.XEngine.Script.BuiltIn_Commands_BaseClass { \r\n" +
365 compileScript +
366 "} }\r\n";
367 return compileScript;
368 }
369
370 private static string CreateCSCompilerScript(string compileScript)
371 {
372 compileScript = String.Empty +
373 "using OpenSim.Region.ScriptEngine.XEngine.Script; using System.Collections.Generic;\r\n" +
374 String.Empty + "namespace SecondLife { " +
375 String.Empty + "public class Script : OpenSim.Region.ScriptEngine.XEngine.Script.BuiltIn_Commands_BaseClass { \r\n" +
376 @"public Script() { } " +
377 compileScript +
378 "} }\r\n";
379 return compileScript;
380 }
381
382 private static string CreateVBCompilerScript(string compileScript)
383 {
384 compileScript = String.Empty +
385 "Imports OpenSim.Region.ScriptEngine.XEngine.Script: Imports System.Collections.Generic: " +
386 String.Empty + "NameSpace SecondLife:" +
387 String.Empty + "Public Class Script: Inherits OpenSim.Region.ScriptEngine.XEngine.Script.BuiltIn_Commands_BaseClass: " +
388 "\r\nPublic Sub New()\r\nEnd Sub: " +
389 compileScript +
390 ":End Class :End Namespace\r\n";
391 return compileScript;
392 }
393
394 /// <summary>
395 /// Compile .NET script to .Net assembly (.dll)
396 /// </summary>
397 /// <param name="Script">CS script</param>
398 /// <returns>Filename to .dll assembly</returns>
399 internal string CompileFromDotNetText(string Script, enumCompileType lang, string asset)
400 {
401 string ext = "." + lang.ToString();
402
403 // Output assembly name
404 scriptCompileCounter++;
405 string OutFile = Path.Combine(ScriptEnginesPath, Path.Combine(
406 m_scriptEngine.World.RegionInfo.RegionID.ToString(),
407 FilePrefix + "_compiled_" + asset + ".dll"));
408#if DEBUG
409// m_scriptEngine.Log.Debug("[" + m_scriptEngine.ScriptEngineName + "]: Starting compile of \"" + OutFile + "\".");
410#endif
411 try
412 {
413 File.Delete(OutFile);
414 }
415 catch (Exception e) // NOTLEGIT - Should be just catching FileIOException
416 {
417 //m_scriptEngine.Log.Error("[" + m_scriptEngine.ScriptEngineName + "]: Unable to delete old existring script-file before writing new. Compile aborted: " + e.ToString());
418 throw new Exception("Unable to delete old existring script-file before writing new. Compile aborted: " + e.ToString());
419 }
420 //string OutFile = Path.Combine("ScriptEngines", "SecondLife.Script.dll");
421
422 // DEBUG - write source to disk
423 if (WriteScriptSourceToDebugFile)
424 {
425 string srcFileName = FilePrefix + "_source_" + Path.GetFileNameWithoutExtension(OutFile) + ext;
426 try
427 {
428 File.WriteAllText(Path.Combine(Path.Combine(
429 ScriptEnginesPath,
430 m_scriptEngine.World.RegionInfo.RegionID.ToString()),
431 srcFileName), Script);
432 }
433 catch (Exception ex) // NOTLEGIT - Should be just catching FileIOException
434 {
435 m_scriptEngine.Log.Error("[" + m_scriptEngine.ScriptEngineName + "]: Exception while trying to write script source to file \"" + srcFileName + "\": " + ex.ToString());
436 }
437 }
438
439 // Do actual compile
440 CompilerParameters parameters = new CompilerParameters();
441
442 parameters.IncludeDebugInformation = true;
443
444 // Add all available assemblies
445// foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
446// {
447// Console.WriteLine("Adding assembly: " + asm.Location);
448// parameters.ReferencedAssemblies.Add(asm.Location);
449// }
450
451 string rootPath = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
452 string rootPathSE = Path.GetDirectoryName(GetType().Assembly.Location);
453 //Console.WriteLine("Assembly location: " + rootPath);
454 parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.XEngine.Script.dll"));
455// parameters.ReferencedAssemblies.Add(Path.Combine(rootPathSE, "OpenSim.Region.ScriptEngine.XEngine.dll"));
456
457 //parameters.ReferencedAssemblies.Add("OpenSim.Region.Environment");
458 parameters.GenerateExecutable = false;
459 parameters.OutputAssembly = OutFile;
460 parameters.IncludeDebugInformation = CompileWithDebugInformation;
461 //parameters.WarningLevel = 1; // Should be 4?
462 parameters.TreatWarningsAsErrors = false;
463
464//Console.WriteLine(Script);
465 CompilerResults results;
466 switch (lang)
467 {
468 case enumCompileType.vb:
469 results = VBcodeProvider.CompileAssemblyFromSource(parameters, Script);
470 break;
471 case enumCompileType.cs:
472 results = CScodeProvider.CompileAssemblyFromSource(parameters, Script);
473 break;
474 case enumCompileType.js:
475 results = JScodeProvider.CompileAssemblyFromSource(parameters, Script);
476 break;
477 default:
478 throw new Exception("Compiler is not able to recongnize language type \"" + lang.ToString() + "\"");
479 }
480
481 // Check result
482 // Go through errors
483
484 //
485 // WARNINGS AND ERRORS
486 //
487 if (results.Errors.Count > 0)
488 {
489 string errtext = String.Empty;
490 foreach (CompilerError CompErr in results.Errors)
491 {
492 errtext += "Line number " + (CompErr.Line - LinesToRemoveOnError) +
493 ", Error Number: " + CompErr.ErrorNumber +
494 ", '" + CompErr.ErrorText + "'\r\n";
495 }
496 if (!File.Exists(OutFile))
497 {
498 throw new Exception(errtext);
499 }
500 }
501
502 //
503 // NO ERRORS, BUT NO COMPILED FILE
504 //
505 if (!File.Exists(OutFile))
506 {
507 string errtext = String.Empty;
508 errtext += "No compile error. But not able to locate compiled file.";
509 throw new Exception(errtext);
510 }
511 m_scriptEngine.Log.DebugFormat("[XEngine] Compiled new assembly for {0}", asset);
512 return OutFile;
513 }
514 }
515}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
index c226a7e..8bfef79 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
@@ -33,7 +33,8 @@ using OpenSim.Framework;
33using OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney; 33using OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney;
34using OpenSim.Region.Environment.Scenes; 34using OpenSim.Region.Environment.Scenes;
35using OpenSim.Region.Environment.Interfaces; 35using OpenSim.Region.Environment.Interfaces;
36using OpenSim.Region.ScriptEngine.XEngine.Script; 36using OpenSim.Region.ScriptEngine.Shared;
37using OpenSim.Region.ScriptEngine.Interfaces;
37using Axiom.Math; 38using Axiom.Math;
38 39
39namespace OpenSim.Region.ScriptEngine.XEngine 40namespace OpenSim.Region.ScriptEngine.XEngine
@@ -83,8 +84,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
83 IClientAPI remoteClient) 84 IClientAPI remoteClient)
84 { 85 {
85 // Add to queue for all scripts in ObjectID object 86 // Add to queue for all scripts in ObjectID object
86 XDetectParams[] det = new XDetectParams[1]; 87 DetectParams[] det = new DetectParams[1];
87 det[0] = new XDetectParams(); 88 det[0] = new DetectParams();
88 det[0].Key = remoteClient.AgentId; 89 det[0].Key = remoteClient.AgentId;
89 det[0].Populate(myScriptEngine.World); 90 det[0].Populate(myScriptEngine.World);
90 91
@@ -97,7 +98,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
97 if (part.ParentGroup.Children.Count > 0) 98 if (part.ParentGroup.Children.Count > 0)
98 det[0].LinkNum = part.LinkNum + 1; 99 det[0].LinkNum = part.LinkNum + 1;
99 100
100 myScriptEngine.PostObjectEvent(localID, new XEventParams( 101 myScriptEngine.PostObjectEvent(localID, new EventParams(
101 "touch_start", new Object[] { new LSL_Types.LSLInteger(1) }, 102 "touch_start", new Object[] { new LSL_Types.LSLInteger(1) },
102 det)); 103 det));
103 } 104 }
@@ -106,8 +107,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
106 IClientAPI remoteClient) 107 IClientAPI remoteClient)
107 { 108 {
108 // Add to queue for all scripts in ObjectID object 109 // Add to queue for all scripts in ObjectID object
109 XDetectParams[] det = new XDetectParams[1]; 110 DetectParams[] det = new DetectParams[1];
110 det[0] = new XDetectParams(); 111 det[0] = new DetectParams();
111 det[0].Key = remoteClient.AgentId; 112 det[0].Key = remoteClient.AgentId;
112 det[0].Populate(myScriptEngine.World); 113 det[0].Populate(myScriptEngine.World);
113 det[0].OffsetPos = new LSL_Types.Vector3(offsetPos.X, 114 det[0].OffsetPos = new LSL_Types.Vector3(offsetPos.X,
@@ -123,7 +124,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
123 if (part.ParentGroup.Children.Count > 0) 124 if (part.ParentGroup.Children.Count > 0)
124 det[0].LinkNum = part.LinkNum + 1; 125 det[0].LinkNum = part.LinkNum + 1;
125 126
126 myScriptEngine.PostObjectEvent(localID, new XEventParams( 127 myScriptEngine.PostObjectEvent(localID, new EventParams(
127 "touch", new Object[] { new LSL_Types.LSLInteger(1) }, 128 "touch", new Object[] { new LSL_Types.LSLInteger(1) },
128 det)); 129 det));
129 } 130 }
@@ -131,8 +132,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
131 public void touch_end(uint localID, IClientAPI remoteClient) 132 public void touch_end(uint localID, IClientAPI remoteClient)
132 { 133 {
133 // Add to queue for all scripts in ObjectID object 134 // Add to queue for all scripts in ObjectID object
134 XDetectParams[] det = new XDetectParams[1]; 135 DetectParams[] det = new DetectParams[1];
135 det[0] = new XDetectParams(); 136 det[0] = new DetectParams();
136 det[0].Key = remoteClient.AgentId; 137 det[0].Key = remoteClient.AgentId;
137 det[0].Populate(myScriptEngine.World); 138 det[0].Populate(myScriptEngine.World);
138 139
@@ -145,7 +146,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
145 if (part.ParentGroup.Children.Count > 0) 146 if (part.ParentGroup.Children.Count > 0)
146 det[0].LinkNum = part.LinkNum + 1; 147 det[0].LinkNum = part.LinkNum + 1;
147 148
148 myScriptEngine.PostObjectEvent(localID, new XEventParams( 149 myScriptEngine.PostObjectEvent(localID, new EventParams(
149 "touch_end", new Object[] { new LSL_Types.LSLInteger(1) }, 150 "touch_end", new Object[] { new LSL_Types.LSLInteger(1) },
150 det)); 151 det));
151 } 152 }
@@ -153,9 +154,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
153 public void changed(uint localID, uint change) 154 public void changed(uint localID, uint change)
154 { 155 {
155 // Add to queue for all scripts in localID, Object pass change. 156 // Add to queue for all scripts in localID, Object pass change.
156 myScriptEngine.PostObjectEvent(localID, new XEventParams( 157 myScriptEngine.PostObjectEvent(localID, new EventParams(
157 "changed",new object[] { new LSL_Types.LSLInteger(change) }, 158 "changed",new object[] { new LSL_Types.LSLInteger(change) },
158 new XDetectParams[0])); 159 new DetectParams[0]));
159 } 160 }
160 161
161 // state_entry: not processed here 162 // state_entry: not processed here
@@ -163,27 +164,27 @@ namespace OpenSim.Region.ScriptEngine.XEngine
163 164
164 public void money(uint localID, LLUUID agentID, int amount) 165 public void money(uint localID, LLUUID agentID, int amount)
165 { 166 {
166 myScriptEngine.PostObjectEvent(localID, new XEventParams( 167 myScriptEngine.PostObjectEvent(localID, new EventParams(
167 "money", new object[] { 168 "money", new object[] {
168 new LSL_Types.LSLString(agentID.ToString()), 169 new LSL_Types.LSLString(agentID.ToString()),
169 new LSL_Types.LSLInteger(amount) }, 170 new LSL_Types.LSLInteger(amount) },
170 new XDetectParams[0])); 171 new DetectParams[0]));
171 } 172 }
172 173
173 public void collision_start(uint localID, ColliderArgs col) 174 public void collision_start(uint localID, ColliderArgs col)
174 { 175 {
175 // Add to queue for all scripts in ObjectID object 176 // Add to queue for all scripts in ObjectID object
176 List<XDetectParams> det = new List<XDetectParams>(); 177 List<DetectParams> det = new List<DetectParams>();
177 178
178 foreach (DetectedObject detobj in col.Colliders) 179 foreach (DetectedObject detobj in col.Colliders)
179 { 180 {
180 XDetectParams d = new XDetectParams(); 181 DetectParams d = new DetectParams();
181 d.Key =detobj.keyUUID; 182 d.Key =detobj.keyUUID;
182 d.Populate(myScriptEngine.World); 183 d.Populate(myScriptEngine.World);
183 det.Add(d); 184 det.Add(d);
184 } 185 }
185 186
186 myScriptEngine.PostObjectEvent(localID, new XEventParams( 187 myScriptEngine.PostObjectEvent(localID, new EventParams(
187 "collision_start", 188 "collision_start",
188 new Object[] { new LSL_Types.LSLInteger(1) }, 189 new Object[] { new LSL_Types.LSLInteger(1) },
189 det.ToArray())); 190 det.ToArray()));
@@ -192,17 +193,17 @@ namespace OpenSim.Region.ScriptEngine.XEngine
192 public void collision(uint localID, ColliderArgs col) 193 public void collision(uint localID, ColliderArgs col)
193 { 194 {
194 // Add to queue for all scripts in ObjectID object 195 // Add to queue for all scripts in ObjectID object
195 List<XDetectParams> det = new List<XDetectParams>(); 196 List<DetectParams> det = new List<DetectParams>();
196 197
197 foreach (DetectedObject detobj in col.Colliders) 198 foreach (DetectedObject detobj in col.Colliders)
198 { 199 {
199 XDetectParams d = new XDetectParams(); 200 DetectParams d = new DetectParams();
200 d.Key =detobj.keyUUID; 201 d.Key =detobj.keyUUID;
201 d.Populate(myScriptEngine.World); 202 d.Populate(myScriptEngine.World);
202 det.Add(d); 203 det.Add(d);
203 } 204 }
204 205
205 myScriptEngine.PostObjectEvent(localID, new XEventParams( 206 myScriptEngine.PostObjectEvent(localID, new EventParams(
206 "collision", new Object[] { new LSL_Types.LSLInteger(1) }, 207 "collision", new Object[] { new LSL_Types.LSLInteger(1) },
207 det.ToArray())); 208 det.ToArray()));
208 } 209 }
@@ -210,17 +211,17 @@ namespace OpenSim.Region.ScriptEngine.XEngine
210 public void collision_end(uint localID, ColliderArgs col) 211 public void collision_end(uint localID, ColliderArgs col)
211 { 212 {
212 // Add to queue for all scripts in ObjectID object 213 // Add to queue for all scripts in ObjectID object
213 List<XDetectParams> det = new List<XDetectParams>(); 214 List<DetectParams> det = new List<DetectParams>();
214 215
215 foreach (DetectedObject detobj in col.Colliders) 216 foreach (DetectedObject detobj in col.Colliders)
216 { 217 {
217 XDetectParams d = new XDetectParams(); 218 DetectParams d = new DetectParams();
218 d.Key =detobj.keyUUID; 219 d.Key =detobj.keyUUID;
219 d.Populate(myScriptEngine.World); 220 d.Populate(myScriptEngine.World);
220 det.Add(d); 221 det.Add(d);
221 } 222 }
222 223
223 myScriptEngine.PostObjectEvent(localID, new XEventParams( 224 myScriptEngine.PostObjectEvent(localID, new EventParams(
224 "collision_end", 225 "collision_end",
225 new Object[] { new LSL_Types.LSLInteger(1) }, 226 new Object[] { new LSL_Types.LSLInteger(1) },
226 det.ToArray())); 227 det.ToArray()));
@@ -228,26 +229,26 @@ namespace OpenSim.Region.ScriptEngine.XEngine
228 229
229 public void land_collision_start(uint localID, LLUUID itemID) 230 public void land_collision_start(uint localID, LLUUID itemID)
230 { 231 {
231 myScriptEngine.PostObjectEvent(localID, new XEventParams( 232 myScriptEngine.PostObjectEvent(localID, new EventParams(
232 "land_collision_start", 233 "land_collision_start",
233 new object[0], 234 new object[0],
234 new XDetectParams[0])); 235 new DetectParams[0]));
235 } 236 }
236 237
237 public void land_collision(uint localID, LLUUID itemID) 238 public void land_collision(uint localID, LLUUID itemID)
238 { 239 {
239 myScriptEngine.PostObjectEvent(localID, new XEventParams( 240 myScriptEngine.PostObjectEvent(localID, new EventParams(
240 "land_collision", 241 "land_collision",
241 new object[0], 242 new object[0],
242 new XDetectParams[0])); 243 new DetectParams[0]));
243 } 244 }
244 245
245 public void land_collision_end(uint localID, LLUUID itemID) 246 public void land_collision_end(uint localID, LLUUID itemID)
246 { 247 {
247 myScriptEngine.PostObjectEvent(localID, new XEventParams( 248 myScriptEngine.PostObjectEvent(localID, new EventParams(
248 "land_collision_end", 249 "land_collision_end",
249 new object[0], 250 new object[0],
250 new XDetectParams[0])); 251 new DetectParams[0]));
251 } 252 }
252 253
253 // timer: not handled here 254 // timer: not handled here
@@ -255,75 +256,75 @@ namespace OpenSim.Region.ScriptEngine.XEngine
255 256
256 public void on_rez(uint localID, LLUUID itemID, int startParam) 257 public void on_rez(uint localID, LLUUID itemID, int startParam)
257 { 258 {
258 myScriptEngine.PostObjectEvent(localID, new XEventParams( 259 myScriptEngine.PostObjectEvent(localID, new EventParams(
259 "on_rez",new object[] { 260 "on_rez",new object[] {
260 new LSL_Types.LSLInteger(startParam)}, 261 new LSL_Types.LSLInteger(startParam)},
261 new XDetectParams[0])); 262 new DetectParams[0]));
262 } 263 }
263 264
264 public void control(uint localID, LLUUID itemID, LLUUID agentID, uint held, uint change) 265 public void control(uint localID, LLUUID itemID, LLUUID agentID, uint held, uint change)
265 { 266 {
266 myScriptEngine.PostObjectEvent(localID, new XEventParams( 267 myScriptEngine.PostObjectEvent(localID, new EventParams(
267 "control",new object[] { 268 "control",new object[] {
268 new LSL_Types.LSLString(agentID.ToString()), 269 new LSL_Types.LSLString(agentID.ToString()),
269 new LSL_Types.LSLInteger(held), 270 new LSL_Types.LSLInteger(held),
270 new LSL_Types.LSLInteger(change)}, 271 new LSL_Types.LSLInteger(change)},
271 new XDetectParams[0])); 272 new DetectParams[0]));
272 } 273 }
273 274
274 public void email(uint localID, LLUUID itemID, string timeSent, 275 public void email(uint localID, LLUUID itemID, string timeSent,
275 string address, string subject, string message, int numLeft) 276 string address, string subject, string message, int numLeft)
276 { 277 {
277 myScriptEngine.PostObjectEvent(localID, new XEventParams( 278 myScriptEngine.PostObjectEvent(localID, new EventParams(
278 "email",new object[] { 279 "email",new object[] {
279 new LSL_Types.LSLString(timeSent), 280 new LSL_Types.LSLString(timeSent),
280 new LSL_Types.LSLString(address), 281 new LSL_Types.LSLString(address),
281 new LSL_Types.LSLString(subject), 282 new LSL_Types.LSLString(subject),
282 new LSL_Types.LSLString(message), 283 new LSL_Types.LSLString(message),
283 new LSL_Types.LSLInteger(numLeft)}, 284 new LSL_Types.LSLInteger(numLeft)},
284 new XDetectParams[0])); 285 new DetectParams[0]));
285 } 286 }
286 287
287 public void at_target(uint localID, uint handle, LLVector3 targetpos, 288 public void at_target(uint localID, uint handle, LLVector3 targetpos,
288 LLVector3 atpos) 289 LLVector3 atpos)
289 { 290 {
290 myScriptEngine.PostObjectEvent(localID, new XEventParams( 291 myScriptEngine.PostObjectEvent(localID, new EventParams(
291 "at_target", new object[] { 292 "at_target", new object[] {
292 new LSL_Types.LSLInteger(handle), 293 new LSL_Types.LSLInteger(handle),
293 new LSL_Types.Vector3(targetpos.X,targetpos.Y,targetpos.Z), 294 new LSL_Types.Vector3(targetpos.X,targetpos.Y,targetpos.Z),
294 new LSL_Types.Vector3(atpos.X,atpos.Y,atpos.Z) }, 295 new LSL_Types.Vector3(atpos.X,atpos.Y,atpos.Z) },
295 new XDetectParams[0])); 296 new DetectParams[0]));
296 } 297 }
297 298
298 public void not_at_target(uint localID) 299 public void not_at_target(uint localID)
299 { 300 {
300 myScriptEngine.PostObjectEvent(localID, new XEventParams( 301 myScriptEngine.PostObjectEvent(localID, new EventParams(
301 "not_at_target",new object[0], 302 "not_at_target",new object[0],
302 new XDetectParams[0])); 303 new DetectParams[0]));
303 } 304 }
304 305
305 public void at_rot_target(uint localID, LLUUID itemID) 306 public void at_rot_target(uint localID, LLUUID itemID)
306 { 307 {
307 myScriptEngine.PostObjectEvent(localID, new XEventParams( 308 myScriptEngine.PostObjectEvent(localID, new EventParams(
308 "at_rot_target",new object[0], 309 "at_rot_target",new object[0],
309 new XDetectParams[0])); 310 new DetectParams[0]));
310 } 311 }
311 312
312 public void not_at_rot_target(uint localID, LLUUID itemID) 313 public void not_at_rot_target(uint localID, LLUUID itemID)
313 { 314 {
314 myScriptEngine.PostObjectEvent(localID, new XEventParams( 315 myScriptEngine.PostObjectEvent(localID, new EventParams(
315 "not_at_rot_target",new object[0], 316 "not_at_rot_target",new object[0],
316 new XDetectParams[0])); 317 new DetectParams[0]));
317 } 318 }
318 319
319 // run_time_permissions: not handled here 320 // run_time_permissions: not handled here
320 321
321 public void attach(uint localID, LLUUID itemID, LLUUID avatar) 322 public void attach(uint localID, LLUUID itemID, LLUUID avatar)
322 { 323 {
323 myScriptEngine.PostObjectEvent(localID, new XEventParams( 324 myScriptEngine.PostObjectEvent(localID, new EventParams(
324 "attach",new object[] { 325 "attach",new object[] {
325 new LSL_Types.LSLString(avatar.ToString()) }, 326 new LSL_Types.LSLString(avatar.ToString()) },
326 new XDetectParams[0])); 327 new DetectParams[0]));
327 } 328 }
328 329
329 // dataserver: not handled here 330 // dataserver: not handled here
@@ -331,16 +332,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine
331 332
332 public void moving_start(uint localID, LLUUID itemID) 333 public void moving_start(uint localID, LLUUID itemID)
333 { 334 {
334 myScriptEngine.PostObjectEvent(localID, new XEventParams( 335 myScriptEngine.PostObjectEvent(localID, new EventParams(
335 "moving_start",new object[0], 336 "moving_start",new object[0],
336 new XDetectParams[0])); 337 new DetectParams[0]));
337 } 338 }
338 339
339 public void moving_end(uint localID, LLUUID itemID) 340 public void moving_end(uint localID, LLUUID itemID)
340 { 341 {
341 myScriptEngine.PostObjectEvent(localID, new XEventParams( 342 myScriptEngine.PostObjectEvent(localID, new EventParams(
342 "moving_end",new object[0], 343 "moving_end",new object[0],
343 new XDetectParams[0])); 344 new DetectParams[0]));
344 } 345 }
345 346
346 // object_rez: not handled here 347 // object_rez: not handled here
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Executor.cs b/OpenSim/Region/ScriptEngine/XEngine/Executor.cs
index 29336ac..e12f2bf 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/Executor.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/Executor.cs
@@ -28,7 +28,8 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using OpenSim.Region.ScriptEngine.XEngine.Script; 31using OpenSim.Region.ScriptEngine.Shared;
32using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
32 33
33namespace OpenSim.Region.ScriptEngine.XEngine 34namespace OpenSim.Region.ScriptEngine.XEngine
34{ 35{
@@ -44,15 +45,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
44 } 45 }
45 46
46 47
47 protected override scriptEvents DoGetStateEventFlags() 48 protected override scriptEvents DoGetStateEventFlags(string state)
48 { 49 {
49 //Console.WriteLine("Get event flags for " + m_Script.State); 50 //Console.WriteLine("Get event flags for " + state);
50 51
51 // Check to see if we've already computed the flags for this state 52 // Check to see if we've already computed the flags for this state
52 scriptEvents eventFlags = scriptEvents.None; 53 scriptEvents eventFlags = scriptEvents.None;
53 if (m_stateEvents.ContainsKey(m_Script.State)) 54 if (m_stateEvents.ContainsKey(state))
54 { 55 {
55 m_stateEvents.TryGetValue(m_Script.State, out eventFlags); 56 m_stateEvents.TryGetValue(state, out eventFlags);
56 return eventFlags; 57 return eventFlags;
57 } 58 }
58 59
@@ -61,7 +62,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
61 // Fill in the events for this state, cache the results in the map 62 // Fill in the events for this state, cache the results in the map
62 foreach (KeyValuePair<string, scriptEvents> kvp in m_eventFlagsMap) 63 foreach (KeyValuePair<string, scriptEvents> kvp in m_eventFlagsMap)
63 { 64 {
64 string evname = m_Script.State + "_event_" + kvp.Key; 65 string evname = state + "_event_" + kvp.Key;
65 //Console.WriteLine("Trying event "+evname); 66 //Console.WriteLine("Trying event "+evname);
66 try 67 try
67 { 68 {
@@ -80,18 +81,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine
80 81
81 // Save the flags we just computed and return the result 82 // Save the flags we just computed and return the result
82 if (eventFlags != 0) 83 if (eventFlags != 0)
83 m_stateEvents.Add(m_Script.State, eventFlags); 84 m_stateEvents.Add(state, eventFlags);
84 85
85 //Console.WriteLine("Returning {0:x}", eventFlags); 86 //Console.WriteLine("Returning {0:x}", eventFlags);
86 return (eventFlags); 87 return (eventFlags);
87 } 88 }
88 89
89 protected override void DoExecuteEvent(string FunctionName, object[] args) 90 protected override void DoExecuteEvent(string state, string FunctionName, object[] args)
90 { 91 {
91 // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. 92 // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory.
92 // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead! 93 // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead!
93 94
94 string EventName = m_Script.State + "_event_" + FunctionName; 95 string EventName = state + "_event_" + FunctionName;
95 96
96//#if DEBUG 97//#if DEBUG
97// Console.WriteLine("ScriptEngine: Script event function name: " + EventName); 98// Console.WriteLine("ScriptEngine: Script event function name: " + EventName);
diff --git a/OpenSim/Region/ScriptEngine/XEngine/ExecutorBase.cs b/OpenSim/Region/ScriptEngine/XEngine/ExecutorBase.cs
index 3775372..799005c 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/ExecutorBase.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/ExecutorBase.cs
@@ -28,7 +28,9 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Runtime.Remoting.Lifetime; 30using System.Runtime.Remoting.Lifetime;
31using OpenSim.Region.ScriptEngine.XEngine.Script; 31using OpenSim.Region.ScriptEngine.Shared;
32using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
33using OpenSim.Region.ScriptEngine.Interfaces;
32 34
33namespace OpenSim.Region.ScriptEngine.XEngine 35namespace OpenSim.Region.ScriptEngine.XEngine
34{ 36{
@@ -117,23 +119,23 @@ namespace OpenSim.Region.ScriptEngine.XEngine
117 /// </summary> 119 /// </summary>
118 /// <param name="FunctionName">Name of function to execute</param> 120 /// <param name="FunctionName">Name of function to execute</param>
119 /// <param name="args">Arguments to pass to function</param> 121 /// <param name="args">Arguments to pass to function</param>
120 public void ExecuteEvent(string FunctionName, object[] args) 122 public void ExecuteEvent(string state, string FunctionName, object[] args)
121 { 123 {
122 DoExecuteEvent(FunctionName, args); 124 DoExecuteEvent(state, FunctionName, args);
123 } 125 }
124 126
125 protected abstract void DoExecuteEvent(string FunctionName, object[] args); 127 protected abstract void DoExecuteEvent(string state, string FunctionName, object[] args);
126 128
127 /// <summary> 129 /// <summary>
128 /// Compute the events handled by the current state of the script 130 /// Compute the events handled by the current state of the script
129 /// </summary> 131 /// </summary>
130 /// <returns>state mask</returns> 132 /// <returns>state mask</returns>
131 public scriptEvents GetStateEventFlags() 133 public scriptEvents GetStateEventFlags(string state)
132 { 134 {
133 return DoGetStateEventFlags(); 135 return DoGetStateEventFlags(state);
134 } 136 }
135 137
136 protected abstract scriptEvents DoGetStateEventFlags(); 138 protected abstract scriptEvents DoGetStateEventFlags(string state);
137 139
138 protected void initEventFlags() 140 protected void initEventFlags()
139 { 141 {
diff --git a/OpenSim/Region/ScriptEngine/XEngine/LSL2CSConverter.cs b/OpenSim/Region/ScriptEngine/XEngine/LSL2CSConverter.cs
deleted file mode 100644
index 2dc8547..0000000
--- a/OpenSim/Region/ScriptEngine/XEngine/LSL2CSConverter.cs
+++ /dev/null
@@ -1,374 +0,0 @@
1/*
2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28
29using System;
30using System.Collections.Generic;
31using System.Text.RegularExpressions;
32
33namespace OpenSim.Region.ScriptEngine.XEngine
34{
35 public class LSL2CSConverter
36 {
37 // Uses regex to convert LSL code to C# code.
38
39 //private Regex rnw = new Regex(@"[a-zA-Z0-9_\-]", RegexOptions.Compiled);
40 private Dictionary<string, string> dataTypes = new Dictionary<string, string>();
41 private Dictionary<string, string> quotes = new Dictionary<string, string>();
42 // c Style
43 private Regex cstylecomments = new Regex(@"/\*(.|[\r\n])*?\*/", RegexOptions.Compiled | RegexOptions.Multiline);
44 // c# one liners
45 private Regex nonCommentFwsl = new Regex("\"[a-zA-Z0-9.,:/\\n ]+//[^\"+]+([\\\\\\\"+]+)?(\\s+)?[\"+](\\s+)?(;)?", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
46 private Regex conelinecomments = new Regex(@"[^:].?([\/]{2}[^\n]*)|([\n]{1,}[\/]{2}[^\n]*)", RegexOptions.Compiled | RegexOptions.Multiline);
47 // ([^\"])((?:[a-zA-Z])\.[a-zA-Z].?)([^\"])
48
49 // value we're looking for: (?:[a-zA-Z])\.[a-zA-Z]
50 public LSL2CSConverter()
51 {
52 // Only the types we need to convert
53 dataTypes.Add("void", "void");
54 dataTypes.Add("integer", "LSL_Types.LSLInteger");
55 dataTypes.Add("float", "LSL_Types.LSLFloat");
56 dataTypes.Add("string", "LSL_Types.LSLString");
57 dataTypes.Add("key", "LSL_Types.LSLString");
58 dataTypes.Add("vector", "LSL_Types.Vector3");
59 dataTypes.Add("rotation", "LSL_Types.Quaternion");
60 dataTypes.Add("list", "LSL_Types.list");
61 dataTypes.Add("null", "null");
62 }
63
64 public string Convert(string Script)
65 {
66 quotes.Clear();
67 string Return = String.Empty;
68 Script = " \r\n" + Script;
69
70 //
71 // Prepare script for processing
72 //
73
74 // Clean up linebreaks
75 Script = Regex.Replace(Script, @"\r\n", "\n");
76 Script = Regex.Replace(Script, @"\n", "\r\n");
77
78 // QUOTE REPLACEMENT
79 // temporarily replace quotes so we can work our magic on the script without
80 // always considering if we are inside our outside quotes's
81 // TODO: Does this work on half-quotes in strings? ;)
82 string _Script = String.Empty;
83 string C;
84 bool in_quote = false;
85 bool quote_replaced = false;
86 string quote_replacement_string = "Q_U_O_T_E_REPLACEMENT_";
87 string quote = String.Empty;
88 bool last_was_escape = false;
89 int quote_replaced_count = 0;
90
91 string removefwnoncomments = nonCommentFwsl.Replace(Script, "\"\";");
92
93 string removecomments = conelinecomments.Replace(removefwnoncomments, "");
94 removecomments = cstylecomments.Replace(removecomments, "");
95 string[] localscript = removecomments.Split('"');
96 string checkscript = String.Empty;
97 bool flip = true;
98
99 for (int p = 0; p < localscript.Length; p++)
100 {
101 //if (localscript[p].Length >= 1)
102 //{
103 if (!localscript[p].EndsWith(@"\"))
104 {
105 flip = !flip;
106 //System.Console.WriteLine("Flip:" + flip.ToString() + " - " + localscript[p] + " ! " + localscript[p].EndsWith(@"\").ToString());
107 }
108 //}
109 //else
110 //{
111 // flip = !flip;
112 // System.Console.WriteLine("Flip:" + flip.ToString() + " - " + localscript[p]);
113 //}
114 if (!flip)
115 checkscript += localscript[p];
116 }
117
118 //System.Console.WriteLine("SCRIPT:" + checkscript);
119
120 // checks for alpha.alpha way of referring to objects in C#
121 // ignores alpha.x alpha.y, alpha.z for refering to vector components
122 Match SecurityM;
123
124 // BROKEN: this check is very wrong. It block's any url in strings.
125 SecurityM = Regex.Match(checkscript, @"(?:[a-zA-Z])\.(?:[a-wA-Z]|[a-zA-Z][a-zA-Z])", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
126
127 if (SecurityM.Success)
128 throw new Exception("CS0103: 'The . symbol cannot be used in LSL except in float values or vector components'. Detected around: " + SecurityM.Captures[0].Value);
129
130 SecurityM = Regex.Match(checkscript, @"typeof\s", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
131 if (SecurityM.Success)
132 throw new Exception("CS0103: 'The object.typeof method isn't allowed in LSL'");
133
134 SecurityM = Regex.Match(checkscript, @"GetType\(", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
135 if (SecurityM.Success)
136 throw new Exception("CS0103: 'The object.GetType method isn't allowed in LSL'");
137
138 for (int p = 0; p < Script.Length; p++)
139 {
140 C = Script.Substring(p, 1);
141 while (true)
142 {
143 // found " and last was not \ so this is not an escaped \"
144 if (C == "\"" && last_was_escape == false)
145 {
146 // Toggle inside/outside quote
147 in_quote = !in_quote;
148 if (in_quote)
149 {
150 quote_replaced_count++;
151 }
152 else
153 {
154 if (quote == String.Empty)
155 {
156 // We didn't replace quote, probably because of empty string?
157 _Script += quote_replacement_string +
158 quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]);
159 }
160 // We just left a quote
161 quotes.Add(
162 quote_replacement_string +
163 quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]), quote);
164 quote = String.Empty;
165 }
166 break;
167 }
168
169 if (!in_quote)
170 {
171 // We are not inside a quote
172 quote_replaced = false;
173 }
174 else
175 {
176 // We are inside a quote
177 if (!quote_replaced)
178 {
179 // Replace quote
180 _Script += quote_replacement_string +
181 quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]);
182 quote_replaced = true;
183 }
184 quote += C;
185 break;
186 }
187 _Script += C;
188 break;
189 }
190 last_was_escape = false;
191 if (C == @"\")
192 {
193 last_was_escape = true;
194 }
195 }
196 Script = _Script;
197 //
198 // END OF QUOTE REPLACEMENT
199 //
200
201 //
202 // PROCESS STATES
203 // Remove state definitions and add state names to start of each event within state
204 //
205 int ilevel = 0;
206 int lastlevel = 0;
207 string ret = String.Empty;
208 string cache = String.Empty;
209 bool in_state = false;
210 string current_statename = String.Empty;
211 for (int p = 0; p < Script.Length; p++)
212 {
213 C = Script.Substring(p, 1);
214 while (true)
215 {
216 // inc / dec level
217 if (C == @"{")
218 ilevel++;
219 if (C == @"}")
220 ilevel--;
221 if (ilevel < 0)
222 ilevel = 0;
223 cache += C;
224
225 // if level == 0, add to return
226 if (ilevel == 1 && lastlevel == 0)
227 {
228 // 0 => 1: Get last
229 Match m =
230 //Regex.Match(cache, @"(?![a-zA-Z_]+)\s*([a-zA-Z_]+)[^a-zA-Z_\(\)]*{",
231 Regex.Match(cache, @"(?![a-zA-Z_]+)\s*(state\s+)?(?<statename>[a-zA-Z_][a-zA-Z_0-9]*)[^a-zA-Z_0-9\(\)]*{",
232
233 RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
234
235 in_state = false;
236 if (m.Success)
237 {
238 // Go back to level 0, this is not a state
239 in_state = true;
240 current_statename = m.Groups["statename"].Captures[0].Value;
241 //Console.WriteLine("Current statename: " + current_statename);
242 cache =
243 //@"(?<s1>(?![a-zA-Z_]+)\s*)" + @"([a-zA-Z_]+)(?<s2>[^a-zA-Z_\(\)]*){",
244 Regex.Replace(cache,
245 @"(?<s1>(?![a-zA-Z_]+)\s*)" + @"(state\s+)?([a-zA-Z_][a-zA-Z_0-9]*)(?<s2>[^a-zA-Z_0-9\(\)]*){",
246 "${s1}${s2}",
247 RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase);
248 }
249 ret += cache;
250 cache = String.Empty;
251 }
252 if (ilevel == 0 && lastlevel == 1)
253 {
254 // 1 => 0: Remove last }
255 if (in_state == true)
256 {
257 cache = cache.Remove(cache.Length - 1, 1);
258 //cache = Regex.Replace(cache, "}$", String.Empty, RegexOptions.Multiline | RegexOptions.Singleline);
259
260 //Replace function names
261 // void dataserver(key query_id, string data) {
262 //cache = Regex.Replace(cache, @"([^a-zA-Z_]\s*)((?!if|switch|for)[a-zA-Z_]+\s*\([^\)]*\)[^{]*{)", "$1" + "<STATE>" + "$2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
263 //Console.WriteLine("Replacing using statename: " + current_statename);
264 cache =
265 Regex.Replace(cache,
266 @"^(\s*)((?!(if|switch|for|while)[^a-zA-Z0-9_])[a-zA-Z0-9_]*\s*\([^\)]*\)[^;]*\{)",
267 @"$1public " + current_statename + "_event_$2",
268 RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase);
269 }
270
271 ret += cache;
272 cache = String.Empty;
273 in_state = true;
274 current_statename = String.Empty;
275 }
276
277 break;
278 }
279 lastlevel = ilevel;
280 }
281 ret += cache;
282 cache = String.Empty;
283
284 Script = ret;
285 ret = String.Empty;
286
287 foreach (string key in dataTypes.Keys)
288 {
289 string val;
290 dataTypes.TryGetValue(key, out val);
291
292 // Replace CAST - (integer) with (int)
293 Script =
294 Regex.Replace(Script, @"\(" + key + @"\)", @"(" + val + ")",
295 RegexOptions.Compiled | RegexOptions.Multiline);
296 // Replace return types and function variables - integer a() and f(integer a, integer a)
297 Script =
298 Regex.Replace(Script, @"(^|;|}|[\(,])(\s*)" + key + @"(\s+)", @"$1$2" + val + "$3",
299 RegexOptions.Compiled | RegexOptions.Multiline);
300 Script =
301 Regex.Replace(Script, @"(^|;|}|[\(,])(\s*)" + key + @"(\s*)[,]", @"$1$2" + val + "$3,",
302 RegexOptions.Compiled | RegexOptions.Multiline);
303 }
304
305 // Change jumps into goto's and prefix its label
306 Script =
307 Regex.Replace(Script,
308 @"(\W)jump\s+([a-zA-Z_][a-zA-Z_0-9]*)\s*;",
309 @"$1goto label_$2;", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
310 // and prefix labels so the do not clash with C#'s reserved words
311 Script =
312 Regex.Replace(Script,
313 @"@([a-zA-Z_][a-zA-Z_0-9]*)\s*;",
314 @"label_$1: ;", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
315
316 // Add "void" in front of functions that needs it
317 Script =
318 Regex.Replace(Script,
319 @"^(\s*public\s+)?((?!(if|switch|for)[^a-zA-Z0-9_])[a-zA-Z0-9_]*\s*\([^\)]*\)[^;]*\{)",
320 @"$1void $2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
321
322 // Replace <x,y,z> and <x,y,z,r>
323 Script =
324 Regex.Replace(Script, @"<([^,>;]*,[^,>;]*,[^,>;]*,[^,>;]*)>", @"new LSL_Types.Quaternion($1)",
325 RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
326 Script =
327 Regex.Replace(Script, @"<([^,>;)]*,[^,>;]*,[^,>;]*)>", @"new LSL_Types.Vector3($1)",
328 RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
329
330 // Replace List []'s
331 Script =
332 Regex.Replace(Script, @"\[([^\]]*)\]", @"new LSL_Types.list($1)",
333 RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
334
335 // Replace (string) to .ToString() //
336 Script =
337 Regex.Replace(Script, @"\(string\)\s*([a-zA-Z0-9_.]+(\s*\([^\)]*\))?)", @"$1.ToString()",
338 RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
339 Script =
340 Regex.Replace(Script, @"\((float|int)\)\s*([a-zA-Z0-9_.]+(\s*\([^\)]*\))?)", @"$1.Parse($2)",
341 RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
342
343 // Replace "state STATENAME" with "state("statename")"
344 Script =
345 Regex.Replace(Script, @"(state)\s+([^;\n\r]+)(;[\r\n\s])", "$1(\"$2\")$3",
346 RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase);
347
348 // REPLACE BACK QUOTES
349 foreach (string key in quotes.Keys)
350 {
351 string val;
352 quotes.TryGetValue(key, out val);
353 Script = Script.Replace(key, "\"" + val + "\"");
354 }
355
356 //System.Console.WriteLine(Script);
357 Return = String.Empty;// +
358 //"using OpenSim.Region.ScriptEngine.Common; using System.Collections.Generic;";
359
360 //Return += String.Empty +
361 // "namespace SecondLife { ";
362 //Return += String.Empty +
363 // //"[Serializable] " +
364 // "public class Script : OpenSim.Region.ScriptEngine.Common.LSL_BaseClass { ";
365 //Return += @"public Script() { } ";
366 Return += Script;
367 //Return += "} }\r\n";
368
369 quotes.Clear();
370
371 return Return;
372 }
373 }
374}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs b/OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs
deleted file mode 100644
index 9c660c1..0000000
--- a/OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs
+++ /dev/null
@@ -1,6593 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Runtime.Remoting.Lifetime;
32using System.Text;
33using System.Threading;
34using Nini.Config;
35using Axiom.Math;
36using libsecondlife;
37using OpenSim;
38using OpenSim.Framework;
39using OpenSim.Region.Environment;
40using OpenSim.Region.Environment.Interfaces;
41using OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney;
42using OpenSim.Region.Environment.Modules.World.Land;
43using OpenSim.Region.Environment.Scenes;
44using OpenSim.Region.ScriptEngine.XEngine;
45using OpenSim.Region.ScriptEngine.XEngine.Script;
46
47
48namespace OpenSim.Region.ScriptEngine.XEngine
49{
50 /// <summary>
51 /// Contains all LSL ll-functions. This class will be in Default AppDomain.
52 /// </summary>
53 public class LSL_ScriptCommands : MarshalByRefObject, ILSL_ScriptCommands
54 {
55 // private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
56
57 internal XEngine m_ScriptEngine;
58 internal XScriptInstance m_Instance;
59 internal SceneObjectPart m_host;
60 internal uint m_localID;
61 internal LLUUID m_itemID;
62 internal bool throwErrorOnNotImplemented = true;
63
64 public LSL_ScriptCommands(XEngine ScriptEngine, XScriptInstance instance, SceneObjectPart host, uint localID, LLUUID itemID)
65 {
66 m_ScriptEngine = ScriptEngine;
67 m_Instance = instance;
68 m_host = host;
69 m_localID = localID;
70 m_itemID = itemID;
71
72 //m_log.Info(ScriptEngineName, "LSL_BaseClass.Start() called. Hosted by [" + m_host.Name + ":" + m_host.UUID + "@" + m_host.AbsolutePosition + "]");
73 }
74
75 private DateTime m_timer = DateTime.Now;
76 private string m_state = "default";
77 private bool m_waitingForScriptAnswer=false;
78
79
80 public string State
81 {
82 get { return m_Instance.State; }
83 set { m_Instance.State = value; }
84 }
85
86 public void state(string newState)
87 {
88 m_Instance.SetState(newState);
89 }
90
91 // Object never expires
92 public override Object InitializeLifetimeService()
93 {
94 //Console.WriteLine("LSL_BuiltIn_Commands: InitializeLifetimeService()");
95 // return null;
96 ILease lease = (ILease)base.InitializeLifetimeService();
97
98 if (lease.CurrentState == LeaseState.Initial)
99 {
100 lease.InitialLeaseTime = TimeSpan.Zero; // TimeSpan.FromMinutes(1);
101 // lease.SponsorshipTimeout = TimeSpan.FromMinutes(2);
102 // lease.RenewOnCallTime = TimeSpan.FromSeconds(2);
103 }
104 return lease;
105 }
106
107 public Scene World
108 {
109 get { return m_ScriptEngine.World; }
110 }
111
112 public void llSay(int channelID, string text)
113 {
114 m_host.AddScriptLPS(1);
115
116 if (text.Length > 1023)
117 text = text.Substring(0, 1023);
118
119 World.SimChat(Helpers.StringToField(text),
120 ChatTypeEnum.Say, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID, false);
121
122 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
123 wComm.DeliverMessage(ChatTypeEnum.Say, channelID, m_host.Name, m_host.UUID, text);
124 }
125
126 // Extension commands use this:
127 public ICommander GetCommander(string name)
128 {
129 return World.GetCommander(name);
130 }
131
132 private LLUUID InventorySelf()
133 {
134 LLUUID invItemID = new LLUUID();
135
136 foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory)
137 {
138 if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID)
139 {
140 invItemID = inv.Key;
141 break;
142 }
143 }
144
145 return invItemID;
146 }
147
148 private LLUUID InventoryKey(string name, int type)
149 {
150 m_host.AddScriptLPS(1);
151 foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory)
152 {
153 if (inv.Value.Name == name)
154 {
155 if (inv.Value.Type != type)
156 return LLUUID.Zero;
157
158 return inv.Value.AssetID.ToString();
159 }
160 }
161 return LLUUID.Zero;
162 }
163
164 private LLUUID InventoryKey(string name)
165 {
166 m_host.AddScriptLPS(1);
167 foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory)
168 {
169 if (inv.Value.Name == name)
170 {
171 return inv.Value.AssetID.ToString();
172 }
173 }
174 return LLUUID.Zero;
175 }
176
177
178 /// <summary>
179 /// accepts a valid LLUUID, -or- a name of an inventory item.
180 /// Returns a valid LLUUID or LLUUID.Zero if key invalid and item not found
181 /// in prim inventory.
182 /// </summary>
183 /// <param name="k"></param>
184 /// <returns></returns>
185 private LLUUID KeyOrName(string k)
186 {
187 LLUUID key = LLUUID.Zero;
188
189 // if we can parse the string as a key, use it.
190 if (LLUUID.TryParse(k, out key))
191 {
192 return key;
193 }
194 // else try to locate the name in inventory of object. found returns key,
195 // not found returns LLUUID.Zero which will translate to the default particle texture
196 else
197 {
198 return InventoryKey(k);
199 }
200 }
201
202 public void osSetRegionWaterHeight(double height)
203 {
204 m_host.AddScriptLPS(1);
205 //Check to make sure that the script's owner is the estate manager/master
206 //World.Permissions.GenericEstatePermission(
207 if (World.ExternalChecks.ExternalChecksCanBeGodLike(m_host.OwnerID))
208 {
209 World.EventManager.TriggerRequestChangeWaterHeight((float)height);
210 }
211 }
212
213 //These are the implementations of the various ll-functions used by the LSL scripts.
214 //starting out, we use the System.Math library for trig functions. - ckrinke 8-14-07
215 public double llSin(double f)
216 {
217 m_host.AddScriptLPS(1);
218 return (double)Math.Sin(f);
219 }
220
221 public double llCos(double f)
222 {
223 m_host.AddScriptLPS(1);
224 return (double)Math.Cos(f);
225 }
226
227 public double llTan(double f)
228 {
229 m_host.AddScriptLPS(1);
230 return (double)Math.Tan(f);
231 }
232
233 public double llAtan2(double x, double y)
234 {
235 m_host.AddScriptLPS(1);
236 return (double)Math.Atan2(y, x);
237 }
238
239 public double llSqrt(double f)
240 {
241 m_host.AddScriptLPS(1);
242 return (double)Math.Sqrt(f);
243 }
244
245 public double llPow(double fbase, double fexponent)
246 {
247 m_host.AddScriptLPS(1);
248 return (double)Math.Pow(fbase, fexponent);
249 }
250
251 public LSL_Types.LSLInteger llAbs(int i)
252 {
253 m_host.AddScriptLPS(1);
254 return (int)Math.Abs(i);
255 }
256
257 public double llFabs(double f)
258 {
259 m_host.AddScriptLPS(1);
260 return (double)Math.Abs(f);
261 }
262
263 public double llFrand(double mag)
264 {
265 m_host.AddScriptLPS(1);
266 lock (Util.RandomClass)
267 {
268 return Util.RandomClass.NextDouble() * mag;
269 }
270 }
271
272 public LSL_Types.LSLInteger llFloor(double f)
273 {
274 m_host.AddScriptLPS(1);
275 return (int)Math.Floor(f);
276 }
277
278 public LSL_Types.LSLInteger llCeil(double f)
279 {
280 m_host.AddScriptLPS(1);
281 return (int)Math.Ceiling(f);
282 }
283
284 // Xantor 01/May/2008 fixed midpointrounding (2.5 becomes 3.0 instead of 2.0, default = ToEven)
285 public LSL_Types.LSLInteger llRound(double f)
286 {
287 m_host.AddScriptLPS(1);
288 return (int)Math.Round(f, MidpointRounding.AwayFromZero);
289 }
290
291 //This next group are vector operations involving squaring and square root. ckrinke
292 public double llVecMag(LSL_Types.Vector3 v)
293 {
294 m_host.AddScriptLPS(1);
295 return LSL_Types.Vector3.Mag(v);
296 }
297
298 public LSL_Types.Vector3 llVecNorm(LSL_Types.Vector3 v)
299 {
300 m_host.AddScriptLPS(1);
301 double mag = LSL_Types.Vector3.Mag(v);
302 LSL_Types.Vector3 nor = new LSL_Types.Vector3();
303 nor.x = v.x / mag;
304 nor.y = v.y / mag;
305 nor.z = v.z / mag;
306 return nor;
307 }
308
309 public double llVecDist(LSL_Types.Vector3 a, LSL_Types.Vector3 b)
310 {
311 m_host.AddScriptLPS(1);
312 double dx = a.x - b.x;
313 double dy = a.y - b.y;
314 double dz = a.z - b.z;
315 return Math.Sqrt(dx * dx + dy * dy + dz * dz);
316 }
317
318 //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke
319
320 // Utility function for llRot2Euler
321
322 // normalize an angle between 0 - 2*PI (0 and 360 degrees)
323 private double NormalizeAngle(double angle)
324 {
325 angle = angle % (Math.PI * 2);
326 if (angle < 0) angle = angle + Math.PI * 2;
327 return angle;
328 }
329
330 // Old implementation of llRot2Euler, now normalized
331
332 public LSL_Types.Vector3 llRot2Euler(LSL_Types.Quaternion r)
333 {
334 m_host.AddScriptLPS(1);
335 //This implementation is from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions. ckrinke
336 LSL_Types.Quaternion t = new LSL_Types.Quaternion(r.x * r.x, r.y * r.y, r.z * r.z, r.s * r.s);
337 double m = (t.x + t.y + t.z + t.s);
338 if (m == 0) return new LSL_Types.Vector3();
339 double n = 2 * (r.y * r.s + r.x * r.z);
340 double p = m * m - n * n;
341 if (p > 0)
342 return new LSL_Types.Vector3(NormalizeAngle(Math.Atan2(2.0 * (r.x * r.s - r.y * r.z), (-t.x - t.y + t.z + t.s))),
343 NormalizeAngle(Math.Atan2(n, Math.Sqrt(p))),
344 NormalizeAngle(Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s))));
345 else if (n > 0)
346 return new LSL_Types.Vector3(0.0, Math.PI / 2, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)));
347 else
348 return new LSL_Types.Vector3(0.0, -Math.PI / 2, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)));
349 }
350
351 // Xantor's newer llEuler2Rot() *try the second* inverted quaternions (-x,-y,-z,w) as LL seems to like
352 // New and improved, now actually works as described. Prim rotates as expected as does llRot2Euler.
353
354 /* From wiki:
355 The Euler angle vector (in radians) is converted to a rotation by doing the rotations around the 3 axes
356 in Z, Y, X order. So llEuler2Rot(<1.0, 2.0, 3.0> * DEG_TO_RAD) generates a rotation by taking the zero rotation,
357 a vector pointing along the X axis, first rotating it 3 degrees around the global Z axis, then rotating the resulting
358 vector 2 degrees around the global Y axis, and finally rotating that 1 degree around the global X axis.
359 */
360
361 public LSL_Types.Quaternion llEuler2Rot(LSL_Types.Vector3 v)
362 {
363 m_host.AddScriptLPS(1);
364
365 double x,y,z,s,s_i;
366
367 double cosX = Math.Cos(v.x);
368 double cosY = Math.Cos(v.y);
369 double cosZ = Math.Cos(v.z);
370 double sinX = Math.Sin(v.x);
371 double sinY = Math.Sin(v.y);
372 double sinZ = Math.Sin(v.z);
373
374 s = Math.Sqrt(cosY * cosZ - sinX * sinY * sinZ + cosX * cosZ + cosX * cosY + 1.0f) * 0.5f;
375 if (Math.Abs(s) < 0.00001) // null rotation
376 {
377 x = 0.0f;
378 y = 1.0f;
379 z = 0.0f;
380 }
381 else
382 {
383 s_i = 1.0f / (4.0f * s);
384 x = - (-sinX * cosY - cosX * sinY * sinZ - sinX * cosZ) * s_i;
385 y = - (-cosX * sinY * cosZ + sinX * sinZ - sinY) * s_i;
386 z = - (-cosY * sinZ - sinX * sinY * cosZ - cosX * sinZ) * s_i;
387 }
388 return new LSL_Types.Quaternion(x, y, z, s);
389 }
390
391 public LSL_Types.Quaternion llAxes2Rot(LSL_Types.Vector3 fwd, LSL_Types.Vector3 left, LSL_Types.Vector3 up)
392 {
393 m_host.AddScriptLPS(1);
394 NotImplemented("llAxes2Rot");
395 return new LSL_Types.Quaternion();
396 }
397
398 public LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r)
399 {
400 m_host.AddScriptLPS(1);
401 return (new LSL_Types.Vector3(1,0,0) * r);
402 }
403
404 public LSL_Types.Vector3 llRot2Left(LSL_Types.Quaternion r)
405 {
406 m_host.AddScriptLPS(1);
407 return (new LSL_Types.Vector3(0, 1, 0) * r);
408 }
409
410 public LSL_Types.Vector3 llRot2Up(LSL_Types.Quaternion r)
411 {
412 m_host.AddScriptLPS(1);
413 return (new LSL_Types.Vector3(0, 0, 1) * r);
414 }
415
416 public LSL_Types.Quaternion llRotBetween(LSL_Types.Vector3 a, LSL_Types.Vector3 b)
417 {
418 //A and B should both be normalized
419 m_host.AddScriptLPS(1);
420 double dotProduct = LSL_Types.Vector3.Dot(a, b);
421 LSL_Types.Vector3 crossProduct = LSL_Types.Vector3.Cross(a, b);
422 double magProduct = LSL_Types.Vector3.Mag(a) * LSL_Types.Vector3.Mag(b);
423 double angle = Math.Acos(dotProduct / magProduct);
424 LSL_Types.Vector3 axis = LSL_Types.Vector3.Norm(crossProduct);
425 double s = Math.Sin(angle / 2);
426
427 return new LSL_Types.Quaternion(axis.x * s, axis.y * s, axis.z * s, (float)Math.Cos(angle / 2));
428 }
429
430 public void llWhisper(int channelID, string text)
431 {
432 m_host.AddScriptLPS(1);
433
434 if (text.Length > 1023)
435 text = text.Substring(0, 1023);
436
437 World.SimChat(Helpers.StringToField(text),
438 ChatTypeEnum.Whisper, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID, false);
439
440 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
441 wComm.DeliverMessage(ChatTypeEnum.Whisper, channelID, m_host.Name, m_host.UUID, text);
442 }
443
444 public void llShout(int channelID, string text)
445 {
446 m_host.AddScriptLPS(1);
447
448 if (text.Length > 1023)
449 text = text.Substring(0, 1023);
450
451 World.SimChat(Helpers.StringToField(text),
452 ChatTypeEnum.Shout, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID, true);
453
454 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
455 wComm.DeliverMessage(ChatTypeEnum.Shout, channelID, m_host.Name, m_host.UUID, text);
456 }
457
458 public void llRegionSay(int channelID, string text)
459 {
460 if (channelID == 0)
461 {
462 LSLError("Cannot use llRegionSay() on channel 0");
463 return;
464 }
465
466 if (text.Length > 1023)
467 text = text.Substring(0, 1023);
468
469 m_host.AddScriptLPS(1);
470
471 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
472 wComm.DeliverMessage(ChatTypeEnum.Region, channelID, m_host.Name, m_host.UUID, text);
473 }
474
475 public LSL_Types.LSLInteger llListen(int channelID, string name, string ID, string msg)
476 {
477 m_host.AddScriptLPS(1);
478 LLUUID keyID;
479 LLUUID.TryParse(ID, out keyID);
480 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
481 return wComm.Listen(m_localID, m_itemID, m_host.UUID, channelID, name, keyID, msg);
482 }
483
484 public void llListenControl(int number, int active)
485 {
486 m_host.AddScriptLPS(1);
487 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
488 wComm.ListenControl(m_itemID, number, active);
489 }
490
491 public void llListenRemove(int number)
492 {
493 m_host.AddScriptLPS(1);
494 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
495 wComm.ListenRemove(m_itemID, number);
496 }
497
498 public void llSensor(string name, string id, int type, double range, double arc)
499 {
500 m_host.AddScriptLPS(1);
501 LLUUID keyID = LLUUID.Zero;
502 LLUUID.TryParse(id, out keyID);
503
504 m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.SenseOnce(m_localID, m_itemID, name, keyID, type, range, arc, m_host);
505 }
506
507 public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate)
508 {
509 m_host.AddScriptLPS(1);
510 LLUUID keyID = LLUUID.Zero;
511 LLUUID.TryParse(id, out keyID);
512
513 m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.SetSenseRepeatEvent(m_localID, m_itemID, name, keyID, type, range, arc, rate, m_host);
514 }
515
516 public void llSensorRemove()
517 {
518 m_host.AddScriptLPS(1);
519 m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.UnSetSenseRepeaterEvents(m_localID, m_itemID);
520 }
521
522 public string resolveName(LLUUID objecUUID)
523 {
524 // try avatar username surname
525 UserProfileData profile = World.CommsManager.UserService.GetUserProfile(objecUUID);
526 if (profile != null)
527 {
528 string avatarname = profile.FirstName + " " + profile.SurName;
529 return avatarname;
530 }
531 // try an scene object
532 SceneObjectPart SOP = World.GetSceneObjectPart(objecUUID);
533 if (SOP != null)
534 {
535 string objectname = SOP.Name;
536 return objectname;
537 }
538
539 EntityBase SensedObject;
540 lock (World.Entities)
541 {
542 World.Entities.TryGetValue(objecUUID, out SensedObject);
543 }
544
545 if (SensedObject == null)
546 return String.Empty;
547 return SensedObject.Name;
548 }
549
550 public string llDetectedName(int number)
551 {
552 m_host.AddScriptLPS(1);
553 XDetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
554 if (d == null)
555 return String.Empty;
556 return d.Name;
557 }
558
559 public string llDetectedKey(int number)
560 {
561 m_host.AddScriptLPS(1);
562 XDetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
563 if (d == null)
564 return String.Empty;
565 return d.Key.ToString();
566 }
567
568 public string llDetectedOwner(int number)
569 {
570 m_host.AddScriptLPS(1);
571 XDetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
572 if (d == null)
573 return String.Empty;
574 return d.Owner.ToString();
575 }
576
577 public LSL_Types.LSLInteger llDetectedType(int number)
578 {
579 m_host.AddScriptLPS(1);
580 XDetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
581 if (d == null)
582 return 0;
583 return new LSL_Types.LSLInteger(d.Type);
584 }
585
586 public LSL_Types.Vector3 llDetectedPos(int number)
587 {
588 m_host.AddScriptLPS(1);
589 XDetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
590 if (d == null)
591 return new LSL_Types.Vector3();
592 return d.Position;
593 }
594
595 public LSL_Types.Vector3 llDetectedVel(int number)
596 {
597 m_host.AddScriptLPS(1);
598 XDetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
599 if (d == null)
600 return new LSL_Types.Vector3();
601 return d.Velocity;
602 }
603
604 public LSL_Types.Vector3 llDetectedGrab(int number)
605 {
606 m_host.AddScriptLPS(1);
607 XDetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number);
608 if (parms == null)
609 return new LSL_Types.Vector3(0, 0, 0);
610
611 return parms.OffsetPos;
612 }
613
614 public LSL_Types.Quaternion llDetectedRot(int number)
615 {
616 m_host.AddScriptLPS(1);
617 XDetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
618 if (d == null)
619 return new LSL_Types.Quaternion();
620 return d.Rotation;
621 }
622
623 public LSL_Types.LSLInteger llDetectedGroup(int number)
624 {
625 m_host.AddScriptLPS(1);
626 XDetectParams d = m_ScriptEngine.GetDetectParams(m_itemID, number);
627 if (d == null)
628 return new LSL_Types.LSLInteger(0);
629 if (m_host.GroupID == d.Group)
630 return new LSL_Types.LSLInteger(1);
631 return new LSL_Types.LSLInteger(0);
632 }
633
634 public LSL_Types.LSLInteger llDetectedLinkNumber(int number)
635 {
636 m_host.AddScriptLPS(1);
637 XDetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number);
638 if (parms == null)
639 return new LSL_Types.LSLInteger(0);
640
641 return new LSL_Types.LSLInteger(parms.LinkNum);
642 }
643
644 public void llDie()
645 {
646 m_host.AddScriptLPS(1);
647 World.DeleteSceneObject(m_host.ParentGroup);
648 }
649
650 public double llGround(LSL_Types.Vector3 offset)
651 {
652 m_host.AddScriptLPS(1);
653 int x = (int)(m_host.AbsolutePosition.X + offset.x);
654 int y = (int)(m_host.AbsolutePosition.Y + offset.y);
655 return World.GetLandHeight(x, y);
656 }
657
658 public double llCloud(LSL_Types.Vector3 offset)
659 {
660 m_host.AddScriptLPS(1);
661 NotImplemented("llCloud");
662 return 0;
663 }
664
665 public LSL_Types.Vector3 llWind(LSL_Types.Vector3 offset)
666 {
667 m_host.AddScriptLPS(1);
668 NotImplemented("llWind");
669 return new LSL_Types.Vector3();
670 }
671
672 public void llSetStatus(int status, int value)
673 {
674 m_host.AddScriptLPS(1);
675
676 int statusrotationaxis = 0;
677
678 if ((status & BuiltIn_Commands_BaseClass.STATUS_PHYSICS) == BuiltIn_Commands_BaseClass.STATUS_PHYSICS)
679 {
680 if (value == 1)
681 m_host.ScriptSetPhysicsStatus(true);
682 else
683 m_host.ScriptSetPhysicsStatus(false);
684 }
685
686 if ((status & BuiltIn_Commands_BaseClass.STATUS_PHANTOM) == BuiltIn_Commands_BaseClass.STATUS_PHANTOM)
687 {
688 if (value == 1)
689 m_host.ScriptSetPhantomStatus(true);
690 else
691 m_host.ScriptSetPhantomStatus(false);
692 }
693
694 if ((status & BuiltIn_Commands_BaseClass.STATUS_CAST_SHADOWS) == BuiltIn_Commands_BaseClass.STATUS_CAST_SHADOWS)
695 {
696 m_host.AddFlag(LLObject.ObjectFlags.CastShadows);
697 }
698
699 if ((status & BuiltIn_Commands_BaseClass.STATUS_ROTATE_X) == BuiltIn_Commands_BaseClass.STATUS_ROTATE_X)
700 {
701 statusrotationaxis |= BuiltIn_Commands_BaseClass.STATUS_ROTATE_X;
702 }
703
704 if ((status & BuiltIn_Commands_BaseClass.STATUS_ROTATE_Y) == BuiltIn_Commands_BaseClass.STATUS_ROTATE_Y)
705 {
706 statusrotationaxis |= BuiltIn_Commands_BaseClass.STATUS_ROTATE_Y;
707 }
708
709 if ((status & BuiltIn_Commands_BaseClass.STATUS_ROTATE_Z) == BuiltIn_Commands_BaseClass.STATUS_ROTATE_Z)
710 {
711 statusrotationaxis |= BuiltIn_Commands_BaseClass.STATUS_ROTATE_Z;
712 }
713
714 if ((status & BuiltIn_Commands_BaseClass.STATUS_BLOCK_GRAB) == BuiltIn_Commands_BaseClass.STATUS_BLOCK_GRAB)
715 {
716 NotImplemented("llSetStatus - STATUS_BLOCK_GRAB");
717 }
718
719 if ((status & BuiltIn_Commands_BaseClass.STATUS_DIE_AT_EDGE) == BuiltIn_Commands_BaseClass.STATUS_DIE_AT_EDGE)
720 {
721 if (value == 1)
722 m_host.SetDieAtEdge(true);
723 else
724 m_host.SetDieAtEdge(false);
725 }
726
727 if ((status & BuiltIn_Commands_BaseClass.STATUS_RETURN_AT_EDGE) == BuiltIn_Commands_BaseClass.STATUS_RETURN_AT_EDGE)
728 {
729 NotImplemented("llSetStatus - STATUS_RETURN_AT_EDGE");
730 }
731
732 if ((status & BuiltIn_Commands_BaseClass.STATUS_SANDBOX) == BuiltIn_Commands_BaseClass.STATUS_SANDBOX)
733 {
734 NotImplemented("llSetStatus - STATUS_SANDBOX");
735 }
736
737 if (statusrotationaxis != 0)
738 {
739 m_host.SetAxisRotation(statusrotationaxis, value);
740 }
741 }
742
743 public LSL_Types.LSLInteger llGetStatus(int status)
744 {
745 m_host.AddScriptLPS(1);
746 // Console.WriteLine(m_host.UUID.ToString() + " status is " + m_host.GetEffectiveObjectFlags().ToString());
747 switch (status)
748 {
749 case BuiltIn_Commands_BaseClass.STATUS_PHYSICS:
750 if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Physics) == (uint)LLObject.ObjectFlags.Physics)
751 {
752 return 1;
753 }
754 return 0;
755
756 case BuiltIn_Commands_BaseClass.STATUS_PHANTOM:
757 if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Phantom) == (uint)LLObject.ObjectFlags.Phantom)
758 {
759 return 1;
760 }
761 return 0;
762
763 case BuiltIn_Commands_BaseClass.STATUS_CAST_SHADOWS:
764 if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.CastShadows) == (uint)LLObject.ObjectFlags.CastShadows)
765 {
766 return 1;
767 }
768 return 0;
769
770 case BuiltIn_Commands_BaseClass.STATUS_BLOCK_GRAB:
771 NotImplemented("llGetStatus - STATUS_BLOCK_GRAB");
772 return 0;
773
774 case BuiltIn_Commands_BaseClass.STATUS_DIE_AT_EDGE:
775 if (m_host.GetDieAtEdge())
776 return 1;
777 else
778 return 0;
779
780 case BuiltIn_Commands_BaseClass.STATUS_RETURN_AT_EDGE:
781 NotImplemented("llGetStatus - STATUS_RETURN_AT_EDGE");
782 return 0;
783
784 case BuiltIn_Commands_BaseClass.STATUS_ROTATE_X:
785 NotImplemented("llGetStatus - STATUS_ROTATE_X");
786 return 0;
787
788 case BuiltIn_Commands_BaseClass.STATUS_ROTATE_Y:
789 NotImplemented("llGetStatus - STATUS_ROTATE_Y");
790 return 0;
791
792 case BuiltIn_Commands_BaseClass.STATUS_ROTATE_Z:
793 NotImplemented("llGetStatus - STATUS_ROTATE_Z");
794 return 0;
795
796 case BuiltIn_Commands_BaseClass.STATUS_SANDBOX:
797 NotImplemented("llGetStatus - STATUS_SANDBOX");
798 return 0;
799 }
800 return 0;
801 }
802
803 public void llSetScale(LSL_Types.Vector3 scale)
804 {
805 m_host.AddScriptLPS(1);
806 SetScale(m_host, scale);
807 }
808
809 private void SetScale(SceneObjectPart part, LSL_Types.Vector3 scale)
810 {
811 // TODO: this needs to trigger a persistance save as well
812 LLVector3 tmp = part.Scale;
813 tmp.X = (float)scale.x;
814 tmp.Y = (float)scale.y;
815 tmp.Z = (float)scale.z;
816 part.Scale = tmp;
817 part.SendFullUpdateToAllClients();
818 }
819
820 public LSL_Types.Vector3 llGetScale()
821 {
822 m_host.AddScriptLPS(1);
823 return new LSL_Types.Vector3(m_host.Scale.X, m_host.Scale.Y, m_host.Scale.Z);
824 }
825
826 public void llSetColor(LSL_Types.Vector3 color, int face)
827 {
828 m_host.AddScriptLPS(1);
829
830 SetColor(m_host, color, face);
831 }
832
833 private void SetColor(SceneObjectPart part, LSL_Types.Vector3 color, int face)
834 {
835 LLObject.TextureEntry tex = part.Shape.Textures;
836 LLColor texcolor;
837 if (face > -1)
838 {
839 texcolor = tex.CreateFace((uint)face).RGBA;
840 texcolor.R = (float)Math.Abs(color.x - 1);
841 texcolor.G = (float)Math.Abs(color.y - 1);
842 texcolor.B = (float)Math.Abs(color.z - 1);
843 tex.FaceTextures[face].RGBA = texcolor;
844 part.UpdateTexture(tex);
845 return;
846 }
847 else if (face == -1)
848 {
849 for (uint i = 0; i < 32; i++)
850 {
851 if (tex.FaceTextures[i] != null)
852 {
853 texcolor = tex.FaceTextures[i].RGBA;
854 texcolor.R = (float)Math.Abs(color.x - 1);
855 texcolor.G = (float)Math.Abs(color.y - 1);
856 texcolor.B = (float)Math.Abs(color.z - 1);
857 tex.FaceTextures[i].RGBA = texcolor;
858 }
859 texcolor = tex.DefaultTexture.RGBA;
860 texcolor.R = (float)Math.Abs(color.x - 1);
861 texcolor.G = (float)Math.Abs(color.y - 1);
862 texcolor.B = (float)Math.Abs(color.z - 1);
863 tex.DefaultTexture.RGBA = texcolor;
864 }
865 part.UpdateTexture(tex);
866 return;
867 }
868 }
869
870 public double llGetAlpha(int face)
871 {
872 m_host.AddScriptLPS(1);
873 LLObject.TextureEntry tex = m_host.Shape.Textures;
874 if (face == -1) // TMP: Until we can determine number of sides, ALL_SIDES (-1) will return default color
875 {
876 return (double)((tex.DefaultTexture.RGBA.A * 255) / 255);
877 }
878 if (face > -1)
879 {
880 return (double)((tex.GetFace((uint)face).RGBA.A * 255) / 255);
881 }
882 return 0;
883 }
884
885 public void llSetAlpha(double alpha, int face)
886 {
887 m_host.AddScriptLPS(1);
888
889 SetAlpha(m_host, alpha, face);
890 }
891
892 private void SetAlpha(SceneObjectPart part, double alpha, int face)
893 {
894 LLObject.TextureEntry tex = part.Shape.Textures;
895 LLColor texcolor;
896 if (face > -1)
897 {
898 texcolor = tex.CreateFace((uint)face).RGBA;
899 texcolor.A = (float)Math.Abs(alpha - 1);
900 tex.FaceTextures[face].RGBA = texcolor;
901 part.UpdateTexture(tex);
902 return;
903 }
904 else if (face == -1)
905 {
906 for (int i = 0; i < 32; i++)
907 {
908 if (tex.FaceTextures[i] != null)
909 {
910 texcolor = tex.FaceTextures[i].RGBA;
911 texcolor.A = (float)Math.Abs(alpha - 1);
912 tex.FaceTextures[i].RGBA = texcolor;
913 }
914 }
915 texcolor = tex.DefaultTexture.RGBA;
916 texcolor.A = (float)Math.Abs(alpha - 1);
917 tex.DefaultTexture.RGBA = texcolor;
918 part.UpdateTexture(tex);
919 return;
920 }
921 }
922
923 private void SetFlexi(SceneObjectPart part, bool flexi, int softness, float gravity, float friction,
924 float wind, float tension, LSL_Types.Vector3 Force)
925 {
926 if (part == null)
927 return;
928
929 bool needs_fakedelete = false;
930 if (flexi)
931 {
932 if (!part.Shape.FlexiEntry)
933 {
934 needs_fakedelete = true;
935 }
936 part.Shape.FlexiEntry = true; // this setting flexi true isn't working, but the below parameters do
937 // work once the prim is already flexi
938 part.Shape.FlexiSoftness = softness;
939 part.Shape.FlexiGravity = gravity;
940 part.Shape.FlexiDrag = friction;
941 part.Shape.FlexiWind = wind;
942 part.Shape.FlexiTension = tension;
943 part.Shape.FlexiForceX = (float)Force.x;
944 part.Shape.FlexiForceY = (float)Force.y;
945 part.Shape.FlexiForceZ = (float)Force.z;
946 part.Shape.PathCurve = 0x80;
947
948 }
949 else
950 {
951 if (part.Shape.FlexiEntry)
952 {
953 needs_fakedelete = true;
954 }
955 part.Shape.FlexiEntry = false;
956 }
957
958 needs_fakedelete = false;
959 if (needs_fakedelete)
960 {
961 if (part.ParentGroup != null)
962 {
963 part.ParentGroup.FakeDeleteGroup();
964 }
965 }
966
967 part.ScheduleFullUpdate();
968 }
969
970 private void SetPointLight(SceneObjectPart part, bool light, LSL_Types.Vector3 color, float intensity, float radius, float falloff)
971 {
972 if (part == null)
973 return;
974
975 if (light)
976 {
977 part.Shape.LightEntry = true;
978 part.Shape.LightColorR = (float)color.x;
979 part.Shape.LightColorG = (float)color.y;
980 part.Shape.LightColorB = (float)color.z;
981 part.Shape.LightIntensity = intensity;
982 part.Shape.LightRadius = radius;
983 part.Shape.LightFalloff = falloff;
984 }
985 else
986 {
987 part.Shape.LightEntry = false;
988 }
989
990 part.ScheduleFullUpdate();
991 }
992
993
994
995 public LSL_Types.Vector3 llGetColor(int face)
996 {
997 m_host.AddScriptLPS(1);
998 LLObject.TextureEntry tex = m_host.Shape.Textures;
999 LLColor texcolor;
1000 LSL_Types.Vector3 rgb;
1001 if (face == -1) // TMP: Until we can determine number of sides, ALL_SIDES (-1) will return default color
1002 {
1003 texcolor = tex.DefaultTexture.RGBA;
1004 rgb.x = (255 - (texcolor.R * 255)) / 255;
1005 rgb.y = (255 - (texcolor.G * 255)) / 255;
1006 rgb.z = (255 - (texcolor.B * 255)) / 255;
1007 return rgb;
1008 }
1009 if (face > -1)
1010 {
1011 texcolor = tex.GetFace((uint)face).RGBA;
1012 rgb.x = (255 - (texcolor.R * 255)) / 255;
1013 rgb.y = (255 - (texcolor.G * 255)) / 255;
1014 rgb.z = (255 - (texcolor.B * 255)) / 255;
1015 return rgb;
1016 }
1017 else
1018 {
1019 return new LSL_Types.Vector3();
1020 }
1021 }
1022
1023 public void llSetTexture(string texture, int face)
1024 {
1025 m_host.AddScriptLPS(1);
1026 SetTexture(m_host, texture, face);
1027 }
1028
1029 private void SetTexture(SceneObjectPart part, string texture, int face)
1030 {
1031 LLUUID textureID=new LLUUID();
1032
1033 if (!LLUUID.TryParse(texture, out textureID))
1034 {
1035 textureID=InventoryKey(texture, (int)AssetType.Texture);
1036 }
1037
1038 if (textureID == LLUUID.Zero)
1039 return;
1040
1041 LLObject.TextureEntry tex = part.Shape.Textures;
1042
1043 if (face > -1)
1044 {
1045 LLObject.TextureEntryFace texface = tex.CreateFace((uint)face);
1046 texface.TextureID = textureID;
1047 tex.FaceTextures[face] = texface;
1048 part.UpdateTexture(tex);
1049 return;
1050 }
1051 else if (face == -1)
1052 {
1053 for (uint i = 0; i < 32; i++)
1054 {
1055 if (tex.FaceTextures[i] != null)
1056 {
1057 tex.FaceTextures[i].TextureID = textureID;
1058 }
1059 }
1060 tex.DefaultTexture.TextureID = textureID;
1061 part.UpdateTexture(tex);
1062 return;
1063 }
1064 }
1065
1066 public void llScaleTexture(double u, double v, int face)
1067 {
1068 m_host.AddScriptLPS(1);
1069
1070 ScaleTexture(m_host, u, v, face);
1071 }
1072
1073 private void ScaleTexture(SceneObjectPart part, double u, double v, int face)
1074 {
1075 LLObject.TextureEntry tex = part.Shape.Textures;
1076 if (face > -1)
1077 {
1078 LLObject.TextureEntryFace texface = tex.CreateFace((uint)face);
1079 texface.RepeatU = (float)u;
1080 texface.RepeatV = (float)v;
1081 tex.FaceTextures[face] = texface;
1082 part.UpdateTexture(tex);
1083 return;
1084 }
1085 if (face == -1)
1086 {
1087 for (int i = 0; i < 32; i++)
1088 {
1089 if (tex.FaceTextures[i] != null)
1090 {
1091 tex.FaceTextures[i].RepeatU = (float)u;
1092 tex.FaceTextures[i].RepeatV = (float)v;
1093 }
1094 }
1095 tex.DefaultTexture.RepeatU = (float)u;
1096 tex.DefaultTexture.RepeatV = (float)v;
1097 part.UpdateTexture(tex);
1098 return;
1099 }
1100 }
1101
1102 public void llOffsetTexture(double u, double v, int face)
1103 {
1104 m_host.AddScriptLPS(1);
1105 OffsetTexture(m_host, u, v, face);
1106 }
1107
1108 private void OffsetTexture(SceneObjectPart part, double u, double v, int face)
1109 {
1110 LLObject.TextureEntry tex = part.Shape.Textures;
1111 if (face > -1)
1112 {
1113 LLObject.TextureEntryFace texface = tex.CreateFace((uint)face);
1114 texface.OffsetU = (float)u;
1115 texface.OffsetV = (float)v;
1116 tex.FaceTextures[face] = texface;
1117 part.UpdateTexture(tex);
1118 return;
1119 }
1120 if (face == -1)
1121 {
1122 for (int i = 0; i < 32; i++)
1123 {
1124 if (tex.FaceTextures[i] != null)
1125 {
1126 tex.FaceTextures[i].OffsetU = (float)u;
1127 tex.FaceTextures[i].OffsetV = (float)v;
1128 }
1129 }
1130 tex.DefaultTexture.OffsetU = (float)u;
1131 tex.DefaultTexture.OffsetV = (float)v;
1132 part.UpdateTexture(tex);
1133 return;
1134 }
1135 }
1136
1137 public void llRotateTexture(double rotation, int face)
1138 {
1139 m_host.AddScriptLPS(1);
1140 RotateTexture(m_host, rotation, face);
1141 }
1142
1143 private void RotateTexture(SceneObjectPart part, double rotation, int face)
1144 {
1145 LLObject.TextureEntry tex = part.Shape.Textures;
1146 if (face > -1)
1147 {
1148 LLObject.TextureEntryFace texface = tex.CreateFace((uint)face);
1149 texface.Rotation = (float)rotation;
1150 tex.FaceTextures[face] = texface;
1151 part.UpdateTexture(tex);
1152 return;
1153 }
1154 if (face == -1)
1155 {
1156 for (int i = 0; i < 32; i++)
1157 {
1158 if (tex.FaceTextures[i] != null)
1159 {
1160 tex.FaceTextures[i].Rotation = (float)rotation;
1161 }
1162 }
1163 tex.DefaultTexture.Rotation = (float)rotation;
1164 part.UpdateTexture(tex);
1165 return;
1166 }
1167 }
1168
1169 public string llGetTexture(int face)
1170 {
1171 m_host.AddScriptLPS(1);
1172 LLObject.TextureEntry tex = m_host.Shape.Textures;
1173 if (face == -1)
1174 {
1175 face = 0;
1176 }
1177 if (face > -1)
1178 {
1179 LLObject.TextureEntryFace texface;
1180 texface = tex.GetFace((uint)face);
1181 return texface.TextureID.ToString();
1182 }
1183 else
1184 {
1185 return String.Empty;
1186 }
1187 }
1188
1189 public void llSetPos(LSL_Types.Vector3 pos)
1190 {
1191 m_host.AddScriptLPS(1);
1192
1193 SetPos(m_host, pos);
1194 }
1195
1196 private void SetPos(SceneObjectPart part, LSL_Types.Vector3 pos)
1197 {
1198 if (part.ParentID != 0)
1199 {
1200 part.UpdateOffSet(new LLVector3((float)pos.x, (float)pos.y, (float)pos.z));
1201 }
1202 else
1203 {
1204 part.UpdateGroupPosition(new LLVector3((float)pos.x, (float)pos.y, (float)pos.z));
1205 }
1206 }
1207
1208 public LSL_Types.Vector3 llGetPos()
1209 {
1210 m_host.AddScriptLPS(1);
1211 return new LSL_Types.Vector3(m_host.AbsolutePosition.X,
1212 m_host.AbsolutePosition.Y,
1213 m_host.AbsolutePosition.Z);
1214 }
1215
1216 public LSL_Types.Vector3 llGetLocalPos()
1217 {
1218 m_host.AddScriptLPS(1);
1219 if (m_host.ParentID != 0)
1220 {
1221 return new LSL_Types.Vector3(m_host.OffsetPosition.X,
1222 m_host.OffsetPosition.Y,
1223 m_host.OffsetPosition.Z);
1224 }
1225 else
1226 {
1227 return new LSL_Types.Vector3(m_host.AbsolutePosition.X,
1228 m_host.AbsolutePosition.Y,
1229 m_host.AbsolutePosition.Z);
1230 }
1231 }
1232
1233 public void llSetRot(LSL_Types.Quaternion rot)
1234 {
1235 m_host.AddScriptLPS(1);
1236
1237 SetRot(m_host, rot);
1238 }
1239
1240 private void SetRot(SceneObjectPart part, LSL_Types.Quaternion rot)
1241 {
1242 part.UpdateRotation(new LLQuaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s));
1243 // Update rotation does not move the object in the physics scene if it's a linkset.
1244 part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition;
1245 }
1246
1247 public LSL_Types.Quaternion llGetRot()
1248 {
1249 m_host.AddScriptLPS(1);
1250 LLQuaternion q = m_host.RotationOffset;
1251 return new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W);
1252 }
1253
1254 public LSL_Types.Quaternion llGetLocalRot()
1255 {
1256 m_host.AddScriptLPS(1);
1257 return new LSL_Types.Quaternion(m_host.RotationOffset.X, m_host.RotationOffset.Y, m_host.RotationOffset.Z, m_host.RotationOffset.W);
1258 }
1259
1260 public void llSetForce(LSL_Types.Vector3 force, int local)
1261 {
1262 m_host.AddScriptLPS(1);
1263 NotImplemented("llSetForce");
1264 }
1265
1266 public LSL_Types.Vector3 llGetForce()
1267 {
1268 m_host.AddScriptLPS(1);
1269 NotImplemented("llGetForce");
1270 return new LSL_Types.Vector3();
1271 }
1272
1273 public LSL_Types.LSLInteger llTarget(LSL_Types.Vector3 position, double range)
1274 {
1275 m_host.AddScriptLPS(1);
1276 return m_host.registerTargetWaypoint(new LLVector3((float)position.x, (float)position.y, (float)position.z), (float)range);
1277
1278 }
1279
1280 public void llTargetRemove(int number)
1281 {
1282 m_host.AddScriptLPS(1);
1283 m_host.unregisterTargetWaypoint(number);
1284 }
1285
1286 public LSL_Types.LSLInteger llRotTarget(LSL_Types.Quaternion rot, double error)
1287 {
1288 m_host.AddScriptLPS(1);
1289 NotImplemented("llRotTarget");
1290 return 0;
1291 }
1292
1293 public void llRotTargetRemove(int number)
1294 {
1295 m_host.AddScriptLPS(1);
1296 NotImplemented("llRotTargetRemove");
1297 }
1298
1299 public void llMoveToTarget(LSL_Types.Vector3 target, double tau)
1300 {
1301 m_host.AddScriptLPS(1);
1302 m_host.MoveToTarget(new LLVector3((float)target.x, (float)target.y, (float)target.z), (float)tau);
1303 }
1304
1305 public void llStopMoveToTarget()
1306 {
1307 m_host.AddScriptLPS(1);
1308 m_host.StopMoveToTarget();
1309 }
1310
1311 public void llApplyImpulse(LSL_Types.Vector3 force, int local)
1312 {
1313 m_host.AddScriptLPS(1);
1314 //No energy force yet
1315
1316 if (force.x > 20000)
1317 force.x = 20000;
1318 if (force.y > 20000)
1319 force.y = 20000;
1320 if (force.z > 20000)
1321 force.z = 20000;
1322
1323 if (local == 1)
1324 {
1325 m_host.ApplyImpulse(new LLVector3((float)force.x, (float)force.y, (float)force.z), true);
1326 }
1327 else
1328 {
1329
1330 m_host.ApplyImpulse(new LLVector3((float)force.x,(float)force.y,(float)force.z), false);
1331 }
1332 }
1333
1334 public void llApplyRotationalImpulse(LSL_Types.Vector3 force, int local)
1335 {
1336 m_host.AddScriptLPS(1);
1337 NotImplemented("llApplyRotationalImpulse");
1338 }
1339
1340 public void llSetTorque(LSL_Types.Vector3 torque, int local)
1341 {
1342 m_host.AddScriptLPS(1);
1343 NotImplemented("llSetTorque");
1344 }
1345
1346 public LSL_Types.Vector3 llGetTorque()
1347 {
1348 m_host.AddScriptLPS(1);
1349 NotImplemented("llGetTorque");
1350 return new LSL_Types.Vector3();
1351 }
1352
1353 public void llSetForceAndTorque(LSL_Types.Vector3 force, LSL_Types.Vector3 torque, int local)
1354 {
1355 m_host.AddScriptLPS(1);
1356 NotImplemented("llSetForceAndTorque");
1357 }
1358
1359 public LSL_Types.Vector3 llGetVel()
1360 {
1361 m_host.AddScriptLPS(1);
1362 return new LSL_Types.Vector3(m_host.Velocity.X, m_host.Velocity.Y, m_host.Velocity.Z);
1363 }
1364
1365 public LSL_Types.Vector3 llGetAccel()
1366 {
1367 m_host.AddScriptLPS(1);
1368 return new LSL_Types.Vector3(m_host.Acceleration.X, m_host.Acceleration.Y, m_host.Acceleration.Z);
1369 }
1370
1371 public LSL_Types.Vector3 llGetOmega()
1372 {
1373 m_host.AddScriptLPS(1);
1374 return new LSL_Types.Vector3(m_host.RotationalVelocity.X, m_host.RotationalVelocity.Y, m_host.RotationalVelocity.Z);
1375 }
1376
1377 public double llGetTimeOfDay()
1378 {
1379 m_host.AddScriptLPS(1);
1380 NotImplemented("llGetTimeOfDay");
1381 return 0;
1382 }
1383
1384 public double llGetWallclock()
1385 {
1386 m_host.AddScriptLPS(1);
1387 return DateTime.Now.TimeOfDay.TotalSeconds;
1388 }
1389
1390 public double llGetTime()
1391 {
1392 m_host.AddScriptLPS(1);
1393 TimeSpan ScriptTime = DateTime.Now - m_timer;
1394 return (double)((ScriptTime.TotalMilliseconds / 1000)*World.TimeDilation);
1395 }
1396
1397 public void llResetTime()
1398 {
1399 m_host.AddScriptLPS(1);
1400 m_timer = DateTime.Now;
1401 }
1402
1403 public double llGetAndResetTime()
1404 {
1405 m_host.AddScriptLPS(1);
1406 TimeSpan ScriptTime = DateTime.Now - m_timer;
1407 m_timer = DateTime.Now;
1408 return (double)((ScriptTime.TotalMilliseconds / 1000)*World.TimeDilation);
1409 }
1410
1411 public void llSound()
1412 {
1413 m_host.AddScriptLPS(1);
1414 // This function has been deprecated
1415 // see http://www.lslwiki.net/lslwiki/wakka.php?wakka=llSound
1416 Deprecated("llSound");
1417 }
1418
1419 // Xantor 20080528 PlaySound updated so it accepts an objectinventory name -or- a key to a sound
1420 // 20080530 Updated to remove code duplication
1421 public void llPlaySound(string sound, double volume)
1422 {
1423 m_host.AddScriptLPS(1);
1424
1425 // send the sound, once, to all clients in range
1426 m_host.SendSound(KeyOrName(sound).ToString(), volume, false, 0);
1427 }
1428
1429 // Xantor 20080528 we should do this differently.
1430 // 1) apply the sound to the object
1431 // 2) schedule full update
1432 // just sending the sound out once doesn't work so well when other avatars come in view later on
1433 // or when the prim gets moved, changed, sat on, whatever
1434 // see large number of mantises (mantes?)
1435 // 20080530 Updated to remove code duplication
1436 // 20080530 Stop sound if there is one, otherwise volume only changes don't work
1437 public void llLoopSound(string sound, double volume)
1438 {
1439 m_host.AddScriptLPS(1);
1440
1441 if (m_host.Sound != LLUUID.Zero)
1442 llStopSound();
1443
1444 m_host.Sound = KeyOrName(sound);
1445 m_host.SoundGain = volume;
1446 m_host.SoundFlags = 1; // looping
1447 m_host.SoundRadius = 20; // Magic number, 20 seems reasonable. Make configurable?
1448
1449 m_host.ScheduleFullUpdate();
1450 m_host.SendFullUpdateToAllClients();
1451 }
1452
1453 public void llLoopSoundMaster(string sound, double volume)
1454 {
1455 m_host.AddScriptLPS(1);
1456 NotImplemented("llLoopSoundMaster");
1457 }
1458
1459 public void llLoopSoundSlave(string sound, double volume)
1460 {
1461 m_host.AddScriptLPS(1);
1462 NotImplemented("llLoopSoundSlave");
1463 }
1464
1465 public void llPlaySoundSlave(string sound, double volume)
1466 {
1467 m_host.AddScriptLPS(1);
1468 NotImplemented("llPlaySoundSlave");
1469 }
1470
1471 public void llTriggerSound(string sound, double volume)
1472 {
1473 m_host.AddScriptLPS(1);
1474 m_host.SendSound(sound, volume, true, 0);
1475 }
1476
1477 // Xantor 20080528: Clear prim data of sound instead
1478 public void llStopSound()
1479 {
1480 m_host.AddScriptLPS(1);
1481
1482 m_host.Sound = LLUUID.Zero;
1483 m_host.SoundGain = 0;
1484 m_host.SoundFlags = 0;
1485 m_host.SoundRadius = 0;
1486
1487 m_host.ScheduleFullUpdate();
1488 m_host.SendFullUpdateToAllClients();
1489
1490 // m_host.SendSound(LLUUID.Zero.ToString(), 1.0, false, 2);
1491 }
1492
1493 public void llPreloadSound(string sound)
1494 {
1495 m_host.AddScriptLPS(1);
1496 m_host.PreloadSound(sound);
1497 }
1498
1499 /// <summary>
1500 /// Return a portion of the designated string bounded by
1501 /// inclusive indices (start and end). As usual, the negative
1502 /// indices, and the tolerance for out-of-bound values, makes
1503 /// this more complicated than it might otherwise seem.
1504 /// </summary>
1505
1506 public string llGetSubString(string src, int start, int end)
1507 {
1508
1509 m_host.AddScriptLPS(1);
1510
1511 // Normalize indices (if negative).
1512 // After normlaization they may still be
1513 // negative, but that is now relative to
1514 // the start, rather than the end, of the
1515 // sequence.
1516
1517 if (start < 0)
1518 {
1519 start = src.Length+start;
1520 }
1521 if (end < 0)
1522 {
1523 end = src.Length+end;
1524 }
1525
1526 // Conventional substring
1527 if (start <= end)
1528 {
1529 // Implies both bounds are out-of-range.
1530 if (end < 0 || start >= src.Length)
1531 {
1532 return String.Empty;
1533 }
1534 // If end is positive, then it directly
1535 // corresponds to the lengt of the substring
1536 // needed (plus one of course). BUT, it
1537 // must be within bounds.
1538 if (end >= src.Length)
1539 {
1540 end = src.Length-1;
1541 }
1542
1543 if (start < 0)
1544 {
1545 return src.Substring(0,end+1);
1546 }
1547 // Both indices are positive
1548 return src.Substring(start, (end+1) - start);
1549 }
1550
1551 // Inverted substring (end < start)
1552 else
1553 {
1554 // Implies both indices are below the
1555 // lower bound. In the inverted case, that
1556 // means the entire string will be returned
1557 // unchanged.
1558 if (start < 0)
1559 {
1560 return src;
1561 }
1562 // If both indices are greater than the upper
1563 // bound the result may seem initially counter
1564 // intuitive.
1565 if (end >= src.Length)
1566 {
1567 return src;
1568 }
1569
1570 if (end < 0)
1571 {
1572 if (start < src.Length)
1573 {
1574 return src.Substring(start);
1575 }
1576 else
1577 {
1578 return String.Empty;
1579 }
1580 }
1581 else
1582 {
1583 if (start < src.Length)
1584 {
1585 return src.Substring(0,end+1) + src.Substring(start);
1586 }
1587 else
1588 {
1589 return src.Substring(0,end+1);
1590 }
1591 }
1592 }
1593 }
1594
1595 /// <summary>
1596 /// Delete substring removes the specified substring bounded
1597 /// by the inclusive indices start and end. Indices may be
1598 /// negative (indicating end-relative) and may be inverted,
1599 /// i.e. end < start.
1600 /// </summary>
1601
1602 public string llDeleteSubString(string src, int start, int end)
1603 {
1604
1605 m_host.AddScriptLPS(1);
1606
1607 // Normalize indices (if negative).
1608 // After normlaization they may still be
1609 // negative, but that is now relative to
1610 // the start, rather than the end, of the
1611 // sequence.
1612 if (start < 0)
1613 {
1614 start = src.Length+start;
1615 }
1616 if (end < 0)
1617 {
1618 end = src.Length+end;
1619 }
1620 // Conventionally delimited substring
1621 if (start <= end)
1622 {
1623 // If both bounds are outside of the existing
1624 // string, then return unchanges.
1625 if (end < 0 || start >= src.Length)
1626 {
1627 return src;
1628 }
1629 // At least one bound is in-range, so we
1630 // need to clip the out-of-bound argument.
1631 if (start < 0)
1632 {
1633 start = 0;
1634 }
1635
1636 if (end >= src.Length)
1637 {
1638 end = src.Length-1;
1639 }
1640
1641 return src.Remove(start,end-start+1);
1642 }
1643 // Inverted substring
1644 else
1645 {
1646 // In this case, out of bounds means that
1647 // the existing string is part of the cut.
1648 if (start < 0 || end >= src.Length)
1649 {
1650 return String.Empty;
1651 }
1652
1653 if (end > 0)
1654 {
1655 if (start < src.Length)
1656 {
1657 return src.Remove(start).Remove(0,end+1);
1658 }
1659 else
1660 {
1661 return src.Remove(0,end+1);
1662 }
1663 }
1664 else
1665 {
1666 if (start < src.Length)
1667 {
1668 return src.Remove(start);
1669 }
1670 else
1671 {
1672 return src;
1673 }
1674 }
1675 }
1676 }
1677
1678 /// <summary>
1679 /// Insert string inserts the specified string identified by src
1680 /// at the index indicated by index. Index may be negative, in
1681 /// which case it is end-relative. The index may exceed either
1682 /// string bound, with the result being a concatenation.
1683 /// </summary>
1684
1685 public string llInsertString(string dest, int index, string src)
1686 {
1687
1688 m_host.AddScriptLPS(1);
1689
1690 // Normalize indices (if negative).
1691 // After normlaization they may still be
1692 // negative, but that is now relative to
1693 // the start, rather than the end, of the
1694 // sequence.
1695 if (index < 0)
1696 {
1697 index = dest.Length+index;
1698
1699 // Negative now means it is less than the lower
1700 // bound of the string.
1701
1702 if (index < 0)
1703 {
1704 return src+dest;
1705 }
1706
1707 }
1708
1709 if (index >= dest.Length)
1710 {
1711 return dest+src;
1712 }
1713
1714 // The index is in bounds.
1715 // In this case the index refers to the index that will
1716 // be assigned to the first character of the inserted string.
1717 // So unlike the other string operations, we do not add one
1718 // to get the correct string length.
1719 return dest.Substring(0,index)+src+dest.Substring(index);
1720
1721 }
1722
1723 public string llToUpper(string src)
1724 {
1725 m_host.AddScriptLPS(1);
1726 return src.ToUpper();
1727 }
1728
1729 public string llToLower(string src)
1730 {
1731 m_host.AddScriptLPS(1);
1732 return src.ToLower();
1733 }
1734
1735 public LSL_Types.LSLInteger llGiveMoney(string destination, int amount)
1736 {
1737 LLUUID invItemID=InventorySelf();
1738 if (invItemID == LLUUID.Zero)
1739 return 0;
1740
1741 m_host.AddScriptLPS(1);
1742
1743 if (m_host.TaskInventory[invItemID].PermsGranter == LLUUID.Zero)
1744 return 0;
1745
1746 if ((m_host.TaskInventory[invItemID].PermsMask & BuiltIn_Commands_BaseClass.PERMISSION_DEBIT) == 0)
1747 {
1748 LSLError("No permissions to give money");
1749 return 0;
1750 }
1751
1752 LLUUID toID=new LLUUID();
1753
1754 if (!LLUUID.TryParse(destination, out toID))
1755 {
1756 LSLError("Bad key in llGiveMoney");
1757 return 0;
1758 }
1759
1760 IMoneyModule money=World.RequestModuleInterface<IMoneyModule>();
1761
1762 if (money == null)
1763 {
1764 NotImplemented("llGiveMoney");
1765 return 0;
1766 }
1767
1768 bool result=money.ObjectGiveMoney(m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount);
1769
1770 if (result)
1771 return 1;
1772
1773 return 0;
1774 }
1775
1776 public void llMakeExplosion()
1777 {
1778 m_host.AddScriptLPS(1);
1779 NotImplemented("llMakeExplosion");
1780 }
1781
1782 public void llMakeFountain()
1783 {
1784 m_host.AddScriptLPS(1);
1785 NotImplemented("llMakeFountain");
1786 }
1787
1788 public void llMakeSmoke()
1789 {
1790 m_host.AddScriptLPS(1);
1791 NotImplemented("llMakeSmoke");
1792 }
1793
1794 public void llMakeFire()
1795 {
1796 m_host.AddScriptLPS(1);
1797 NotImplemented("llMakeFire");
1798 }
1799
1800 public void llRezObject(string inventory, LSL_Types.Vector3 pos, LSL_Types.Vector3 vel, LSL_Types.Quaternion rot, int param)
1801 {
1802 m_host.AddScriptLPS(1);
1803 //NotImplemented("llRezObject");
1804 bool found = false;
1805
1806 // Instead of using return;, I'm using continue; because in our TaskInventory implementation
1807 // it's possible to have two items with the same task inventory name.
1808 // this is an easter egg of sorts.
1809
1810 foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory)
1811 {
1812 if (inv.Value.Name == inventory)
1813 {
1814 // make sure we're an object.
1815 if (inv.Value.InvType != (int)InventoryType.Object)
1816 {
1817 llSay(0, "Unable to create requested object. Object is missing from database.");
1818 continue;
1819 }
1820
1821 LLVector3 llpos = new LLVector3((float)pos.x, (float)pos.y, (float)pos.z);
1822
1823 // test if we're further away then 10m
1824 if (Util.GetDistanceTo(llpos, m_host.AbsolutePosition) > 10)
1825 return; // wiki says, if it's further away then 10m, silently fail.
1826
1827 LLVector3 llvel = new LLVector3((float)vel.x, (float)vel.y, (float)vel.z);
1828
1829 // need the magnitude later
1830 float velmag = (float)Util.GetMagnitude(llvel);
1831
1832 SceneObjectGroup new_group = World.RezObject(inv.Value, llpos, new LLQuaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s), llvel, param);
1833
1834 // If either of these are null, then there was an unknown error.
1835 if (new_group == null)
1836 continue;
1837 if (new_group.RootPart == null)
1838 continue;
1839
1840 // objects rezzed with this method are die_at_edge by default.
1841 new_group.RootPart.SetDieAtEdge(true);
1842
1843 m_ScriptEngine.PostScriptEvent(m_itemID, new XEventParams(
1844 "object_rez", new Object[] {
1845 new LSL_Types.LSLString(
1846 new_group.RootPart.UUID.ToString()) },
1847 new XDetectParams[0]));
1848
1849 float groupmass = new_group.GetMass();
1850
1851 //Recoil.
1852 llApplyImpulse(new LSL_Types.Vector3(llvel.X * groupmass, llvel.Y * groupmass, llvel.Z * groupmass), 0);
1853 found = true;
1854 //script delay
1855 System.Threading.Thread.Sleep((int)((groupmass * velmag) / 10));
1856 break;
1857 }
1858 }
1859 if (!found)
1860 llSay(0, "Could not find object " + inventory);
1861 }
1862
1863 public void llLookAt(LSL_Types.Vector3 target, double strength, double damping)
1864 {
1865 m_host.AddScriptLPS(1);
1866 NotImplemented("llLookAt");
1867 }
1868
1869 public void llStopLookAt()
1870 {
1871 m_host.AddScriptLPS(1);
1872 NotImplemented("llStopLookAt");
1873 }
1874
1875 public void llSetTimerEvent(double sec)
1876 {
1877 m_host.AddScriptLPS(1);
1878 // Setting timer repeat
1879 m_ScriptEngine.m_ASYNCLSLCommandManager.m_Timer.SetTimerEvent(m_localID, m_itemID, sec);
1880 }
1881
1882 public void llSleep(double sec)
1883 {
1884 m_host.AddScriptLPS(1);
1885 Thread.Sleep((int)(sec * 1000));
1886 }
1887
1888 public double llGetMass()
1889 {
1890 m_host.AddScriptLPS(1);
1891 return m_host.GetMass();
1892 }
1893
1894 public void llCollisionFilter(string name, string id, int accept)
1895 {
1896 m_host.AddScriptLPS(1);
1897 NotImplemented("llCollisionFilter");
1898 }
1899
1900 public void llTakeControls(int controls, int accept, int pass_on)
1901 {
1902 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
1903 {
1904 return;
1905 }
1906
1907 if (m_host.TaskInventory[InventorySelf()].PermsGranter != LLUUID.Zero)
1908 {
1909 ScenePresence presence = World.GetScenePresence(m_host.TaskInventory[InventorySelf()].PermsGranter);
1910
1911 if (presence != null)
1912 {
1913 if ((m_host.TaskInventory[InventorySelf()].PermsMask & BuiltIn_Commands_BaseClass.PERMISSION_TAKE_CONTROLS) != 0)
1914 {
1915 presence.RegisterControlEventsToScript(controls, accept, pass_on, m_localID, m_itemID);
1916
1917 }
1918 }
1919 }
1920
1921 m_host.AddScriptLPS(1);
1922 //NotImplemented("llTakeControls");
1923 }
1924
1925 public void llReleaseControls()
1926 {
1927 m_host.AddScriptLPS(1);
1928
1929 if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
1930 {
1931 return;
1932 }
1933
1934 if (m_host.TaskInventory[InventorySelf()].PermsGranter != LLUUID.Zero)
1935 {
1936 ScenePresence presence = World.GetScenePresence(m_host.TaskInventory[InventorySelf()].PermsGranter);
1937
1938 if (presence != null)
1939 {
1940 if ((m_host.TaskInventory[InventorySelf()].PermsMask & BuiltIn_Commands_BaseClass.PERMISSION_TAKE_CONTROLS) != 0)
1941 {
1942 // Unregister controls from Presence
1943 presence.UnRegisterControlEventsToScript(m_localID, m_itemID);
1944 // Remove Take Control permission.
1945 m_host.TaskInventory[InventorySelf()].PermsMask &= ~BuiltIn_Commands_BaseClass.PERMISSION_TAKE_CONTROLS;
1946 }
1947 }
1948 }
1949 }
1950
1951 public void llAttachToAvatar(int attachment)
1952 {
1953 m_host.AddScriptLPS(1);
1954 NotImplemented("llAttachToAvatar");
1955 }
1956
1957 public void llDetachFromAvatar()
1958 {
1959 m_host.AddScriptLPS(1);
1960 NotImplemented("llDetachFromAvatar");
1961 }
1962
1963 public void llTakeCamera()
1964 {
1965 m_host.AddScriptLPS(1);
1966 NotImplemented("llTakeCamera");
1967 }
1968
1969 public void llReleaseCamera()
1970 {
1971 m_host.AddScriptLPS(1);
1972 NotImplemented("llReleaseCamera");
1973 }
1974
1975 public string llGetOwner()
1976 {
1977 m_host.AddScriptLPS(1);
1978
1979 return m_host.ObjectOwner.ToString();
1980 }
1981
1982 public void llInstantMessage(string user, string message)
1983 {
1984 m_host.AddScriptLPS(1);
1985
1986 // We may be able to use ClientView.SendInstantMessage here, but we need a client instance.
1987 // InstantMessageModule.OnInstantMessage searches through a list of scenes for a client matching the toAgent,
1988 // but I don't think we have a list of scenes available from here.
1989 // (We also don't want to duplicate the code in OnInstantMessage if we can avoid it.)
1990
1991 // user is a UUID
1992
1993 // TODO: figure out values for client, fromSession, and imSessionID
1994 // client.SendInstantMessage(m_host.UUID, fromSession, message, user, imSessionID, m_host.Name, AgentManager.InstantMessageDialog.MessageFromAgent, (uint)Util.UnixTimeSinceEpoch());
1995 LLUUID friendTransactionID = LLUUID.Random();
1996
1997 //m_pendingFriendRequests.Add(friendTransactionID, fromAgentID);
1998
1999 GridInstantMessage msg = new GridInstantMessage();
2000 msg.fromAgentID = new Guid(m_host.UUID.ToString()); // fromAgentID.UUID;
2001 msg.fromAgentSession = new Guid(friendTransactionID.ToString());// fromAgentSession.UUID;
2002 msg.toAgentID = new Guid(user); // toAgentID.UUID;
2003 msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here
2004// Console.WriteLine("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message);
2005// Console.WriteLine("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString());
2006 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();// timestamp;
2007 //if (client != null)
2008 //{
2009 msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName;
2010 //}
2011 //else
2012 //{
2013 // msg.fromAgentName = "(hippos)";// Added for posterity. This means that we can't figure out who sent it
2014 //}
2015 msg.message = message;
2016 msg.dialog = (byte)19; // messgage from script ??? // dialog;
2017 msg.fromGroup = false;// fromGroup;
2018 msg.offline = (byte)0; //offline;
2019 msg.ParentEstateID = 0; //ParentEstateID;
2020 msg.Position = new sLLVector3();// new sLLVector3(m_host.AbsolutePosition);
2021 msg.RegionID = World.RegionInfo.RegionID.UUID;//RegionID.UUID;
2022 msg.binaryBucket = new byte[0];// binaryBucket;
2023 World.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule);
2024 // NotImplemented("llInstantMessage");
2025 }
2026
2027 public void llEmail(string address, string subject, string message)
2028 {
2029 m_host.AddScriptLPS(1);
2030 NotImplemented("llEmail");
2031 }
2032
2033 public void llGetNextEmail(string address, string subject)
2034 {
2035 m_host.AddScriptLPS(1);
2036 NotImplemented("llGetNextEmail");
2037 }
2038
2039 public string llGetKey()
2040 {
2041 m_host.AddScriptLPS(1);
2042 return m_host.UUID.ToString();
2043 }
2044
2045 public void llSetBuoyancy(double buoyancy)
2046 {
2047 m_host.AddScriptLPS(1);
2048 if (m_host.ParentGroup != null)
2049 {
2050 if (m_host.ParentGroup.RootPart != null)
2051 {
2052 m_host.ParentGroup.RootPart.SetBuoyancy((float)buoyancy);
2053 }
2054 }
2055 }
2056
2057
2058
2059 public void llSetHoverHeight(double height, int water, double tau)
2060 {
2061 m_host.AddScriptLPS(1);
2062 NotImplemented("llSetHoverHeight");
2063 }
2064
2065 public void llStopHover()
2066 {
2067 m_host.AddScriptLPS(1);
2068 NotImplemented("llStopHover");
2069 }
2070
2071 public void llMinEventDelay(double delay)
2072 {
2073 m_host.AddScriptLPS(1);
2074 NotImplemented("llMinEventDelay");
2075 }
2076
2077 public void llSoundPreload()
2078 {
2079 m_host.AddScriptLPS(1);
2080 NotImplemented("llSoundPreload");
2081 }
2082
2083 public void llRotLookAt(LSL_Types.Quaternion target, double strength, double damping)
2084 {
2085 m_host.AddScriptLPS(1);
2086 NotImplemented("llRotLookAt");
2087 }
2088
2089 public LSL_Types.LSLInteger llStringLength(string str)
2090 {
2091 m_host.AddScriptLPS(1);
2092 if (str.Length > 0)
2093 {
2094 return str.Length;
2095 }
2096 else
2097 {
2098 return 0;
2099 }
2100 }
2101
2102 public void llStartAnimation(string anim)
2103 {
2104 m_host.AddScriptLPS(1);
2105
2106 LLUUID invItemID=InventorySelf();
2107 if (invItemID == LLUUID.Zero)
2108 return;
2109
2110 if (m_host.TaskInventory[invItemID].PermsGranter == LLUUID.Zero)
2111 return;
2112
2113 if ((m_host.TaskInventory[invItemID].PermsMask & BuiltIn_Commands_BaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
2114 {
2115 ScenePresence presence = World.GetScenePresence(m_host.TaskInventory[invItemID].PermsGranter);
2116
2117 if (presence != null)
2118 {
2119 // Do NOT try to parse LLUUID, animations cannot be triggered by ID
2120 LLUUID animID=InventoryKey(anim, (int)AssetType.Animation);
2121 if (animID == LLUUID.Zero)
2122 presence.AddAnimation(anim);
2123 else
2124 presence.AddAnimation(animID);
2125 }
2126 }
2127 }
2128
2129 public void llStopAnimation(string anim)
2130 {
2131 m_host.AddScriptLPS(1);
2132
2133 LLUUID invItemID=InventorySelf();
2134 if (invItemID == LLUUID.Zero)
2135 return;
2136
2137 if (m_host.TaskInventory[invItemID].PermsGranter == LLUUID.Zero)
2138 return;
2139
2140 if ((m_host.TaskInventory[invItemID].PermsMask & BuiltIn_Commands_BaseClass.PERMISSION_TRIGGER_ANIMATION) != 0)
2141 {
2142 LLUUID animID = new LLUUID();
2143
2144 if (!LLUUID.TryParse(anim, out animID))
2145 {
2146 animID=InventoryKey(anim);
2147 }
2148
2149 if (animID == LLUUID.Zero)
2150 return;
2151
2152 ScenePresence presence = World.GetScenePresence(m_host.TaskInventory[invItemID].PermsGranter);
2153
2154 if (presence != null)
2155 {
2156 if (animID == LLUUID.Zero)
2157 presence.RemoveAnimation(anim);
2158 else
2159 presence.RemoveAnimation(animID);
2160 }
2161 }
2162 }
2163
2164 public void llPointAt()
2165 {
2166 m_host.AddScriptLPS(1);
2167 NotImplemented("llPointAt");
2168 }
2169
2170 public void llStopPointAt()
2171 {
2172 m_host.AddScriptLPS(1);
2173 NotImplemented("llStopPointAt");
2174 }
2175
2176 public void llTargetOmega(LSL_Types.Vector3 axis, double spinrate, double gain)
2177 {
2178 m_host.AddScriptLPS(1);
2179 m_host.RotationalVelocity = new LLVector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate));
2180 m_host.AngularVelocity = new LLVector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate));
2181 m_host.ScheduleTerseUpdate();
2182 m_host.SendTerseUpdateToAllClients();
2183 }
2184
2185 public LSL_Types.LSLInteger llGetStartParameter()
2186 {
2187 m_host.AddScriptLPS(1);
2188 // NotImplemented("llGetStartParameter");
2189 return m_host.ParentGroup.StartParameter;
2190 }
2191
2192 public void llGodLikeRezObject(string inventory, LSL_Types.Vector3 pos)
2193 {
2194 m_host.AddScriptLPS(1);
2195 NotImplemented("llGodLikeRezObject");
2196 }
2197
2198 public void llRequestPermissions(string agent, int perm)
2199 {
2200 LLUUID agentID=new LLUUID();
2201
2202 if (!LLUUID.TryParse(agent, out agentID))
2203 return;
2204
2205 LLUUID invItemID=InventorySelf();
2206
2207 if (invItemID == LLUUID.Zero)
2208 return; // Not in a prim? How??
2209
2210 if (agentID == LLUUID.Zero || perm == 0) // Releasing permissions
2211 {
2212 m_host.TaskInventory[invItemID].PermsGranter=LLUUID.Zero;
2213 m_host.TaskInventory[invItemID].PermsMask=0;
2214
2215 m_ScriptEngine.PostScriptEvent(m_itemID, new XEventParams(
2216 "run_time_permissions", new Object[] {
2217 new LSL_Types.LSLInteger(0) },
2218 new XDetectParams[0]));
2219
2220 return;
2221 }
2222
2223 m_host.AddScriptLPS(1);
2224
2225 if (m_host.ParentGroup.RootPart.m_IsAttachment && agent == m_host.ParentGroup.RootPart.m_attachedAvatar)
2226 {
2227 // When attached, certain permissions are implicit if requested from owner
2228 int implicitPerms = BuiltIn_Commands_BaseClass.PERMISSION_TAKE_CONTROLS |
2229 BuiltIn_Commands_BaseClass.PERMISSION_TRIGGER_ANIMATION |
2230 BuiltIn_Commands_BaseClass.PERMISSION_ATTACH;
2231
2232 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
2233 {
2234 m_host.TaskInventory[invItemID].PermsGranter=agentID;
2235 m_host.TaskInventory[invItemID].PermsMask=perm;
2236
2237 m_ScriptEngine.PostScriptEvent(m_itemID, new XEventParams(
2238 "run_time_permissions", new Object[] {
2239 new LSL_Types.LSLInteger(perm) },
2240 new XDetectParams[0]));
2241
2242 return;
2243 }
2244 }
2245 else if (m_host.m_sitTargetAvatar == agentID) // Sitting avatar
2246 {
2247 // When agent is sitting, certain permissions are implicit if requested from sitting agent
2248 int implicitPerms = BuiltIn_Commands_BaseClass.PERMISSION_TRIGGER_ANIMATION |
2249 BuiltIn_Commands_BaseClass.PERMISSION_TRACK_CAMERA;
2250
2251 if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
2252 {
2253 m_host.TaskInventory[invItemID].PermsGranter=agentID;
2254 m_host.TaskInventory[invItemID].PermsMask=perm;
2255
2256 m_ScriptEngine.PostScriptEvent(m_itemID, new XEventParams(
2257 "run_time_permissions", new Object[] {
2258 new LSL_Types.LSLInteger(perm) },
2259 new XDetectParams[0]));
2260
2261 return;
2262 }
2263 }
2264
2265 ScenePresence presence = World.GetScenePresence(agentID);
2266
2267 if (presence != null)
2268 {
2269 string ownerName=resolveName(m_host.ParentGroup.RootPart.OwnerID);
2270 if (ownerName == String.Empty)
2271 ownerName="(hippos)";
2272
2273 if (!m_waitingForScriptAnswer)
2274 {
2275 m_host.TaskInventory[invItemID].PermsGranter=agentID;
2276 m_host.TaskInventory[invItemID].PermsMask=0;
2277 presence.ControllingClient.OnScriptAnswer+=handleScriptAnswer;
2278 m_waitingForScriptAnswer=true;
2279 }
2280
2281 presence.ControllingClient.SendScriptQuestion(m_host.UUID, m_host.ParentGroup.RootPart.Name, ownerName, invItemID, perm);
2282 return;
2283 }
2284
2285 // Requested agent is not in range, refuse perms
2286 m_ScriptEngine.PostScriptEvent(m_itemID, new XEventParams(
2287 "run_time_permissions", new Object[] {
2288 new LSL_Types.LSLInteger(0) },
2289 new XDetectParams[0]));
2290 }
2291
2292 void handleScriptAnswer(IClientAPI client, LLUUID taskID, LLUUID itemID, int answer)
2293 {
2294 if (taskID != m_host.UUID)
2295 return;
2296
2297 LLUUID invItemID=InventorySelf();
2298
2299 if (invItemID == LLUUID.Zero)
2300 return;
2301
2302 client.OnScriptAnswer-=handleScriptAnswer;
2303 m_waitingForScriptAnswer=false;
2304
2305 m_host.TaskInventory[invItemID].PermsMask=answer;
2306 m_ScriptEngine.PostScriptEvent(m_itemID, new XEventParams(
2307 "run_time_permissions", new Object[] {
2308 new LSL_Types.LSLInteger(answer) },
2309 new XDetectParams[0]));
2310 }
2311
2312 public string llGetPermissionsKey()
2313 {
2314 m_host.AddScriptLPS(1);
2315
2316 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
2317 {
2318 if (item.Type == 10 && item.ItemID == m_itemID)
2319 {
2320 return item.PermsGranter.ToString();
2321 }
2322 }
2323
2324 return LLUUID.Zero.ToString();
2325 }
2326
2327 public LSL_Types.LSLInteger llGetPermissions()
2328 {
2329 m_host.AddScriptLPS(1);
2330
2331 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
2332 {
2333 if (item.Type == 10 && item.ItemID == m_itemID)
2334 {
2335 return item.PermsMask;
2336 }
2337 }
2338
2339 return 0;
2340 }
2341
2342 public LSL_Types.LSLInteger llGetLinkNumber()
2343 {
2344 m_host.AddScriptLPS(1);
2345
2346 if (m_host.ParentGroup.Children.Count > 0)
2347 {
2348 return m_host.LinkNum + 1;
2349 }
2350 else
2351 {
2352 return 0;
2353 }
2354 }
2355
2356 public void llSetLinkColor(int linknumber, LSL_Types.Vector3 color, int face)
2357 {
2358 m_host.AddScriptLPS(1);
2359 SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknumber);
2360 if (linknumber > -1)
2361 {
2362 LLObject.TextureEntry tex = part.Shape.Textures;
2363 LLColor texcolor;
2364 if (face > -1)
2365 {
2366 texcolor = tex.CreateFace((uint)face).RGBA;
2367 texcolor.R = (float)Math.Abs(color.x - 1);
2368 texcolor.G = (float)Math.Abs(color.y - 1);
2369 texcolor.B = (float)Math.Abs(color.z - 1);
2370 tex.FaceTextures[face].RGBA = texcolor;
2371 part.UpdateTexture(tex);
2372 return;
2373 }
2374 else if (face == -1)
2375 {
2376 texcolor = tex.DefaultTexture.RGBA;
2377 texcolor.R = (float)Math.Abs(color.x - 1);
2378 texcolor.G = (float)Math.Abs(color.y - 1);
2379 texcolor.B = (float)Math.Abs(color.z - 1);
2380 tex.DefaultTexture.RGBA = texcolor;
2381 for (uint i = 0; i < 32; i++)
2382 {
2383 if (tex.FaceTextures[i] != null)
2384 {
2385 texcolor = tex.FaceTextures[i].RGBA;
2386 texcolor.R = (float)Math.Abs(color.x - 1);
2387 texcolor.G = (float)Math.Abs(color.y - 1);
2388 texcolor.B = (float)Math.Abs(color.z - 1);
2389 tex.FaceTextures[i].RGBA = texcolor;
2390 }
2391 }
2392 texcolor = tex.DefaultTexture.RGBA;
2393 texcolor.R = (float)Math.Abs(color.x - 1);
2394 texcolor.G = (float)Math.Abs(color.y - 1);
2395 texcolor.B = (float)Math.Abs(color.z - 1);
2396 tex.DefaultTexture.RGBA = texcolor;
2397 part.UpdateTexture(tex);
2398 return;
2399 }
2400 return;
2401 }
2402 else if (linknumber == -1)
2403 {
2404 int num = m_host.ParentGroup.PrimCount;
2405 for (int w = 0; w < num; w++)
2406 {
2407 linknumber = w;
2408 part = m_host.ParentGroup.GetLinkNumPart(linknumber);
2409 LLObject.TextureEntry tex = part.Shape.Textures;
2410 LLColor texcolor;
2411 if (face > -1)
2412 {
2413 texcolor = tex.CreateFace((uint)face).RGBA;
2414 texcolor.R = (float)Math.Abs(color.x - 1);
2415 texcolor.G = (float)Math.Abs(color.y - 1);
2416 texcolor.B = (float)Math.Abs(color.z - 1);
2417 tex.FaceTextures[face].RGBA = texcolor;
2418 part.UpdateTexture(tex);
2419 }
2420 else if (face == -1)
2421 {
2422 texcolor = tex.DefaultTexture.RGBA;
2423 texcolor.R = (float)Math.Abs(color.x - 1);
2424 texcolor.G = (float)Math.Abs(color.y - 1);
2425 texcolor.B = (float)Math.Abs(color.z - 1);
2426 tex.DefaultTexture.RGBA = texcolor;
2427 for (uint i = 0; i < 32; i++)
2428 {
2429 if (tex.FaceTextures[i] != null)
2430 {
2431 texcolor = tex.FaceTextures[i].RGBA;
2432 texcolor.R = (float)Math.Abs(color.x - 1);
2433 texcolor.G = (float)Math.Abs(color.y - 1);
2434 texcolor.B = (float)Math.Abs(color.z - 1);
2435 tex.FaceTextures[i].RGBA = texcolor;
2436 }
2437 }
2438 texcolor = tex.DefaultTexture.RGBA;
2439 texcolor.R = (float)Math.Abs(color.x - 1);
2440 texcolor.G = (float)Math.Abs(color.y - 1);
2441 texcolor.B = (float)Math.Abs(color.z - 1);
2442 tex.DefaultTexture.RGBA = texcolor;
2443 part.UpdateTexture(tex);
2444 }
2445 }
2446 return;
2447 }
2448 }
2449
2450 public void llCreateLink(string target, int parent)
2451 {
2452 m_host.AddScriptLPS(1);
2453 NotImplemented("llCreateLink");
2454 }
2455
2456 public void llBreakLink(int linknum)
2457 {
2458 m_host.AddScriptLPS(1);
2459 NotImplemented("llBreakLink");
2460 }
2461
2462 public void llBreakAllLinks()
2463 {
2464 m_host.AddScriptLPS(1);
2465 NotImplemented("llBreakAllLinks");
2466 }
2467
2468 public string llGetLinkKey(int linknum)
2469 {
2470 m_host.AddScriptLPS(1);
2471 SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknum);
2472 if (part != null)
2473 {
2474 return part.UUID.ToString();
2475 }
2476 else
2477 {
2478 return LLUUID.Zero.ToString();
2479 }
2480 }
2481
2482 public string llGetLinkName(int linknum)
2483 {
2484 m_host.AddScriptLPS(1);
2485 SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknum);
2486 if (part != null)
2487 {
2488 return part.Name;
2489 }
2490 else
2491 {
2492 return LLUUID.Zero.ToString();
2493 }
2494 }
2495
2496 public LSL_Types.LSLInteger llGetInventoryNumber(int type)
2497 {
2498 m_host.AddScriptLPS(1);
2499 int count = 0;
2500 foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory)
2501 {
2502 if (inv.Value.Type == type || type == -1)
2503 {
2504 count = count + 1;
2505 }
2506 }
2507 return count;
2508 }
2509
2510 public string llGetInventoryName(int type, int number)
2511 {
2512 m_host.AddScriptLPS(1);
2513 ArrayList keys = new ArrayList();
2514 foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory)
2515 {
2516 if (inv.Value.Type == type || type == -1)
2517 {
2518 keys.Add(inv.Value.Name);
2519 }
2520 }
2521 if (keys.Count == 0)
2522 {
2523 return String.Empty;
2524 }
2525 keys.Sort();
2526 if (keys.Count > number)
2527 {
2528 return (string)keys[number];
2529 }
2530 return String.Empty;
2531 }
2532
2533 public void llSetScriptState(string name, int run)
2534 {
2535 LLUUID item;
2536
2537 m_host.AddScriptLPS(1);
2538
2539 // These functions are supposed to be robust,
2540 // so get the state one step at a time.
2541
2542 if ((item = ScriptByName(name)) != LLUUID.Zero)
2543 {
2544 m_ScriptEngine.SetScriptState(item, run == 0 ? false : true);
2545 }
2546 else
2547 {
2548 ShoutError("llSetScriptState: script "+name+" not found");
2549 }
2550 }
2551
2552 public double llGetEnergy()
2553 {
2554 m_host.AddScriptLPS(1);
2555 // TODO: figure out real energy value
2556 return 1.0f;
2557 }
2558
2559 public void llGiveInventory(string destination, string inventory)
2560 {
2561 m_host.AddScriptLPS(1);
2562 NotImplemented("llGiveInventory");
2563 }
2564
2565 public void llRemoveInventory(string item)
2566 {
2567 m_host.AddScriptLPS(1);
2568 NotImplemented("llRemoveInventory");
2569 }
2570
2571 public void llSetText(string text, LSL_Types.Vector3 color, double alpha)
2572 {
2573 m_host.AddScriptLPS(1);
2574 Vector3 av3 = new Vector3((float)color.x, (float)color.y, (float)color.z);
2575 m_host.SetText(text, av3, alpha);
2576 }
2577
2578 public double llWater(LSL_Types.Vector3 offset)
2579 {
2580 m_host.AddScriptLPS(1);
2581 return World.RegionInfo.EstateSettings.waterHeight;
2582 }
2583
2584 public void llPassTouches(int pass)
2585 {
2586 m_host.AddScriptLPS(1);
2587 NotImplemented("llPassTouches");
2588 }
2589
2590 public string llRequestAgentData(string id, int data)
2591 {
2592 m_host.AddScriptLPS(1);
2593
2594 UserProfileData userProfile =
2595 World.CommsManager.UserService.GetUserProfile(id);
2596
2597 UserAgentData userAgent =
2598 World.CommsManager.UserService.GetAgentByUUID(id);
2599
2600 if (userProfile == null || userAgent == null)
2601 return LLUUID.Zero.ToString();
2602
2603 string reply = String.Empty;
2604
2605 switch (data)
2606 {
2607 case 1: // DATA_ONLINE (0|1)
2608 // TODO: implement fetching of this information
2609 if (userProfile.CurrentAgent.AgentOnline)
2610 reply = "1";
2611 else
2612 reply = "0";
2613 break;
2614 case 2: // DATA_NAME (First Last)
2615 reply = userProfile.FirstName + " " + userProfile.SurName;
2616 break;
2617 case 3: // DATA_BORN (YYYY-MM-DD)
2618 DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0);
2619 born = born.AddSeconds(userProfile.Created);
2620 reply = born.ToString("yyyy-MM-dd");
2621 break;
2622 case 4: // DATA_RATING (0,0,0,0,0,0)
2623 reply = "0,0,0,0,0,0";
2624 break;
2625 case 8: // DATA_PAYINFO (0|1|2|3)
2626 reply = "0";
2627 break;
2628 default:
2629 return LLUUID.Zero.ToString(); // Raise no event
2630 }
2631
2632 LLUUID rq = LLUUID.Random();
2633
2634 LLUUID tid = m_ScriptEngine.m_ASYNCLSLCommandManager.
2635 m_Dataserver.RegisterRequest(m_localID,
2636 m_itemID, rq.ToString());
2637
2638 m_ScriptEngine.m_ASYNCLSLCommandManager.
2639 m_Dataserver.DataserverReply(rq.ToString(), reply);
2640
2641 return tid.ToString();
2642 }
2643
2644 public string llRequestInventoryData(string name)
2645 {
2646 m_host.AddScriptLPS(1);
2647
2648 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
2649 {
2650 if (item.Type == 3 && item.Name == name)
2651 {
2652 LLUUID tid = m_ScriptEngine.m_ASYNCLSLCommandManager.
2653 m_Dataserver.RegisterRequest(m_localID,
2654 m_itemID, item.AssetID.ToString());
2655
2656 LLVector3 region = new LLVector3(
2657 World.RegionInfo.RegionLocX * Constants.RegionSize,
2658 World.RegionInfo.RegionLocY * Constants.RegionSize,
2659 0);
2660
2661 World.AssetCache.GetAsset(item.AssetID,
2662 delegate(LLUUID i, AssetBase a)
2663 {
2664 AssetLandmark lm = new AssetLandmark(a);
2665
2666 region += lm.Position;
2667
2668 string reply = region.ToString();
2669
2670 m_ScriptEngine.m_ASYNCLSLCommandManager.
2671 m_Dataserver.DataserverReply(i.ToString(),
2672 reply);
2673 }, false);
2674
2675 return tid.ToString();
2676 }
2677 }
2678
2679 return String.Empty;
2680 }
2681
2682 public void llSetDamage(double damage)
2683 {
2684 m_host.AddScriptLPS(1);
2685 NotImplemented("llSetDamage");
2686 }
2687
2688 public void llTeleportAgentHome(string agent)
2689 {
2690 m_host.AddScriptLPS(1);
2691 NotImplemented("llTeleportAgentHome");
2692 }
2693
2694 public void llModifyLand(int action, int brush)
2695 {
2696 m_host.AddScriptLPS(1);
2697 World.ExternalChecks.ExternalChecksCanTerraformLand(m_host.OwnerID, new LLVector3(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, 0));
2698 }
2699
2700 public void llCollisionSound(string impact_sound, double impact_volume)
2701 {
2702 m_host.AddScriptLPS(1);
2703 NotImplemented("llCollisionSound");
2704 }
2705
2706 public void llCollisionSprite(string impact_sprite)
2707 {
2708 m_host.AddScriptLPS(1);
2709 NotImplemented("llCollisionSprite");
2710 }
2711
2712 public string llGetAnimation(string id)
2713 {
2714 m_host.AddScriptLPS(1);
2715 NotImplemented("llGetAnimation");
2716 return String.Empty;
2717 }
2718
2719 public void llResetScript()
2720 {
2721 m_host.AddScriptLPS(1);
2722 m_ScriptEngine.ResetScript(m_itemID);
2723 }
2724
2725 public void llMessageLinked(int linknum, int num, string msg, string id)
2726 {
2727
2728 m_host.AddScriptLPS(1);
2729
2730 uint partLocalID;
2731 LLUUID partItemID;
2732
2733 switch ((int)linknum)
2734 {
2735
2736 case (int)BuiltIn_Commands_BaseClass.LINK_ROOT:
2737
2738 SceneObjectPart part = m_host.ParentGroup.RootPart;
2739
2740 foreach (TaskInventoryItem item in part.TaskInventory.Values)
2741 {
2742 if (item.Type == 10)
2743 {
2744 partLocalID = part.LocalId;
2745 partItemID = item.ItemID;
2746
2747 object[] resobj = new object[]
2748 {
2749 new LSL_Types.LSLInteger(m_host.LinkNum + 1), new LSL_Types.LSLInteger(num), new LSL_Types.LSLString(msg), new LSL_Types.LSLString(id)
2750 };
2751
2752 m_ScriptEngine.PostScriptEvent(partItemID,
2753 new XEventParams("link_message",
2754 resobj, new XDetectParams[0]));
2755 }
2756 }
2757
2758 break;
2759
2760 case (int)BuiltIn_Commands_BaseClass.LINK_SET:
2761
2762 foreach (SceneObjectPart partInst in m_host.ParentGroup.GetParts())
2763 {
2764
2765 foreach (TaskInventoryItem item in partInst.TaskInventory.Values)
2766 {
2767 if (item.Type == 10)
2768 {
2769 partLocalID = partInst.LocalId;
2770 partItemID = item.ItemID;
2771 Object[] resobj = new object[]
2772 {
2773 new LSL_Types.LSLInteger(m_host.LinkNum + 1), new LSL_Types.LSLInteger(num), new LSL_Types.LSLString(msg), new LSL_Types.LSLString(id)
2774 };
2775
2776 m_ScriptEngine.PostScriptEvent(partItemID,
2777 new XEventParams("link_message",
2778 resobj, new XDetectParams[0]));
2779 }
2780 }
2781 }
2782
2783 break;
2784
2785 case (int)BuiltIn_Commands_BaseClass.LINK_ALL_OTHERS:
2786
2787 foreach (SceneObjectPart partInst in m_host.ParentGroup.GetParts())
2788 {
2789
2790 if (partInst.LocalId != m_host.LocalId)
2791 {
2792
2793 foreach (TaskInventoryItem item in partInst.TaskInventory.Values)
2794 {
2795 if (item.Type == 10)
2796 {
2797 partLocalID = partInst.LocalId;
2798 partItemID = item.ItemID;
2799 Object[] resobj = new object[]
2800 {
2801 new LSL_Types.LSLInteger(m_host.LinkNum + 1), new LSL_Types.LSLInteger(num), new LSL_Types.LSLString(msg), new LSL_Types.LSLString(id)
2802 };
2803
2804 m_ScriptEngine.PostScriptEvent(partItemID,
2805 new XEventParams("link_message",
2806 resobj, new XDetectParams[0]));
2807 }
2808 }
2809
2810 }
2811 }
2812
2813 break;
2814
2815 case (int)BuiltIn_Commands_BaseClass.LINK_ALL_CHILDREN:
2816
2817 foreach (SceneObjectPart partInst in m_host.ParentGroup.GetParts())
2818 {
2819
2820 if (partInst.LocalId != m_host.ParentGroup.RootPart.LocalId)
2821 {
2822
2823 foreach (TaskInventoryItem item in partInst.TaskInventory.Values)
2824 {
2825 if (item.Type == 10)
2826 {
2827 partLocalID = partInst.LocalId;
2828 partItemID = item.ItemID;
2829 Object[] resobj = new object[]
2830 {
2831 new LSL_Types.LSLInteger(m_host.LinkNum + 1), new LSL_Types.LSLInteger(num), new LSL_Types.LSLString(msg), new LSL_Types.LSLString(id)
2832 };
2833
2834 m_ScriptEngine.PostScriptEvent(partItemID,
2835 new XEventParams("link_message",
2836 resobj, new XDetectParams[0]));
2837 }
2838 }
2839
2840 }
2841 }
2842
2843 break;
2844
2845 case (int)BuiltIn_Commands_BaseClass.LINK_THIS:
2846
2847 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
2848 {
2849 if (item.Type == 10)
2850 {
2851 partItemID = item.ItemID;
2852
2853 object[] resobj = new object[]
2854 {
2855 new LSL_Types.LSLInteger(m_host.LinkNum + 1), new LSL_Types.LSLInteger(num), new LSL_Types.LSLString(msg), new LSL_Types.LSLString(id)
2856 };
2857
2858 m_ScriptEngine.PostScriptEvent(partItemID,
2859 new XEventParams("link_message",
2860 resobj, new XDetectParams[0]));
2861 }
2862 }
2863
2864 break;
2865
2866 default:
2867
2868 foreach (SceneObjectPart partInst in m_host.ParentGroup.GetParts())
2869 {
2870
2871 if ((partInst.LinkNum + 1) == linknum)
2872 {
2873
2874 foreach (TaskInventoryItem item in partInst.TaskInventory.Values)
2875 {
2876 if (item.Type == 10)
2877 {
2878 partLocalID = partInst.LocalId;
2879 partItemID = item.ItemID;
2880 Object[] resObjDef = new object[]
2881 {
2882 new LSL_Types.LSLInteger(m_host.LinkNum + 1), new LSL_Types.LSLInteger(num), new LSL_Types.LSLString(msg), new LSL_Types.LSLString(id)
2883 };
2884
2885 m_ScriptEngine.PostScriptEvent(partItemID,
2886 new XEventParams("link_message",
2887 resObjDef, new XDetectParams[0]));
2888 }
2889 }
2890
2891 }
2892 }
2893
2894 break;
2895
2896 }
2897
2898 }
2899
2900 public void llPushObject(string target, LSL_Types.Vector3 impulse, LSL_Types.Vector3 ang_impulse, int local)
2901 {
2902 m_host.AddScriptLPS(1);
2903 NotImplemented("llPushObject");
2904 }
2905
2906 public void llPassCollisions(int pass)
2907 {
2908 m_host.AddScriptLPS(1);
2909 NotImplemented("llPassCollisions");
2910 }
2911
2912 public string llGetScriptName()
2913 {
2914
2915 string result = String.Empty;
2916
2917 m_host.AddScriptLPS(1);
2918
2919 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
2920 {
2921 if (item.Type == 10 && item.ItemID == m_itemID)
2922 {
2923 result = item.Name!=null?item.Name:String.Empty;
2924 break;
2925 }
2926 }
2927
2928 return result;
2929
2930 }
2931
2932 public LSL_Types.LSLInteger llGetNumberOfSides()
2933 {
2934 m_host.AddScriptLPS(1);
2935 NotImplemented("llGetNumberOfSides");
2936 return 0;
2937 }
2938
2939
2940 /* The new / changed functions were tested with the following LSL script:
2941
2942 default
2943 {
2944 state_entry()
2945 {
2946 rotation rot = llEuler2Rot(<0,70,0> * DEG_TO_RAD);
2947
2948 llOwnerSay("to get here, we rotate over: "+ (string) llRot2Axis(rot));
2949 llOwnerSay("and we rotate for: "+ (llRot2Angle(rot) * RAD_TO_DEG));
2950
2951 // convert back and forth between quaternion <-> vector and angle
2952
2953 rotation newrot = llAxisAngle2Rot(llRot2Axis(rot),llRot2Angle(rot));
2954
2955 llOwnerSay("Old rotation was: "+(string) rot);
2956 llOwnerSay("re-converted rotation is: "+(string) newrot);
2957
2958 llSetRot(rot); // to check the parameters in the prim
2959 }
2960 }
2961 */
2962
2963
2964
2965 // Xantor 29/apr/2008
2966 // Returns rotation described by rotating angle radians about axis.
2967 // q = cos(a/2) + i (x * sin(a/2)) + j (y * sin(a/2)) + k (z * sin(a/2))
2968 public LSL_Types.Quaternion llAxisAngle2Rot(LSL_Types.Vector3 axis, double angle)
2969 {
2970 m_host.AddScriptLPS(1);
2971
2972 double x, y, z, s, t;
2973
2974 s = Math.Cos(angle / 2);
2975 t = Math.Sin(angle / 2); // temp value to avoid 2 more sin() calcs
2976 x = axis.x * t;
2977 y = axis.y * t;
2978 z = axis.z * t;
2979
2980 return new LSL_Types.Quaternion(x,y,z,s);
2981 }
2982
2983
2984 // Xantor 29/apr/2008
2985 // converts a Quaternion to X,Y,Z axis rotations
2986 public LSL_Types.Vector3 llRot2Axis(LSL_Types.Quaternion rot)
2987 {
2988 m_host.AddScriptLPS(1);
2989 double x,y,z;
2990
2991 if (rot.s > 1) // normalization needed
2992 {
2993 double length = Math.Sqrt(rot.x * rot.x + rot.y * rot.y +
2994 rot.z * rot.z + rot.s * rot.s);
2995
2996 rot.x /= length;
2997 rot.y /= length;
2998 rot.z /= length;
2999 rot.s /= length;
3000
3001 }
3002
3003 double angle = 2 * Math.Acos(rot.s);
3004 double s = Math.Sqrt(1 - rot.s * rot.s);
3005 if (s < 0.001)
3006 {
3007 x = 1;
3008 y = z = 0;
3009 }
3010 else
3011 {
3012 x = rot.x / s; // normalise axis
3013 y = rot.y / s;
3014 z = rot.z / s;
3015 }
3016
3017
3018 return new LSL_Types.Vector3(x,y,z);
3019
3020
3021// NotImplemented("llRot2Axis");
3022 }
3023
3024
3025 // Returns the angle of a quaternion (see llRot2Axis for the axis)
3026 public double llRot2Angle(LSL_Types.Quaternion rot)
3027 {
3028 m_host.AddScriptLPS(1);
3029
3030 if (rot.s > 1) // normalization needed
3031 {
3032 double length = Math.Sqrt(rot.x * rot.x + rot.y * rot.y +
3033 rot.z * rot.z + rot.s * rot.s);
3034
3035 rot.x /= length;
3036 rot.y /= length;
3037 rot.z /= length;
3038 rot.s /= length;
3039
3040 }
3041
3042 double angle = 2 * Math.Acos(rot.s);
3043
3044 return angle;
3045
3046// NotImplemented("llRot2Angle");
3047 }
3048
3049 public double llAcos(double val)
3050 {
3051 m_host.AddScriptLPS(1);
3052 return (double)Math.Acos(val);
3053 }
3054
3055 public double llAsin(double val)
3056 {
3057 m_host.AddScriptLPS(1);
3058 return (double)Math.Asin(val);
3059 }
3060
3061 // Xantor 30/apr/2008
3062 public double llAngleBetween(LSL_Types.Quaternion a, LSL_Types.Quaternion b)
3063 {
3064 m_host.AddScriptLPS(1);
3065
3066 return (double) Math.Acos(a.x * b.x + a.y * b.y + a.z * b.z + a.s * b.s) * 2;
3067 }
3068
3069 public string llGetInventoryKey(string name)
3070 {
3071 m_host.AddScriptLPS(1);
3072 foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory)
3073 {
3074 if (inv.Value.Name == name)
3075 {
3076 if ((inv.Value.OwnerMask & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify))
3077 {
3078 return inv.Value.AssetID.ToString();
3079 }
3080 else
3081 {
3082 return LLUUID.Zero.ToString();
3083 }
3084 }
3085 }
3086 return LLUUID.Zero.ToString();
3087 }
3088
3089 public void llAllowInventoryDrop(int add)
3090 {
3091 m_host.AddScriptLPS(1);
3092 NotImplemented("llAllowInventoryDrop");
3093 }
3094
3095 public LSL_Types.Vector3 llGetSunDirection()
3096 {
3097 m_host.AddScriptLPS(1);
3098
3099 LSL_Types.Vector3 SunDoubleVector3;
3100 LLVector3 SunFloatVector3;
3101
3102 // sunPosition estate setting is set in OpenSim.Region.Environment.Modules.SunModule
3103 // have to convert from LLVector3 (float) to LSL_Types.Vector3 (double)
3104 SunFloatVector3 = World.RegionInfo.EstateSettings.sunPosition;
3105 SunDoubleVector3.x = (double)SunFloatVector3.X;
3106 SunDoubleVector3.y = (double)SunFloatVector3.Y;
3107 SunDoubleVector3.z = (double)SunFloatVector3.Z;
3108
3109 return SunDoubleVector3;
3110 }
3111
3112 public LSL_Types.Vector3 llGetTextureOffset(int face)
3113 {
3114 m_host.AddScriptLPS(1);
3115 LLObject.TextureEntry tex = m_host.Shape.Textures;
3116 LSL_Types.Vector3 offset;
3117 if (face == -1)
3118 {
3119 face = 0;
3120 }
3121 offset.x = tex.GetFace((uint)face).OffsetU;
3122 offset.y = tex.GetFace((uint)face).OffsetV;
3123 offset.z = 0.0;
3124 return offset;
3125 }
3126
3127 public LSL_Types.Vector3 llGetTextureScale(int side)
3128 {
3129 m_host.AddScriptLPS(1);
3130 LLObject.TextureEntry tex = m_host.Shape.Textures;
3131 LSL_Types.Vector3 scale;
3132 if (side == -1)
3133 {
3134 side = 0;
3135 }
3136 scale.x = tex.GetFace((uint)side).RepeatU;
3137 scale.y = tex.GetFace((uint)side).RepeatV;
3138 scale.z = 0.0;
3139 return scale;
3140 }
3141
3142 public double llGetTextureRot(int face)
3143 {
3144 m_host.AddScriptLPS(1);
3145 LLObject.TextureEntry tex = m_host.Shape.Textures;
3146 if (face == -1)
3147 {
3148 face = 0;
3149 }
3150 return tex.GetFace((uint)face).Rotation;
3151 }
3152
3153 public LSL_Types.LSLInteger llSubStringIndex(string source, string pattern)
3154 {
3155 m_host.AddScriptLPS(1);
3156 return source.IndexOf(pattern);
3157 }
3158
3159 public string llGetOwnerKey(string id)
3160 {
3161 m_host.AddScriptLPS(1);
3162 LLUUID key = new LLUUID();
3163 if (LLUUID.TryParse(id, out key))
3164 {
3165 return World.GetSceneObjectPart(World.Entities[key].LocalId).OwnerID.ToString();
3166 }
3167 else
3168 {
3169 return LLUUID.Zero.ToString();
3170 }
3171 }
3172
3173 public LSL_Types.Vector3 llGetCenterOfMass()
3174 {
3175 m_host.AddScriptLPS(1);
3176 NotImplemented("llGetCenterOfMass");
3177 return new LSL_Types.Vector3();
3178 }
3179
3180 public LSL_Types.list llListSort(LSL_Types.list src, int stride, int ascending)
3181 {
3182 m_host.AddScriptLPS(1);
3183 return src.Sort(stride, ascending);
3184 }
3185
3186 public LSL_Types.LSLInteger llGetListLength(LSL_Types.list src)
3187 {
3188 m_host.AddScriptLPS(1);
3189 return src.Length;
3190 }
3191
3192 public LSL_Types.LSLInteger llList2Integer(LSL_Types.list src, int index)
3193 {
3194 m_host.AddScriptLPS(1);
3195 if (index < 0)
3196 {
3197 index = src.Length + index;
3198 }
3199 if (index >= src.Length)
3200 {
3201 return 0;
3202 }
3203 try
3204 {
3205 return Convert.ToInt32(src.Data[index]);
3206 }
3207 catch (FormatException)
3208 {
3209 return 0;
3210 }
3211 }
3212
3213 public double osList2Double(LSL_Types.list src, int index)
3214 {
3215 m_host.AddScriptLPS(1);
3216 if (index < 0)
3217 {
3218 index = src.Length + index;
3219 }
3220 if (index >= src.Length)
3221 {
3222 return 0.0;
3223 }
3224 return Convert.ToDouble(src.Data[index]);
3225 }
3226
3227 public double llList2Float(LSL_Types.list src, int index)
3228 {
3229 m_host.AddScriptLPS(1);
3230 if (index < 0)
3231 {
3232 index = src.Length + index;
3233 }
3234 if (index >= src.Length)
3235 {
3236 return 0.0;
3237 }
3238 try
3239 {
3240 return Convert.ToDouble(src.Data[index]);
3241 }
3242 catch (FormatException)
3243 {
3244 return 0.0;
3245 }
3246 }
3247
3248 public string llList2String(LSL_Types.list src, int index)
3249 {
3250 m_host.AddScriptLPS(1);
3251 if (index < 0)
3252 {
3253 index = src.Length + index;
3254 }
3255 if (index >= src.Length)
3256 {
3257 return String.Empty;
3258 }
3259 return src.Data[index].ToString();
3260 }
3261
3262 public string llList2Key(LSL_Types.list src, int index)
3263 {
3264 m_host.AddScriptLPS(1);
3265 if (index < 0)
3266 {
3267 index = src.Length + index;
3268 }
3269 if (index >= src.Length)
3270 {
3271 return "";
3272 }
3273 return src.Data[index].ToString();
3274 }
3275
3276 public LSL_Types.Vector3 llList2Vector(LSL_Types.list src, int index)
3277 {
3278 m_host.AddScriptLPS(1);
3279 if (index < 0)
3280 {
3281 index = src.Length + index;
3282 }
3283 if (index >= src.Length)
3284 {
3285 return new LSL_Types.Vector3(0, 0, 0);
3286 }
3287 if (src.Data[index].GetType() == typeof(LSL_Types.Vector3))
3288 {
3289 return (LSL_Types.Vector3)src.Data[index];
3290 }
3291 else
3292 {
3293 return new LSL_Types.Vector3(src.Data[index].ToString());
3294 }
3295 }
3296
3297 public LSL_Types.Quaternion llList2Rot(LSL_Types.list src, int index)
3298 {
3299 m_host.AddScriptLPS(1);
3300 if (index < 0)
3301 {
3302 index = src.Length + index;
3303 }
3304 if (index >= src.Length)
3305 {
3306 return new LSL_Types.Quaternion(0, 0, 0, 1);
3307 }
3308 if (src.Data[index].GetType() == typeof(LSL_Types.Quaternion))
3309 {
3310 return (LSL_Types.Quaternion)src.Data[index];
3311 }
3312 else
3313 {
3314 return new LSL_Types.Quaternion(src.Data[index].ToString());
3315 }
3316 }
3317
3318 public LSL_Types.list llList2List(LSL_Types.list src, int start, int end)
3319 {
3320 m_host.AddScriptLPS(1);
3321 return src.GetSublist(start, end);
3322 }
3323
3324 public LSL_Types.list llDeleteSubList(LSL_Types.list src, int start, int end)
3325 {
3326 return src.DeleteSublist(end, start);
3327 }
3328
3329 public LSL_Types.LSLInteger llGetListEntryType(LSL_Types.list src, int index)
3330 {
3331 m_host.AddScriptLPS(1);
3332 if (index < 0)
3333 {
3334 index = src.Length + index;
3335 }
3336 if (index >= src.Length)
3337 {
3338 return 0;
3339 }
3340
3341 if (src.Data[index] is Int32)
3342 return 1;
3343 if (src.Data[index] is Double)
3344 return 2;
3345 if (src.Data[index] is String)
3346 {
3347 LLUUID tuuid;
3348 if (LLUUID.TryParse(src.Data[index].ToString(), out tuuid))
3349 {
3350 return 3;
3351 }
3352 else
3353 {
3354 return 4;
3355 }
3356 }
3357 if (src.Data[index] is LSL_Types.Vector3)
3358 return 5;
3359 if (src.Data[index] is LSL_Types.Quaternion)
3360 return 6;
3361 if (src.Data[index] is LSL_Types.list)
3362 return 7;
3363 return 0;
3364
3365 }
3366
3367 /// <summary>
3368 /// Process the supplied list and return the
3369 /// content of the list formatted as a comma
3370 /// separated list. There is a space after
3371 /// each comma.
3372 /// </summary>
3373
3374 public string llList2CSV(LSL_Types.list src)
3375 {
3376
3377 string ret = String.Empty;
3378 int x = 0;
3379
3380 m_host.AddScriptLPS(1);
3381
3382 if (src.Data.Length > 0)
3383 {
3384 ret = src.Data[x++].ToString();
3385 for (; x < src.Data.Length; x++)
3386 {
3387 ret += ", "+src.Data[x].ToString();
3388 }
3389 }
3390
3391 return ret;
3392 }
3393
3394 /// <summary>
3395 /// The supplied string is scanned for commas
3396 /// and converted into a list. Commas are only
3397 /// effective if they are encountered outside
3398 /// of '<' '>' delimiters. Any whitespace
3399 /// before or after an element is trimmed.
3400 /// </summary>
3401
3402 public LSL_Types.list llCSV2List(string src)
3403 {
3404
3405 LSL_Types.list result = new LSL_Types.list();
3406 int parens = 0;
3407 int start = 0;
3408 int length = 0;
3409
3410 m_host.AddScriptLPS(1);
3411
3412 for (int i = 0; i < src.Length; i++)
3413 {
3414 switch (src[i])
3415 {
3416 case '<':
3417 parens++;
3418 length++;
3419 break;
3420 case '>':
3421 if (parens > 0)
3422 parens--;
3423 length++;
3424 break;
3425 case ',':
3426 if (parens == 0)
3427 {
3428 result.Add(src.Substring(start,length).Trim());
3429 start += length+1;
3430 length = 0;
3431 }
3432 else
3433 {
3434 length++;
3435 }
3436 break;
3437 default:
3438 length++;
3439 break;
3440 }
3441 }
3442
3443 result.Add(src.Substring(start,length).Trim());
3444
3445 return result;
3446 }
3447
3448 /// <summary>
3449 /// Randomizes the list, be arbitrarily reordering
3450 /// sublists of stride elements. As the stride approaches
3451 /// the size of the list, the options become very
3452 /// limited.
3453 /// </summary>
3454 /// <remarks>
3455 /// This could take a while for very large list
3456 /// sizes.
3457 /// </remarks>
3458
3459 public LSL_Types.list llListRandomize(LSL_Types.list src, int stride)
3460 {
3461
3462 LSL_Types.list result;
3463 Random rand = new Random();
3464
3465 int chunkk;
3466 int[] chunks;
3467 int index1;
3468 int index2;
3469 int tmp;
3470
3471 m_host.AddScriptLPS(1);
3472
3473 if (stride == 0)
3474 stride = 1;
3475
3476 // Stride MUST be a factor of the list length
3477 // If not, then return the src list. This also
3478 // traps those cases where stride > length.
3479
3480 if (src.Length != stride && src.Length%stride == 0)
3481 {
3482 chunkk = src.Length/stride;
3483
3484 chunks = new int[chunkk];
3485
3486 for (int i = 0; i < chunkk; i++)
3487 chunks[i] = i;
3488
3489 for (int i = 0; i < chunkk - 1; i++)
3490 {
3491 // randomly select 2 chunks
3492 index1 = rand.Next(rand.Next(65536));
3493 index1 = index1%chunkk;
3494 index2 = rand.Next(rand.Next(65536));
3495 index2 = index2%chunkk;
3496
3497 // and swap their relative positions
3498 tmp = chunks[index1];
3499 chunks[index1] = chunks[index2];
3500 chunks[index2] = tmp;
3501 }
3502
3503 // Construct the randomized list
3504
3505 result = new LSL_Types.list();
3506
3507 for (int i = 0; i < chunkk; i++)
3508 {
3509 for (int j = 0; j < stride; j++)
3510 {
3511 result.Add(src.Data[chunks[i]*stride+j]);
3512 }
3513 }
3514 }
3515 else {
3516 object[] array = new object[src.Length];
3517 Array.Copy(src.Data, 0, array, 0, src.Length);
3518 result = new LSL_Types.list(array);
3519 }
3520
3521 return result;
3522
3523 }
3524
3525 /// <summary>
3526 /// Elements in the source list starting with 0 and then
3527 /// every i+stride. If the stride is negative then the scan
3528 /// is backwards producing an inverted result.
3529 /// Only those elements that are also in the specified
3530 /// range are included in the result.
3531 /// </summary>
3532
3533 public LSL_Types.list llList2ListStrided(LSL_Types.list src, int start, int end, int stride)
3534 {
3535
3536 LSL_Types.list result = new LSL_Types.list();
3537 int[] si = new int[2];
3538 int[] ei = new int[2];
3539 bool twopass = false;
3540
3541 m_host.AddScriptLPS(1);
3542
3543 // First step is always to deal with negative indices
3544
3545 if (start < 0)
3546 start = src.Length+start;
3547 if (end < 0)
3548 end = src.Length+end;
3549
3550 // Out of bounds indices are OK, just trim them
3551 // accordingly
3552
3553 if (start > src.Length)
3554 start = src.Length;
3555
3556 if (end > src.Length)
3557 end = src.Length;
3558
3559 // There may be one or two ranges to be considered
3560
3561 if (start != end)
3562 {
3563
3564 if (start <= end)
3565 {
3566 si[0] = start;
3567 ei[0] = end;
3568 }
3569 else
3570 {
3571 si[1] = start;
3572 ei[1] = src.Length;
3573 si[0] = 0;
3574 ei[0] = end;
3575 twopass = true;
3576 }
3577
3578 // The scan always starts from the beginning of the
3579 // source list, but members are only selected if they
3580 // fall within the specified sub-range. The specified
3581 // range values are inclusive.
3582 // A negative stride reverses the direction of the
3583 // scan producing an inverted list as a result.
3584
3585 if (stride == 0)
3586 stride = 1;
3587
3588 if (stride > 0)
3589 {
3590 for (int i = 0; i < src.Length; i += stride)
3591 {
3592 if (i<=ei[0] && i>=si[0])
3593 result.Add(src.Data[i]);
3594 if (twopass && i>=si[1] && i<=ei[1])
3595 result.Add(src.Data[i]);
3596 }
3597 }
3598 else if (stride < 0)
3599 {
3600 for (int i = src.Length - 1; i >= 0; i += stride)
3601 {
3602 if (i <= ei[0] && i >= si[0])
3603 result.Add(src.Data[i]);
3604 if (twopass && i >= si[1] && i <= ei[1])
3605 result.Add(src.Data[i]);
3606 }
3607 }
3608 }
3609
3610 return result;
3611 }
3612
3613 public LSL_Types.Vector3 llGetRegionCorner()
3614 {
3615 m_host.AddScriptLPS(1);
3616 return new LSL_Types.Vector3(World.RegionInfo.RegionLocX * Constants.RegionSize, World.RegionInfo.RegionLocY * Constants.RegionSize, 0);
3617 }
3618
3619 /// <summary>
3620 /// Insert the list identified by <src> into the
3621 /// list designated by <dest> such that the first
3622 /// new element has the index specified by <index>
3623 /// </summary>
3624
3625 public LSL_Types.list llListInsertList(LSL_Types.list dest, LSL_Types.list src, int index)
3626 {
3627
3628 LSL_Types.list pref = null;
3629 LSL_Types.list suff = null;
3630
3631 m_host.AddScriptLPS(1);
3632
3633 if (index < 0)
3634 {
3635 index = index+dest.Length;
3636 if (index < 0)
3637 {
3638 index = 0;
3639 }
3640 }
3641
3642 if (index != 0)
3643 {
3644 pref = dest.GetSublist(0,index-1);
3645 if (index < dest.Length)
3646 {
3647 suff = dest.GetSublist(index,-1);
3648 return pref + src + suff;
3649 }
3650 else
3651 {
3652 return pref + src;
3653 }
3654 }
3655 else
3656 {
3657 if (index < dest.Length)
3658 {
3659 suff = dest.GetSublist(index,-1);
3660 return src + suff;
3661 }
3662 else
3663 {
3664 return src;
3665 }
3666 }
3667
3668 }
3669
3670 /// <summary>
3671 /// Returns the index of the first occurrence of test
3672 /// in src.
3673 /// </summary>
3674
3675 public LSL_Types.LSLInteger llListFindList(LSL_Types.list src, LSL_Types.list test)
3676 {
3677
3678 int index = -1;
3679 int length = src.Length - test.Length + 1;
3680
3681 m_host.AddScriptLPS(1);
3682
3683 // If either list is empty, do not match
3684
3685 if (src.Length != 0 && test.Length != 0)
3686 {
3687 for (int i = 0; i < length; i++)
3688 {
3689 if (src.Data[i].Equals(test.Data[0]))
3690 {
3691 int j;
3692 for (j = 1; j < test.Length; j++)
3693 if (!src.Data[i+j].Equals(test.Data[j]))
3694 break;
3695 if (j == test.Length)
3696 {
3697 index = i;
3698 break;
3699 }
3700 }
3701 }
3702 }
3703
3704 return index;
3705
3706 }
3707
3708 public string llGetObjectName()
3709 {
3710 m_host.AddScriptLPS(1);
3711 return m_host.Name!=null?m_host.Name:String.Empty;
3712 }
3713
3714 public void llSetObjectName(string name)
3715 {
3716 m_host.AddScriptLPS(1);
3717 m_host.Name = name!=null?name:String.Empty;
3718 }
3719
3720 public string llGetDate()
3721 {
3722 m_host.AddScriptLPS(1);
3723 DateTime date = DateTime.Now.ToUniversalTime();
3724 string result = date.ToString("yyyy-MM-dd");
3725 return result;
3726 }
3727
3728 public LSL_Types.LSLInteger llEdgeOfWorld(LSL_Types.Vector3 pos, LSL_Types.Vector3 dir)
3729 {
3730 m_host.AddScriptLPS(1);
3731 NotImplemented("llEdgeOfWorld");
3732 return 0;
3733 }
3734
3735 public LSL_Types.LSLInteger llGetAgentInfo(string id)
3736 {
3737 m_host.AddScriptLPS(1);
3738 NotImplemented("llGetAgentInfo");
3739 return 0;
3740 }
3741
3742 public void llAdjustSoundVolume(double volume)
3743 {
3744 m_host.AddScriptLPS(1);
3745 m_host.AdjustSoundGain(volume);
3746 }
3747
3748 public void llSetSoundQueueing(int queue)
3749 {
3750 m_host.AddScriptLPS(1);
3751 NotImplemented("llSetSoundQueueing");
3752 }
3753
3754 public void llSetSoundRadius(double radius)
3755 {
3756 m_host.AddScriptLPS(1);
3757 NotImplemented("llSetSoundRadius");
3758 }
3759
3760 public string llKey2Name(string id)
3761 {
3762 m_host.AddScriptLPS(1);
3763 LLUUID key = new LLUUID();
3764 if (LLUUID.TryParse(id,out key))
3765 {
3766 ScenePresence presence = World.GetScenePresence(key);
3767
3768 if (presence != null)
3769 {
3770 return presence.ControllingClient.Name;
3771 //return presence.Name;
3772 }
3773
3774 if (World.GetSceneObjectPart(key) != null)
3775 {
3776 return World.GetSceneObjectPart(key).Name;
3777 }
3778 }
3779 return String.Empty;
3780 }
3781
3782
3783
3784 public void llSetTextureAnim(int mode, int face, int sizex, int sizey, double start, double length, double rate)
3785 {
3786 m_host.AddScriptLPS(1);
3787 Primitive.TextureAnimation pTexAnim = new Primitive.TextureAnimation();
3788 pTexAnim.Flags =(uint) mode;
3789
3790 //ALL_SIDES
3791 if (face == -1)
3792 face = 255;
3793
3794 pTexAnim.Face = (uint)face;
3795 pTexAnim.Length = (float)length;
3796 pTexAnim.Rate = (float)rate;
3797 pTexAnim.SizeX = (uint)sizex;
3798 pTexAnim.SizeY = (uint)sizey;
3799 pTexAnim.Start = (float)start;
3800
3801 m_host.AddTextureAnimation(pTexAnim);
3802 m_host.SendFullUpdateToAllClients();
3803 }
3804
3805 public void llTriggerSoundLimited(string sound, double volume, LSL_Types.Vector3 top_north_east,
3806 LSL_Types.Vector3 bottom_south_west)
3807 {
3808 m_host.AddScriptLPS(1);
3809 NotImplemented("llTriggerSoundLimited");
3810 }
3811
3812 public void llEjectFromLand(string pest)
3813 {
3814 m_host.AddScriptLPS(1);
3815 NotImplemented("llEjectFromLand");
3816 }
3817
3818 public LSL_Types.list llParseString2List(string str, LSL_Types.list separators, LSL_Types.list spacers)
3819 {
3820 m_host.AddScriptLPS(1);
3821 LSL_Types.list ret = new LSL_Types.list();
3822 object[] delimiters = new object[separators.Length + spacers.Length];
3823 separators.Data.CopyTo(delimiters, 0);
3824 spacers.Data.CopyTo(delimiters, separators.Length);
3825 bool dfound = false;
3826 do
3827 {
3828 dfound = false;
3829 int cindex = -1;
3830 string cdeli = "";
3831 for (int i = 0; i < delimiters.Length; i++)
3832 {
3833 int index = str.IndexOf(delimiters[i].ToString());
3834 bool found = index != -1;
3835 if (found)
3836 {
3837 if ((cindex > index) || (cindex == -1))
3838 {
3839 cindex = index;
3840 cdeli = (string)delimiters[i];
3841 }
3842 dfound = dfound || found;
3843 }
3844 }
3845 if (cindex != -1)
3846 {
3847 if (cindex > 0)
3848 {
3849 ret.Add(str.Substring(0, cindex));
3850 if (spacers.Contains(cdeli))
3851 {
3852 ret.Add(cdeli);
3853 }
3854 }
3855 if (cindex == 0 && spacers.Contains(cdeli))
3856 {
3857 ret.Add(cdeli);
3858 }
3859 str = str.Substring(cindex + cdeli.Length);
3860 }
3861 } while (dfound);
3862 if (str != "")
3863 {
3864 ret.Add(str);
3865 }
3866 return ret;
3867 }
3868
3869 public LSL_Types.LSLInteger llOverMyLand(string id)
3870 {
3871
3872 m_host.AddScriptLPS(1);
3873 LLUUID key = new LLUUID();
3874 if (LLUUID.TryParse(id,out key))
3875 {
3876 SceneObjectPart obj = new SceneObjectPart();
3877 obj = World.GetSceneObjectPart(World.Entities[key].LocalId);
3878 if (obj.OwnerID == World.GetLandOwner(obj.AbsolutePosition.X, obj.AbsolutePosition.Y))
3879 {
3880 return 1;
3881 }
3882 else
3883 {
3884 return 0;
3885 }
3886 }
3887 else
3888 {
3889 return 0;
3890 }
3891 }
3892
3893 public string llGetLandOwnerAt(LSL_Types.Vector3 pos)
3894 {
3895 m_host.AddScriptLPS(1);
3896 return World.GetLandOwner((float)pos.x, (float)pos.y).ToString();
3897 }
3898
3899 public LSL_Types.Vector3 llGetAgentSize(string id)
3900 {
3901 m_host.AddScriptLPS(1);
3902 NotImplemented("llGetAgentSize");
3903 return new LSL_Types.Vector3();
3904 }
3905
3906 public LSL_Types.LSLInteger llSameGroup(string agent)
3907 {
3908 m_host.AddScriptLPS(1);
3909 NotImplemented("llSameGroup");
3910 return 0;
3911 }
3912
3913 public void llUnSit(string id)
3914 {
3915 m_host.AddScriptLPS(1);
3916
3917 LLUUID key = new LLUUID();
3918 if (LLUUID.TryParse(id, out key))
3919 {
3920 ScenePresence av = World.GetScenePresence(key);
3921
3922 if (av != null)
3923 {
3924 if (llAvatarOnSitTarget() == id)
3925 {
3926 // if the avatar is sitting on this object, then
3927 // we can unsit them. We don't want random scripts unsitting random people
3928 // Lets avoid the popcorn avatar scenario.
3929 av.StandUp();
3930 }
3931 else
3932 {
3933 // If the object owner also owns the parcel
3934 // or
3935 // if the land is group owned and the object is group owned by the same group
3936 // or
3937 // if the object is owned by a person with estate access.
3938
3939 ILandObject parcel = World.LandChannel.GetLandObject(av.AbsolutePosition.X, av.AbsolutePosition.Y);
3940 if (parcel != null)
3941 {
3942 if (m_host.ObjectOwner == parcel.landData.ownerID ||
3943 (m_host.OwnerID == m_host.GroupID && m_host.GroupID == parcel.landData.groupID
3944 && parcel.landData.isGroupOwned) || World.ExternalChecks.ExternalChecksCanBeGodLike(m_host.OwnerID))
3945 {
3946 av.StandUp();
3947 }
3948 }
3949 }
3950 }
3951
3952 }
3953
3954 }
3955
3956 public LSL_Types.Vector3 llGroundSlope(LSL_Types.Vector3 offset)
3957 {
3958 m_host.AddScriptLPS(1);
3959 NotImplemented("llGroundSlope");
3960 return new LSL_Types.Vector3();
3961 }
3962
3963 public LSL_Types.Vector3 llGroundNormal(LSL_Types.Vector3 offset)
3964 {
3965 m_host.AddScriptLPS(1);
3966 NotImplemented("llGroundNormal");
3967 return new LSL_Types.Vector3();
3968 }
3969
3970 public LSL_Types.Vector3 llGroundContour(LSL_Types.Vector3 offset)
3971 {
3972 m_host.AddScriptLPS(1);
3973 NotImplemented("llGroundContour");
3974 return new LSL_Types.Vector3();
3975 }
3976
3977 public LSL_Types.LSLInteger llGetAttached()
3978 {
3979 m_host.AddScriptLPS(1);
3980 NotImplemented("llGetAttached");
3981 return 0;
3982 }
3983
3984 public LSL_Types.LSLInteger llGetFreeMemory()
3985 {
3986 m_host.AddScriptLPS(1);
3987 NotImplemented("llGetFreeMemory");
3988 return 0;
3989 }
3990
3991 public string llGetRegionName()
3992 {
3993 m_host.AddScriptLPS(1);
3994 return World.RegionInfo.RegionName;
3995 }
3996
3997 public double llGetRegionTimeDilation()
3998 {
3999 m_host.AddScriptLPS(1);
4000 return (double)World.TimeDilation;
4001 }
4002
4003 public double llGetRegionFPS()
4004 {
4005 m_host.AddScriptLPS(1);
4006 //TODO: return actual FPS
4007 return 10.0f;
4008 }
4009
4010 /* particle system rules should be coming into this routine as doubles, that is
4011 rule[0] should be an integer from this list and rule[1] should be the arg
4012 for the same integer. wiki.secondlife.com has most of this mapping, but some
4013 came from http://www.caligari-designs.com/p4u2
4014
4015 We iterate through the list for 'Count' elements, incrementing by two for each
4016 iteration and set the members of Primitive.ParticleSystem, one at a time.
4017 */
4018
4019 public enum PrimitiveRule : int
4020 {
4021 PSYS_PART_FLAGS = 0,
4022 PSYS_PART_START_COLOR = 1,
4023 PSYS_PART_START_ALPHA = 2,
4024 PSYS_PART_END_COLOR = 3,
4025 PSYS_PART_END_ALPHA = 4,
4026 PSYS_PART_START_SCALE = 5,
4027 PSYS_PART_END_SCALE = 6,
4028 PSYS_PART_MAX_AGE = 7,
4029 PSYS_SRC_ACCEL = 8,
4030 PSYS_SRC_PATTERN = 9,
4031 PSYS_SRC_TEXTURE = 12,
4032 PSYS_SRC_BURST_RATE = 13,
4033 PSYS_SRC_BURST_PART_COUNT = 15,
4034 PSYS_SRC_BURST_RADIUS = 16,
4035 PSYS_SRC_BURST_SPEED_MIN = 17,
4036 PSYS_SRC_BURST_SPEED_MAX = 18,
4037 PSYS_SRC_MAX_AGE = 19,
4038 PSYS_SRC_TARGET_KEY = 20,
4039 PSYS_SRC_OMEGA = 21,
4040 PSYS_SRC_ANGLE_BEGIN = 22,
4041 PSYS_SRC_ANGLE_END = 23
4042 }
4043
4044 internal Primitive.ParticleSystem.ParticleDataFlags ConvertUINTtoFlags(uint flags)
4045 {
4046 Primitive.ParticleSystem.ParticleDataFlags returnval = Primitive.ParticleSystem.ParticleDataFlags.None;
4047
4048 return returnval;
4049 }
4050
4051
4052 public void llParticleSystem(LSL_Types.list rules)
4053 {
4054 m_host.AddScriptLPS(1);
4055 Primitive.ParticleSystem prules = new Primitive.ParticleSystem();
4056 LSL_Types.Vector3 tempv = new LSL_Types.Vector3();
4057
4058 float tempf = 0;
4059
4060 for (int i = 0; i < rules.Length; i += 2)
4061 {
4062 switch ((int)rules.Data[i])
4063 {
4064 case (int)BuiltIn_Commands_BaseClass.PSYS_PART_FLAGS:
4065 prules.PartDataFlags = (Primitive.ParticleSystem.ParticleDataFlags)((uint)Convert.ToInt32(rules.Data[i + 1].ToString()));
4066 break;
4067
4068 case (int)BuiltIn_Commands_BaseClass.PSYS_PART_START_COLOR:
4069 tempv = (LSL_Types.Vector3)rules.Data[i + 1];
4070 prules.PartStartColor.R = (float)tempv.x;
4071 prules.PartStartColor.G = (float)tempv.y;
4072 prules.PartStartColor.B = (float)tempv.z;
4073 break;
4074
4075 case (int)BuiltIn_Commands_BaseClass.PSYS_PART_START_ALPHA:
4076 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4077 prules.PartStartColor.A = (float)tempf;
4078 break;
4079
4080 case (int)BuiltIn_Commands_BaseClass.PSYS_PART_END_COLOR:
4081 tempv = (LSL_Types.Vector3)rules.Data[i + 1];
4082 //prules.PartEndColor = new LLColor(tempv.x,tempv.y,tempv.z,1);
4083
4084 prules.PartEndColor.R = (float)tempv.x;
4085 prules.PartEndColor.G = (float)tempv.y;
4086 prules.PartEndColor.B = (float)tempv.z;
4087 break;
4088
4089 case (int)BuiltIn_Commands_BaseClass.PSYS_PART_END_ALPHA:
4090 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4091 prules.PartEndColor.A = (float)tempf;
4092 break;
4093
4094 case (int)BuiltIn_Commands_BaseClass.PSYS_PART_START_SCALE:
4095 tempv = (LSL_Types.Vector3)rules.Data[i + 1];
4096 prules.PartStartScaleX = (float)tempv.x;
4097 prules.PartStartScaleY = (float)tempv.y;
4098 break;
4099
4100 case (int)BuiltIn_Commands_BaseClass.PSYS_PART_END_SCALE:
4101 tempv = (LSL_Types.Vector3)rules.Data[i + 1];
4102 prules.PartEndScaleX = (float)tempv.x;
4103 prules.PartEndScaleY = (float)tempv.y;
4104 break;
4105
4106 case (int)BuiltIn_Commands_BaseClass.PSYS_PART_MAX_AGE:
4107 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4108 prules.PartMaxAge = (float)tempf;
4109 break;
4110
4111 case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_ACCEL:
4112 tempv = (LSL_Types.Vector3)rules.Data[i + 1];
4113 prules.PartAcceleration.X = (float)tempv.x;
4114 prules.PartAcceleration.Y = (float)tempv.y;
4115 prules.PartAcceleration.Z = (float)tempv.z;
4116 break;
4117
4118 case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_PATTERN:
4119 int tmpi = int.Parse(rules.Data[i + 1].ToString());
4120 prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi;
4121 break;
4122
4123 // Xantor 20080503
4124 // Wiki: PSYS_SRC_TEXTURE string inventory item name or key of the particle texture
4125 // "" = default texture.
4126 // 20080530 Updated to remove code duplication
4127 case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_TEXTURE:
4128 prules.Texture = KeyOrName(rules.Data[i + 1].ToString());
4129 break;
4130
4131 case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_BURST_RATE:
4132 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4133 prules.BurstRate = (float)tempf;
4134 break;
4135
4136 case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_BURST_PART_COUNT:
4137 prules.BurstPartCount = (byte)Convert.ToByte(rules.Data[i + 1].ToString());
4138 break;
4139
4140 case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_BURST_RADIUS:
4141 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4142 prules.BurstRadius = (float)tempf;
4143 break;
4144
4145 case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_BURST_SPEED_MIN:
4146 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4147 prules.BurstSpeedMin = (float)tempf;
4148 break;
4149
4150 case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_BURST_SPEED_MAX:
4151 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4152 prules.BurstSpeedMax = (float)tempf;
4153 break;
4154
4155 case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_MAX_AGE:
4156 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4157 prules.MaxAge = (float)tempf;
4158 break;
4159
4160 case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_TARGET_KEY:
4161 LLUUID key = LLUUID.Zero;
4162 if (LLUUID.TryParse(rules.Data[i + 1].ToString(), out key))
4163 {
4164 prules.Target = key;
4165 }
4166 else
4167 {
4168 prules.Target = m_host.UUID;
4169 }
4170 break;
4171
4172 case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_OMEGA:
4173 // AL: This is an assumption, since it is the only thing that would match.
4174 tempv = (LSL_Types.Vector3)rules.Data[i + 1];
4175 prules.AngularVelocity.X = (float)tempv.x;
4176 prules.AngularVelocity.Y = (float)tempv.y;
4177 prules.AngularVelocity.Z = (float)tempv.z;
4178 //cast?? prules.MaxAge = (float)rules[i + 1];
4179 break;
4180
4181 case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_ANGLE_BEGIN:
4182 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4183 prules.InnerAngle = (float)tempf;
4184 break;
4185
4186 case (int)BuiltIn_Commands_BaseClass.PSYS_SRC_ANGLE_END:
4187 tempf = Convert.ToSingle(rules.Data[i + 1].ToString());
4188 prules.OuterAngle = (float)tempf;
4189 break;
4190 }
4191
4192 }
4193 prules.CRC = 1;
4194
4195 m_host.AddNewParticleSystem(prules);
4196 m_host.SendFullUpdateToAllClients();
4197 }
4198
4199 public void llGroundRepel(double height, int water, double tau)
4200 {
4201 m_host.AddScriptLPS(1);
4202 NotImplemented("llGroundRepel");
4203 }
4204
4205 public void llGiveInventoryList(string destination, string category, LSL_Types.list inventory)
4206 {
4207 m_host.AddScriptLPS(1);
4208 NotImplemented("llGiveInventoryList");
4209 }
4210
4211 public void llSetVehicleType(int type)
4212 {
4213 m_host.AddScriptLPS(1);
4214 NotImplemented("llSetVehicleType");
4215 }
4216
4217 public void llSetVehicledoubleParam(int param, double value)
4218 {
4219 m_host.AddScriptLPS(1);
4220 NotImplemented("llSetVehicledoubleParam");
4221 }
4222
4223 public void llSetVehicleFloatParam(int param, float value)
4224 {
4225 m_host.AddScriptLPS(1);
4226 NotImplemented("llSetVehicleFloatParam");
4227 }
4228
4229 public void llSetVehicleVectorParam(int param, LSL_Types.Vector3 vec)
4230 {
4231 m_host.AddScriptLPS(1);
4232 NotImplemented("llSetVehicleVectorParam");
4233 }
4234
4235 public void llSetVehicleRotationParam(int param, LSL_Types.Quaternion rot)
4236 {
4237 m_host.AddScriptLPS(1);
4238 NotImplemented("llSetVehicleRotationParam");
4239 }
4240
4241 public void llSetVehicleFlags(int flags)
4242 {
4243 m_host.AddScriptLPS(1);
4244 NotImplemented("llSetVehicleFlags");
4245 }
4246
4247 public void llRemoveVehicleFlags(int flags)
4248 {
4249 m_host.AddScriptLPS(1);
4250 NotImplemented("llRemoveVehicleFlags");
4251 }
4252
4253 public void llSitTarget(LSL_Types.Vector3 offset, LSL_Types.Quaternion rot)
4254 {
4255 m_host.AddScriptLPS(1);
4256 // LSL quaternions can normalize to 0, normal Quaternions can't.
4257 if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0)
4258 rot.z = 1; // ZERO_ROTATION = 0,0,0,1
4259
4260 m_host.SetSitTarget(new Vector3((float)offset.x, (float)offset.y, (float)offset.z), new Quaternion((float)rot.s, (float)rot.x, (float)rot.y, (float)rot.z));
4261 }
4262
4263 public string llAvatarOnSitTarget()
4264 {
4265 m_host.AddScriptLPS(1);
4266 return m_host.GetAvatarOnSitTarget().ToString();
4267 }
4268
4269 public void llAddToLandPassList(string avatar, double hours)
4270 {
4271 m_host.AddScriptLPS(1);
4272 LLUUID key;
4273 LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).landData;
4274 if (land.ownerID == m_host.OwnerID)
4275 {
4276 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
4277 if (LLUUID.TryParse(avatar, out key))
4278 {
4279 entry.AgentID = key;
4280 entry.Flags = ParcelManager.AccessList.Access;
4281 entry.Time = DateTime.Now.AddHours(hours);
4282 land.parcelAccessList.Add(entry);
4283 }
4284 }
4285 }
4286
4287 public void llSetTouchText(string text)
4288 {
4289 m_host.AddScriptLPS(1);
4290 m_host.TouchName = text;
4291 }
4292
4293 public void llSetSitText(string text)
4294 {
4295 m_host.AddScriptLPS(1);
4296 m_host.SitName = text;
4297 }
4298
4299 public void llSetCameraEyeOffset(LSL_Types.Vector3 offset)
4300 {
4301 m_host.AddScriptLPS(1);
4302 NotImplemented("llSetCameraEyeOffset");
4303 }
4304
4305 public void llSetCameraAtOffset(LSL_Types.Vector3 offset)
4306 {
4307 m_host.AddScriptLPS(1);
4308 NotImplemented("llSetCameraAtOffset");
4309 }
4310
4311 public string llDumpList2String(LSL_Types.list src, string seperator)
4312 {
4313 m_host.AddScriptLPS(1);
4314 if (src.Length == 0)
4315 {
4316 return String.Empty;
4317 }
4318 string ret = String.Empty;
4319 foreach (object o in src.Data)
4320 {
4321 ret = ret + o.ToString() + seperator;
4322 }
4323 ret = ret.Substring(0, ret.Length - seperator.Length);
4324 return ret;
4325 }
4326
4327 public LSL_Types.LSLInteger llScriptDanger(LSL_Types.Vector3 pos)
4328 {
4329 m_host.AddScriptLPS(1);
4330 bool result = World.scriptDanger(m_host.LocalId, new LLVector3((float)pos.x, (float)pos.y, (float)pos.z));
4331 if (result)
4332 {
4333 return 1;
4334 }
4335 else
4336 {
4337 return 0;
4338 }
4339
4340 }
4341
4342 public void llDialog(string avatar, string message, LSL_Types.list buttons, int chat_channel)
4343 {
4344 m_host.AddScriptLPS(1);
4345 LLUUID av = new LLUUID();
4346 if (!LLUUID.TryParse(avatar,out av))
4347 {
4348 LSLError("First parameter to llDialog needs to be a key");
4349 return;
4350 }
4351 if (buttons.Length > 12)
4352 {
4353 LSLError("No more than 12 buttons can be shown");
4354 return;
4355 }
4356 string[] buts = new string[buttons.Length];
4357 for (int i = 0; i < buttons.Length; i++)
4358 {
4359 if (buttons.Data[i].ToString() == String.Empty)
4360 {
4361 LSLError("button label cannot be blank");
4362 return;
4363 }
4364 if (buttons.Data[i].ToString().Length > 24)
4365 {
4366 LSLError("button label cannot be longer than 24 characters");
4367 return;
4368 }
4369 buts[i] = buttons.Data[i].ToString();
4370 }
4371 World.SendDialogToUser(av, m_host.Name, m_host.UUID, m_host.OwnerID, message, new LLUUID("00000000-0000-2222-3333-100000001000"), chat_channel, buts);
4372 }
4373
4374 public void llVolumeDetect(int detect)
4375 {
4376 m_host.AddScriptLPS(1);
4377 NotImplemented("llVolumeDetect");
4378 }
4379
4380 /// <summary>
4381 /// Reset the named script. The script must be present
4382 /// in the same prim.
4383 /// </summary>
4384
4385 public void llResetOtherScript(string name)
4386 {
4387 LLUUID item;
4388
4389 m_host.AddScriptLPS(1);
4390
4391 if ((item = ScriptByName(name)) != LLUUID.Zero)
4392 m_ScriptEngine.ResetScript(item);
4393 else
4394 ShoutError("llResetOtherScript: script "+name+" not found");
4395 }
4396
4397 public LSL_Types.LSLInteger llGetScriptState(string name)
4398 {
4399 LLUUID item;
4400
4401 m_host.AddScriptLPS(1);
4402
4403 if ((item = ScriptByName(name)) != LLUUID.Zero)
4404 {
4405 return m_ScriptEngine.GetScriptState(item) ?1:0;
4406 }
4407
4408 ShoutError("llGetScriptState: script "+name+" not found");
4409
4410 // If we didn't find it, then it's safe to
4411 // assume it is not running.
4412
4413 return 0;
4414 }
4415
4416 public void llRemoteLoadScript()
4417 {
4418 m_host.AddScriptLPS(1);
4419 Deprecated("llRemoteLoadScript");
4420 }
4421
4422 public void llSetRemoteScriptAccessPin(int pin)
4423 {
4424 m_host.AddScriptLPS(1);
4425 NotImplemented("llSetRemoteScriptAccessPin");
4426 }
4427
4428 public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param)
4429 {
4430 m_host.AddScriptLPS(1);
4431 NotImplemented("llRemoteLoadScriptPin");
4432 }
4433
4434 // remote_data(integer type, key channel, key message_id, string sender, integer ival, string sval)
4435 // Not sure where these constants should live:
4436 // REMOTE_DATA_CHANNEL = 1
4437 // REMOTE_DATA_REQUEST = 2
4438 // REMOTE_DATA_REPLY = 3
4439 public void llOpenRemoteDataChannel()
4440 {
4441 m_host.AddScriptLPS(1);
4442 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
4443 if (xmlrpcMod.IsEnabled())
4444 {
4445 LLUUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_localID, m_itemID, LLUUID.Zero);
4446 object[] resobj = new object[] { new LSL_Types.LSLInteger(1), new LSL_Types.LSLString(channelID.ToString()), new LSL_Types.LSLString(LLUUID.Zero.ToString()), new LSL_Types.LSLString(String.Empty), new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(String.Empty) };
4447 m_ScriptEngine.PostScriptEvent(m_itemID, new XEventParams(
4448 "remote_data", resobj,
4449 new XDetectParams[0]));
4450 }
4451 }
4452
4453 public string llSendRemoteData(string channel, string dest, int idata, string sdata)
4454 {
4455 m_host.AddScriptLPS(1);
4456 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
4457 return (xmlrpcMod.SendRemoteData(m_localID, m_itemID, channel, dest, idata, sdata)).ToString();
4458 }
4459
4460 public void llRemoteDataReply(string channel, string message_id, string sdata, int idata)
4461 {
4462 m_host.AddScriptLPS(1);
4463 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
4464 xmlrpcMod.RemoteDataReply(channel, message_id, sdata, idata);
4465 }
4466
4467 public void llCloseRemoteDataChannel(string channel)
4468 {
4469 m_host.AddScriptLPS(1);
4470 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
4471 xmlrpcMod.CloseXMLRPCChannel(channel);
4472 }
4473
4474 public string llMD5String(string src, int nonce)
4475 {
4476 m_host.AddScriptLPS(1);
4477 return Util.Md5Hash(src + ":" + nonce.ToString());
4478 }
4479
4480 public void llSetPrimitiveParams(LSL_Types.list rules)
4481 {
4482 llSetLinkPrimitiveParams(m_host.LinkNum+1, rules);
4483 }
4484
4485 public void llSetLinkPrimitiveParams(int linknumber, LSL_Types.list rules)
4486 {
4487 m_host.AddScriptLPS(1);
4488
4489 SceneObjectPart part=null;
4490
4491 if (m_host.LinkNum+1 != linknumber)
4492 {
4493 foreach (SceneObjectPart partInst in m_host.ParentGroup.GetParts())
4494 {
4495 if ((partInst.LinkNum + 1) == linknumber)
4496 {
4497 part = partInst;
4498 break;
4499 }
4500 }
4501 }
4502 else
4503 {
4504 part = m_host;
4505 }
4506
4507 if (part == null)
4508 return;
4509
4510 int idx = 0;
4511
4512 while (idx < rules.Length)
4513 {
4514 int code = Convert.ToInt32(rules.Data[idx++]);
4515
4516 int remain = rules.Length - idx;
4517
4518 int face;
4519 LSL_Types.Vector3 v;
4520
4521 switch (code)
4522 {
4523 case 6: // PRIM_POSITION
4524 if (remain < 1)
4525 return;
4526
4527 v=new LSL_Types.Vector3(rules.Data[idx++].ToString());
4528 SetPos(part, v);
4529
4530 break;
4531 case 7: // PRIM_SIZE
4532 if (remain < 1)
4533 return;
4534
4535 v=new LSL_Types.Vector3(rules.Data[idx++].ToString());
4536 SetScale(part, v);
4537
4538 break;
4539 case 8: // PRIM_ROTATION
4540 if (remain < 1)
4541 return;
4542
4543 LSL_Types.Quaternion q = new LSL_Types.Quaternion(rules.Data[idx++].ToString());
4544 SetRot(part, q);
4545
4546 break;
4547
4548 case 17: // PRIM_TEXTURE
4549 if (remain < 5)
4550 return;
4551
4552 face=Convert.ToInt32(rules.Data[idx++]);
4553 string tex=rules.Data[idx++].ToString();
4554 LSL_Types.Vector3 repeats=new LSL_Types.Vector3(rules.Data[idx++].ToString());
4555 LSL_Types.Vector3 offsets=new LSL_Types.Vector3(rules.Data[idx++].ToString());
4556 double rotation=Convert.ToDouble(rules.Data[idx++]);
4557
4558 SetTexture(part, tex, face);
4559 ScaleTexture(part, repeats.x, repeats.y, face);
4560 OffsetTexture(part, offsets.x, offsets.y, face);
4561 RotateTexture(part, rotation, face);
4562
4563 break;
4564
4565 case 18: // PRIM_COLOR
4566 if (remain < 3)
4567 return;
4568
4569 face=Convert.ToInt32(rules.Data[idx++]);
4570 LSL_Types.Vector3 color=new LSL_Types.Vector3(rules.Data[idx++].ToString());
4571 double alpha=Convert.ToDouble(rules.Data[idx++]);
4572
4573 SetColor(part, color, face);
4574 SetAlpha(part, alpha, face);
4575
4576 break;
4577 case 21: // PRIM_FLEXI
4578 if (remain < 7)
4579 return;
4580
4581 int flexi = Convert.ToInt32(rules.Data[idx++]);
4582 int softness = Convert.ToInt32(rules.Data[idx++]);
4583 float gravity = (float)Convert.ToDouble(rules.Data[idx++]);
4584 float friction = (float)Convert.ToDouble(rules.Data[idx++]);
4585 float wind = (float)Convert.ToDouble(rules.Data[idx++]);
4586 float tension = (float)Convert.ToDouble(rules.Data[idx++]);
4587 LSL_Types.Vector3 force =new LSL_Types.Vector3(rules.Data[idx++].ToString());
4588
4589 SetFlexi(part, (flexi == 1), softness, gravity, friction, wind, tension, force);
4590
4591 break;
4592 case 23: // PRIM_POINT_LIGHT
4593 if (remain < 5)
4594 return;
4595 int light = Convert.ToInt32(rules.Data[idx++]);
4596 LSL_Types.Vector3 lightcolor =new LSL_Types.Vector3(rules.Data[idx++].ToString());
4597 float intensity = (float)Convert.ToDouble(rules.Data[idx++]);
4598 float radius = (float)Convert.ToDouble(rules.Data[idx++]);
4599 float falloff = (float)Convert.ToDouble(rules.Data[idx++]);
4600
4601 SetPointLight(part, (light == 1), lightcolor, intensity, radius, falloff);
4602
4603 break;
4604 }
4605 }
4606 }
4607
4608 public string llStringToBase64(string str)
4609 {
4610 m_host.AddScriptLPS(1);
4611 try
4612 {
4613 byte[] encData_byte = new byte[str.Length];
4614 encData_byte = Encoding.UTF8.GetBytes(str);
4615 string encodedData = Convert.ToBase64String(encData_byte);
4616 return encodedData;
4617 }
4618 catch (Exception e)
4619 {
4620 throw new Exception("Error in base64Encode" + e.Message);
4621 }
4622 }
4623
4624 public string llBase64ToString(string str)
4625 {
4626 m_host.AddScriptLPS(1);
4627 UTF8Encoding encoder = new UTF8Encoding();
4628 Decoder utf8Decode = encoder.GetDecoder();
4629 try
4630 {
4631 byte[] todecode_byte = Convert.FromBase64String(str);
4632 int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
4633 char[] decoded_char = new char[charCount];
4634 utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
4635 string result = new String(decoded_char);
4636 return result;
4637 }
4638 catch (Exception e)
4639 {
4640 throw new Exception("Error in base64Decode" + e.Message);
4641 }
4642 }
4643
4644 public void llXorBase64Strings()
4645 {
4646 m_host.AddScriptLPS(1);
4647 Deprecated("llXorBase64Strings");
4648 }
4649
4650 public void llRemoteDataSetRegion()
4651 {
4652 m_host.AddScriptLPS(1);
4653 NotImplemented("llRemoteDataSetRegion");
4654 }
4655
4656 public double llLog10(double val)
4657 {
4658 m_host.AddScriptLPS(1);
4659 return (double)Math.Log10(val);
4660 }
4661
4662 public double llLog(double val)
4663 {
4664 m_host.AddScriptLPS(1);
4665 return (double)Math.Log(val);
4666 }
4667
4668 public LSL_Types.list llGetAnimationList(string id)
4669 {
4670 m_host.AddScriptLPS(1);
4671 NotImplemented("llGetAnimationList");
4672 return new LSL_Types.list();
4673 }
4674
4675 public void llSetParcelMusicURL(string url)
4676 {
4677 m_host.AddScriptLPS(1);
4678 LLUUID landowner = World.GetLandOwner(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y);
4679 if (landowner == LLUUID.Zero)
4680 {
4681 return;
4682 }
4683 if (landowner != m_host.ObjectOwner)
4684 {
4685 return;
4686 }
4687 World.SetLandMusicURL(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, url);
4688 }
4689
4690 public void osSetParcelMediaURL(string url)
4691 {
4692 m_host.AddScriptLPS(1);
4693 LLUUID landowner = World.GetLandOwner(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y);
4694
4695 if (landowner == LLUUID.Zero)
4696 {
4697 return;
4698 }
4699
4700 if (landowner != m_host.ObjectOwner)
4701 {
4702 return;
4703 }
4704
4705 World.SetLandMediaURL(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, url);
4706 }
4707
4708 public LSL_Types.Vector3 llGetRootPosition()
4709 {
4710 m_host.AddScriptLPS(1);
4711 return new LSL_Types.Vector3(m_host.ParentGroup.AbsolutePosition.X, m_host.ParentGroup.AbsolutePosition.Y, m_host.ParentGroup.AbsolutePosition.Z);
4712 }
4713
4714 public LSL_Types.Quaternion llGetRootRotation()
4715 {
4716 m_host.AddScriptLPS(1);
4717 return new LSL_Types.Quaternion(m_host.ParentGroup.GroupRotation.X, m_host.ParentGroup.GroupRotation.Y, m_host.ParentGroup.GroupRotation.Z, m_host.ParentGroup.GroupRotation.W);
4718 }
4719
4720 public string llGetObjectDesc()
4721 {
4722 return m_host.Description!=null?m_host.Description:String.Empty;
4723 }
4724
4725 public void llSetObjectDesc(string desc)
4726 {
4727 m_host.AddScriptLPS(1);
4728 m_host.Description = desc!=null?desc:String.Empty;
4729 }
4730
4731 public string llGetCreator()
4732 {
4733 m_host.AddScriptLPS(1);
4734 return m_host.ObjectCreator.ToString();
4735 }
4736
4737 public string llGetTimestamp()
4738 {
4739 m_host.AddScriptLPS(1);
4740 return DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ");
4741 }
4742
4743 public void llSetLinkAlpha(int linknumber, double alpha, int face)
4744 {
4745 m_host.AddScriptLPS(1);
4746 SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknumber);
4747 if (linknumber > -1)
4748 {
4749 LLObject.TextureEntry tex = part.Shape.Textures;
4750 LLColor texcolor;
4751 if (face > -1)
4752 {
4753 texcolor = tex.CreateFace((uint)face).RGBA;
4754 texcolor.A = (float)Math.Abs(alpha - 1);
4755 tex.FaceTextures[face].RGBA = texcolor;
4756 part.UpdateTexture(tex);
4757 return;
4758 }
4759 else if (face == -1)
4760 {
4761 texcolor = tex.DefaultTexture.RGBA;
4762 texcolor.A = (float)Math.Abs(alpha - 1);
4763 tex.DefaultTexture.RGBA = texcolor;
4764 for (uint i = 0; i < 32; i++)
4765 {
4766 if (tex.FaceTextures[i] != null)
4767 {
4768 texcolor = tex.FaceTextures[i].RGBA;
4769 texcolor.A = (float)Math.Abs(alpha - 1);
4770 tex.FaceTextures[i].RGBA = texcolor;
4771 }
4772 }
4773 texcolor = tex.DefaultTexture.RGBA;
4774 texcolor.A = (float)Math.Abs(alpha - 1);
4775 tex.DefaultTexture.RGBA = texcolor;
4776 part.UpdateTexture(tex);
4777 return;
4778 }
4779 return;
4780 }
4781 else if (linknumber == -1)
4782 {
4783 int num = m_host.ParentGroup.PrimCount;
4784 for (int w = 0; w < num; w++)
4785 {
4786 linknumber = w;
4787 part = m_host.ParentGroup.GetLinkNumPart(linknumber);
4788 LLObject.TextureEntry tex = part.Shape.Textures;
4789 LLColor texcolor;
4790 if (face > -1)
4791 {
4792 texcolor = tex.CreateFace((uint)face).RGBA;
4793 texcolor.A = (float)Math.Abs(alpha - 1);
4794 tex.FaceTextures[face].RGBA = texcolor;
4795 part.UpdateTexture(tex);
4796 }
4797 else if (face == -1)
4798 {
4799 texcolor = tex.DefaultTexture.RGBA;
4800 texcolor.A = (float)Math.Abs(alpha - 1);
4801 tex.DefaultTexture.RGBA = texcolor;
4802 for (uint i = 0; i < 32; i++)
4803 {
4804 if (tex.FaceTextures[i] != null)
4805 {
4806 texcolor = tex.FaceTextures[i].RGBA;
4807 texcolor.A = (float)Math.Abs(alpha - 1);
4808 tex.FaceTextures[i].RGBA = texcolor;
4809 }
4810 }
4811 texcolor = tex.DefaultTexture.RGBA;
4812 texcolor.A = (float)Math.Abs(alpha - 1);
4813 tex.DefaultTexture.RGBA = texcolor;
4814 part.UpdateTexture(tex);
4815 }
4816 }
4817 return;
4818 }
4819 }
4820
4821 public LSL_Types.LSLInteger llGetNumberOfPrims()
4822 {
4823 m_host.AddScriptLPS(1);
4824 return m_host.ParentGroup.PrimCount;
4825 }
4826
4827 public LSL_Types.list llGetBoundingBox(string obj)
4828 {
4829 m_host.AddScriptLPS(1);
4830 NotImplemented("llGetBoundingBox");
4831 return new LSL_Types.list();
4832 }
4833
4834 public LSL_Types.Vector3 llGetGeometricCenter()
4835 {
4836 return new LSL_Types.Vector3(m_host.GetGeometricCenter().X, m_host.GetGeometricCenter().Y, m_host.GetGeometricCenter().Z);
4837 }
4838
4839 public LSL_Types.list llGetPrimitiveParams(LSL_Types.list rules)
4840 {
4841 m_host.AddScriptLPS(1);
4842
4843 LSL_Types.list res = new LSL_Types.list();
4844 int idx=0;
4845 while (idx < rules.Length)
4846 {
4847 int code=Convert.ToInt32(rules.Data[idx++]);
4848 int remain=rules.Length-idx;
4849
4850 switch (code)
4851 {
4852 case 2: // PRIM_MATERIAL
4853 res.Add(new LSL_Types.LSLInteger(m_host.Material));
4854 break;
4855
4856 case 3: // PRIM_PHYSICS
4857 if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Physics) != 0)
4858 res.Add(new LSL_Types.LSLInteger(1));
4859 else
4860 res.Add(new LSL_Types.LSLInteger(0));
4861 break;
4862
4863 case 4: // PRIM_TEMP_ON_REZ
4864 if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.TemporaryOnRez) != 0)
4865 res.Add(new LSL_Types.LSLInteger(1));
4866 else
4867 res.Add(new LSL_Types.LSLInteger(0));
4868 break;
4869
4870 case 5: // PRIM_PHANTOM
4871 if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Phantom) != 0)
4872 res.Add(new LSL_Types.LSLInteger(1));
4873 else
4874 res.Add(new LSL_Types.LSLInteger(0));
4875 break;
4876
4877 case 6: // PRIM_POSITION
4878 res.Add(new LSL_Types.Vector3(m_host.AbsolutePosition.X,
4879 m_host.AbsolutePosition.Y,
4880 m_host.AbsolutePosition.Z));
4881 break;
4882
4883 case 7: // PRIM_SIZE
4884 res.Add(new LSL_Types.Vector3(m_host.Scale.X,
4885 m_host.Scale.Y,
4886 m_host.Scale.Z));
4887 break;
4888
4889 case 8: // PRIM_ROTATION
4890 res.Add(new LSL_Types.Quaternion(m_host.RotationOffset.X,
4891 m_host.RotationOffset.Y,
4892 m_host.RotationOffset.Z,
4893 m_host.RotationOffset.W));
4894 break;
4895
4896 case 9: // PRIM_TYPE
4897 // TODO--------------
4898 res.Add(new LSL_Types.LSLInteger(0));
4899 break;
4900
4901 case 17: // PRIM_TEXTURE
4902 if (remain < 1)
4903 return res;
4904
4905 int face=Convert.ToInt32(rules.Data[idx++]);
4906 if (face == -1)
4907 face = 0;
4908
4909 LLObject.TextureEntry tex = m_host.Shape.Textures;
4910 LLObject.TextureEntryFace texface = tex.GetFace((uint)face);
4911
4912 res.Add(new LSL_Types.LSLString(texface.TextureID.ToString()));
4913 res.Add(new LSL_Types.Vector3(texface.RepeatU,
4914 texface.RepeatV,
4915 0));
4916 res.Add(new LSL_Types.Vector3(texface.OffsetU,
4917 texface.OffsetV,
4918 0));
4919 res.Add(new LSL_Types.LSLFloat(texface.Rotation));
4920 break;
4921
4922 case 18: // PRIM_COLOR
4923 if (remain < 1)
4924 return res;
4925
4926 face=Convert.ToInt32(rules.Data[idx++]);
4927
4928 tex = m_host.Shape.Textures;
4929 LLColor texcolor;
4930 if (face == -1) // TMP: Until we can determine number of sides, ALL_SIDES (-1) will return default color
4931 texcolor = tex.DefaultTexture.RGBA;
4932 else
4933 texcolor = tex.GetFace((uint)face).RGBA;
4934 res.Add(new LSL_Types.Vector3((255 - (texcolor.R * 255)) / 255,
4935 (255 - (texcolor.G * 255)) / 255,
4936 (255 - (texcolor.B * 255)) / 255));
4937 res.Add(new LSL_Types.LSLFloat((texcolor.A * 255) / 255));
4938 break;
4939
4940 case 19: // PRIM_BUMP_SHINY
4941 // TODO--------------
4942 if (remain < 1)
4943 return res;
4944
4945 face=Convert.ToInt32(rules.Data[idx++]);
4946
4947 res.Add(new LSL_Types.LSLInteger(0));
4948 res.Add(new LSL_Types.LSLInteger(0));
4949 break;
4950
4951 case 20: // PRIM_FULLBRIGHT
4952 // TODO--------------
4953 if (remain < 1)
4954 return res;
4955
4956 face=Convert.ToInt32(rules.Data[idx++]);
4957
4958 res.Add(new LSL_Types.LSLInteger(0));
4959 break;
4960
4961 case 21: // PRIM_FLEXIBLE
4962 PrimitiveBaseShape shape = m_host.Shape;
4963
4964 if (shape.FlexiEntry)
4965 res.Add(new LSL_Types.LSLInteger(1)); // active
4966 else
4967 res.Add(new LSL_Types.LSLInteger(0));
4968 res.Add(new LSL_Types.LSLInteger(shape.FlexiSoftness));// softness
4969 res.Add(new LSL_Types.LSLFloat(shape.FlexiGravity)); // gravity
4970 res.Add(new LSL_Types.LSLFloat(shape.FlexiDrag)); // friction
4971 res.Add(new LSL_Types.LSLFloat(shape.FlexiWind)); // wind
4972 res.Add(new LSL_Types.LSLFloat(shape.FlexiTension)); // tension
4973 res.Add(new LSL_Types.Vector3(shape.FlexiForceX, // force
4974 shape.FlexiForceY,
4975 shape.FlexiForceZ));
4976 break;
4977
4978 case 22: // PRIM_TEXGEN
4979 // TODO--------------
4980 // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR)
4981 if (remain < 1)
4982 return res;
4983
4984 face=Convert.ToInt32(rules.Data[idx++]);
4985
4986 res.Add(new LSL_Types.LSLInteger(0));
4987 break;
4988
4989 case 23: // PRIM_POINT_LIGHT:
4990 shape = m_host.Shape;
4991
4992 if (shape.LightEntry)
4993 res.Add(new LSL_Types.LSLInteger(1)); // active
4994 else
4995 res.Add(new LSL_Types.LSLInteger(0));
4996 res.Add(new LSL_Types.Vector3(shape.LightColorR, // color
4997 shape.LightColorG,
4998 shape.LightColorB));
4999 res.Add(new LSL_Types.LSLFloat(shape.LightIntensity)); // intensity
5000 res.Add(new LSL_Types.LSLFloat(shape.LightRadius)); // radius
5001 res.Add(new LSL_Types.LSLFloat(shape.LightFalloff)); // falloff
5002 break;
5003
5004 case 24: // PRIM_GLOW
5005 // TODO--------------
5006 if (remain < 1)
5007 return res;
5008
5009 face=Convert.ToInt32(rules.Data[idx++]);
5010
5011 res.Add(new LSL_Types.LSLFloat(0));
5012 break;
5013 }
5014 }
5015 return res;
5016 }
5017
5018 // <remarks>
5019 // <para>
5020 // The .NET definition of base 64 is:
5021 // <list>
5022 // <item>
5023 // Significant: A-Z a-z 0-9 + -
5024 // </item>
5025 // <item>
5026 // Whitespace: \t \n \r ' '
5027 // </item>
5028 // <item>
5029 // Valueless: =
5030 // </item>
5031 // <item>
5032 // End-of-string: \0 or '=='
5033 // </item>
5034 // </list>
5035 // </para>
5036 // <para>
5037 // Each point in a base-64 string represents
5038 // a 6 bit value. A 32-bit integer can be
5039 // represented using 6 characters (with some
5040 // redundancy).
5041 // </para>
5042 // <para>
5043 // LSL requires a base64 string to be 8
5044 // characters in length. LSL also uses '/'
5045 // rather than '-' (MIME compliant).
5046 // </para>
5047 // <para>
5048 // RFC 1341 used as a reference (as specified
5049 // by the SecondLife Wiki).
5050 // </para>
5051 // <para>
5052 // SL do not record any kind of exception for
5053 // these functions, so the string to integer
5054 // conversion returns '0' if an invalid
5055 // character is encountered during conversion.
5056 // </para>
5057 // <para>
5058 // References
5059 // <list>
5060 // <item>
5061 // http://lslwiki.net/lslwiki/wakka.php?wakka=Base64
5062 // </item>
5063 // <item>
5064 // </item>
5065 // </list>
5066 // </para>
5067 // </remarks>
5068
5069 // <summary>
5070 // Table for converting 6-bit integers into
5071 // base-64 characters
5072 // </summary>
5073
5074 private static readonly char[] i2ctable =
5075 {
5076 'A','B','C','D','E','F','G','H',
5077 'I','J','K','L','M','N','O','P',
5078 'Q','R','S','T','U','V','W','X',
5079 'Y','Z',
5080 'a','b','c','d','e','f','g','h',
5081 'i','j','k','l','m','n','o','p',
5082 'q','r','s','t','u','v','w','x',
5083 'y','z',
5084 '0','1','2','3','4','5','6','7',
5085 '8','9',
5086 '+','/'
5087 };
5088
5089 // <summary>
5090 // Table for converting base-64 characters
5091 // into 6-bit integers.
5092 // </summary>
5093
5094 private static readonly int[] c2itable =
5095 {
5096 -1,-1,-1,-1,-1,-1,-1,-1, // 0x
5097 -1,-1,-1,-1,-1,-1,-1,-1,
5098 -1,-1,-1,-1,-1,-1,-1,-1, // 1x
5099 -1,-1,-1,-1,-1,-1,-1,-1,
5100 -1,-1,-1,-1,-1,-1,-1,-1, // 2x
5101 -1,-1,-1,63,-1,-1,-1,64,
5102 53,54,55,56,57,58,59,60, // 3x
5103 61,62,-1,-1,-1,0,-1,-1,
5104 -1,1,2,3,4,5,6,7, // 4x
5105 8,9,10,11,12,13,14,15,
5106 16,17,18,19,20,21,22,23, // 5x
5107 24,25,26,-1,-1,-1,-1,-1,
5108 -1,27,28,29,30,31,32,33, // 6x
5109 34,35,36,37,38,39,40,41,
5110 42,43,44,45,46,47,48,49, // 7x
5111 50,51,52,-1,-1,-1,-1,-1,
5112 -1,-1,-1,-1,-1,-1,-1,-1, // 8x
5113 -1,-1,-1,-1,-1,-1,-1,-1,
5114 -1,-1,-1,-1,-1,-1,-1,-1, // 9x
5115 -1,-1,-1,-1,-1,-1,-1,-1,
5116 -1,-1,-1,-1,-1,-1,-1,-1, // Ax
5117 -1,-1,-1,-1,-1,-1,-1,-1,
5118 -1,-1,-1,-1,-1,-1,-1,-1, // Bx
5119 -1,-1,-1,-1,-1,-1,-1,-1,
5120 -1,-1,-1,-1,-1,-1,-1,-1, // Cx
5121 -1,-1,-1,-1,-1,-1,-1,-1,
5122 -1,-1,-1,-1,-1,-1,-1,-1, // Dx
5123 -1,-1,-1,-1,-1,-1,-1,-1,
5124 -1,-1,-1,-1,-1,-1,-1,-1, // Ex
5125 -1,-1,-1,-1,-1,-1,-1,-1,
5126 -1,-1,-1,-1,-1,-1,-1,-1, // Fx
5127 -1,-1,-1,-1,-1,-1,-1,-1
5128 };
5129
5130 // <summary>
5131 // Converts a 32-bit integer into a Base64
5132 // character string. Base64 character strings
5133 // are always 8 characters long. All iinteger
5134 // values are acceptable.
5135 // </summary>
5136 // <param name="number">
5137 // 32-bit integer to be converted.
5138 // </param>
5139 // <returns>
5140 // 8 character string. The 1st six characters
5141 // contain the encoded number, the last two
5142 // characters are padded with "=".
5143 // </returns>
5144
5145 public string llIntegerToBase64(int number)
5146 {
5147 // uninitialized string
5148
5149 char[] imdt = new char[8];
5150
5151 m_host.AddScriptLPS(1);
5152
5153 // Manually unroll the loop
5154
5155 imdt[7] = '=';
5156 imdt[6] = '=';
5157 imdt[5] = i2ctable[number<<4 & 0x3F];
5158 imdt[4] = i2ctable[number>>2 & 0x3F];
5159 imdt[3] = i2ctable[number>>8 & 0x3F];
5160 imdt[2] = i2ctable[number>>14 & 0x3F];
5161 imdt[1] = i2ctable[number>>20 & 0x3F];
5162 imdt[0] = i2ctable[number>>26 & 0x3F];
5163
5164 return new string(imdt);
5165 }
5166
5167 // <summary>
5168 // Converts an eight character base-64 string
5169 // into a 32-bit integer.
5170 // </summary>
5171 // <param name="str">
5172 // 8 characters string to be converted. Other
5173 // length strings return zero.
5174 // </param>
5175 // <returns>
5176 // Returns an integer representing the
5177 // encoded value providedint he 1st 6
5178 // characters of the string.
5179 // </returns>
5180 // <remarks>
5181 // This is coded to behave like LSL's
5182 // implementation (I think), based upon the
5183 // information available at the Wiki.
5184 // If more than 8 characters are supplied,
5185 // zero is returned.
5186 // If a NULL string is supplied, zero will
5187 // be returned.
5188 // If fewer than 6 characters are supplied, then
5189 // the answer will reflect a partial
5190 // accumulation.
5191 // <para>
5192 // The 6-bit segments are
5193 // extracted left-to-right in big-endian mode,
5194 // which means that segment 6 only contains the
5195 // two low-order bits of the 32 bit integer as
5196 // its high order 2 bits. A short string therefore
5197 // means loss of low-order information. E.g.
5198 //
5199 // |<---------------------- 32-bit integer ----------------------->|<-Pad->|
5200 // |<--Byte 0----->|<--Byte 1----->|<--Byte 2----->|<--Byte 3----->|<-Pad->|
5201 // |3|3|2|2|2|2|2|2|2|2|2|2|1|1|1|1|1|1|1|1|1|1| | | | | | | | | | |P|P|P|P|
5202 // |1|0|9|8|7|6|5|4|3|2|1|0|9|8|7|6|5|4|3|2|1|0|9|8|7|6|5|4|3|2|1|0|P|P|P|P|
5203 // | str[0] | str[1] | str[2] | str[3] | str[4] | str[6] |
5204 //
5205 // </para>
5206 // </remarks>
5207
5208 public LSL_Types.LSLInteger llBase64ToInteger(string str)
5209 {
5210 int number = 0;
5211 int digit;
5212
5213 m_host.AddScriptLPS(1);
5214
5215 // Require a well-fromed base64 string
5216
5217 if (str.Length > 8)
5218 return 0;
5219
5220 // The loop is unrolled in the interests
5221 // of performance and simple necessity.
5222 //
5223 // MUST find 6 digits to be well formed
5224 // -1 == invalid
5225 // 0 == padding
5226
5227 if ((digit=c2itable[str[0]])<=0)
5228 {
5229 return digit<0?(int)0:number;
5230 }
5231 number += --digit<<26;
5232
5233 if ((digit=c2itable[str[1]])<=0)
5234 {
5235 return digit<0?(int)0:number;
5236 }
5237 number += --digit<<20;
5238
5239 if ((digit=c2itable[str[2]])<=0)
5240 {
5241 return digit<0?(int)0:number;
5242 }
5243 number += --digit<<14;
5244
5245 if ((digit=c2itable[str[3]])<=0)
5246 {
5247 return digit<0?(int)0:number;
5248 }
5249 number += --digit<<8;
5250
5251 if ((digit=c2itable[str[4]])<=0)
5252 {
5253 return digit<0?(int)0:number;
5254 }
5255 number += --digit<<2;
5256
5257 if ((digit=c2itable[str[5]])<=0)
5258 {
5259 return digit<0?(int)0:number;
5260 }
5261 number += --digit>>4;
5262
5263 // ignore trailing padding
5264
5265 return number;
5266 }
5267
5268 public double llGetGMTclock()
5269 {
5270 m_host.AddScriptLPS(1);
5271 return DateTime.UtcNow.TimeOfDay.TotalSeconds;
5272 }
5273
5274 public string llGetSimulatorHostname()
5275 {
5276 m_host.AddScriptLPS(1);
5277 return System.Environment.MachineName;
5278 }
5279
5280 public void llSetLocalRot(LSL_Types.Quaternion rot)
5281 {
5282 m_host.AddScriptLPS(1);
5283 m_host.RotationOffset = new LLQuaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s);
5284 }
5285
5286 // <summary>
5287 // Scan the string supplied in 'src' and
5288 // tokenize it based upon two sets of
5289 // tokenizers provided in two lists,
5290 // separators and spacers.
5291 // </summary>
5292 //
5293 // <remarks>
5294 // Separators demarcate tokens and are
5295 // elided as they are encountered. Spacers
5296 // also demarcate tokens, but are themselves
5297 // retained as tokens.
5298 //
5299 // Both separators and spacers may be arbitrarily
5300 // long strings. i.e. ":::".
5301 //
5302 // The function returns an ordered list
5303 // representing the tokens found in the supplied
5304 // sources string. If two successive tokenizers
5305 // are encountered, then a NULL entry is added
5306 // to the list.
5307 //
5308 // It is a precondition that the source and
5309 // toekizer lisst are non-null. If they are null,
5310 // then a null pointer exception will be thrown
5311 // while their lengths are being determined.
5312 //
5313 // A small amount of working memoryis required
5314 // of approximately 8*#tokenizers.
5315 //
5316 // There are many ways in which this function
5317 // can be implemented, this implementation is
5318 // fairly naive and assumes that when the
5319 // function is invooked with a short source
5320 // string and/or short lists of tokenizers, then
5321 // performance will not be an issue.
5322 //
5323 // In order to minimize the perofrmance
5324 // effects of long strings, or large numbers
5325 // of tokeizers, the function skips as far as
5326 // possible whenever a toekenizer is found,
5327 // and eliminates redundant tokenizers as soon
5328 // as is possible.
5329 //
5330 // The implementation tries to avoid any copying
5331 // of arrays or other objects.
5332 // </remarks>
5333
5334 public LSL_Types.list llParseStringKeepNulls(string src, LSL_Types.list separators, LSL_Types.list spacers)
5335 {
5336 int beginning = 0;
5337 int srclen = src.Length;
5338 int seplen = separators.Length;
5339 object[] separray = separators.Data;
5340 int spclen = spacers.Length;
5341 object[] spcarray = spacers.Data;
5342 int mlen = seplen+spclen;
5343
5344 int[] offset = new int[mlen+1];
5345 bool[] active = new bool[mlen];
5346
5347 int best;
5348 int j;
5349
5350 // Initial capacity reduces resize cost
5351
5352 LSL_Types.list tokens = new LSL_Types.list();
5353
5354 m_host.AddScriptLPS(1);
5355
5356 // All entries are initially valid
5357
5358 for (int i = 0; i < mlen; i++)
5359 active[i] = true;
5360
5361 offset[mlen] = srclen;
5362
5363 while (beginning < srclen)
5364 {
5365
5366 best = mlen; // as bad as it gets
5367
5368 // Scan for separators
5369
5370 for (j = 0; j < seplen; j++)
5371 {
5372 if (active[j])
5373 {
5374 // scan all of the markers
5375 if ((offset[j] = src.IndexOf((string)separray[j],beginning)) == -1)
5376 {
5377 // not present at all
5378 active[j] = false;
5379 }
5380 else
5381 {
5382 // present and correct
5383 if (offset[j] < offset[best])
5384 {
5385 // closest so far
5386 best = j;
5387 if (offset[best] == beginning)
5388 break;
5389 }
5390 }
5391 }
5392 }
5393
5394 // Scan for spacers
5395
5396 if (offset[best] != beginning)
5397 {
5398 for (j = seplen; (j < mlen) && (offset[best] > beginning); j++)
5399 {
5400 if (active[j])
5401 {
5402 // scan all of the markers
5403 if ((offset[j] = src.IndexOf((string)spcarray[j-seplen], beginning)) == -1)
5404 {
5405 // not present at all
5406 active[j] = false;
5407 }
5408 else
5409 {
5410 // present and correct
5411 if (offset[j] < offset[best])
5412 {
5413 // closest so far
5414 best = j;
5415 }
5416 }
5417 }
5418 }
5419 }
5420
5421 // This is the normal exit from the scanning loop
5422
5423 if (best == mlen)
5424 {
5425 // no markers were found on this pass
5426 // so we're pretty much done
5427 tokens.Add(src.Substring(beginning, srclen - beginning));
5428 break;
5429 }
5430
5431 // Otherwise we just add the newly delimited token
5432 // and recalculate where the search should continue.
5433
5434 tokens.Add(src.Substring(beginning,offset[best]-beginning));
5435
5436 if (best < seplen)
5437 {
5438 beginning = offset[best] + ((string)separray[best]).Length;
5439 }
5440 else
5441 {
5442 beginning = offset[best] + ((string)spcarray[best - seplen]).Length;
5443 tokens.Add(spcarray[best - seplen]);
5444 }
5445 }
5446
5447 // This an awkward an not very intuitive boundary case. If the
5448 // last substring is a tokenizer, then there is an implied trailing
5449 // null list entry. Hopefully the single comparison will not be too
5450 // arduous. Alternatively the 'break' could be replced with a return
5451 // but that's shabby programming.
5452
5453 if (beginning == srclen)
5454 {
5455 if (srclen != 0)
5456 tokens.Add("");
5457 }
5458
5459 return tokens;
5460 }
5461
5462 public void llRezAtRoot(string inventory, LSL_Types.Vector3 position, LSL_Types.Vector3 velocity,
5463 LSL_Types.Quaternion rot, int param)
5464 {
5465 m_host.AddScriptLPS(1);
5466 NotImplemented("llRezAtRoot");
5467 }
5468
5469 public LSL_Types.LSLInteger llGetObjectPermMask(int mask)
5470 {
5471 m_host.AddScriptLPS(1);
5472
5473 int permmask = 0;
5474
5475 if (mask == BuiltIn_Commands_BaseClass.MASK_BASE)//0
5476 {
5477 permmask = (int)m_host.BaseMask;
5478 }
5479
5480 else if (mask == BuiltIn_Commands_BaseClass.MASK_OWNER)//1
5481 {
5482 permmask = (int)m_host.OwnerMask;
5483 }
5484
5485 else if (mask == BuiltIn_Commands_BaseClass.MASK_GROUP)//2
5486 {
5487 permmask = (int)m_host.GroupMask;
5488 }
5489
5490 else if (mask == BuiltIn_Commands_BaseClass.MASK_EVERYONE)//3
5491 {
5492 permmask = (int)m_host.EveryoneMask;
5493 }
5494
5495 else if (mask == BuiltIn_Commands_BaseClass.MASK_NEXT)//4
5496 {
5497 permmask = (int)m_host.NextOwnerMask;
5498 }
5499
5500 return permmask;
5501 }
5502
5503 public void llSetObjectPermMask(int mask, int value)
5504 {
5505 m_host.AddScriptLPS(1);
5506 IConfigSource config = new IniConfigSource(Application.iniFilePath);
5507 if (config.Configs["XEngine"] == null)
5508 config.AddConfig("XEngine");
5509
5510 if (config.Configs["XEngine"].GetBoolean("AllowGodFunctions", false))
5511 {
5512 if (World.ExternalChecks.ExternalChecksCanRunConsoleCommand(m_host.OwnerID))
5513 {
5514 if (mask == BuiltIn_Commands_BaseClass.MASK_BASE)//0
5515 {
5516 m_host.BaseMask = (uint)value;
5517 }
5518
5519 else if (mask == BuiltIn_Commands_BaseClass.MASK_OWNER)//1
5520 {
5521 m_host.OwnerMask = (uint)value;
5522 }
5523
5524 else if (mask == BuiltIn_Commands_BaseClass.MASK_GROUP)//2
5525 {
5526 m_host.GroupMask = (uint)value;
5527 }
5528
5529 else if (mask == BuiltIn_Commands_BaseClass.MASK_EVERYONE)//3
5530 {
5531 m_host.EveryoneMask = (uint)value;
5532 }
5533
5534 else if (mask == BuiltIn_Commands_BaseClass.MASK_NEXT)//4
5535 {
5536 m_host.NextOwnerMask = (uint)value;
5537 }
5538 }
5539 }
5540 }
5541
5542 public LSL_Types.LSLInteger llGetInventoryPermMask(string item, int mask)
5543 {
5544 m_host.AddScriptLPS(1);
5545 foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory)
5546 {
5547 if (inv.Value.Name == item)
5548 {
5549 switch (mask)
5550 {
5551 case 0:
5552 return (int)inv.Value.BaseMask;
5553 case 1:
5554 return (int)inv.Value.OwnerMask;
5555 case 2:
5556 return (int)inv.Value.GroupMask;
5557 case 3:
5558 return (int)inv.Value.EveryoneMask;
5559 case 4:
5560 return (int)inv.Value.NextOwnerMask;
5561 }
5562 }
5563 }
5564 return -1;
5565 }
5566
5567 public void llSetInventoryPermMask(string item, int mask, int value)
5568 {
5569 m_host.AddScriptLPS(1);
5570 NotImplemented("llSetInventoryPermMask");
5571 }
5572
5573 public string llGetInventoryCreator(string item)
5574 {
5575 m_host.AddScriptLPS(1);
5576 foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory)
5577 {
5578 if (inv.Value.Name == item)
5579 {
5580 return inv.Value.CreatorID.ToString();
5581 }
5582 }
5583 llSay(0, "No item name '" + item + "'");
5584 return String.Empty;
5585 }
5586
5587 public void llOwnerSay(string msg)
5588 {
5589 m_host.AddScriptLPS(1);
5590
5591 World.SimChatBroadcast(Helpers.StringToField(msg), ChatTypeEnum.Owner, 0, m_host.AbsolutePosition, m_host.Name, m_host.UUID, false);
5592// IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
5593// wComm.DeliverMessage(ChatTypeEnum.Owner, 0, m_host.Name, m_host.UUID, msg);
5594 }
5595
5596 public string llRequestSimulatorData(string simulator, int data)
5597 {
5598 try
5599 {
5600 m_host.AddScriptLPS(1);
5601
5602 string reply = String.Empty;
5603
5604 RegionInfo info = m_ScriptEngine.World.RequestClosestRegion(simulator);
5605
5606 switch (data)
5607 {
5608 case 5: // DATA_SIM_POS
5609 if (info == null)
5610 return LLUUID.Zero.ToString();
5611 reply = new LSL_Types.Vector3(
5612 info.RegionLocX * Constants.RegionSize,
5613 info.RegionLocY * Constants.RegionSize,
5614 0).ToString();
5615 break;
5616 case 6: // DATA_SIM_STATUS
5617 if (info != null)
5618 reply = "up"; // Duh!
5619 else
5620 reply = "unknown";
5621 break;
5622 case 7: // DATA_SIM_RATING
5623 if (info == null)
5624 return LLUUID.Zero.ToString();
5625 int access = (int)info.EstateSettings.simAccess;
5626 if (access == 21)
5627 reply = "MATURE";
5628 else if (access == 13)
5629 reply = "MATURE";
5630 else
5631 reply = "UNKNOWN";
5632 break;
5633 default:
5634 return LLUUID.Zero.ToString(); // Raise no event
5635 }
5636 LLUUID rq = LLUUID.Random();
5637
5638 LLUUID tid = m_ScriptEngine.m_ASYNCLSLCommandManager.
5639 m_Dataserver.RegisterRequest(m_localID,
5640 m_itemID, rq.ToString());
5641
5642 m_ScriptEngine.m_ASYNCLSLCommandManager.
5643 m_Dataserver.DataserverReply(rq.ToString(), reply);
5644
5645 return tid.ToString();
5646 }
5647 catch(Exception e)
5648 {
5649 Console.WriteLine(e.ToString());
5650 return LLUUID.Zero.ToString();
5651 }
5652 }
5653
5654 public void llForceMouselook(int mouselook)
5655 {
5656 m_host.AddScriptLPS(1);
5657 NotImplemented("llForceMouselook");
5658 }
5659
5660 public double llGetObjectMass(string id)
5661 {
5662 m_host.AddScriptLPS(1);
5663 LLUUID key = new LLUUID();
5664 if (LLUUID.TryParse(id,out key))
5665 {
5666 return (double) World.GetSceneObjectPart(World.Entities[key].LocalId).GetMass();
5667 }
5668 return 0;
5669 }
5670
5671 /// <summary>
5672 /// illListReplaceList removes the sub-list defined by the inclusive indices
5673 /// start and end and inserts the src list in its place. The inclusive
5674 /// nature of the indices means that at least one element must be deleted
5675 /// if the indices are within the bounds of the existing list. I.e. 2,2
5676 /// will remove the element at index 2 and replace it with the source
5677 /// list. Both indices may be negative, with the usual interpretation. An
5678 /// interesting case is where end is lower than start. As these indices
5679 /// bound the list to be removed, then 0->end, and start->lim are removed
5680 /// and the source list is added as a suffix.
5681 /// </summary>
5682
5683 public LSL_Types.list llListReplaceList(LSL_Types.list dest, LSL_Types.list src, int start, int end)
5684 {
5685 LSL_Types.list pref = null;
5686
5687 m_host.AddScriptLPS(1);
5688
5689 // Note that although we have normalized, both
5690 // indices could still be negative.
5691 if (start < 0)
5692 {
5693 start = start+dest.Length;
5694 }
5695
5696 if (end < 0)
5697 {
5698 end = end+dest.Length;
5699 }
5700 // The comventional case, remove a sequence starting with
5701 // start and ending with end. And then insert the source
5702 // list.
5703 if (start <= end)
5704 {
5705 // If greater than zero, then there is going to be a
5706 // surviving prefix. Otherwise the inclusive nature
5707 // of the indices mean that we're going to add the
5708 // source list as a prefix.
5709 if (start > 0)
5710 {
5711 pref = dest.GetSublist(0,start-1);
5712 // Only add a suffix if there is something
5713 // beyond the end index (it's inclusive too).
5714 if (end + 1 < dest.Length)
5715 {
5716 return pref + src + dest.GetSublist(end + 1, -1);
5717 }
5718 else
5719 {
5720 return pref + src;
5721 }
5722 }
5723 // If start is less than or equal to zero, then
5724 // the new list is simply a prefix. We still need to
5725 // figure out any necessary surgery to the destination
5726 // based upon end. Note that if end exceeds the upper
5727 // bound in this case, the entire destination list
5728 // is removed.
5729 else
5730 {
5731 if (end + 1 < dest.Length)
5732 {
5733 return src + dest.GetSublist(end + 1, -1);
5734 }
5735 else
5736 {
5737 return src;
5738 }
5739 }
5740 }
5741 // Finally, if start > end, we strip away a prefix and
5742 // a suffix, to leave the list that sits <between> ens
5743 // and start, and then tag on the src list. AT least
5744 // that's my interpretation. We can get sublist to do
5745 // this for us. Note that one, or both of the indices
5746 // might have been negative.
5747 else
5748 {
5749 return dest.GetSublist(end + 1, start - 1) + src;
5750 }
5751 }
5752
5753 public void llLoadURL(string avatar_id, string message, string url)
5754 {
5755 m_host.AddScriptLPS(1);
5756 LLUUID avatarId = new LLUUID(avatar_id);
5757 m_ScriptEngine.World.SendUrlToUser(avatarId, m_host.Name, m_host.UUID, m_host.ObjectOwner, false, message,
5758 url);
5759 }
5760
5761 public void llParcelMediaCommandList(LSL_Types.list commandList)
5762 {
5763 m_host.AddScriptLPS(1);
5764 NotImplemented("llParcelMediaCommandList");
5765 }
5766
5767 public void llParcelMediaQuery()
5768 {
5769 m_host.AddScriptLPS(1);
5770 NotImplemented("llParcelMediaQuery");
5771 }
5772
5773 public LSL_Types.LSLInteger llModPow(int a, int b, int c)
5774 {
5775 m_host.AddScriptLPS(1);
5776 Int64 tmp = 0;
5777 Math.DivRem(Convert.ToInt64(Math.Pow(a, b)), c, out tmp);
5778 return Convert.ToInt32(tmp);
5779 }
5780
5781 public LSL_Types.LSLInteger llGetInventoryType(string name)
5782 {
5783 m_host.AddScriptLPS(1);
5784 foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory)
5785 {
5786 if (inv.Value.Name == name)
5787 {
5788 return inv.Value.InvType;
5789 }
5790 }
5791 return -1;
5792 }
5793
5794 public void llSetPayPrice(int price, LSL_Types.list quick_pay_buttons)
5795 {
5796 m_host.AddScriptLPS(1);
5797
5798 if (quick_pay_buttons.Data.Length != 4)
5799 {
5800 LSLError("List must have 4 elements");
5801 return;
5802 }
5803 m_host.ParentGroup.RootPart.PayPrice[0]=price;
5804 m_host.ParentGroup.RootPart.PayPrice[1]=(int)quick_pay_buttons.Data[0];
5805 m_host.ParentGroup.RootPart.PayPrice[2]=(int)quick_pay_buttons.Data[1];
5806 m_host.ParentGroup.RootPart.PayPrice[3]=(int)quick_pay_buttons.Data[2];
5807 m_host.ParentGroup.RootPart.PayPrice[4]=(int)quick_pay_buttons.Data[3];
5808 }
5809
5810 public LSL_Types.Vector3 llGetCameraPos()
5811 {
5812 m_host.AddScriptLPS(1);
5813 NotImplemented("llGetCameraPos");
5814 return new LSL_Types.Vector3();
5815 }
5816
5817 public LSL_Types.Quaternion llGetCameraRot()
5818 {
5819 m_host.AddScriptLPS(1);
5820 NotImplemented("llGetCameraRot");
5821 return new LSL_Types.Quaternion();
5822 }
5823
5824 public void llSetPrimURL()
5825 {
5826 m_host.AddScriptLPS(1);
5827 NotImplemented("llSetPrimURL");
5828 }
5829
5830 public void llRefreshPrimURL()
5831 {
5832 m_host.AddScriptLPS(1);
5833 NotImplemented("llRefreshPrimURL");
5834 }
5835
5836 public string llEscapeURL(string url)
5837 {
5838 m_host.AddScriptLPS(1);
5839 try
5840 {
5841 return Uri.EscapeUriString(url);
5842 }
5843 catch (Exception ex)
5844 {
5845 return "llEscapeURL: " + ex.ToString();
5846 }
5847 }
5848
5849 public string llUnescapeURL(string url)
5850 {
5851 m_host.AddScriptLPS(1);
5852 try
5853 {
5854 return Uri.UnescapeDataString(url);
5855 }
5856 catch (Exception ex)
5857 {
5858 return "llUnescapeURL: " + ex.ToString();
5859 }
5860 }
5861
5862 public void llMapDestination(string simname, LSL_Types.Vector3 pos, LSL_Types.Vector3 look_at)
5863 {
5864 m_host.AddScriptLPS(1);
5865 NotImplemented("llMapDestination");
5866 }
5867
5868 public void llAddToLandBanList(string avatar, double hours)
5869 {
5870 m_host.AddScriptLPS(1);
5871 LLUUID key;
5872 LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).landData;
5873 if (land.ownerID == m_host.OwnerID)
5874 {
5875 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
5876 if (LLUUID.TryParse(avatar, out key))
5877 {
5878 entry.AgentID = key;
5879 entry.Flags = ParcelManager.AccessList.Ban;
5880 entry.Time = DateTime.Now.AddHours(hours);
5881 land.parcelAccessList.Add(entry);
5882 }
5883 }
5884 }
5885
5886 public void llRemoveFromLandPassList(string avatar)
5887 {
5888 m_host.AddScriptLPS(1);
5889 LLUUID key;
5890 LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).landData;
5891 if (land.ownerID == m_host.OwnerID)
5892 {
5893 if (LLUUID.TryParse(avatar, out key))
5894 {
5895 foreach (ParcelManager.ParcelAccessEntry entry in land.parcelAccessList)
5896 {
5897 if (entry.AgentID == key && entry.Flags == ParcelManager.AccessList.Access)
5898 {
5899 land.parcelAccessList.Remove(entry);
5900 break;
5901 }
5902 }
5903 }
5904 }
5905 }
5906
5907 public void llRemoveFromLandBanList(string avatar)
5908 {
5909 m_host.AddScriptLPS(1);
5910 LLUUID key;
5911 LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).landData;
5912 if (land.ownerID == m_host.OwnerID)
5913 {
5914 if (LLUUID.TryParse(avatar, out key))
5915 {
5916 foreach (ParcelManager.ParcelAccessEntry entry in land.parcelAccessList)
5917 {
5918 if (entry.AgentID == key && entry.Flags == ParcelManager.AccessList.Ban)
5919 {
5920 land.parcelAccessList.Remove(entry);
5921 break;
5922 }
5923 }
5924 }
5925 }
5926 }
5927
5928 public void llSetCameraParams(LSL_Types.list rules)
5929 {
5930 m_host.AddScriptLPS(1);
5931 NotImplemented("llSetCameraParams");
5932 }
5933
5934 public void llClearCameraParams()
5935 {
5936 m_host.AddScriptLPS(1);
5937 NotImplemented("llClearCameraParams");
5938 }
5939
5940 public double llListStatistics(int operation, LSL_Types.list src)
5941 {
5942 m_host.AddScriptLPS(1);
5943 LSL_Types.list nums = LSL_Types.list.ToDoubleList(src);
5944 switch (operation)
5945 {
5946 case BuiltIn_Commands_BaseClass.LIST_STAT_RANGE:
5947 return nums.Range();
5948 case BuiltIn_Commands_BaseClass.LIST_STAT_MIN:
5949 return nums.Min();
5950 case BuiltIn_Commands_BaseClass.LIST_STAT_MAX:
5951 return nums.Max();
5952 case BuiltIn_Commands_BaseClass.LIST_STAT_MEAN:
5953 return nums.Mean();
5954 case BuiltIn_Commands_BaseClass.LIST_STAT_MEDIAN:
5955 return nums.Median();
5956 case BuiltIn_Commands_BaseClass.LIST_STAT_NUM_COUNT:
5957 return nums.NumericLength();
5958 case BuiltIn_Commands_BaseClass.LIST_STAT_STD_DEV:
5959 return nums.StdDev();
5960 case BuiltIn_Commands_BaseClass.LIST_STAT_SUM:
5961 return nums.Sum();
5962 case BuiltIn_Commands_BaseClass.LIST_STAT_SUM_SQUARES:
5963 return nums.SumSqrs();
5964 case BuiltIn_Commands_BaseClass.LIST_STAT_GEOMETRIC_MEAN:
5965 return nums.GeometricMean();
5966 case BuiltIn_Commands_BaseClass.LIST_STAT_HARMONIC_MEAN:
5967 return nums.HarmonicMean();
5968 default:
5969 return 0.0;
5970 }
5971 }
5972
5973 public LSL_Types.LSLInteger llGetUnixTime()
5974 {
5975 m_host.AddScriptLPS(1);
5976 return Util.UnixTimeSinceEpoch();
5977 }
5978
5979 public LSL_Types.LSLInteger llGetParcelFlags(LSL_Types.Vector3 pos)
5980 {
5981 m_host.AddScriptLPS(1);
5982 return (int)World.LandChannel.GetLandObject((float)pos.x, (float)pos.y).landData.landFlags;
5983 }
5984
5985 public LSL_Types.LSLInteger llGetRegionFlags()
5986 {
5987 m_host.AddScriptLPS(1);
5988 return (int)World.RegionInfo.EstateSettings.regionFlags;
5989 }
5990
5991 public string llXorBase64StringsCorrect(string str1, string str2)
5992 {
5993 m_host.AddScriptLPS(1);
5994 string ret = String.Empty;
5995 string src1 = llBase64ToString(str1);
5996 string src2 = llBase64ToString(str2);
5997 int c = 0;
5998 for (int i = 0; i < src1.Length; i++)
5999 {
6000 ret += src1[i] ^ src2[c];
6001
6002 c++;
6003 if (c > src2.Length)
6004 c = 0;
6005 }
6006 return llStringToBase64(ret);
6007 }
6008
6009 public string llHTTPRequest(string url, LSL_Types.list parameters, string body)
6010 {
6011 // Partial implementation: support for parameter flags needed
6012 // see http://wiki.secondlife.com/wiki/LlHTTPRequest
6013 // parameter flags support are implemented in ScriptsHttpRequests.cs
6014 // in StartHttpRequest
6015
6016 m_host.AddScriptLPS(1);
6017 IHttpRequests httpScriptMod =
6018 m_ScriptEngine.World.RequestModuleInterface<IHttpRequests>();
6019 List<string> param = new List<string>();
6020 foreach (object o in parameters.Data)
6021 {
6022 param.Add(o.ToString());
6023 }
6024 LLUUID reqID = httpScriptMod.
6025 StartHttpRequest(m_localID, m_itemID, url, param, body);
6026
6027 if (reqID != LLUUID.Zero)
6028 return reqID.ToString();
6029 else
6030 return null;
6031 }
6032
6033 public void llResetLandBanList()
6034 {
6035 m_host.AddScriptLPS(1);
6036 LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).landData;
6037 if (land.ownerID == m_host.OwnerID)
6038 {
6039 foreach (ParcelManager.ParcelAccessEntry entry in land.parcelAccessList)
6040 {
6041 if (entry.Flags == ParcelManager.AccessList.Ban)
6042 {
6043 land.parcelAccessList.Remove(entry);
6044 }
6045 }
6046 }
6047 }
6048
6049 public void llResetLandPassList()
6050 {
6051 m_host.AddScriptLPS(1);
6052 LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).landData;
6053 if (land.ownerID == m_host.OwnerID)
6054 {
6055 foreach (ParcelManager.ParcelAccessEntry entry in land.parcelAccessList)
6056 {
6057 if (entry.Flags == ParcelManager.AccessList.Access)
6058 {
6059 land.parcelAccessList.Remove(entry);
6060 }
6061 }
6062 }
6063 }
6064
6065 public LSL_Types.LSLInteger llGetParcelPrimCount(LSL_Types.Vector3 pos, int category, int sim_wide)
6066 {
6067 m_host.AddScriptLPS(1);
6068
6069 LandData land = World.GetLandData((float)pos.x, (float)pos.y);
6070
6071 if (land == null)
6072 {
6073 return 0;
6074 }
6075
6076 else
6077 {
6078 if (sim_wide == 1)
6079 {
6080 if (category == 0)
6081 {
6082 return land.simwidePrims;
6083 }
6084
6085 else
6086 {
6087 //public int simwideArea = 0;
6088 return 0;
6089 }
6090 }
6091
6092 else
6093 {
6094 if (category == 0)//Total Prims
6095 {
6096 return 0;//land.
6097 }
6098
6099 else if (category == 1)//Owner Prims
6100 {
6101 return land.ownerPrims;
6102 }
6103
6104 else if (category == 2)//Group Prims
6105 {
6106 return land.groupPrims;
6107 }
6108
6109 else if (category == 3)//Other Prims
6110 {
6111 return land.otherPrims;
6112 }
6113
6114 else if (category == 4)//Selected
6115 {
6116 return land.selectedPrims;
6117 }
6118
6119 else if (category == 5)//Temp
6120 {
6121 return 0;//land.
6122 }
6123 }
6124 }
6125 return 0;
6126 }
6127
6128 public LSL_Types.list llGetParcelPrimOwners(LSL_Types.Vector3 pos)
6129 {
6130 m_host.AddScriptLPS(1);
6131 LandObject land = (LandObject)World.LandChannel.GetLandObject((float)pos.x, (float)pos.y);
6132 LSL_Types.list ret = new LSL_Types.list();
6133 if (land != null)
6134 {
6135 foreach (KeyValuePair<LLUUID, int> d in land.getLandObjectOwners())
6136 {
6137 ret.Add(d.Key.ToString());
6138 ret.Add(d.Value);
6139 }
6140 }
6141 return ret;
6142 }
6143
6144 public LSL_Types.LSLInteger llGetObjectPrimCount(string object_id)
6145 {
6146 m_host.AddScriptLPS(1);
6147 SceneObjectPart part = World.GetSceneObjectPart(new LLUUID(object_id));
6148 if (part == null)
6149 {
6150 return 0;
6151 }
6152 else
6153 {
6154 return part.ParentGroup.Children.Count;
6155 }
6156 }
6157
6158 public LSL_Types.LSLInteger llGetParcelMaxPrims(LSL_Types.Vector3 pos, int sim_wide)
6159 {
6160 m_host.AddScriptLPS(1);
6161 // Alondria: This currently just is utilizing the normal grid's 0.22 prims/m2 calculation
6162 // Which probably will be irrelevent in OpenSim....
6163 LandData land = World.GetLandData((float)pos.x, (float)pos.y);
6164
6165 float bonusfactor = World.RegionInfo.EstateSettings.objectBonusFactor;
6166
6167 if (land == null)
6168 {
6169 return 0;
6170 }
6171
6172 if (sim_wide == 1)
6173 {
6174 decimal v = land.simwideArea * (decimal)(0.22) * (decimal)bonusfactor;
6175
6176 return (int)v;
6177 }
6178
6179 else
6180 {
6181 decimal v = land.area * (decimal)(0.22) * (decimal)bonusfactor;
6182
6183 return (int)v;
6184 }
6185
6186 }
6187
6188 public LSL_Types.list llGetParcelDetails(LSL_Types.Vector3 pos, LSL_Types.list param)
6189 {
6190 m_host.AddScriptLPS(1);
6191 LandData land = World.GetLandData((float)pos.x, (float)pos.y);
6192 if (land == null)
6193 {
6194 return new LSL_Types.list(0);
6195 }
6196 LSL_Types.list ret = new LSL_Types.list();
6197 foreach (object o in param.Data)
6198 {
6199 switch (o.ToString())
6200 {
6201 case "0":
6202 ret = ret + new LSL_Types.list(land.landName);
6203 break;
6204 case "1":
6205 ret = ret + new LSL_Types.list(land.landDesc);
6206 break;
6207 case "2":
6208 ret = ret + new LSL_Types.list(land.ownerID.ToString());
6209 break;
6210 case "3":
6211 ret = ret + new LSL_Types.list(land.groupID.ToString());
6212 break;
6213 case "4":
6214 ret = ret + new LSL_Types.list(land.area);
6215 break;
6216 default:
6217 ret = ret + new LSL_Types.list(0);
6218 break;
6219 }
6220 }
6221 return ret;
6222 }
6223
6224 public void llSetLinkTexture(int linknumber, string texture, int face)
6225 {
6226 m_host.AddScriptLPS(1);
6227 NotImplemented("llSetLinkTexture");
6228 }
6229
6230 public string llStringTrim(string src, int type)
6231 {
6232 m_host.AddScriptLPS(1);
6233 if (type == (int)BuiltIn_Commands_BaseClass.STRING_TRIM_HEAD) { return src.TrimStart(); }
6234 if (type == (int)BuiltIn_Commands_BaseClass.STRING_TRIM_TAIL) { return src.TrimEnd(); }
6235 if (type == (int)BuiltIn_Commands_BaseClass.STRING_TRIM) { return src.Trim(); }
6236 return src;
6237 }
6238
6239 public LSL_Types.list llGetObjectDetails(string id, LSL_Types.list args)
6240 {
6241 m_host.AddScriptLPS(1);
6242 LSL_Types.list ret = new LSL_Types.list();
6243 LLUUID key = new LLUUID();
6244 if (LLUUID.TryParse(id, out key))
6245 {
6246 ScenePresence av = World.GetScenePresence(key);
6247
6248 if (av != null)
6249 {
6250 foreach (object o in args.Data)
6251 {
6252 switch (o.ToString())
6253 {
6254 case "1":
6255 ret.Add(av.Firstname + " " + av.Lastname);
6256 break;
6257 case "2":
6258 ret.Add("");
6259 break;
6260 case "3":
6261 ret.Add(new LSL_Types.Vector3((double)av.AbsolutePosition.X, (double)av.AbsolutePosition.Y, (double)av.AbsolutePosition.Z));
6262 break;
6263 case "4":
6264 ret.Add(new LSL_Types.Quaternion((double)av.Rotation.x, (double)av.Rotation.y, (double)av.Rotation.z, (double)av.Rotation.w));
6265 break;
6266 case "5":
6267 ret.Add(new LSL_Types.Vector3(av.Velocity.X,av.Velocity.Y,av.Velocity.Z));
6268 break;
6269 case "6":
6270 ret.Add(id);
6271 break;
6272 case "7":
6273 ret.Add(LLUUID.Zero.ToString());
6274 break;
6275 case "8":
6276 ret.Add(LLUUID.Zero.ToString());
6277 break;
6278 }
6279 }
6280 return ret;
6281 }
6282 SceneObjectPart obj = World.GetSceneObjectPart(key);
6283 if (obj != null)
6284 {
6285 foreach (object o in args.Data)
6286 {
6287 switch (o.ToString())
6288 {
6289 case "1":
6290 ret.Add(obj.Name);
6291 break;
6292 case "2":
6293 ret.Add(obj.Description);
6294 break;
6295 case "3":
6296 ret.Add(new LSL_Types.Vector3(obj.AbsolutePosition.X,obj.AbsolutePosition.Y,obj.AbsolutePosition.Z));
6297 break;
6298 case "4":
6299 ret.Add(new LSL_Types.Quaternion(obj.RotationOffset.X, obj.RotationOffset.Y, obj.RotationOffset.Z, obj.RotationOffset.W));
6300 break;
6301 case "5":
6302 ret.Add(new LSL_Types.Vector3(obj.Velocity.X, obj.Velocity.Y, obj.Velocity.Z));
6303 break;
6304 case "6":
6305 ret.Add(obj.OwnerID.ToString());
6306 break;
6307 case "7":
6308 ret.Add(obj.GroupID.ToString());
6309 break;
6310 case "8":
6311 ret.Add(obj.CreatorID.ToString());
6312 break;
6313 }
6314 }
6315 return ret;
6316 }
6317 }
6318 return new LSL_Types.list();
6319 }
6320
6321
6322 internal LLUUID ScriptByName(string name)
6323 {
6324 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
6325 {
6326 if (item.Type == 10 && item.Name == name)
6327 return item.ItemID;
6328 }
6329 return LLUUID.Zero;
6330 }
6331
6332 internal void ShoutError(string msg)
6333 {
6334 llShout(BuiltIn_Commands_BaseClass.DEBUG_CHANNEL, msg);
6335 }
6336
6337
6338
6339 internal void NotImplemented(string command)
6340 {
6341 if (throwErrorOnNotImplemented)
6342 throw new NotImplementedException("Command not implemented: " + command);
6343 }
6344
6345 internal void Deprecated(string command)
6346 {
6347 throw new Exception("Command deprecated: " + command);
6348 }
6349
6350 internal void LSLError(string msg)
6351 {
6352 throw new Exception("LSL Runtime Error: " + msg);
6353 }
6354
6355 public delegate void AssetRequestCallback(LLUUID assetID, AssetBase asset);
6356 private void WithNotecard(LLUUID assetID, AssetRequestCallback cb)
6357 {
6358 World.AssetCache.GetAsset(assetID, delegate(LLUUID i, AssetBase a) { cb(i, a); }, false);
6359 }
6360
6361 public string llGetNumberOfNotecardLines(string name)
6362 {
6363 m_host.AddScriptLPS(1);
6364
6365 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
6366 {
6367 if (item.Type == 7 && item.Name == name)
6368 {
6369 LLUUID tid = m_ScriptEngine.m_ASYNCLSLCommandManager.
6370 m_Dataserver.RegisterRequest(m_localID,
6371 m_itemID, item.AssetID.ToString());
6372 if (NotecardCache.IsCached(item.AssetID))
6373 {
6374 m_ScriptEngine.m_ASYNCLSLCommandManager.
6375 m_Dataserver.DataserverReply(item.AssetID.ToString(),
6376 NotecardCache.GetLines(item.AssetID).ToString());
6377 return tid.ToString();
6378 }
6379 WithNotecard(item.AssetID, delegate (LLUUID id, AssetBase a)
6380 {
6381 System.Text.ASCIIEncoding enc =
6382 new System.Text.ASCIIEncoding();
6383 string data = enc.GetString(a.Data);
6384 //Console.WriteLine(data);
6385 NotecardCache.Cache(id, data);
6386 m_ScriptEngine.m_ASYNCLSLCommandManager.
6387 m_Dataserver.DataserverReply(id.ToString(),
6388 NotecardCache.GetLines(id).ToString());
6389 });
6390
6391 return tid.ToString();
6392 }
6393 }
6394 return LLUUID.Zero.ToString();
6395 }
6396
6397 public string llGetNotecardLine(string name, int line)
6398 {
6399 m_host.AddScriptLPS(1);
6400
6401 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
6402 {
6403 if (item.Type == 7 && item.Name == name)
6404 {
6405 LLUUID tid = m_ScriptEngine.m_ASYNCLSLCommandManager.
6406 m_Dataserver.RegisterRequest(m_localID,
6407 m_itemID, item.AssetID.ToString());
6408 if (NotecardCache.IsCached(item.AssetID))
6409 {
6410 m_ScriptEngine.m_ASYNCLSLCommandManager.
6411 m_Dataserver.DataserverReply(item.AssetID.ToString(),
6412 NotecardCache.GetLine(item.AssetID, line));
6413 return tid.ToString();
6414 }
6415 WithNotecard(item.AssetID, delegate (LLUUID id, AssetBase a)
6416 {
6417 System.Text.ASCIIEncoding enc =
6418 new System.Text.ASCIIEncoding();
6419 string data = enc.GetString(a.Data);
6420 //Console.WriteLine(data);
6421 NotecardCache.Cache(id, data);
6422 m_ScriptEngine.m_ASYNCLSLCommandManager.
6423 m_Dataserver.DataserverReply(id.ToString(),
6424 NotecardCache.GetLine(id, line));
6425 });
6426
6427 return tid.ToString();
6428 }
6429 }
6430
6431 return String.Empty;
6432 }
6433
6434 }
6435
6436 public class NotecardCache
6437 {
6438 private class Notecard
6439 {
6440 public string[] text;
6441 public DateTime lastRef;
6442 }
6443
6444 private static Dictionary<LLUUID, Notecard> m_Notecards =
6445 new Dictionary<LLUUID, Notecard>();
6446
6447 public static void Cache(LLUUID assetID, string text)
6448 {
6449 CacheCheck();
6450
6451 lock (m_Notecards)
6452 {
6453 if (m_Notecards.ContainsKey(assetID))
6454 return;
6455
6456 Notecard nc = new Notecard();
6457 nc.lastRef = DateTime.Now;
6458 nc.text = ParseText(text.Replace("\r", "").Split('\n'));
6459 m_Notecards[assetID] = nc;
6460 }
6461 }
6462
6463 private static string[] ParseText(string[] input)
6464 {
6465 int idx = 0;
6466 int level = 0;
6467 List<string> output = new List<string>();
6468 string[] words;
6469
6470 while (idx < input.Length)
6471 {
6472 if (input[idx] == "{")
6473 {
6474 level++;
6475 idx++;
6476 continue;
6477 }
6478
6479 if (input[idx]== "}")
6480 {
6481 level--;
6482 idx++;
6483 continue;
6484 }
6485
6486 switch (level)
6487 {
6488 case 0:
6489 words = input[idx].Split(' '); // Linden text ver
6490 int version = int.Parse(words[3]);
6491 if (version != 2)
6492 return new String[0];
6493 break;
6494 case 1:
6495 words = input[idx].Split(' ');
6496 if (words[0] == "LLEmbeddedItems")
6497 break;
6498 if (words[0] == "Text")
6499 {
6500 int len = int.Parse(words[2]);
6501 idx++;
6502
6503 int count = -1;
6504
6505 while (count < len)
6506 {
6507 int l = input[idx].Length;
6508 string ln = input[idx];
6509
6510 int need = len-count-1;
6511 if (ln.Length > need)
6512 ln = ln.Substring(0, need);
6513
6514 output.Add(ln);
6515 count += ln.Length + 1;
6516 idx++;
6517 }
6518
6519 return output.ToArray();
6520 }
6521 break;
6522 case 2:
6523 words = input[idx].Split(' '); // count
6524 if (words[0] == "count")
6525 {
6526 int c = int.Parse(words[1]);
6527 if (c > 0)
6528 return new String[0];
6529 break;
6530 }
6531 break;
6532 }
6533 idx++;
6534 }
6535 return output.ToArray();
6536 }
6537
6538 public static bool IsCached(LLUUID assetID)
6539 {
6540 lock (m_Notecards)
6541 {
6542 return m_Notecards.ContainsKey(assetID);
6543 }
6544 }
6545
6546 public static int GetLines(LLUUID assetID)
6547 {
6548 if (!IsCached(assetID))
6549 return -1;
6550
6551 lock (m_Notecards)
6552 {
6553 m_Notecards[assetID].lastRef = DateTime.Now;
6554 return m_Notecards[assetID].text.Length;
6555 }
6556 }
6557
6558 public static string GetLine(LLUUID assetID, int line)
6559 {
6560 if (line < 0)
6561 return "";
6562
6563 string data;
6564
6565 if (!IsCached(assetID))
6566 return "";
6567
6568 lock (m_Notecards)
6569 {
6570 m_Notecards[assetID].lastRef = DateTime.Now;
6571
6572 if (line >= m_Notecards[assetID].text.Length)
6573 return "\n\n\n";
6574
6575 data = m_Notecards[assetID].text[line];
6576 if (data.Length > 255)
6577 data = data.Substring(0, 255);
6578
6579 return data;
6580 }
6581 }
6582
6583 public static void CacheCheck()
6584 {
6585 foreach (LLUUID key in new List<LLUUID>(m_Notecards.Keys))
6586 {
6587 Notecard nc = m_Notecards[key];
6588 if (nc.lastRef.AddSeconds(30) < DateTime.Now)
6589 m_Notecards.Remove(key);
6590 }
6591 }
6592 }
6593}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/OSSL_ScriptCommands.cs b/OpenSim/Region/ScriptEngine/XEngine/OSSL_ScriptCommands.cs
deleted file mode 100644
index bc4e8ba..0000000
--- a/OpenSim/Region/ScriptEngine/XEngine/OSSL_ScriptCommands.cs
+++ /dev/null
@@ -1,553 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using Axiom.Math;
29using libsecondlife;
30using Nini.Config;
31using OpenSim.Framework.Console;
32using OpenSim.Region.Environment.Interfaces;
33using OpenSim.Region.Environment.Scenes;
34using OpenSim.Region.ScriptEngine.XEngine.Script;
35
36namespace OpenSim.Region.ScriptEngine.XEngine
37{
38 [Serializable]
39 public class OSSL_ScriptCommands : MarshalByRefObject, IOSSL_ScriptCommands
40 {
41 internal XEngine m_ScriptEngine;
42 internal XScriptInstance m_Instance;
43 internal SceneObjectPart m_host;
44 internal uint m_localID;
45 internal LLUUID m_itemID;
46
47 public OSSL_ScriptCommands(XEngine scriptEngine,
48 XScriptInstance instance, SceneObjectPart host,
49 uint localID, LLUUID itemID)
50 {
51 m_ScriptEngine = scriptEngine;
52 m_Instance = instance;
53 m_host = host;
54 m_localID = localID;
55 m_itemID = itemID;
56 }
57
58
59 //
60 // OpenSim functions
61 //
62
63 public int osTerrainSetHeight(int x, int y, double val)
64 {
65 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
66 {
67 OSSLError("osTerrainSetHeight: permission denied");
68 return 0;
69 }
70
71 m_host.AddScriptLPS(1);
72 if (x > 255 || x < 0 || y > 255 || y < 0)
73 OSSLError("osTerrainSetHeight: Coordinate out of bounds");
74
75 if (World.ExternalChecks.ExternalChecksCanTerraformLand(m_host.OwnerID, new LLVector3(x, y, 0)))
76 {
77 World.Heightmap[x, y] = val;
78 return 1;
79 }
80 else
81 {
82 return 0;
83 }
84 }
85
86 public double osTerrainGetHeight(int x, int y)
87 {
88 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
89 {
90 OSSLError("osTerrainGetHeight: permission denied");
91 return 0.0;
92 }
93
94 m_host.AddScriptLPS(1);
95 if (x > 255 || x < 0 || y > 255 || y < 0)
96 OSSLError("osTerrainGetHeight: Coordinate out of bounds");
97
98 return World.Heightmap[x, y];
99 }
100
101 public int osRegionRestart(double seconds)
102 {
103 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
104 {
105 OSSLError("osRegionRestart: permission denied");
106 return 0;
107 }
108
109 m_host.AddScriptLPS(1);
110 if (World.ExternalChecks.ExternalChecksCanIssueEstateCommand(m_host.OwnerID))
111 {
112 World.Restart((float)seconds);
113 return 1;
114 }
115 else
116 {
117 return 0;
118 }
119 }
120
121 public void osRegionNotice(string msg)
122 {
123 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
124 {
125 OSSLError("osRegionNotice: permission denied");
126 return;
127 }
128
129 m_host.AddScriptLPS(1);
130 World.SendGeneralAlert(msg);
131 }
132
133 public void osSetRot(LLUUID target, Quaternion rotation)
134 {
135 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
136 {
137 OSSLError("osSetRot: permission denied");
138 return;
139 }
140
141 m_host.AddScriptLPS(1);
142 if (World.Entities.ContainsKey(target))
143 {
144 World.Entities[target].Rotation = rotation;
145 }
146 else
147 {
148 OSSLError("osSetRot: Invalid target");
149 }
150 }
151
152 public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams,
153 int timer)
154 {
155 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
156 {
157 OSSLError("osSetDynamicTextureURL: permission denied");
158 return String.Empty;
159 }
160
161 m_host.AddScriptLPS(1);
162 if (dynamicID == String.Empty)
163 {
164 IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
165 LLUUID createdTexture =
166 textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, contentType, url,
167 extraParams, timer);
168 return createdTexture.ToString();
169 }
170 else
171 {
172 //TODO update existing dynamic textures
173 }
174
175 return LLUUID.Zero.ToString();
176 }
177
178 public string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams,
179 int timer, int alpha)
180 {
181 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
182 {
183 OSSLError("osSetDynamicTextureURLBlend: permission denied");
184 return String.Empty;
185 }
186
187 m_host.AddScriptLPS(1);
188 if (dynamicID == String.Empty)
189 {
190 IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
191 LLUUID createdTexture =
192 textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, contentType, url,
193 extraParams, timer, true, (byte) alpha);
194 return createdTexture.ToString();
195 }
196 else
197 {
198 //TODO update existing dynamic textures
199 }
200
201 return LLUUID.Zero.ToString();
202 }
203
204 public string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams,
205 int timer)
206 {
207 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
208 {
209 OSSLError("osSetDynamicTextureData: permission denied");
210 return String.Empty;
211 }
212
213 m_host.AddScriptLPS(1);
214 if (dynamicID == String.Empty)
215 {
216 IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
217 if (textureManager != null)
218 {
219 LLUUID createdTexture =
220 textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, contentType, data,
221 extraParams, timer);
222 return createdTexture.ToString();
223 }
224 }
225 else
226 {
227 //TODO update existing dynamic textures
228 }
229
230 return LLUUID.Zero.ToString();
231 }
232
233 public string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams,
234 int timer, int alpha)
235 {
236 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
237 {
238 OSSLError("osSetDynamicTextureDataBlend: permission denied");
239 return String.Empty;
240 }
241
242 m_host.AddScriptLPS(1);
243 if (dynamicID == String.Empty)
244 {
245 IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
246 if (textureManager != null)
247 {
248 LLUUID createdTexture =
249 textureManager.AddDynamicTextureData(World.RegionInfo.RegionID, m_host.UUID, contentType, data,
250 extraParams, timer, true, (byte) alpha);
251 return createdTexture.ToString();
252 }
253 }
254 else
255 {
256 //TODO update existing dynamic textures
257 }
258
259 return LLUUID.Zero.ToString();
260 }
261
262 public bool osConsoleCommand(string command)
263 {
264 m_host.AddScriptLPS(1);
265 if (m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowosConsoleCommand", false))
266 {
267 if (World.ExternalChecks.ExternalChecksCanRunConsoleCommand(m_host.OwnerID))
268 {
269 MainConsole.Instance.RunCommand(command);
270 return true;
271 }
272 return false;
273 }
274 return false;
275 }
276 public void osSetPrimFloatOnWater(int floatYN)
277 {
278 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
279 {
280 OSSLError("osSetPrimFloatOnWater: permission denied");
281 return;
282 }
283
284 m_host.AddScriptLPS(1);
285 if (m_host.ParentGroup != null)
286 {
287 if (m_host.ParentGroup.RootPart != null)
288 {
289 m_host.ParentGroup.RootPart.SetFloatOnWater(floatYN);
290 }
291 }
292 }
293
294 // Adam's super super custom animation functions
295 public void osAvatarPlayAnimation(string avatar, string animation)
296 {
297 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
298 {
299 OSSLError("osAvatarPlayAnimation: permission denied");
300 return;
301 }
302
303 m_host.AddScriptLPS(1);
304 if (World.Entities.ContainsKey(avatar) && World.Entities[avatar] is ScenePresence)
305 {
306 ScenePresence target = (ScenePresence)World.Entities[avatar];
307 target.AddAnimation(avatar);
308 }
309 }
310
311 public void osAvatarStopAnimation(string avatar, string animation)
312 {
313 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
314 {
315 OSSLError("osAvatarStopAnimation: permission denied");
316 return;
317 }
318
319 m_host.AddScriptLPS(1);
320 if (World.Entities.ContainsKey(avatar) && World.Entities[avatar] is ScenePresence)
321 {
322 ScenePresence target = (ScenePresence)World.Entities[avatar];
323 target.RemoveAnimation(animation);
324 }
325 }
326
327 //Texture draw functions
328 public string osMovePen(string drawList, int x, int y)
329 {
330 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
331 {
332 OSSLError("osMovePen: permission denied");
333 return String.Empty;
334 }
335
336 m_host.AddScriptLPS(1);
337 drawList += "MoveTo " + x + "," + y + ";";
338 return drawList;
339 }
340
341 public string osDrawLine(string drawList, int startX, int startY, int endX, int endY)
342 {
343 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
344 {
345 OSSLError("osDrawLine: permission denied");
346 return String.Empty;
347 }
348
349 m_host.AddScriptLPS(1);
350 drawList += "MoveTo "+ startX+","+ startY +"; LineTo "+endX +","+endY +"; ";
351 return drawList;
352 }
353
354 public string osDrawLine(string drawList, int endX, int endY)
355 {
356 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
357 {
358 OSSLError("osDrawLine: permission denied");
359 return String.Empty;
360 }
361
362 m_host.AddScriptLPS(1);
363 drawList += "LineTo " + endX + "," + endY + "; ";
364 return drawList;
365 }
366
367 public string osDrawText(string drawList, string text)
368 {
369 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
370 {
371 OSSLError("osDrawText: permission denied");
372 return String.Empty;
373 }
374
375 m_host.AddScriptLPS(1);
376 drawList += "Text " + text + "; ";
377 return drawList;
378 }
379
380 public string osDrawEllipse(string drawList, int width, int height)
381 {
382 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
383 {
384 OSSLError("osDrawEllipse: permission denied");
385 return String.Empty;
386 }
387
388 m_host.AddScriptLPS(1);
389 drawList += "Ellipse " + width + "," + height + "; ";
390 return drawList;
391 }
392
393 public string osDrawRectangle(string drawList, int width, int height)
394 {
395 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
396 {
397 OSSLError("osDrawRectangle: permission denied");
398 return String.Empty;
399 }
400
401 m_host.AddScriptLPS(1);
402 drawList += "Rectangle " + width + "," + height + "; ";
403 return drawList;
404 }
405
406 public string osDrawFilledRectangle(string drawList, int width, int height)
407 {
408 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
409 {
410 OSSLError("osDrawFilledRectangle: permission denied");
411 return String.Empty;
412 }
413
414 m_host.AddScriptLPS(1);
415 drawList += "FillRectangle " + width + "," + height + "; ";
416 return drawList;
417 }
418
419 public string osSetFontSize(string drawList, int fontSize)
420 {
421 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
422 {
423 OSSLError("osSetFontSize: permission denied");
424 return String.Empty;
425 }
426
427 m_host.AddScriptLPS(1);
428 drawList += "FontSize "+ fontSize +"; ";
429 return drawList;
430 }
431
432 public string osSetPenSize(string drawList, int penSize)
433 {
434 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
435 {
436 OSSLError("osSetPenSize: permission denied");
437 return String.Empty;
438 }
439
440 m_host.AddScriptLPS(1);
441 drawList += "PenSize " + penSize + "; ";
442 return drawList;
443 }
444
445 public string osSetPenColour(string drawList, string colour)
446 {
447 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
448 {
449 OSSLError("osSetPenColour: permission denied");
450 return String.Empty;
451 }
452
453 m_host.AddScriptLPS(1);
454 drawList += "PenColour " + colour + "; ";
455 return drawList;
456 }
457
458 public string osDrawImage(string drawList, int width, int height, string imageUrl)
459 {
460 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
461 {
462 OSSLError("osDrawImage: permission denied");
463 return String.Empty;
464 }
465
466 m_host.AddScriptLPS(1);
467 drawList +="Image " +width + "," + height+ ","+ imageUrl +"; " ;
468 return drawList;
469 }
470
471 public void osSetStateEvents(int events)
472 {
473 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
474 {
475 OSSLError("osSetStateEvents: permission denied");
476 return;
477 }
478
479 m_host.SetScriptEvents(m_itemID, events);
480 }
481
482 public void osSetRegionWaterHeight(double height)
483 {
484 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
485 {
486 OSSLError("osSetRegionWaterHeight: permission denied");
487 return;
488 }
489
490 m_host.AddScriptLPS(1);
491 //Check to make sure that the script's owner is the estate manager/master
492 //World.Permissions.GenericEstatePermission(
493 if (World.ExternalChecks.ExternalChecksCanBeGodLike(m_host.OwnerID))
494 {
495 World.EventManager.TriggerRequestChangeWaterHeight((float)height);
496 }
497 }
498
499 public double osList2Double(LSL_Types.list src, int index)
500 {
501 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
502 {
503 OSSLError("osList2Double: permission denied");
504 return 0.0;
505 }
506
507 m_host.AddScriptLPS(1);
508 if (index < 0)
509 {
510 index = src.Length + index;
511 }
512 if (index >= src.Length)
513 {
514 return 0.0;
515 }
516 return Convert.ToDouble(src.Data[index]);
517 }
518
519 public void osSetParcelMediaURL(string url)
520 {
521 if (!m_ScriptEngine.ScriptConfigSource.GetBoolean("AllowOSFunctions", false))
522 {
523 OSSLError("osSetParcelMediaURL: permission denied");
524 return;
525 }
526
527 m_host.AddScriptLPS(1);
528 LLUUID landowner = World.GetLandOwner(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y);
529
530 if (landowner == LLUUID.Zero)
531 {
532 return;
533 }
534
535 if (landowner != m_host.ObjectOwner)
536 {
537 return;
538 }
539
540 World.SetLandMediaURL(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, url);
541 }
542
543 public Scene World
544 {
545 get { return m_ScriptEngine.World; }
546 }
547
548 internal void OSSLError(string msg)
549 {
550 throw new Exception("OSSL Runtime Error: " + msg);
551 }
552 }
553}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Script/AssemblyResolver.cs b/OpenSim/Region/ScriptEngine/XEngine/Script/AssemblyResolver.cs
deleted file mode 100644
index cf15b67..0000000
--- a/OpenSim/Region/ScriptEngine/XEngine/Script/AssemblyResolver.cs
+++ /dev/null
@@ -1,65 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.IO;
30using System.Reflection;
31
32namespace OpenSim.Region.ScriptEngine.XEngine.Script
33{
34 [Serializable]
35 public class AssemblyResolver
36 {
37 public static Assembly OnAssemblyResolve(object sender,
38 ResolveEventArgs args)
39 {
40 if (!(sender is System.AppDomain))
41 return null;
42
43 AppDomain myDomain = (AppDomain)sender;
44 string dirName = myDomain.FriendlyName;
45
46 string[] pathList = new string[] {"bin", "ScriptEngines",
47 Path.Combine("ScriptEngines", dirName)};
48
49 string assemblyName = args.Name;
50 if (assemblyName.IndexOf(",") != -1)
51 assemblyName = args.Name.Substring(0, args.Name.IndexOf(","));
52
53 foreach (string s in pathList)
54 {
55 string path = Path.Combine(Directory.GetCurrentDirectory(),
56 Path.Combine(s, assemblyName))+".dll";
57
58 if (File.Exists(path))
59 return Assembly.LoadFrom(path);
60 }
61
62 return null;
63 }
64 }
65}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Script/BuiltIn_Commands_BaseClass.cs b/OpenSim/Region/ScriptEngine/XEngine/Script/BuiltIn_Commands_BaseClass.cs
deleted file mode 100644
index fc9f8fc..0000000
--- a/OpenSim/Region/ScriptEngine/XEngine/Script/BuiltIn_Commands_BaseClass.cs
+++ /dev/null
@@ -1,2397 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Runtime.Remoting.Lifetime;
30using System.Threading;
31using System.Reflection;
32using System.Collections;
33using System.Collections.Generic;
34using OpenSim.Region.Environment.Interfaces;
35using integer = OpenSim.Region.ScriptEngine.XEngine.Script.LSL_Types.LSLInteger;
36using key = System.String;
37using vector = OpenSim.Region.ScriptEngine.XEngine.Script.LSL_Types.Vector3;
38using rotation = OpenSim.Region.ScriptEngine.XEngine.Script.LSL_Types.Quaternion;
39
40namespace OpenSim.Region.ScriptEngine.XEngine.Script
41{
42 public class BuiltIn_Commands_BaseClass : MarshalByRefObject, IOSSL_ScriptCommands, ILSL_ScriptCommands, IScript
43 {
44 //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
45
46 // Object never expires
47 public override Object InitializeLifetimeService()
48 {
49 //Console.WriteLine("LSL_BaseClass: InitializeLifetimeService()");
50 // return null;
51 ILease lease = (ILease)base.InitializeLifetimeService();
52
53 if (lease.CurrentState == LeaseState.Initial)
54 {
55 lease.InitialLeaseTime = TimeSpan.Zero; // TimeSpan.FromMinutes(1);
56 //lease.SponsorshipTimeout = TimeSpan.FromMinutes(2);
57 //lease.RenewOnCallTime = TimeSpan.FromSeconds(2);
58 }
59 return lease;
60 }
61
62 public ILSL_ScriptCommands m_LSL_Functions;
63 public IOSSL_ScriptCommands m_OSSL_Functions;
64
65 public BuiltIn_Commands_BaseClass()
66 {
67 }
68
69 public Type Start(ILSL_ScriptCommands LSL_Functions, IOSSL_ScriptCommands OSSL_Functions)
70 {
71 m_LSL_Functions = LSL_Functions;
72 m_OSSL_Functions = OSSL_Functions;
73 m_InitialValues=GetVars();
74 return GetType();
75 }
76
77 private Dictionary<string, object> m_InitialValues =
78 new Dictionary<string, object>();
79 private Dictionary<string, FieldInfo> m_Fields =
80 new Dictionary<string, FieldInfo>();
81
82 public Dictionary<string, object> GetVars()
83 {
84 Dictionary<string, object> vars = new Dictionary<string, object>();
85
86 if (m_Fields == null)
87 return vars;
88
89 m_Fields.Clear();
90
91 Type t = GetType();
92
93 FieldInfo[] fields = t.GetFields(BindingFlags.NonPublic |
94 BindingFlags.Public |
95 BindingFlags.Instance |
96 BindingFlags.DeclaredOnly);
97
98 foreach (FieldInfo field in fields)
99 {
100 m_Fields[field.Name]=field;
101
102 vars[field.Name]=field.GetValue(this);
103 }
104
105 return vars;
106 }
107
108 public void SetVars(Dictionary<string, object> vars)
109 {
110 foreach (KeyValuePair<string, object> var in vars)
111 {
112 if (m_Fields.ContainsKey(var.Key))
113 {
114 m_Fields[var.Key].SetValue(this, var.Value);
115 }
116 }
117 }
118
119 public void ResetVars()
120 {
121 SetVars(m_InitialValues);
122 }
123
124 public string State
125 {
126 get { return m_LSL_Functions.State; }
127 set { m_LSL_Functions.State = value; }
128 }
129
130 public void state(string newState)
131 {
132 m_LSL_Functions.state(newState);
133 }
134
135 public void llSay(int channelID, string text)
136 {
137 m_LSL_Functions.llSay(channelID, text);
138 }
139
140 //
141 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
142 //
143 // They are only forwarders to LSL_BuiltIn_Commands.cs
144 //
145
146 public ICommander GetCommander(string name)
147 {
148 return m_LSL_Functions.GetCommander(name);
149 }
150
151 public double llSin(double f)
152 {
153 return m_LSL_Functions.llSin(f);
154 }
155 public double llCos(double f)
156 {
157 return m_LSL_Functions.llCos(f);
158 }
159
160 public double llTan(double f)
161 {
162 return m_LSL_Functions.llTan(f);
163 }
164
165 public double llAtan2(double x, double y)
166 {
167 return m_LSL_Functions.llAtan2(x, y);
168 }
169
170 public double llSqrt(double f)
171 {
172 return m_LSL_Functions.llSqrt(f);
173 }
174
175 public double llPow(double fbase, double fexponent)
176 {
177 return m_LSL_Functions.llPow(fbase, fexponent);
178 }
179
180 public LSL_Types.LSLInteger llAbs(int i)
181 {
182 return m_LSL_Functions.llAbs(i);
183 }
184
185 public double llFabs(double f)
186 {
187 return m_LSL_Functions.llFabs(f);
188 }
189
190 public double llFrand(double mag)
191 {
192 return m_LSL_Functions.llFrand(mag);
193 }
194
195 public LSL_Types.LSLInteger llFloor(double f)
196 {
197 return m_LSL_Functions.llFloor(f);
198 }
199
200 public LSL_Types.LSLInteger llCeil(double f)
201 {
202 return m_LSL_Functions.llCeil(f);
203 }
204
205 public LSL_Types.LSLInteger llRound(double f)
206 {
207 return m_LSL_Functions.llRound(f);
208 }
209
210 public double llVecMag(vector v)
211 {
212 return m_LSL_Functions.llVecMag(v);
213 }
214
215 public vector llVecNorm(vector v)
216 {
217 return m_LSL_Functions.llVecNorm(v);
218 }
219
220 public double llVecDist(vector a, vector b)
221 {
222 return m_LSL_Functions.llVecDist(a, b);
223 }
224
225 public vector llRot2Euler(rotation r)
226 {
227 return m_LSL_Functions.llRot2Euler(r);
228 }
229
230 public rotation llEuler2Rot(vector v)
231 {
232 return m_LSL_Functions.llEuler2Rot(v);
233 }
234
235 public rotation llAxes2Rot(vector fwd, vector left, vector up)
236 {
237 return m_LSL_Functions.llAxes2Rot(fwd, left, up);
238 }
239
240 public vector llRot2Fwd(rotation r)
241 {
242 return m_LSL_Functions.llRot2Fwd(r);
243 }
244
245 public vector llRot2Left(rotation r)
246 {
247 return m_LSL_Functions.llRot2Left(r);
248 }
249
250 public vector llRot2Up(rotation r)
251 {
252 return m_LSL_Functions.llRot2Up(r);
253 }
254
255 public rotation llRotBetween(vector start, vector end)
256 {
257 return m_LSL_Functions.llRotBetween(start, end);
258 }
259
260 public void llWhisper(int channelID, string text)
261 {
262 m_LSL_Functions.llWhisper(channelID, text);
263 }
264
265 //
266 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
267 //
268 public void llShout(int channelID, string text)
269 {
270 m_LSL_Functions.llShout(channelID, text);
271 }
272
273 public void llRegionSay(int channelID, string text)
274 {
275 m_LSL_Functions.llRegionSay(channelID, text);
276 }
277
278 public LSL_Types.LSLInteger llListen(int channelID, string name, string ID, string msg)
279 {
280 return m_LSL_Functions.llListen(channelID, name, ID, msg);
281 }
282
283 public void llListenControl(int number, int active)
284 {
285 m_LSL_Functions.llListenControl(number, active);
286 }
287
288 public void llListenRemove(int number)
289 {
290 m_LSL_Functions.llListenRemove(number);
291 }
292
293 public void llSensor(string name, string id, int type, double range, double arc)
294 {
295 m_LSL_Functions.llSensor(name, id, type, range, arc);
296 }
297
298 public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate)
299 {
300 m_LSL_Functions.llSensorRepeat(name, id, type, range, arc, rate);
301 }
302
303 public void llSensorRemove()
304 {
305 m_LSL_Functions.llSensorRemove();
306 }
307
308 public string llDetectedName(int number)
309 {
310 return m_LSL_Functions.llDetectedName(number);
311 }
312
313 public string llDetectedKey(int number)
314 {
315 return m_LSL_Functions.llDetectedKey(number);
316 }
317
318 public string llDetectedOwner(int number)
319 {
320 return m_LSL_Functions.llDetectedOwner(number);
321 }
322
323 public LSL_Types.LSLInteger llDetectedType(int number)
324 {
325 return m_LSL_Functions.llDetectedType(number);
326 }
327
328 public vector llDetectedPos(int number)
329 {
330 return m_LSL_Functions.llDetectedPos(number);
331 }
332
333 public vector llDetectedVel(int number)
334 {
335 return m_LSL_Functions.llDetectedVel(number);
336 }
337
338 public vector llDetectedGrab(int number)
339 {
340 return m_LSL_Functions.llDetectedGrab(number);
341 }
342
343 public rotation llDetectedRot(int number)
344 {
345 return m_LSL_Functions.llDetectedRot(number);
346 }
347
348 public LSL_Types.LSLInteger llDetectedGroup(int number)
349 {
350 return m_LSL_Functions.llDetectedGroup(number);
351 }
352
353 public LSL_Types.LSLInteger llDetectedLinkNumber(int number)
354 {
355 return m_LSL_Functions.llDetectedLinkNumber(number);
356 }
357
358 //
359 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
360 //
361 public void llDie()
362 {
363 m_LSL_Functions.llDie();
364 }
365
366 public double llGround(vector offset)
367 {
368 return m_LSL_Functions.llGround(offset);
369 }
370
371 public double llCloud(vector offset)
372 {
373 return m_LSL_Functions.llCloud(offset);
374 }
375
376 public vector llWind(vector offset)
377 {
378 return m_LSL_Functions.llWind(offset);
379 }
380
381 public void llSetStatus(int status, int value)
382 {
383 m_LSL_Functions.llSetStatus(status, value);
384 }
385
386 public LSL_Types.LSLInteger llGetStatus(int status)
387 {
388 return m_LSL_Functions.llGetStatus(status);
389 }
390
391 public void llSetScale(vector scale)
392 {
393 m_LSL_Functions.llSetScale(scale);
394 }
395
396 public vector llGetScale()
397 {
398 return m_LSL_Functions.llGetScale();
399 }
400
401 public void llSetColor(vector color, int face)
402 {
403 m_LSL_Functions.llSetColor(color, face);
404 }
405
406 public double llGetAlpha(int face)
407 {
408 return m_LSL_Functions.llGetAlpha(face);
409 }
410
411 public void llSetAlpha(double alpha, int face)
412 {
413 m_LSL_Functions.llSetAlpha(alpha, face);
414 }
415
416 public vector llGetColor(int face)
417 {
418 return m_LSL_Functions.llGetColor(face);
419 }
420
421 public void llSetTexture(string texture, int face)
422 {
423 m_LSL_Functions.llSetTexture(texture, face);
424 }
425
426 public void llScaleTexture(double u, double v, int face)
427 {
428 m_LSL_Functions.llScaleTexture(u, v, face);
429 }
430
431 public void llOffsetTexture(double u, double v, int face)
432 {
433 m_LSL_Functions.llOffsetTexture(u, v, face);
434 }
435
436 public void llRotateTexture(double rotation, int face)
437 {
438 m_LSL_Functions.llRotateTexture(rotation, face);
439 }
440
441 public string llGetTexture(int face)
442 {
443 return m_LSL_Functions.llGetTexture(face);
444 }
445
446 //
447 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
448 //
449 public void llSetPos(vector pos)
450 {
451 m_LSL_Functions.llSetPos(pos);
452 }
453
454 public vector llGetPos()
455 {
456 return m_LSL_Functions.llGetPos();
457 }
458
459 public vector llGetLocalPos()
460 {
461 return m_LSL_Functions.llGetLocalPos();
462 }
463
464 public void llSetRot(rotation rot)
465 {
466 m_LSL_Functions.llSetRot(rot);
467 }
468
469 public rotation llGetRot()
470 {
471 return m_LSL_Functions.llGetRot();
472 }
473
474 public rotation llGetLocalRot()
475 {
476 return m_LSL_Functions.llGetLocalRot();
477 }
478
479 public void llSetForce(vector force, int local)
480 {
481 m_LSL_Functions.llSetForce(force, local);
482 }
483
484 public vector llGetForce()
485 {
486 return m_LSL_Functions.llGetForce();
487 }
488
489 public LSL_Types.LSLInteger llTarget(vector position, double range)
490 {
491 return m_LSL_Functions.llTarget(position, range);
492 }
493
494 public void llTargetRemove(int number)
495 {
496 m_LSL_Functions.llTargetRemove(number);
497 }
498
499 public LSL_Types.LSLInteger llRotTarget(rotation rot, double error)
500 {
501 return m_LSL_Functions.llRotTarget(rot, error);
502 }
503
504 public void llRotTargetRemove(int number)
505 {
506 m_LSL_Functions.llRotTargetRemove(number);
507 }
508
509 public void llMoveToTarget(vector target, double tau)
510 {
511 m_LSL_Functions.llMoveToTarget(target, tau);
512 }
513
514 public void llStopMoveToTarget()
515 {
516 m_LSL_Functions.llStopMoveToTarget();
517 }
518
519 public void llApplyImpulse(vector force, int local)
520 {
521 m_LSL_Functions.llApplyImpulse(force, local);
522 }
523
524 //
525 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
526 //
527 public void llApplyRotationalImpulse(vector force, int local)
528 {
529 m_LSL_Functions.llApplyRotationalImpulse(force, local);
530 }
531
532 public void llSetTorque(vector torque, int local)
533 {
534 m_LSL_Functions.llSetTorque(torque, local);
535 }
536
537 public vector llGetTorque()
538 {
539 return m_LSL_Functions.llGetTorque();
540 }
541
542 public void llSetForceAndTorque(vector force, vector torque, int local)
543 {
544 m_LSL_Functions.llSetForceAndTorque(force, torque, local);
545 }
546
547 public vector llGetVel()
548 {
549 return m_LSL_Functions.llGetVel();
550 }
551
552 public vector llGetAccel()
553 {
554 return m_LSL_Functions.llGetAccel();
555 }
556
557 public vector llGetOmega()
558 {
559 return m_LSL_Functions.llGetOmega();
560 }
561
562 public double llGetTimeOfDay()
563 {
564 return m_LSL_Functions.llGetTimeOfDay();
565 }
566
567 public double llGetWallclock()
568 {
569 return m_LSL_Functions.llGetWallclock();
570 }
571
572 public double llGetTime()
573 {
574 return m_LSL_Functions.llGetTime();
575 }
576
577 public void llResetTime()
578 {
579 m_LSL_Functions.llResetTime();
580 }
581
582 public double llGetAndResetTime()
583 {
584 return m_LSL_Functions.llGetAndResetTime();
585 }
586
587 public void llSound()
588 {
589 m_LSL_Functions.llSound();
590 }
591
592 public void llPlaySound(string sound, double volume)
593 {
594 m_LSL_Functions.llPlaySound(sound, volume);
595 }
596
597 public void llLoopSound(string sound, double volume)
598 {
599 m_LSL_Functions.llLoopSound(sound, volume);
600 }
601
602 public void llLoopSoundMaster(string sound, double volume)
603 {
604 m_LSL_Functions.llLoopSoundMaster(sound, volume);
605 }
606
607 public void llLoopSoundSlave(string sound, double volume)
608 {
609 m_LSL_Functions.llLoopSoundSlave(sound, volume);
610 }
611
612 public void llPlaySoundSlave(string sound, double volume)
613 {
614 m_LSL_Functions.llPlaySoundSlave(sound, volume);
615 }
616
617 //
618 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
619 //
620 public void llTriggerSound(string sound, double volume)
621 {
622 m_LSL_Functions.llTriggerSound(sound, volume);
623 }
624
625 public void llStopSound()
626 {
627 m_LSL_Functions.llStopSound();
628 }
629
630 public void llPreloadSound(string sound)
631 {
632 m_LSL_Functions.llPreloadSound(sound);
633 }
634
635 public string llGetSubString(string src, int start, int end)
636 {
637 return m_LSL_Functions.llGetSubString(src, start, end);
638 }
639
640 public string llDeleteSubString(string src, int start, int end)
641 {
642 return m_LSL_Functions.llDeleteSubString(src, start, end);
643 }
644
645 public string llInsertString(string dst, int position, string src)
646 {
647 return m_LSL_Functions.llInsertString(dst, position, src);
648 }
649
650 public string llToUpper(string source)
651 {
652 return m_LSL_Functions.llToUpper(source);
653 }
654
655 public string llToLower(string source)
656 {
657 return m_LSL_Functions.llToLower(source);
658 }
659
660 public LSL_Types.LSLInteger llGiveMoney(string destination, int amount)
661 {
662 return m_LSL_Functions.llGiveMoney(destination, amount);
663 }
664
665 public void llMakeExplosion()
666 {
667 m_LSL_Functions.llMakeExplosion();
668 }
669
670 public void llMakeFountain()
671 {
672 m_LSL_Functions.llMakeFountain();
673 }
674
675 public void llMakeSmoke()
676 {
677 m_LSL_Functions.llMakeSmoke();
678 }
679
680 public void llMakeFire()
681 {
682 m_LSL_Functions.llMakeFire();
683 }
684
685 public void llRezObject(string inventory, vector pos, vector vel, rotation rot, int param)
686 {
687 m_LSL_Functions.llRezObject(inventory, pos, vel, rot, param);
688 }
689
690 public void llLookAt(vector target, double strength, double damping)
691 {
692 m_LSL_Functions.llLookAt(target, strength, damping);
693 }
694
695 public void llStopLookAt()
696 {
697 m_LSL_Functions.llStopLookAt();
698 }
699
700 public void llSetTimerEvent(double sec)
701 {
702 m_LSL_Functions.llSetTimerEvent(sec);
703 }
704
705 public void llSleep(double sec)
706 {
707 m_LSL_Functions.llSleep(sec);
708 }
709
710 //
711 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
712 //
713 public double llGetMass()
714 {
715 return m_LSL_Functions.llGetMass();
716 }
717
718 public void llCollisionFilter(string name, string id, int accept)
719 {
720 m_LSL_Functions.llCollisionFilter(name, id, accept);
721 }
722
723 public void llTakeControls(int controls, int accept, int pass_on)
724 {
725 m_LSL_Functions.llTakeControls(controls, accept, pass_on);
726 }
727
728 public void llReleaseControls()
729 {
730 m_LSL_Functions.llReleaseControls();
731 }
732
733 public void llAttachToAvatar(int attachment)
734 {
735 m_LSL_Functions.llAttachToAvatar(attachment);
736 }
737
738 public void llDetachFromAvatar()
739 {
740 m_LSL_Functions.llDetachFromAvatar();
741 }
742
743 public void llTakeCamera()
744 {
745 m_LSL_Functions.llTakeCamera();
746 }
747
748 public void llReleaseCamera()
749 {
750 m_LSL_Functions.llReleaseCamera();
751 }
752
753 public string llGetOwner()
754 {
755 return m_LSL_Functions.llGetOwner();
756 }
757
758 public void llInstantMessage(string user, string message)
759 {
760 m_LSL_Functions.llInstantMessage(user, message);
761 }
762
763 public void llEmail(string address, string subject, string message)
764 {
765 m_LSL_Functions.llEmail(address, subject, message);
766 }
767
768 public void llGetNextEmail(string address, string subject)
769 {
770 m_LSL_Functions.llGetNextEmail(address, subject);
771 }
772
773 public string llGetKey()
774 {
775 return m_LSL_Functions.llGetKey();
776 }
777
778 public void llSetBuoyancy(double buoyancy)
779 {
780 m_LSL_Functions.llSetBuoyancy(buoyancy);
781 }
782
783 public void llSetHoverHeight(double height, int water, double tau)
784 {
785 m_LSL_Functions.llSetHoverHeight(height, water, tau);
786 }
787
788 public void llStopHover()
789 {
790 m_LSL_Functions.llStopHover();
791 }
792
793 public void llMinEventDelay(double delay)
794 {
795 m_LSL_Functions.llMinEventDelay(delay);
796 }
797
798 public void llSoundPreload()
799 {
800 m_LSL_Functions.llSoundPreload();
801 }
802
803 public void llRotLookAt(rotation target, double strength, double damping)
804 {
805 m_LSL_Functions.llRotLookAt(target, strength, damping);
806 }
807
808 //
809 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
810 //
811 public LSL_Types.LSLInteger llStringLength(string str)
812 {
813 return m_LSL_Functions.llStringLength(str);
814 }
815
816 public void llStartAnimation(string anim)
817 {
818 m_LSL_Functions.llStartAnimation(anim);
819 }
820
821 public void llStopAnimation(string anim)
822 {
823 m_LSL_Functions.llStopAnimation(anim);
824 }
825
826 public void llPointAt()
827 {
828 m_LSL_Functions.llPointAt();
829 }
830
831 public void llStopPointAt()
832 {
833 m_LSL_Functions.llStopPointAt();
834 }
835
836 public void llTargetOmega(vector axis, double spinrate, double gain)
837 {
838 m_LSL_Functions.llTargetOmega(axis, spinrate, gain);
839 }
840
841 public LSL_Types.LSLInteger llGetStartParameter()
842 {
843 return m_LSL_Functions.llGetStartParameter();
844 }
845
846 public void llGodLikeRezObject(string inventory, vector pos)
847 {
848 m_LSL_Functions.llGodLikeRezObject(inventory, pos);
849 }
850
851 public void llRequestPermissions(string agent, int perm)
852 {
853 m_LSL_Functions.llRequestPermissions(agent, perm);
854 }
855
856 public string llGetPermissionsKey()
857 {
858 return m_LSL_Functions.llGetPermissionsKey();
859 }
860
861 public LSL_Types.LSLInteger llGetPermissions()
862 {
863 return m_LSL_Functions.llGetPermissions();
864 }
865
866 public LSL_Types.LSLInteger llGetLinkNumber()
867 {
868 return m_LSL_Functions.llGetLinkNumber();
869 }
870
871 public void llSetLinkColor(int linknumber, vector color, int face)
872 {
873 m_LSL_Functions.llSetLinkColor(linknumber, color, face);
874 }
875
876 public void llCreateLink(string target, int parent)
877 {
878 m_LSL_Functions.llCreateLink(target, parent);
879 }
880
881 public void llBreakLink(int linknum)
882 {
883 m_LSL_Functions.llBreakLink(linknum);
884 }
885
886 public void llBreakAllLinks()
887 {
888 m_LSL_Functions.llBreakAllLinks();
889 }
890
891 public string llGetLinkKey(int linknum)
892 {
893 return m_LSL_Functions.llGetLinkKey(linknum);
894 }
895
896 public string llGetLinkName(int linknum)
897 {
898 return m_LSL_Functions.llGetLinkName(linknum);
899 }
900
901 public LSL_Types.LSLInteger llGetInventoryNumber(int type)
902 {
903 return m_LSL_Functions.llGetInventoryNumber(type);
904 }
905
906 public string llGetInventoryName(int type, int number)
907 {
908 return m_LSL_Functions.llGetInventoryName(type, number);
909 }
910
911 //
912 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
913 //
914 public void llSetScriptState(string name, int run)
915 {
916 m_LSL_Functions.llSetScriptState(name, run);
917 }
918
919 public double llGetEnergy()
920 {
921 return m_LSL_Functions.llGetEnergy();
922 }
923
924 public void llGiveInventory(string destination, string inventory)
925 {
926 m_LSL_Functions.llGiveInventory(destination, inventory);
927 }
928
929 public void llRemoveInventory(string item)
930 {
931 m_LSL_Functions.llRemoveInventory(item);
932 }
933
934 public void llSetText(string text, vector color, double alpha)
935 {
936 m_LSL_Functions.llSetText(text, color, alpha);
937 }
938
939 public double llWater(vector offset)
940 {
941 return m_LSL_Functions.llWater(offset);
942 }
943
944 public void llPassTouches(int pass)
945 {
946 m_LSL_Functions.llPassTouches(pass);
947 }
948
949 public string llRequestAgentData(string id, int data)
950 {
951 return m_LSL_Functions.llRequestAgentData(id, data);
952 }
953
954 public string llRequestInventoryData(string name)
955 {
956 return m_LSL_Functions.llRequestInventoryData(name);
957 }
958
959 public void llSetDamage(double damage)
960 {
961 m_LSL_Functions.llSetDamage(damage);
962 }
963
964 public void llTeleportAgentHome(string agent)
965 {
966 m_LSL_Functions.llTeleportAgentHome(agent);
967 }
968
969 public void llModifyLand(int action, int brush)
970 {
971 m_LSL_Functions.llModifyLand(action, brush);
972 }
973
974 public void llCollisionSound(string impact_sound, double impact_volume)
975 {
976 m_LSL_Functions.llCollisionSound(impact_sound, impact_volume);
977 }
978
979 public void llCollisionSprite(string impact_sprite)
980 {
981 m_LSL_Functions.llCollisionSprite(impact_sprite);
982 }
983
984 public string llGetAnimation(string id)
985 {
986 return m_LSL_Functions.llGetAnimation(id);
987 }
988
989 public void llResetScript()
990 {
991 m_LSL_Functions.llResetScript();
992 }
993
994 public void llMessageLinked(int linknum, int num, string str, string id)
995 {
996 m_LSL_Functions.llMessageLinked(linknum, num, str, id);
997 }
998
999 public void llPushObject(string target, vector impulse, vector ang_impulse, int local)
1000 {
1001 m_LSL_Functions.llPushObject(target, impulse, ang_impulse, local);
1002 }
1003
1004 public void llPassCollisions(int pass)
1005 {
1006 m_LSL_Functions.llPassCollisions(pass);
1007 }
1008
1009 public string llGetScriptName()
1010 {
1011 return m_LSL_Functions.llGetScriptName();
1012 }
1013
1014 public LSL_Types.LSLInteger llGetNumberOfSides()
1015 {
1016 return m_LSL_Functions.llGetNumberOfSides();
1017 }
1018
1019 //
1020 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
1021 //
1022 public rotation llAxisAngle2Rot(vector axis, double angle)
1023 {
1024 return m_LSL_Functions.llAxisAngle2Rot(axis, angle);
1025 }
1026
1027 public vector llRot2Axis(rotation rot)
1028 {
1029 return m_LSL_Functions.llRot2Axis(rot);
1030 }
1031
1032 public double llRot2Angle(rotation rot)
1033 {
1034 return m_LSL_Functions.llRot2Angle(rot);
1035 }
1036
1037 public double llAcos(double val)
1038 {
1039 return m_LSL_Functions.llAcos(val);
1040 }
1041
1042 public double llAsin(double val)
1043 {
1044 return m_LSL_Functions.llAsin(val);
1045 }
1046
1047 public double llAngleBetween(rotation a, rotation b)
1048 {
1049 return m_LSL_Functions.llAngleBetween(a, b);
1050 }
1051
1052 public string llGetInventoryKey(string name)
1053 {
1054 return m_LSL_Functions.llGetInventoryKey(name);
1055 }
1056
1057 public void llAllowInventoryDrop(int add)
1058 {
1059 m_LSL_Functions.llAllowInventoryDrop(add);
1060 }
1061
1062 public vector llGetSunDirection()
1063 {
1064 return m_LSL_Functions.llGetSunDirection();
1065 }
1066
1067 public vector llGetTextureOffset(int face)
1068 {
1069 return m_LSL_Functions.llGetTextureOffset(face);
1070 }
1071
1072 public vector llGetTextureScale(int side)
1073 {
1074 return m_LSL_Functions.llGetTextureScale(side);
1075 }
1076
1077 public double llGetTextureRot(int side)
1078 {
1079 return m_LSL_Functions.llGetTextureRot(side);
1080 }
1081
1082 public LSL_Types.LSLInteger llSubStringIndex(string source, string pattern)
1083 {
1084 return m_LSL_Functions.llSubStringIndex(source, pattern);
1085 }
1086
1087 public string llGetOwnerKey(string id)
1088 {
1089 return m_LSL_Functions.llGetOwnerKey(id);
1090 }
1091
1092 public vector llGetCenterOfMass()
1093 {
1094 return m_LSL_Functions.llGetCenterOfMass();
1095 }
1096
1097 public LSL_Types.list llListSort(LSL_Types.list src, int stride, int ascending)
1098 {
1099 return m_LSL_Functions.llListSort(src, stride, ascending);
1100 }
1101
1102 public LSL_Types.LSLInteger llGetListLength(LSL_Types.list src)
1103 {
1104 return m_LSL_Functions.llGetListLength(src);
1105 }
1106
1107 //
1108 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
1109 //
1110 public LSL_Types.LSLInteger llList2Integer(LSL_Types.list src, int index)
1111 {
1112 return m_LSL_Functions.llList2Integer(src, index);
1113 }
1114
1115 public string llList2String(LSL_Types.list src, int index)
1116 {
1117 return m_LSL_Functions.llList2String(src, index);
1118 }
1119
1120 public string llList2Key(LSL_Types.list src, int index)
1121 {
1122 return m_LSL_Functions.llList2Key(src, index);
1123 }
1124
1125 public vector llList2Vector(LSL_Types.list src, int index)
1126 {
1127 return m_LSL_Functions.llList2Vector(src, index);
1128 }
1129
1130 public rotation llList2Rot(LSL_Types.list src, int index)
1131 {
1132 return m_LSL_Functions.llList2Rot(src, index);
1133 }
1134
1135 public LSL_Types.list llList2List(LSL_Types.list src, int start, int end)
1136 {
1137 return m_LSL_Functions.llList2List(src, start, end);
1138 }
1139
1140 public LSL_Types.list llDeleteSubList(LSL_Types.list src, int start, int end)
1141 {
1142 return m_LSL_Functions.llDeleteSubList(src, start, end);
1143 }
1144
1145 public LSL_Types.LSLInteger llGetListEntryType(LSL_Types.list src, int index)
1146 {
1147 return m_LSL_Functions.llGetListEntryType(src, index);
1148 }
1149
1150 public string llList2CSV(LSL_Types.list src)
1151 {
1152 return m_LSL_Functions.llList2CSV(src);
1153 }
1154
1155 public LSL_Types.list llCSV2List(string src)
1156 {
1157 return m_LSL_Functions.llCSV2List(src);
1158 }
1159
1160 public LSL_Types.list llListRandomize(LSL_Types.list src, int stride)
1161 {
1162 return m_LSL_Functions.llListRandomize(src, stride);
1163 }
1164
1165 public LSL_Types.list llList2ListStrided(LSL_Types.list src, int start, int end, int stride)
1166 {
1167 return m_LSL_Functions.llList2ListStrided(src, start, end, stride);
1168 }
1169
1170 public vector llGetRegionCorner()
1171 {
1172 return m_LSL_Functions.llGetRegionCorner();
1173 }
1174
1175 public LSL_Types.list llListInsertList(LSL_Types.list dest, LSL_Types.list src, int start)
1176 {
1177 return m_LSL_Functions.llListInsertList(dest, src, start);
1178 }
1179
1180 public LSL_Types.LSLInteger llListFindList(LSL_Types.list src, LSL_Types.list test)
1181 {
1182 return m_LSL_Functions.llListFindList(src, test);
1183 }
1184
1185 public string llGetObjectName()
1186 {
1187 return m_LSL_Functions.llGetObjectName();
1188 }
1189
1190 public void llSetObjectName(string name)
1191 {
1192 m_LSL_Functions.llSetObjectName(name);
1193 }
1194
1195 public string llGetDate()
1196 {
1197 return m_LSL_Functions.llGetDate();
1198 }
1199
1200 public LSL_Types.LSLInteger llEdgeOfWorld(vector pos, vector dir)
1201 {
1202 return m_LSL_Functions.llEdgeOfWorld(pos, dir);
1203 }
1204
1205 public LSL_Types.LSLInteger llGetAgentInfo(string id)
1206 {
1207 return m_LSL_Functions.llGetAgentInfo(id);
1208 }
1209
1210 //
1211 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
1212 //
1213 public void llAdjustSoundVolume(double volume)
1214 {
1215 m_LSL_Functions.llAdjustSoundVolume(volume);
1216 }
1217
1218 public void llSetSoundQueueing(int queue)
1219 {
1220 m_LSL_Functions.llSetSoundQueueing(queue);
1221 }
1222
1223 public void llSetSoundRadius(double radius)
1224 {
1225 m_LSL_Functions.llSetSoundRadius(radius);
1226 }
1227
1228 public string llKey2Name(string id)
1229 {
1230 return m_LSL_Functions.llKey2Name(id);
1231 }
1232
1233 public void llSetTextureAnim(int mode, int face, int sizex, int sizey, double start, double length, double rate)
1234 {
1235 m_LSL_Functions.llSetTextureAnim(mode, face, sizex, sizey, start, length, rate);
1236 }
1237
1238 public void llTriggerSoundLimited(string sound, double volume, vector top_north_east, vector bottom_south_west)
1239 {
1240 m_LSL_Functions.llTriggerSoundLimited(sound, volume, top_north_east, bottom_south_west);
1241 }
1242
1243 public void llEjectFromLand(string pest)
1244 {
1245 m_LSL_Functions.llEjectFromLand(pest);
1246 }
1247
1248 public LSL_Types.list llParseString2List(string str, LSL_Types.list separators, LSL_Types.list spacers)
1249 {
1250 return m_LSL_Functions.llParseString2List(str,separators,spacers);
1251 }
1252
1253 public LSL_Types.LSLInteger llOverMyLand(string id)
1254 {
1255 return m_LSL_Functions.llOverMyLand(id);
1256 }
1257
1258 public string llGetLandOwnerAt(vector pos)
1259 {
1260 return m_LSL_Functions.llGetLandOwnerAt(pos);
1261 }
1262
1263 public string llGetNotecardLine(string name, int line)
1264 {
1265 return m_LSL_Functions.llGetNotecardLine(name, line);
1266 }
1267
1268 public vector llGetAgentSize(string id)
1269 {
1270 return m_LSL_Functions.llGetAgentSize(id);
1271 }
1272
1273 public LSL_Types.LSLInteger llSameGroup(string agent)
1274 {
1275 return m_LSL_Functions.llSameGroup(agent);
1276 }
1277
1278 public void llUnSit(string id)
1279 {
1280 m_LSL_Functions.llUnSit(id);
1281 }
1282
1283 public vector llGroundSlope(vector offset)
1284 {
1285 return m_LSL_Functions.llGroundSlope(offset);
1286 }
1287
1288 public vector llGroundNormal(vector offset)
1289 {
1290 return m_LSL_Functions.llGroundNormal(offset);
1291 }
1292
1293 public vector llGroundContour(vector offset)
1294 {
1295 return m_LSL_Functions.llGroundContour(offset);
1296 }
1297
1298 public LSL_Types.LSLInteger llGetAttached()
1299 {
1300 return m_LSL_Functions.llGetAttached();
1301 }
1302
1303 public LSL_Types.LSLInteger llGetFreeMemory()
1304 {
1305 return m_LSL_Functions.llGetFreeMemory();
1306 }
1307
1308 public string llGetRegionName()
1309 {
1310 return m_LSL_Functions.llGetRegionName();
1311 }
1312
1313 public double llGetRegionTimeDilation()
1314 {
1315 return m_LSL_Functions.llGetRegionTimeDilation();
1316 }
1317
1318 public double llGetRegionFPS()
1319 {
1320 return m_LSL_Functions.llGetRegionFPS();
1321 }
1322
1323 //
1324 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
1325 //
1326 public void llParticleSystem(LSL_Types.list rules)
1327 {
1328 m_LSL_Functions.llParticleSystem(rules);
1329 }
1330
1331 public void llGroundRepel(double height, int water, double tau)
1332 {
1333 m_LSL_Functions.llGroundRepel(height, water, tau);
1334 }
1335
1336 public void llGiveInventoryList(string destination, string category, LSL_Types.list inventory)
1337 {
1338 m_LSL_Functions.llGiveInventoryList(destination, category, inventory);
1339 }
1340
1341 public void llSetVehicleType(int type)
1342 {
1343 m_LSL_Functions.llSetVehicleType(type);
1344 }
1345
1346 public void llSetVehicledoubleParam(int param, double value)
1347 {
1348 m_LSL_Functions.llSetVehicledoubleParam(param, value);
1349 }
1350
1351 public void llSetVehicleFloatParam(int param, float value)
1352 {
1353 m_LSL_Functions.llSetVehicleFloatParam(param, value);
1354 }
1355
1356 public void llSetVehicleVectorParam(int param, vector vec)
1357 {
1358 m_LSL_Functions.llSetVehicleVectorParam(param, vec);
1359 }
1360
1361 public void llSetVehicleRotationParam(int param, rotation rot)
1362 {
1363 m_LSL_Functions.llSetVehicleRotationParam(param, rot);
1364 }
1365
1366 public void llSetVehicleFlags(int flags)
1367 {
1368 m_LSL_Functions.llSetVehicleFlags(flags);
1369 }
1370
1371 public void llRemoveVehicleFlags(int flags)
1372 {
1373 m_LSL_Functions.llRemoveVehicleFlags(flags);
1374 }
1375
1376 public void llSitTarget(vector offset, rotation rot)
1377 {
1378 m_LSL_Functions.llSitTarget(offset, rot);
1379 }
1380
1381 public string llAvatarOnSitTarget()
1382 {
1383 return m_LSL_Functions.llAvatarOnSitTarget();
1384 }
1385
1386 public void llAddToLandPassList(string avatar, double hours)
1387 {
1388 m_LSL_Functions.llAddToLandPassList(avatar, hours);
1389 }
1390
1391 public void llSetTouchText(string text)
1392 {
1393 m_LSL_Functions.llSetTouchText(text);
1394 }
1395
1396 public void llSetSitText(string text)
1397 {
1398 m_LSL_Functions.llSetSitText(text);
1399 }
1400
1401 public void llSetCameraEyeOffset(vector offset)
1402 {
1403 m_LSL_Functions.llSetCameraEyeOffset(offset);
1404 }
1405
1406 public void llSetCameraAtOffset(vector offset)
1407 {
1408 m_LSL_Functions.llSetCameraAtOffset(offset);
1409 }
1410
1411 public string llDumpList2String(LSL_Types.list src, string seperator)
1412 {
1413 return m_LSL_Functions.llDumpList2String(src, seperator);
1414 }
1415
1416 public LSL_Types.LSLInteger llScriptDanger(vector pos)
1417 {
1418 return m_LSL_Functions.llScriptDanger(pos);
1419 }
1420
1421 public void llDialog(string avatar, string message, LSL_Types.list buttons, int chat_channel)
1422 {
1423 m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel);
1424 }
1425
1426 public void llVolumeDetect(int detect)
1427 {
1428 m_LSL_Functions.llVolumeDetect(detect);
1429 }
1430
1431 public void llResetOtherScript(string name)
1432 {
1433 m_LSL_Functions.llResetOtherScript(name);
1434 }
1435
1436 public LSL_Types.LSLInteger llGetScriptState(string name)
1437 {
1438 return m_LSL_Functions.llGetScriptState(name);
1439 }
1440
1441 public void llRemoteLoadScript()
1442 {
1443 m_LSL_Functions.llRemoteLoadScript();
1444 }
1445
1446 public void llSetRemoteScriptAccessPin(int pin)
1447 {
1448 m_LSL_Functions.llSetRemoteScriptAccessPin(pin);
1449 }
1450
1451 public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param)
1452 {
1453 m_LSL_Functions.llRemoteLoadScriptPin(target, name, pin, running, start_param);
1454 }
1455
1456 //
1457 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
1458 //
1459 public void llOpenRemoteDataChannel()
1460 {
1461 m_LSL_Functions.llOpenRemoteDataChannel();
1462 }
1463
1464 public string llSendRemoteData(string channel, string dest, int idata, string sdata)
1465 {
1466 return m_LSL_Functions.llSendRemoteData(channel, dest, idata, sdata);
1467 }
1468
1469 public void llRemoteDataReply(string channel, string message_id, string sdata, int idata)
1470 {
1471 m_LSL_Functions.llRemoteDataReply(channel, message_id, sdata, idata);
1472 }
1473
1474 public void llCloseRemoteDataChannel(string channel)
1475 {
1476 m_LSL_Functions.llCloseRemoteDataChannel(channel);
1477 }
1478
1479 public string llMD5String(string src, int nonce)
1480 {
1481 return m_LSL_Functions.llMD5String(src, nonce);
1482 }
1483
1484 public void llSetPrimitiveParams(LSL_Types.list rules)
1485 {
1486 m_LSL_Functions.llSetPrimitiveParams(rules);
1487 }
1488
1489 public void llSetLinkPrimitiveParams(int linknumber, LSL_Types.list rules)
1490 {
1491 m_LSL_Functions.llSetLinkPrimitiveParams(linknumber, rules);
1492 }
1493 public string llStringToBase64(string str)
1494 {
1495 return m_LSL_Functions.llStringToBase64(str);
1496 }
1497
1498 public string llBase64ToString(string str)
1499 {
1500 return m_LSL_Functions.llBase64ToString(str);
1501 }
1502
1503 public void llXorBase64Strings()
1504 {
1505 m_LSL_Functions.llXorBase64Strings();
1506 }
1507
1508 public void llRemoteDataSetRegion()
1509 {
1510 m_LSL_Functions.llRemoteDataSetRegion();
1511 }
1512
1513 public double llLog10(double val)
1514 {
1515 return m_LSL_Functions.llLog10(val);
1516 }
1517
1518 public double llLog(double val)
1519 {
1520 return m_LSL_Functions.llLog(val);
1521 }
1522
1523 public LSL_Types.list llGetAnimationList(string id)
1524 {
1525 return m_LSL_Functions.llGetAnimationList(id);
1526 }
1527
1528 public void llSetParcelMusicURL(string url)
1529 {
1530 m_LSL_Functions.llSetParcelMusicURL(url);
1531 }
1532
1533 public vector llGetRootPosition()
1534 {
1535 return m_LSL_Functions.llGetRootPosition();
1536 }
1537
1538 public rotation llGetRootRotation()
1539 {
1540 return m_LSL_Functions.llGetRootRotation();
1541 }
1542
1543 public string llGetObjectDesc()
1544 {
1545 return m_LSL_Functions.llGetObjectDesc();
1546 }
1547
1548 public void llSetObjectDesc(string desc)
1549 {
1550 m_LSL_Functions.llSetObjectDesc(desc);
1551 }
1552
1553 public string llGetCreator()
1554 {
1555 return m_LSL_Functions.llGetCreator();
1556 }
1557
1558 public string llGetTimestamp()
1559 {
1560 return m_LSL_Functions.llGetTimestamp();
1561 }
1562
1563 public void llSetLinkAlpha(int linknumber, double alpha, int face)
1564 {
1565 m_LSL_Functions.llSetLinkAlpha(linknumber, alpha, face);
1566 }
1567
1568 public LSL_Types.LSLInteger llGetNumberOfPrims()
1569 {
1570 return m_LSL_Functions.llGetNumberOfPrims();
1571 }
1572
1573 public string llGetNumberOfNotecardLines(string name)
1574 {
1575 return m_LSL_Functions.llGetNumberOfNotecardLines(name);
1576 }
1577
1578 public LSL_Types.list llGetBoundingBox(string obj)
1579 {
1580 return m_LSL_Functions.llGetBoundingBox(obj);
1581 }
1582
1583 public vector llGetGeometricCenter()
1584 {
1585 return m_LSL_Functions.llGetGeometricCenter();
1586 }
1587
1588 public LSL_Types.list llGetPrimitiveParams(LSL_Types.list rules)
1589 {
1590 return m_LSL_Functions.llGetPrimitiveParams(rules);
1591 }
1592
1593 //
1594 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
1595 //
1596 public string llIntegerToBase64(int number)
1597 {
1598 return m_LSL_Functions.llIntegerToBase64(number);
1599 }
1600
1601 public LSL_Types.LSLInteger llBase64ToInteger(string str)
1602 {
1603 return m_LSL_Functions.llBase64ToInteger(str);
1604 }
1605
1606 public double llGetGMTclock()
1607 {
1608 return m_LSL_Functions.llGetGMTclock();
1609 }
1610
1611 public string llGetSimulatorHostname()
1612 {
1613 return m_LSL_Functions.llGetSimulatorHostname();
1614 }
1615
1616 public void llSetLocalRot(rotation rot)
1617 {
1618 m_LSL_Functions.llSetLocalRot(rot);
1619 }
1620
1621 public LSL_Types.list llParseStringKeepNulls(string src, LSL_Types.list seperators, LSL_Types.list spacers)
1622 {
1623 return m_LSL_Functions.llParseStringKeepNulls(src, seperators, spacers);
1624 }
1625
1626 public void llRezAtRoot(string inventory, vector position, vector velocity, rotation rot, int param)
1627 {
1628 m_LSL_Functions.llRezAtRoot(inventory, position, velocity, rot, param);
1629 }
1630
1631 public LSL_Types.LSLInteger llGetObjectPermMask(int mask)
1632 {
1633 return m_LSL_Functions.llGetObjectPermMask(mask);
1634 }
1635
1636 public void llSetObjectPermMask(int mask, int value)
1637 {
1638 m_LSL_Functions.llSetObjectPermMask(mask, value);
1639 }
1640
1641 public LSL_Types.LSLInteger llGetInventoryPermMask(string item, int mask)
1642 {
1643 return m_LSL_Functions.llGetInventoryPermMask(item, mask);
1644 }
1645
1646 public void llSetInventoryPermMask(string item, int mask, int value)
1647 {
1648 m_LSL_Functions.llSetInventoryPermMask(item, mask, value);
1649 }
1650
1651 public string llGetInventoryCreator(string item)
1652 {
1653 return m_LSL_Functions.llGetInventoryCreator(item);
1654 }
1655
1656 public void llOwnerSay(string msg)
1657 {
1658 m_LSL_Functions.llOwnerSay(msg);
1659 }
1660
1661 public string llRequestSimulatorData(string simulator, int data)
1662 {
1663 return m_LSL_Functions.llRequestSimulatorData(simulator, data);
1664 }
1665
1666 public void llForceMouselook(int mouselook)
1667 {
1668 m_LSL_Functions.llForceMouselook(mouselook);
1669 }
1670
1671 public double llGetObjectMass(string id)
1672 {
1673 return m_LSL_Functions.llGetObjectMass(id);
1674 }
1675
1676 public LSL_Types.list llListReplaceList(LSL_Types.list dest, LSL_Types.list src, int start, int end)
1677 {
1678 return m_LSL_Functions.llListReplaceList(dest, src, start, end);
1679 }
1680
1681 public void llLoadURL(string avatar_id, string message, string url)
1682 {
1683 m_LSL_Functions.llLoadURL(avatar_id, message, url);
1684 }
1685
1686 public void llParcelMediaCommandList(LSL_Types.list commandList)
1687 {
1688 m_LSL_Functions.llParcelMediaCommandList(commandList);
1689 }
1690
1691 public void llParcelMediaQuery()
1692 {
1693 m_LSL_Functions.llParcelMediaQuery();
1694 }
1695
1696 public LSL_Types.LSLInteger llModPow(int a, int b, int c)
1697 {
1698 return m_LSL_Functions.llModPow(a, b, c);
1699 }
1700
1701 //
1702 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
1703 //
1704 public LSL_Types.LSLInteger llGetInventoryType(string name)
1705 {
1706 return m_LSL_Functions.llGetInventoryType(name);
1707 }
1708
1709 public void llSetPayPrice(int price, LSL_Types.list quick_pay_buttons)
1710 {
1711 m_LSL_Functions.llSetPayPrice(price, quick_pay_buttons);
1712 }
1713
1714 public vector llGetCameraPos()
1715 {
1716 return m_LSL_Functions.llGetCameraPos();
1717 }
1718
1719 public rotation llGetCameraRot()
1720 {
1721 return m_LSL_Functions.llGetCameraRot();
1722 }
1723
1724 public void llSetPrimURL()
1725 {
1726 m_LSL_Functions.llSetPrimURL();
1727 }
1728
1729 public void llRefreshPrimURL()
1730 {
1731 m_LSL_Functions.llRefreshPrimURL();
1732 }
1733
1734 public string llEscapeURL(string url)
1735 {
1736 return m_LSL_Functions.llEscapeURL(url);
1737 }
1738
1739 public string llUnescapeURL(string url)
1740 {
1741 return m_LSL_Functions.llUnescapeURL(url);
1742 }
1743
1744 public void llMapDestination(string simname, vector pos, vector look_at)
1745 {
1746 m_LSL_Functions.llMapDestination(simname, pos, look_at);
1747 }
1748
1749 public void llAddToLandBanList(string avatar, double hours)
1750 {
1751 m_LSL_Functions.llAddToLandBanList(avatar, hours);
1752 }
1753
1754 public void llRemoveFromLandPassList(string avatar)
1755 {
1756 m_LSL_Functions.llRemoveFromLandPassList(avatar);
1757 }
1758
1759 public void llRemoveFromLandBanList(string avatar)
1760 {
1761 m_LSL_Functions.llRemoveFromLandBanList(avatar);
1762 }
1763
1764 public void llSetCameraParams(LSL_Types.list rules)
1765 {
1766 m_LSL_Functions.llSetCameraParams(rules);
1767 }
1768
1769 public void llClearCameraParams()
1770 {
1771 m_LSL_Functions.llClearCameraParams();
1772 }
1773
1774 public double llListStatistics(int operation, LSL_Types.list src)
1775 {
1776 return m_LSL_Functions.llListStatistics(operation, src);
1777 }
1778
1779 public LSL_Types.LSLInteger llGetUnixTime()
1780 {
1781 return m_LSL_Functions.llGetUnixTime();
1782 }
1783
1784 public LSL_Types.LSLInteger llGetParcelFlags(vector pos)
1785 {
1786 return m_LSL_Functions.llGetParcelFlags(pos);
1787 }
1788
1789 public LSL_Types.LSLInteger llGetRegionFlags()
1790 {
1791 return m_LSL_Functions.llGetRegionFlags();
1792 }
1793
1794 public string llXorBase64StringsCorrect(string str1, string str2)
1795 {
1796 return m_LSL_Functions.llXorBase64StringsCorrect(str1, str2);
1797 }
1798
1799 public string llHTTPRequest(string url, LSL_Types.list parameters, string body)
1800 {
1801 return m_LSL_Functions.llHTTPRequest(url, parameters, body);
1802 }
1803
1804 public void llResetLandBanList()
1805 {
1806 m_LSL_Functions.llResetLandBanList();
1807 }
1808
1809 public void llResetLandPassList()
1810 {
1811 m_LSL_Functions.llResetLandPassList();
1812 }
1813
1814 public LSL_Types.LSLInteger llGetParcelPrimCount(vector pos, int category, int sim_wide)
1815 {
1816 return m_LSL_Functions.llGetParcelPrimCount(pos, category, sim_wide);
1817 }
1818
1819 public LSL_Types.list llGetParcelPrimOwners(vector pos)
1820 {
1821 return m_LSL_Functions.llGetParcelPrimOwners(pos);
1822 }
1823
1824 public LSL_Types.LSLInteger llGetObjectPrimCount(string object_id)
1825 {
1826 return m_LSL_Functions.llGetObjectPrimCount(object_id);
1827 }
1828
1829 //
1830 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
1831 //
1832 public LSL_Types.LSLInteger llGetParcelMaxPrims(vector pos, int sim_wide)
1833 {
1834 return m_LSL_Functions.llGetParcelMaxPrims(pos, sim_wide);
1835 }
1836
1837 public LSL_Types.list llGetParcelDetails(vector pos, LSL_Types.list param)
1838 {
1839 return m_LSL_Functions.llGetParcelDetails(pos, param);
1840 }
1841
1842 public void llSetLinkTexture(int linknumber, string texture, int face)
1843 {
1844 m_LSL_Functions.llSetLinkTexture(linknumber, texture, face);
1845 }
1846
1847 public string llStringTrim(string src, int type)
1848 {
1849 return m_LSL_Functions.llStringTrim(src, type);
1850 }
1851
1852 public LSL_Types.list llGetObjectDetails(string id, LSL_Types.list args)
1853 {
1854 return m_LSL_Functions.llGetObjectDetails(id, args);
1855 }
1856
1857 public double llList2Float(LSL_Types.list src, int index)
1858 {
1859 return m_LSL_Functions.llList2Float(src, index);
1860 }
1861
1862 // LSL CONSTANTS
1863 public const int TRUE = 1;
1864 public const int FALSE = 0;
1865
1866 public const int STATUS_PHYSICS = 1;
1867 public const int STATUS_ROTATE_X = 2;
1868 public const int STATUS_ROTATE_Y = 4;
1869 public const int STATUS_ROTATE_Z = 8;
1870 public const int STATUS_PHANTOM = 16;
1871 public const int STATUS_SANDBOX = 32;
1872 public const int STATUS_BLOCK_GRAB = 64;
1873 public const int STATUS_DIE_AT_EDGE = 128;
1874 public const int STATUS_RETURN_AT_EDGE = 256;
1875 public const int STATUS_CAST_SHADOWS = 512;
1876
1877 public const int AGENT = 1;
1878 public const int ACTIVE = 2;
1879 public const int PASSIVE = 4;
1880 public const int SCRIPTED = 8;
1881
1882 public const int CONTROL_FWD = 1;
1883 public const int CONTROL_BACK = 2;
1884 public const int CONTROL_LEFT = 4;
1885 public const int CONTROL_RIGHT = 8;
1886 public const int CONTROL_UP = 16;
1887 public const int CONTROL_DOWN = 32;
1888 public const int CONTROL_ROT_LEFT = 256;
1889 public const int CONTROL_ROT_RIGHT = 512;
1890 public const int CONTROL_LBUTTON = 268435456;
1891 public const int CONTROL_ML_LBUTTON = 1073741824;
1892
1893 //Permissions
1894 public const int PERMISSION_DEBIT = 2;
1895 public const int PERMISSION_TAKE_CONTROLS = 4;
1896 public const int PERMISSION_REMAP_CONTROLS = 8;
1897 public const int PERMISSION_TRIGGER_ANIMATION = 16;
1898 public const int PERMISSION_ATTACH = 32;
1899 public const int PERMISSION_RELEASE_OWNERSHIP = 64;
1900 public const int PERMISSION_CHANGE_LINKS = 128;
1901 public const int PERMISSION_CHANGE_JOINTS = 256;
1902 public const int PERMISSION_CHANGE_PERMISSIONS = 512;
1903 public const int PERMISSION_TRACK_CAMERA = 1024;
1904
1905 public const int AGENT_FLYING = 1;
1906 public const int AGENT_ATTACHMENTS = 2;
1907 public const int AGENT_SCRIPTED = 4;
1908 public const int AGENT_MOUSELOOK = 8;
1909 public const int AGENT_SITTING = 16;
1910 public const int AGENT_ON_OBJECT = 32;
1911 public const int AGENT_AWAY = 64;
1912 public const int AGENT_WALKING = 128;
1913 public const int AGENT_IN_AIR = 256;
1914 public const int AGENT_TYPING = 512;
1915 public const int AGENT_CROUCHING = 1024;
1916 public const int AGENT_BUSY = 2048;
1917 public const int AGENT_ALWAYS_RUN = 4096;
1918
1919 //Particle Systems
1920 public const int PSYS_PART_INTERP_COLOR_MASK = 1;
1921 public const int PSYS_PART_INTERP_SCALE_MASK = 2;
1922 public const int PSYS_PART_BOUNCE_MASK = 4;
1923 public const int PSYS_PART_WIND_MASK = 8;
1924 public const int PSYS_PART_FOLLOW_SRC_MASK = 16;
1925 public const int PSYS_PART_FOLLOW_VELOCITY_MASK = 32;
1926 public const int PSYS_PART_TARGET_POS_MASK = 64;
1927 public const int PSYS_PART_TARGET_LINEAR_MASK = 128;
1928 public const int PSYS_PART_EMISSIVE_MASK = 256;
1929 public const int PSYS_PART_FLAGS = 0;
1930 public const int PSYS_PART_START_COLOR = 1;
1931 public const int PSYS_PART_START_ALPHA = 2;
1932 public const int PSYS_PART_END_COLOR = 3;
1933 public const int PSYS_PART_END_ALPHA = 4;
1934 public const int PSYS_PART_START_SCALE = 5;
1935 public const int PSYS_PART_END_SCALE = 6;
1936 public const int PSYS_PART_MAX_AGE = 7;
1937 public const int PSYS_SRC_ACCEL = 8;
1938 public const int PSYS_SRC_PATTERN = 9;
1939 public const int PSYS_SRC_INNERANGLE = 10;
1940 public const int PSYS_SRC_OUTERANGLE = 11;
1941 public const int PSYS_SRC_TEXTURE = 12;
1942 public const int PSYS_SRC_BURST_RATE = 13;
1943 public const int PSYS_SRC_BURST_PART_COUNT = 15;
1944 public const int PSYS_SRC_BURST_RADIUS = 16;
1945 public const int PSYS_SRC_BURST_SPEED_MIN = 17;
1946 public const int PSYS_SRC_BURST_SPEED_MAX = 18;
1947 public const int PSYS_SRC_MAX_AGE = 19;
1948 public const int PSYS_SRC_TARGET_KEY = 20;
1949 public const int PSYS_SRC_OMEGA = 21;
1950 public const int PSYS_SRC_ANGLE_BEGIN = 22;
1951 public const int PSYS_SRC_ANGLE_END = 23;
1952 public const int PSYS_SRC_PATTERN_DROP = 1;
1953 public const int PSYS_SRC_PATTERN_EXPLODE = 2;
1954 public const int PSYS_SRC_PATTERN_ANGLE = 4;
1955 public const int PSYS_SRC_PATTERN_ANGLE_CONE = 8;
1956 public const int PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY = 16;
1957
1958 public const int VEHICLE_TYPE_NONE = 0;
1959 public const int VEHICLE_TYPE_SLED = 1;
1960 public const int VEHICLE_TYPE_CAR = 2;
1961 public const int VEHICLE_TYPE_BOAT = 3;
1962 public const int VEHICLE_TYPE_AIRPLANE = 4;
1963 public const int VEHICLE_TYPE_BALLOON = 5;
1964 public const int VEHICLE_LINEAR_FRICTION_TIMESCALE = 16;
1965 public const int VEHICLE_ANGULAR_FRICTION_TIMESCALE = 17;
1966 public const int VEHICLE_LINEAR_MOTOR_DIRECTION = 18;
1967 public const int VEHICLE_LINEAR_MOTOR_OFFSET = 20;
1968 public const int VEHICLE_ANGULAR_MOTOR_DIRECTION = 19;
1969 public const int VEHICLE_HOVER_HEIGHT = 24;
1970 public const int VEHICLE_HOVER_EFFICIENCY = 25;
1971 public const int VEHICLE_HOVER_TIMESCALE = 26;
1972 public const int VEHICLE_BUOYANCY = 27;
1973 public const int VEHICLE_LINEAR_DEFLECTION_EFFICIENCY = 28;
1974 public const int VEHICLE_LINEAR_DEFLECTION_TIMESCALE = 29;
1975 public const int VEHICLE_LINEAR_MOTOR_TIMESCALE = 30;
1976 public const int VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE = 31;
1977 public const int VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY = 32;
1978 public const int VEHICLE_ANGULAR_DEFLECTION_TIMESCALE = 33;
1979 public const int VEHICLE_ANGULAR_MOTOR_TIMESCALE = 34;
1980 public const int VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE = 35;
1981 public const int VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY = 36;
1982 public const int VEHICLE_VERTICAL_ATTRACTION_TIMESCALE = 37;
1983 public const int VEHICLE_BANKING_EFFICIENCY = 38;
1984 public const int VEHICLE_BANKING_MIX = 39;
1985 public const int VEHICLE_BANKING_TIMESCALE = 40;
1986 public const int VEHICLE_REFERENCE_FRAME = 44;
1987 public const int VEHICLE_FLAG_NO_DEFLECTION_UP = 1;
1988 public const int VEHICLE_FLAG_LIMIT_ROLL_ONLY = 2;
1989 public const int VEHICLE_FLAG_HOVER_WATER_ONLY = 4;
1990 public const int VEHICLE_FLAG_HOVER_TERRAIN_ONLY = 8;
1991 public const int VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT = 16;
1992 public const int VEHICLE_FLAG_HOVER_UP_ONLY = 32;
1993 public const int VEHICLE_FLAG_LIMIT_MOTOR_UP = 64;
1994 public const int VEHICLE_FLAG_MOUSELOOK_STEER = 128;
1995 public const int VEHICLE_FLAG_MOUSELOOK_BANK = 256;
1996 public const int VEHICLE_FLAG_CAMERA_DECOUPLED = 512;
1997
1998 public const int INVENTORY_ALL = -1;
1999 public const int INVENTORY_NONE = -1;
2000 public const int INVENTORY_TEXTURE = 0;
2001 public const int INVENTORY_SOUND = 1;
2002 public const int INVENTORY_LANDMARK = 3;
2003 public const int INVENTORY_CLOTHING = 5;
2004 public const int INVENTORY_OBJECT = 6;
2005 public const int INVENTORY_NOTECARD = 7;
2006 public const int INVENTORY_SCRIPT = 10;
2007 public const int INVENTORY_BODYPART = 13;
2008 public const int INVENTORY_ANIMATION = 20;
2009 public const int INVENTORY_GESTURE = 21;
2010
2011 public const int ATTACH_CHEST = 1;
2012 public const int ATTACH_HEAD = 2;
2013 public const int ATTACH_LSHOULDER = 3;
2014 public const int ATTACH_RSHOULDER = 4;
2015 public const int ATTACH_LHAND = 5;
2016 public const int ATTACH_RHAND = 6;
2017 public const int ATTACH_LFOOT = 7;
2018 public const int ATTACH_RFOOT = 8;
2019 public const int ATTACH_BACK = 9;
2020 public const int ATTACH_PELVIS = 10;
2021 public const int ATTACH_MOUTH = 11;
2022 public const int ATTACH_CHIN = 12;
2023 public const int ATTACH_LEAR = 13;
2024 public const int ATTACH_REAR = 14;
2025 public const int ATTACH_LEYE = 15;
2026 public const int ATTACH_REYE = 16;
2027 public const int ATTACH_NOSE = 17;
2028 public const int ATTACH_RUARM = 18;
2029 public const int ATTACH_RLARM = 19;
2030 public const int ATTACH_LUARM = 20;
2031 public const int ATTACH_LLARM = 21;
2032 public const int ATTACH_RHIP = 22;
2033 public const int ATTACH_RULEG = 23;
2034 public const int ATTACH_RLLEG = 24;
2035 public const int ATTACH_LHIP = 25;
2036 public const int ATTACH_LULEG = 26;
2037 public const int ATTACH_LLLEG = 27;
2038 public const int ATTACH_BELLY = 28;
2039 public const int ATTACH_RPEC = 29;
2040 public const int ATTACH_LPEC = 30;
2041
2042 public const int LAND_LEVEL = 0;
2043 public const int LAND_RAISE = 1;
2044 public const int LAND_LOWER = 2;
2045 public const int LAND_SMOOTH = 3;
2046 public const int LAND_NOISE = 4;
2047 public const int LAND_REVERT = 5;
2048 public const int LAND_SMALL_BRUSH = 1;
2049 public const int LAND_MEDIUM_BRUSH = 2;
2050 public const int LAND_LARGE_BRUSH = 3;
2051
2052 //Agent Dataserver
2053 public const int DATA_ONLINE = 1;
2054 public const int DATA_NAME = 2;
2055 public const int DATA_BORN = 3;
2056 public const int DATA_RATING = 4;
2057 public const int DATA_SIM_POS = 5;
2058 public const int DATA_SIM_STATUS = 6;
2059 public const int DATA_SIM_RATING = 7;
2060 public const int DATA_PAYINFO = 8;
2061
2062 public const int ANIM_ON = 1;
2063 public const int LOOP = 2;
2064 public const int REVERSE = 4;
2065 public const int PING_PONG = 8;
2066 public const int SMOOTH = 16;
2067 public const int ROTATE = 32;
2068 public const int SCALE = 64;
2069 public const int ALL_SIDES = -1;
2070 public const int LINK_SET = -1;
2071 public const int LINK_ROOT = 1;
2072 public const int LINK_ALL_OTHERS = -2;
2073 public const int LINK_ALL_CHILDREN = -3;
2074 public const int LINK_THIS = -4;
2075 public const int CHANGED_INVENTORY = 1;
2076 public const int CHANGED_COLOR = 2;
2077 public const int CHANGED_SHAPE = 4;
2078 public const int CHANGED_SCALE = 8;
2079 public const int CHANGED_TEXTURE = 16;
2080 public const int CHANGED_LINK = 32;
2081 public const int CHANGED_ALLOWED_DROP = 64;
2082 public const int CHANGED_OWNER = 128;
2083 public const int CHANGED_REGION_RESTART = 256;
2084 public const int TYPE_INVALID = 0;
2085 public const int TYPE_INTEGER = 1;
2086 public const int TYPE_double = 2;
2087 public const int TYPE_STRING = 3;
2088 public const int TYPE_KEY = 4;
2089 public const int TYPE_VECTOR = 5;
2090 public const int TYPE_ROTATION = 6;
2091
2092 //XML RPC Remote Data Channel
2093 public const int REMOTE_DATA_CHANNEL = 1;
2094 public const int REMOTE_DATA_REQUEST = 2;
2095 public const int REMOTE_DATA_REPLY = 3;
2096
2097 //llHTTPRequest
2098 public const int HTTP_METHOD = 0;
2099 public const int HTTP_MIMETYPE = 1;
2100 public const int HTTP_BODY_MAXLENGTH = 2;
2101 public const int HTTP_VERIFY_CERT = 3;
2102
2103 public const int PRIM_MATERIAL = 2;
2104 public const int PRIM_PHYSICS = 3;
2105 public const int PRIM_TEMP_ON_REZ = 4;
2106 public const int PRIM_PHANTOM = 5;
2107 public const int PRIM_POSITION = 6;
2108 public const int PRIM_SIZE = 7;
2109 public const int PRIM_ROTATION = 8;
2110 public const int PRIM_TYPE = 9;
2111 public const int PRIM_TEXTURE = 17;
2112 public const int PRIM_COLOR = 18;
2113 public const int PRIM_BUMP_SHINY = 19;
2114 public const int PRIM_FULLBRIGHT = 20;
2115 public const int PRIM_FLEXIBLE = 21;
2116 public const int PRIM_TEXGEN = 22;
2117 public const int PRIM_CAST_SHADOWS = 24; // Not implemented, here for completeness sake
2118 public const int PRIM_POINT_LIGHT = 23; // Huh?
2119 public const int PRIM_TEXGEN_DEFAULT = 0;
2120 public const int PRIM_TEXGEN_PLANAR = 1;
2121
2122 public const int PRIM_TYPE_BOX = 0;
2123 public const int PRIM_TYPE_CYLINDER = 1;
2124 public const int PRIM_TYPE_PRISM = 2;
2125 public const int PRIM_TYPE_SPHERE = 3;
2126 public const int PRIM_TYPE_TORUS = 4;
2127 public const int PRIM_TYPE_TUBE = 5;
2128 public const int PRIM_TYPE_RING = 6;
2129 public const int PRIM_TYPE_SCULPT = 7;
2130
2131 public const int PRIM_HOLE_DEFAULT = 0;
2132 public const int PRIM_HOLE_CIRCLE = 16;
2133 public const int PRIM_HOLE_SQUARE = 32;
2134 public const int PRIM_HOLE_TRIANGLE = 48;
2135
2136 public const int PRIM_MATERIAL_STONE = 0;
2137 public const int PRIM_MATERIAL_METAL = 1;
2138 public const int PRIM_MATERIAL_GLASS = 2;
2139 public const int PRIM_MATERIAL_WOOD = 3;
2140 public const int PRIM_MATERIAL_FLESH = 4;
2141 public const int PRIM_MATERIAL_PLASTIC = 5;
2142 public const int PRIM_MATERIAL_RUBBER = 6;
2143 public const int PRIM_MATERIAL_LIGHT = 7;
2144
2145 public const int PRIM_SHINY_NONE = 0;
2146 public const int PRIM_SHINY_LOW = 1;
2147 public const int PRIM_SHINY_MEDIUM = 2;
2148 public const int PRIM_SHINY_HIGH = 3;
2149 public const int PRIM_BUMP_NONE = 0;
2150 public const int PRIM_BUMP_BRIGHT = 1;
2151 public const int PRIM_BUMP_DARK = 2;
2152 public const int PRIM_BUMP_WOOD = 3;
2153 public const int PRIM_BUMP_BARK = 4;
2154 public const int PRIM_BUMP_BRICKS = 5;
2155 public const int PRIM_BUMP_CHECKER = 6;
2156 public const int PRIM_BUMP_CONCRETE = 7;
2157 public const int PRIM_BUMP_TILE = 8;
2158 public const int PRIM_BUMP_STONE = 9;
2159 public const int PRIM_BUMP_DISKS = 10;
2160 public const int PRIM_BUMP_GRAVEL = 11;
2161 public const int PRIM_BUMP_BLOBS = 12;
2162 public const int PRIM_BUMP_SIDING = 13;
2163 public const int PRIM_BUMP_LARGETILE = 14;
2164 public const int PRIM_BUMP_STUCCO = 15;
2165 public const int PRIM_BUMP_SUCTION = 16;
2166 public const int PRIM_BUMP_WEAVE = 17;
2167
2168 public const int PRIM_SCULPT_TYPE_SPHERE = 1;
2169 public const int PRIM_SCULPT_TYPE_TORUS = 2;
2170 public const int PRIM_SCULPT_TYPE_PLANE = 3;
2171 public const int PRIM_SCULPT_TYPE_CYLINDER = 4;
2172
2173 public const int MASK_BASE = 0;
2174 public const int MASK_OWNER = 1;
2175 public const int MASK_GROUP = 2;
2176 public const int MASK_EVERYONE = 3;
2177 public const int MASK_NEXT = 4;
2178
2179 public const int PERM_TRANSFER = 8192;
2180 public const int PERM_MODIFY = 16384;
2181 public const int PERM_COPY = 32768;
2182 public const int PERM_MOVE = 524288;
2183 public const int PERM_ALL = 2147483647;
2184
2185 public const int PARCEL_MEDIA_COMMAND_STOP = 0;
2186 public const int PARCEL_MEDIA_COMMAND_PAUSE = 1;
2187 public const int PARCEL_MEDIA_COMMAND_PLAY = 2;
2188 public const int PARCEL_MEDIA_COMMAND_LOOP = 3;
2189 public const int PARCEL_MEDIA_COMMAND_TEXTURE = 4;
2190 public const int PARCEL_MEDIA_COMMAND_URL = 5;
2191 public const int PARCEL_MEDIA_COMMAND_TIME = 6;
2192 public const int PARCEL_MEDIA_COMMAND_AGENT = 7;
2193 public const int PARCEL_MEDIA_COMMAND_UNLOAD = 8;
2194 public const int PARCEL_MEDIA_COMMAND_AUTO_ALIGN = 9;
2195
2196 public const int PAY_HIDE = -1;
2197 public const int PAY_DEFAULT = -2;
2198
2199 public const string NULL_KEY = "00000000-0000-0000-0000-000000000000";
2200 public const string EOF = "\n\n\n";
2201 public const double PI = 3.14159274f;
2202 public const double TWO_PI = 6.28318548f;
2203 public const double PI_BY_TWO = 1.57079637f;
2204 public const double DEG_TO_RAD = 0.01745329238f;
2205 public const double RAD_TO_DEG = 57.29578f;
2206 public const double SQRT2 = 1.414213538f;
2207 public const int STRING_TRIM_HEAD = 1;
2208 public const int STRING_TRIM_TAIL = 2;
2209 public const int STRING_TRIM = 3;
2210 public const int LIST_STAT_RANGE = 0;
2211 public const int LIST_STAT_MIN = 1;
2212 public const int LIST_STAT_MAX = 2;
2213 public const int LIST_STAT_MEAN = 3;
2214 public const int LIST_STAT_MEDIAN = 4;
2215 public const int LIST_STAT_STD_DEV = 5;
2216 public const int LIST_STAT_SUM = 6;
2217 public const int LIST_STAT_SUM_SQUARES = 7;
2218 public const int LIST_STAT_NUM_COUNT = 8;
2219 public const int LIST_STAT_GEOMETRIC_MEAN = 9;
2220 public const int LIST_STAT_HARMONIC_MEAN = 100;
2221
2222 //ParcelPrim Categories
2223 public const int PARCEL_COUNT_TOTAL = 0;
2224 public const int PARCEL_COUNT_OWNER = 1;
2225 public const int PARCEL_COUNT_GROUP = 2;
2226 public const int PARCEL_COUNT_OTHER = 3;
2227 public const int PARCEL_COUNT_SELECTED = 4;
2228 public const int PARCEL_COUNT_TEMP = 5;
2229
2230 public const int DEBUG_CHANNEL = 0x7FFFFFFF;
2231 public const int PUBLIC_CHANNEL = 0x00000000;
2232
2233 public const int OBJECT_NAME = 1;
2234 public const int OBJECT_DESC = 2;
2235 public const int OBJECT_POS = 3;
2236 public const int OBJECT_ROT = 4;
2237 public const int OBJECT_VELOCITY = 5;
2238 public const int OBJECT_OWNER = 6;
2239 public const int OBJECT_GROUP = 7;
2240 public const int OBJECT_CREATOR = 8;
2241
2242 // Can not be public const?
2243 public vector ZERO_VECTOR = new vector(0.0, 0.0, 0.0);
2244 public rotation ZERO_ROTATION = new rotation(0.0, 0, 0.0, 1.0);
2245
2246
2247 //
2248 // OSSL
2249 //
2250 // FIXME: Refactor so we don't need to pull the script engine
2251 // into the app domain
2252 //
2253
2254 public void osSetRegionWaterHeight(double height)
2255 {
2256 m_OSSL_Functions.osSetRegionWaterHeight(height);
2257 }
2258
2259 public double osList2Double(LSL_Types.list src, int index)
2260 {
2261 return m_OSSL_Functions.osList2Double(src, index);
2262 }
2263
2264 public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams,
2265 int timer)
2266 {
2267 return m_OSSL_Functions.osSetDynamicTextureURL(dynamicID, contentType, url, extraParams, timer);
2268 }
2269
2270 public string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams,
2271 int timer)
2272 {
2273 return m_OSSL_Functions.osSetDynamicTextureData(dynamicID, contentType, data, extraParams, timer);
2274 }
2275
2276 public string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams,
2277 int timer, int alpha)
2278 {
2279 return m_OSSL_Functions.osSetDynamicTextureURLBlend(dynamicID, contentType, url, extraParams, timer, alpha);
2280 }
2281
2282 public string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams,
2283 int timer, int alpha)
2284 {
2285 return m_OSSL_Functions.osSetDynamicTextureDataBlend(dynamicID, contentType, data, extraParams, timer, alpha);
2286 }
2287
2288 public double osTerrainGetHeight(int x, int y)
2289 {
2290 return m_OSSL_Functions.osTerrainGetHeight(x, y);
2291 }
2292
2293 public int osTerrainSetHeight(int x, int y, double val)
2294 {
2295 return m_OSSL_Functions.osTerrainSetHeight(x, y, val);
2296 }
2297
2298 public int osRegionRestart(double seconds)
2299 {
2300 return m_OSSL_Functions.osRegionRestart(seconds);
2301 }
2302
2303 public void osRegionNotice(string msg)
2304 {
2305 m_OSSL_Functions.osRegionNotice(msg);
2306 }
2307
2308 public bool osConsoleCommand(string Command)
2309 {
2310 return m_OSSL_Functions.osConsoleCommand(Command);
2311 }
2312
2313 public void osSetParcelMediaURL(string url)
2314 {
2315 m_OSSL_Functions.osSetParcelMediaURL(url);
2316 }
2317
2318 public void osSetPrimFloatOnWater(int floatYN)
2319 {
2320 m_OSSL_Functions.osSetPrimFloatOnWater(floatYN);
2321 }
2322
2323 // Animation Functions
2324
2325 public void osAvatarPlayAnimation(string avatar, string animation)
2326 {
2327 m_OSSL_Functions.osAvatarPlayAnimation(avatar, animation);
2328 }
2329
2330 public void osAvatarStopAnimation(string avatar, string animation)
2331 {
2332 m_OSSL_Functions.osAvatarStopAnimation(avatar, animation);
2333 }
2334
2335
2336 //Texture Draw functions
2337
2338 public string osMovePen(string drawList, int x, int y)
2339 {
2340 return m_OSSL_Functions.osMovePen(drawList, x, y);
2341 }
2342
2343 public string osDrawLine(string drawList, int startX, int startY, int endX, int endY)
2344 {
2345 return m_OSSL_Functions.osDrawLine(drawList, startX, startY, endX, endY);
2346 }
2347
2348 public string osDrawLine(string drawList, int endX, int endY)
2349 {
2350 return m_OSSL_Functions.osDrawLine(drawList, endX, endY);
2351 }
2352
2353 public string osDrawText(string drawList, string text)
2354 {
2355 return m_OSSL_Functions.osDrawText(drawList, text);
2356 }
2357
2358 public string osDrawEllipse(string drawList, int width, int height)
2359 {
2360 return m_OSSL_Functions.osDrawEllipse(drawList, width, height);
2361 }
2362
2363 public string osDrawRectangle(string drawList, int width, int height)
2364 {
2365 return m_OSSL_Functions.osDrawRectangle(drawList, width, height);
2366 }
2367
2368 public string osDrawFilledRectangle(string drawList, int width, int height)
2369 {
2370 return m_OSSL_Functions.osDrawFilledRectangle(drawList, width, height);
2371 }
2372
2373 public string osSetFontSize(string drawList, int fontSize)
2374 {
2375 return m_OSSL_Functions.osSetFontSize(drawList, fontSize);
2376 }
2377
2378 public string osSetPenSize(string drawList, int penSize)
2379 {
2380 return m_OSSL_Functions.osSetPenSize(drawList, penSize);
2381 }
2382
2383 public string osSetPenColour(string drawList, string colour)
2384 {
2385 return m_OSSL_Functions.osSetPenColour(drawList, colour);
2386 }
2387
2388 public string osDrawImage(string drawList, int width, int height, string imageUrl)
2389 {
2390 return m_OSSL_Functions.osDrawImage(drawList, width, height, imageUrl);
2391 }
2392 public void osSetStateEvents(int events)
2393 {
2394 m_OSSL_Functions.osSetStateEvents(events);
2395 }
2396 }
2397}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Script/ILSL_ScriptCommands.cs b/OpenSim/Region/ScriptEngine/XEngine/Script/ILSL_ScriptCommands.cs
deleted file mode 100644
index 9e8965c..0000000
--- a/OpenSim/Region/ScriptEngine/XEngine/Script/ILSL_ScriptCommands.cs
+++ /dev/null
@@ -1,653 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using OpenSim.Region.Environment.Interfaces;
29
30namespace OpenSim.Region.ScriptEngine.XEngine.Script
31{
32 public interface ILSL_ScriptCommands
33 {
34 // Interface used for loading and executing scripts
35
36 string State { get; set ; }
37
38 void state(string newState);
39
40 ICommander GetCommander(string name);
41
42 void llSay(int channelID, string text);
43 double llSin(double f);
44 double llCos(double f);
45 double llTan(double f);
46 double llAtan2(double x, double y);
47 double llSqrt(double f);
48 double llPow(double fbase, double fexponent);
49 LSL_Types.LSLInteger llAbs(int i);
50 double llFabs(double f);
51 double llFrand(double mag);
52 LSL_Types.LSLInteger llFloor(double f);
53 LSL_Types.LSLInteger llCeil(double f);
54 LSL_Types.LSLInteger llRound(double f);
55 double llVecMag(LSL_Types.Vector3 v);
56 LSL_Types.Vector3 llVecNorm(LSL_Types.Vector3 v);
57 double llVecDist(LSL_Types.Vector3 a, LSL_Types.Vector3 b);
58 LSL_Types.Vector3 llRot2Euler(LSL_Types.Quaternion r);
59 LSL_Types.Quaternion llEuler2Rot(LSL_Types.Vector3 v);
60 LSL_Types.Quaternion llAxes2Rot(LSL_Types.Vector3 fwd, LSL_Types.Vector3 left, LSL_Types.Vector3 up);
61 LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r);
62 LSL_Types.Vector3 llRot2Left(LSL_Types.Quaternion r);
63 LSL_Types.Vector3 llRot2Up(LSL_Types.Quaternion r);
64 LSL_Types.Quaternion llRotBetween(LSL_Types.Vector3 start, LSL_Types.Vector3 end);
65 void llWhisper(int channelID, string text);
66 //void llSay(int channelID, string text);
67 void llShout(int channelID, string text);
68 void llRegionSay(int channelID, string text);
69 LSL_Types.LSLInteger llListen(int channelID, string name, string ID, string msg);
70 void llListenControl(int number, int active);
71 void llListenRemove(int number);
72 void llSensor(string name, string id, int type, double range, double arc);
73 void llSensorRepeat(string name, string id, int type, double range, double arc, double rate);
74 void llSensorRemove();
75 string llDetectedName(int number);
76 string llDetectedKey(int number);
77 string llDetectedOwner(int number);
78 LSL_Types.LSLInteger llDetectedType(int number);
79 LSL_Types.Vector3 llDetectedPos(int number);
80 LSL_Types.Vector3 llDetectedVel(int number);
81 LSL_Types.Vector3 llDetectedGrab(int number);
82 LSL_Types.Quaternion llDetectedRot(int number);
83 LSL_Types.LSLInteger llDetectedGroup(int number);
84 LSL_Types.LSLInteger llDetectedLinkNumber(int number);
85 void llDie();
86 double llGround(LSL_Types.Vector3 offset);
87 double llCloud(LSL_Types.Vector3 offset);
88 LSL_Types.Vector3 llWind(LSL_Types.Vector3 offset);
89 void llSetStatus(int status, int value);
90 LSL_Types.LSLInteger llGetStatus(int status);
91 void llSetScale(LSL_Types.Vector3 scale);
92 LSL_Types.Vector3 llGetScale();
93 void llSetColor(LSL_Types.Vector3 color, int face);
94 double llGetAlpha(int face);
95 void llSetAlpha(double alpha, int face);
96 LSL_Types.Vector3 llGetColor(int face);
97 void llSetTexture(string texture, int face);
98 void llScaleTexture(double u, double v, int face);
99 void llOffsetTexture(double u, double v, int face);
100 void llRotateTexture(double rotation, int face);
101 string llGetTexture(int face);
102 void llSetPos(LSL_Types.Vector3 pos);
103
104 //wiki: vector llGetPos()
105 LSL_Types.Vector3 llGetPos();
106 //wiki: vector llGetLocalPos()
107 LSL_Types.Vector3 llGetLocalPos();
108 //wiki: llSetRot(rotation rot)
109 void llSetRot(LSL_Types.Quaternion rot);
110 //wiki: rotation llGetRot()
111 LSL_Types.Quaternion llGetRot();
112 //wiki: rotation llGetLocalRot()
113 LSL_Types.Quaternion llGetLocalRot();
114 //wiki: llSetForce(vector force, integer local)
115 void llSetForce(LSL_Types.Vector3 force, int local);
116 //wiki: vector llGetForce()
117 LSL_Types.Vector3 llGetForce();
118 //wiki: integer llTarget(vector position, double range)
119 LSL_Types.LSLInteger llTarget(LSL_Types.Vector3 position, double range);
120 //wiki: llTargetRemove(integer number)
121 void llTargetRemove(int number);
122 //wiki: integer llRotTarget(rotation rot, double error)
123 LSL_Types.LSLInteger llRotTarget(LSL_Types.Quaternion rot, double error);
124 //wiki: integer llRotTargetRemove(integer number)
125 void llRotTargetRemove(int number);
126 //wiki: llMoveToTarget(vector target, double tau)
127 void llMoveToTarget(LSL_Types.Vector3 target, double tau);
128 //wiki: llStopMoveToTarget()
129 void llStopMoveToTarget();
130 //wiki: llApplyImpulse(vector force, integer local)
131 void llApplyImpulse(LSL_Types.Vector3 force, int local);
132 //wiki: llapplyRotationalImpulse(vector force, integer local)
133 void llApplyRotationalImpulse(LSL_Types.Vector3 force, int local);
134 //wiki: llSetTorque(vector torque, integer local)
135 void llSetTorque(LSL_Types.Vector3 torque, int local);
136 //wiki: vector llGetTorque()
137 LSL_Types.Vector3 llGetTorque();
138 //wiki: llSeForceAndTorque(vector force, vector torque, integer local)
139 void llSetForceAndTorque(LSL_Types.Vector3 force, LSL_Types.Vector3 torque, int local);
140 //wiki: vector llGetVel()
141 LSL_Types.Vector3 llGetVel();
142 //wiki: vector llGetAccel()
143 LSL_Types.Vector3 llGetAccel();
144 //wiki: vector llGetOmega()
145 LSL_Types.Vector3 llGetOmega();
146 //wiki: double llGetTimeOfDay()
147 double llGetTimeOfDay();
148 //wiki: double llGetWallclock()
149 double llGetWallclock();
150 //wiki: double llGetTime()
151 double llGetTime();
152 //wiki: llResetTime()
153 void llResetTime();
154 //wiki: double llGetAndResetTime()
155 double llGetAndResetTime();
156 //wiki (deprecated) llSound(string sound, double volume, integer queue, integer loop)
157 void llSound();
158 //wiki: llPlaySound(string sound, double volume)
159 void llPlaySound(string sound, double volume);
160 //wiki: llLoopSound(string sound, double volume)
161 void llLoopSound(string sound, double volume);
162 //wiki: llLoopSoundMaster(string sound, double volume)
163 void llLoopSoundMaster(string sound, double volume);
164 //wiki: llLoopSoundSlave(string sound, double volume)
165 void llLoopSoundSlave(string sound, double volume);
166 //wiki llPlaySoundSlave(string sound, double volume)
167 void llPlaySoundSlave(string sound, double volume);
168 //wiki: llTriggerSound(string sound, double volume)
169 void llTriggerSound(string sound, double volume);
170 //wiki: llStopSound()
171 void llStopSound();
172 //wiki: llPreloadSound(string sound)
173 void llPreloadSound(string sound);
174 //wiki: string llGetSubString(string src, integer start, integer end)
175 string llGetSubString(string src, int start, int end);
176 //wiki: string llDeleteSubString(string src, integer start, integer end)
177 string llDeleteSubString(string src, int start, int end);
178 //wiki string llInsertString(string dst, integer position, string src)
179 string llInsertString(string dst, int position, string src);
180 //wiki: string llToUpper(string source)
181 string llToUpper(string source);
182 //wiki: string llToLower(string source)
183 string llToLower(string source);
184 //wiki: integer llGiveMoney(key destination, integer amount)
185 LSL_Types.LSLInteger llGiveMoney(string destination, int amount);
186 //wiki: (deprecated)
187 void llMakeExplosion();
188 //wiki: (deprecated)
189 void llMakeFountain();
190 //wiki: (deprecated)
191 void llMakeSmoke();
192 //wiki: (deprecated)
193 void llMakeFire();
194 //wiki: llRezObject(string inventory, vector pos, vector rel, rotation rot, integer param)
195 void llRezObject(string inventory, LSL_Types.Vector3 pos, LSL_Types.Vector3 vel, LSL_Types.Quaternion rot, int param);
196 //wiki: llLookAt(vector target, double strength, double damping)
197 void llLookAt(LSL_Types.Vector3 target, double strength, double damping);
198 //wiki: llStopLookAt()
199 void llStopLookAt();
200 //wiki: llSetTimerEvent(double sec)
201 void llSetTimerEvent(double sec);
202 //wiki: llSleep(double sec)
203 void llSleep(double sec);
204 //wiki: double llGetMass()
205 double llGetMass();
206 //wiki: llCollisionFilter(string name, key id, integer accept)
207 void llCollisionFilter(string name, string id, int accept);
208 //wiki: llTakeControls(integer controls, integer accept, integer pass_on)
209 void llTakeControls(int controls, int accept, int pass_on);
210 //wiki: llReleaseControls()
211 void llReleaseControls();
212 //wiki: llAttachToAvatar(integer attachment)
213 void llAttachToAvatar(int attachment);
214 //wiki: llDetachFromAvatar()
215 void llDetachFromAvatar();
216 //wiki: (deprecated) llTakeCamera()
217 void llTakeCamera();
218 //wiki: (deprecated) llReleaseCamera()
219 void llReleaseCamera();
220 //wiki: key llGetOwner()
221 string llGetOwner();
222 //wiki: llInstantMessage(key user, string message)
223 void llInstantMessage(string user, string message);
224 //wiki: llEmail(string address, string subject, string message)
225 void llEmail(string address, string subject, string message);
226 //wiki: llGetNextEmail(string address, string subject)
227 void llGetNextEmail(string address, string subject);
228 //wiki: key llGetKey()
229 string llGetKey();
230 //wiki: llSetBuoyancy(double buoyancy)
231 void llSetBuoyancy(double buoyancy);
232 //wiki: llSetHoverHeight(double height, integer water, double tau)
233 void llSetHoverHeight(double height, int water, double tau);
234 //wiki: llStopHover
235 void llStopHover();
236 //wiki: llMinEventDelay(double delay)
237 void llMinEventDelay(double delay);
238 //wiki: (deprecated) llSoundPreload()
239 void llSoundPreload();
240 //wiki: llRotLookAt(rotation target, double strength, double damping)
241 void llRotLookAt(LSL_Types.Quaternion target, double strength, double damping);
242 //wiki: integer llStringLength(string str)
243 LSL_Types.LSLInteger llStringLength(string str);
244 //wiki: llStartAnimation(string anim)
245 void llStartAnimation(string anim);
246 //wiki: llStopAnimation(string anim)
247 void llStopAnimation(string anim);
248 //wiki: (deprecated) llPointAt
249 void llPointAt();
250 //wiki: (deprecated) llStopPointAt
251 void llStopPointAt();
252 //wiki: llTargetOmega(vector axis, double spinrate, double gain)
253 void llTargetOmega(LSL_Types.Vector3 axis, double spinrate, double gain);
254 //wiki: integer llGetStartParameter()
255 LSL_Types.LSLInteger llGetStartParameter();
256 //wiki: llGodLikeRezObject(key inventory, vector pos)
257 void llGodLikeRezObject(string inventory, LSL_Types.Vector3 pos);
258 //wiki: llRequestPermissions(key agent, integer perm)
259 void llRequestPermissions(string agent, int perm);
260 //wiki: key llGetPermissionsKey()
261 string llGetPermissionsKey();
262 //wiki: integer llGetPermissions()
263 LSL_Types.LSLInteger llGetPermissions();
264 //wiki integer llGetLinkNumber()
265 LSL_Types.LSLInteger llGetLinkNumber();
266 //wiki: llSetLinkColor(integer linknumber, vector color, integer face)
267 void llSetLinkColor(int linknumber, LSL_Types.Vector3 color, int face);
268 //wiki: llCreateLink(key target, integer parent)
269 void llCreateLink(string target, int parent);
270 //wiki: llBreakLink(integer linknum)
271 void llBreakLink(int linknum);
272 //wiki: llBreakAllLinks()
273 void llBreakAllLinks();
274 //wiki: key llGetLinkKey(integer linknum)
275 string llGetLinkKey(int linknum);
276 //wiki: llGetLinkName(integer linknum)
277 string llGetLinkName(int linknum);
278 //wiki: integer llGetInventoryNumber(integer type)
279 LSL_Types.LSLInteger llGetInventoryNumber(int type);
280 //wiki: string llGetInventoryName(integer type, integer number)
281 string llGetInventoryName(int type, int number);
282 //wiki: llSetScriptState(string name, integer run)
283 void llSetScriptState(string name, int run);
284 //wiki: double llGetEnergy()
285 double llGetEnergy();
286 //wiki: llGiveInventory(key destination, string inventory)
287 void llGiveInventory(string destination, string inventory);
288 //wiki: llRemoveInventory(string item)
289 void llRemoveInventory(string item);
290 //wiki: llSetText(string text, vector color, double alpha)
291 void llSetText(string text, LSL_Types.Vector3 color, double alpha);
292 //wiki: double llWater(vector offset)
293 double llWater(LSL_Types.Vector3 offset);
294 //wiki: llPassTouches(integer pass)
295 void llPassTouches(int pass);
296 //wiki: key llRequestAgentData(key id, integer data)
297 string llRequestAgentData(string id, int data);
298 //wiki: key llRequestInventoryData(string name)
299 string llRequestInventoryData(string name);
300 //wiki: llSetDamage(double damage)
301 void llSetDamage(double damage);
302 //wiki: llTeleportAgentHome(key agent)
303 void llTeleportAgentHome(string agent);
304 //wiki: llModifyLand(integer action, integer brush)
305 void llModifyLand(int action, int brush);
306 //wiki: llCollisionSound(string impact_sound, double impact_volume)
307 void llCollisionSound(string impact_sound, double impact_volume);
308 //wiki: llCollisionSprite(string impact_sprite)
309 void llCollisionSprite(string impact_sprite);
310 //wiki: string llGetAnimation(key id)
311 string llGetAnimation(string id);
312 //wiki: llResetScript()
313 void llResetScript();
314 //wiki: llMessageLinked(integer linknum, integer num, string str, key id)
315 void llMessageLinked(int linknum, int num, string str, string id);
316 //wiki: llPushObject(key target, vector impulse, vector ang_impulse, integer local)
317 void llPushObject(string target, LSL_Types.Vector3 impulse, LSL_Types.Vector3 ang_impulse, int local);
318 //wiki: llPassCollisions(integer pass)
319 void llPassCollisions(int pass);
320 //wiki: string llGetScriptName()
321 string llGetScriptName();
322 //wiki: integer llGetNumberOfSides()
323 LSL_Types.LSLInteger llGetNumberOfSides();
324 //wiki: rotation llAxisAngle2Rot(vector axis, double angle)
325 LSL_Types.Quaternion llAxisAngle2Rot(LSL_Types.Vector3 axis, double angle);
326 //wiki: vector llRot2Axis(rotation rot)
327 LSL_Types.Vector3 llRot2Axis(LSL_Types.Quaternion rot);
328 //wiki: double llRot2Angle(rotation rot);
329 double llRot2Angle(LSL_Types.Quaternion rot);
330 //wiki: double llAcos(double val)
331 double llAcos(double val);
332 //wiki: double llAsin(double val)
333 double llAsin(double val);
334 //wiki: double llAngleBetween(rotation a, rotation b)
335 double llAngleBetween(LSL_Types.Quaternion a, LSL_Types.Quaternion b);
336 //wiki: string llGetInventoryKey(string name)
337 string llGetInventoryKey(string name);
338 //wiki: llAllowInventoryDrop(integer add)
339 void llAllowInventoryDrop(int add);
340 //wiki: vector llGetSunDirection()
341 LSL_Types.Vector3 llGetSunDirection();
342 //wiki: vector llGetTextureOffset(integer face)
343 LSL_Types.Vector3 llGetTextureOffset(int face);
344 //wiki: vector llGetTextureScale(integer side)
345 LSL_Types.Vector3 llGetTextureScale(int side);
346 //wiki: double llGetTextureRot(integer side)
347 double llGetTextureRot(int side);
348 //wiki: integer llSubStringIndex(string source, string pattern)
349 LSL_Types.LSLInteger llSubStringIndex(string source, string pattern);
350 //wiki: key llGetOwnerKey(key id)
351 string llGetOwnerKey(string id);
352 //wiki: vector llGetCenterOfMass()
353 LSL_Types.Vector3 llGetCenterOfMass();
354 //wiki: list llListSort(list src, integer stride, integer ascending)
355 LSL_Types.list llListSort(LSL_Types.list src, int stride, int ascending);
356 //integer llGetListLength(list src)
357 LSL_Types.LSLInteger llGetListLength(LSL_Types.list src);
358 //wiki: integer llList2Integer(list src, integer index)
359 LSL_Types.LSLInteger llList2Integer(LSL_Types.list src, int index);
360 //wiki: double llList2double(list src, integer index)
361 double llList2Float(LSL_Types.list src, int index);
362 //wiki: string llList2String(list src, integer index)
363 string llList2String(LSL_Types.list src, int index);
364 //wiki: key llList2Key(list src, integer index)
365 string llList2Key(LSL_Types.list src, int index);
366 //wiki: vector llList2Vector(list src, integer index)
367 LSL_Types.Vector3 llList2Vector(LSL_Types.list src, int index);
368 //wiki rotation llList2Rot(list src, integer index)
369 LSL_Types.Quaternion llList2Rot(LSL_Types.list src, int index);
370 //wiki: list llList2List(list src, integer start, integer end)
371 LSL_Types.list llList2List(LSL_Types.list src, int start, int end);
372 //wiki: llDeleteSubList(list src, integer start, integer end)
373 LSL_Types.list llDeleteSubList(LSL_Types.list src, int start, int end);
374 //wiki: integer llGetListEntryType(list src, integer index)
375 LSL_Types.LSLInteger llGetListEntryType(LSL_Types.list src, int index);
376 //wiki: string llList2CSV(list src)
377 string llList2CSV(LSL_Types.list src);
378 //wiki: list llCSV2List(string src)
379 LSL_Types.list llCSV2List(string src);
380 //wiki: list llListRandomize(list src, integer stride)
381 LSL_Types.list llListRandomize(LSL_Types.list src, int stride);
382 //wiki: list llList2ListStrided(list src, integer start, integer end, integer stride)
383 LSL_Types.list llList2ListStrided(LSL_Types.list src, int start, int end, int stride);
384 //wiki: vector llGetRegionCorner()
385 LSL_Types.Vector3 llGetRegionCorner();
386 //wiki: list llListInsertList(list dest, list src, integer start)
387 LSL_Types.list llListInsertList(LSL_Types.list dest, LSL_Types.list src, int start);
388 //wiki: integer llListFindList(list src, list test)
389 LSL_Types.LSLInteger llListFindList(LSL_Types.list src, LSL_Types.list test);
390 //wiki: string llGetObjectName()
391 string llGetObjectName();
392 //wiki: llSetObjectName(string name)
393 void llSetObjectName(string name);
394 //wiki: string llGetDate()
395 string llGetDate();
396 //wiki: integer llEdgeOfWorld(vector pos, vector dir)
397 LSL_Types.LSLInteger llEdgeOfWorld(LSL_Types.Vector3 pos, LSL_Types.Vector3 dir);
398 //wiki: integer llGetAgentInfo(key id)
399 LSL_Types.LSLInteger llGetAgentInfo(string id);
400 //wiki: llAdjustSoundVolume(double volume)
401 void llAdjustSoundVolume(double volume);
402 //wiki: llSetSoundQueueing(integer queue)
403 void llSetSoundQueueing(int queue);
404 //wiki: llSetSoundRadius(double radius)
405 void llSetSoundRadius(double radius);
406 //wiki: string llKey2Name(key id)
407 string llKey2Name(string id);
408 //wiki: llSetTextureAnim(integer mode, integer face, integer sizex, integer sizey, double start, double length, double rate)
409 void llSetTextureAnim(int mode, int face, int sizex, int sizey, double start, double length, double rate);
410 //wiki: llTriggerSoundLimited(string sound, double volume, vector top_north_east, vector bottom_south_west)
411 void llTriggerSoundLimited(string sound, double volume, LSL_Types.Vector3 top_north_east,
412 LSL_Types.Vector3 bottom_south_west);
413
414 //wiki: llEjectFromLand(key pest)
415 void llEjectFromLand(string pest);
416 LSL_Types.list llParseString2List(string str, LSL_Types.list separators, LSL_Types.list spacers);
417 //wiki: integer llOverMyLand(key id)
418 LSL_Types.LSLInteger llOverMyLand(string id);
419 //wiki: key llGetLandOwnerAt(vector pos)
420 string llGetLandOwnerAt(LSL_Types.Vector3 pos);
421 //wiki: key llGetNotecardLine(string name, integer line)
422 string llGetNotecardLine(string name, int line);
423 //wiki: vector llGetAgentSize(key id)
424 LSL_Types.Vector3 llGetAgentSize(string id);
425 //wiki: integer llSameGroup(key agent)
426 LSL_Types.LSLInteger llSameGroup(string agent);
427 //wiki: llUnSit(key id)
428 void llUnSit(string id);
429 //wiki: vector llGroundSlope(vector offset)
430 LSL_Types.Vector3 llGroundSlope(LSL_Types.Vector3 offset);
431 //wiki: vector llGroundNormal(vector offset)
432 LSL_Types.Vector3 llGroundNormal(LSL_Types.Vector3 offset);
433 //wiki: vector llGroundContour(vector offset)
434 LSL_Types.Vector3 llGroundContour(LSL_Types.Vector3 offset);
435 //wiki: integer llGetAttached()
436 LSL_Types.LSLInteger llGetAttached();
437 //wiki: integer llGetFreeMemory()
438 LSL_Types.LSLInteger llGetFreeMemory();
439 //wiki: string llGetRegionName()
440 string llGetRegionName();
441 //wiki: double llGetRegionTimeDilation()
442 double llGetRegionTimeDilation();
443 //wiki: double llGetRegionFPS()
444 double llGetRegionFPS();
445 //wiki: llParticleSystem(List<Object> rules
446 void llParticleSystem(LSL_Types.list rules);
447 //wiki: llGroundRepel(double height, integer water, double tau)
448 void llGroundRepel(double height, int water, double tau);
449 //wiki: llGiveInventoryList(string destination, string category, LSL_Types.list inventory)
450 void llGiveInventoryList(string destination, string category, LSL_Types.list inventory);
451 //wiki: llSetVehicleType(integer type)
452 void llSetVehicleType(int type);
453 //wiki: llSetVehicledoubleParam(integer param, double value)
454 void llSetVehicledoubleParam(int param, double value);
455 // wiki: llSetVehicleFloatParam(integer param, float value)
456 void llSetVehicleFloatParam(int param, float value);
457 //wiki: llSetVehicleVectorParam(integer param, vector vec)
458 void llSetVehicleVectorParam(int param, LSL_Types.Vector3 vec);
459 //wiki: llSetVehicleRotationParam(integer param, rotation rot)
460 void llSetVehicleRotationParam(int param, LSL_Types.Quaternion rot);
461 //wiki: llSetVehicleFlags(integer flags)
462 void llSetVehicleFlags(int flags);
463 //wiki: llRemoveVehicleFlags(integer flags)
464 void llRemoveVehicleFlags(int flags);
465 //wiki: llSitTarget(vector offset, rotation rot)
466 void llSitTarget(LSL_Types.Vector3 offset, LSL_Types.Quaternion rot);
467 //wiki key llAvatarOnSitTarget()
468 string llAvatarOnSitTarget();
469 //wiki: llAddToLandPassList(key avatar, double hours)
470 void llAddToLandPassList(string avatar, double hours);
471 //wiki: llSetTouchText(string text)
472 void llSetTouchText(string text);
473 //wiki: llSetSitText(string text)
474 void llSetSitText(string text);
475 //wiki: llSetCameraEyeOffset(vector offset)
476 void llSetCameraEyeOffset(LSL_Types.Vector3 offset);
477 //wiki: llSeteCameraAtOffset(vector offset)
478 void llSetCameraAtOffset(LSL_Types.Vector3 offset);
479 //
480 string llDumpList2String(LSL_Types.list src, string seperator);
481 //wiki: integer llScriptDanger(vector pos)
482 LSL_Types.LSLInteger llScriptDanger(LSL_Types.Vector3 pos);
483 //wiki: llDialog(key avatar, string message, list buttons, integer chat_channel)
484 void llDialog(string avatar, string message, LSL_Types.list buttons, int chat_channel);
485 //wiki: llVolumeDetect(integer detect)
486 void llVolumeDetect(int detect);
487 //wiki: llResetOtherScript(string name)
488 void llResetOtherScript(string name);
489 //wiki: integer llGetScriptState(string name)
490 LSL_Types.LSLInteger llGetScriptState(string name);
491 //wiki: (deprecated)
492 void llRemoteLoadScript();
493 //wiki: llSetRemoteScriptAccessPin(integer pin)
494 void llSetRemoteScriptAccessPin(int pin);
495 //wiki: llRemoteLoadScriptPin(key target, string name, integer pin, integer running, integer start_param)
496 void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param);
497 //wiki: llOpenRemoteDataChannel()
498 void llOpenRemoteDataChannel();
499 //wiki: key llSendRemoteData(key channel, string dest, integer idata, string sdata)
500 string llSendRemoteData(string channel, string dest, int idata, string sdata);
501 //wiki: llRemoteDataReply(key channel, key message_id, string sdata, integer idata)
502 void llRemoteDataReply(string channel, string message_id, string sdata, int idata);
503 //wiki: llCloseRemoteDataChannel(key channel)
504 void llCloseRemoteDataChannel(string channel);
505 //wiki: string llMD5String(string src, integer nonce)
506 string llMD5String(string src, int nonce);
507 //wiki: llSetPrimitiveParams(list rules)
508 void llSetPrimitiveParams(LSL_Types.list rules);
509 //wiki: llSetLinkPrimitiveParams(integer linknumber, list rules)
510 void llSetLinkPrimitiveParams(int linknumber, LSL_Types.list rules);
511 //wiki: string llStringToBase64(string str)
512 string llStringToBase64(string str);
513 //wiki: string llBase64ToString(string str)
514 string llBase64ToString(string str);
515 //wiki: (deprecated)
516 void llXorBase64Strings();
517 //wiki: llRemoteDataSetRegion()
518 void llRemoteDataSetRegion();
519 //wiki: double llLog10(double val)
520 double llLog10(double val);
521 //wiki: double llLog(double val)
522 double llLog(double val);
523 //wiki: list llGetAnimationList(key id)
524 LSL_Types.list llGetAnimationList(string id);
525 //wiki: llSetParcelMusicURL(string url)
526 void llSetParcelMusicURL(string url);
527 //wiki: vector llGetRootPosition()
528 LSL_Types.Vector3 llGetRootPosition();
529 //wiki: rotation llGetRootRotation()
530 LSL_Types.Quaternion llGetRootRotation();
531 //wiki: string llGetObjectDesc()
532 string llGetObjectDesc();
533 //wiki: llSetObjectDesc(string desc)
534 void llSetObjectDesc(string desc);
535 //wiki: key llGetCreator()
536 string llGetCreator();
537 //wiki: string llGetTimestamp()
538 string llGetTimestamp();
539 //wiki: llSetLinkAlpha(integer linknumber, double alpha, integer face)
540 void llSetLinkAlpha(int linknumber, double alpha, int face);
541 //wiki: integer llGetNumberOfPrims()
542 LSL_Types.LSLInteger llGetNumberOfPrims();
543 //wiki: key llGetNumberOfNotecardLines(string name)
544 string llGetNumberOfNotecardLines(string name);
545 //wiki: list llGetBoundingBox(key object)
546 LSL_Types.list llGetBoundingBox(string obj);
547 //wiki: vector llGetGeometricCenter()
548 LSL_Types.Vector3 llGetGeometricCenter();
549 //wiki: list llGetPrimitiveParams(list rules)
550 LSL_Types.list llGetPrimitiveParams(LSL_Types.list rules);
551 //wiki: string llIntegerToBase64(integer number)
552 string llIntegerToBase64(int number);
553 //wiki integer llBase64ToInteger(string str)
554 LSL_Types.LSLInteger llBase64ToInteger(string str);
555 //wiki: double llGetGMTclock()
556 double llGetGMTclock();
557 //wiki: string llGetSimulatorHostname()
558 string llGetSimulatorHostname();
559 //llSetLocalRot(rotation rot)
560 void llSetLocalRot(LSL_Types.Quaternion rot);
561 //wiki: list llParseStringKeepNulls(string src, list separators, list spacers)
562 LSL_Types.list llParseStringKeepNulls(string src, LSL_Types.list seperators, LSL_Types.list spacers);
563 //wiki: llRezAtRoot(string inventory, vector position, vector velocity, rotation rot, integer param)
564 void llRezAtRoot(string inventory, LSL_Types.Vector3 position, LSL_Types.Vector3 velocity,
565 LSL_Types.Quaternion rot, int param);
566
567 //wiki: integer llGetObjectPermMask(integer mask)
568 LSL_Types.LSLInteger llGetObjectPermMask(int mask);
569 //wiki: llSetObjectPermMask(integer mask, integer value)
570 void llSetObjectPermMask(int mask, int value);
571 //wiki integer llGetInventoryPermMask(string item, integer mask)
572 LSL_Types.LSLInteger llGetInventoryPermMask(string item, int mask);
573 //wiki: llSetInventoryPermMask(string item, integer mask, integer value)
574 void llSetInventoryPermMask(string item, int mask, int value);
575 //wiki: key llGetInventoryCreator(string item)
576 string llGetInventoryCreator(string item);
577 //wiki: llOwnerSay(string msg)
578 void llOwnerSay(string msg);
579 //wiki: key llRequestSimulatorData(string simulator, integer data)
580 string llRequestSimulatorData(string simulator, int data);
581 //wiki: llForceMouselook(integer mouselook)
582 void llForceMouselook(int mouselook);
583 //wiki: double llGetObjectMass(key id)
584 double llGetObjectMass(string id);
585 LSL_Types.list llListReplaceList(LSL_Types.list dest, LSL_Types.list src, int start, int end);
586 //wiki: llLoadURL(key avatar_id, string message, string url)
587 void llLoadURL(string avatar_id, string message, string url);
588 //wiki: llParcelMediaCommandList(list commandList)
589 void llParcelMediaCommandList(LSL_Types.list commandList);
590 void llParcelMediaQuery();
591 //wiki integer llModPow(integer a, integer b, integer c)
592 LSL_Types.LSLInteger llModPow(int a, int b, int c);
593 //wiki: integer llGetInventoryType(string name)
594 LSL_Types.LSLInteger llGetInventoryType(string name);
595 //wiki: llSetPayPrice(integer price, list quick_pay_buttons)
596 void llSetPayPrice(int price, LSL_Types.list quick_pay_buttons);
597 //wiki: vector llGetCameraPos()
598 LSL_Types.Vector3 llGetCameraPos();
599 //wiki rotation llGetCameraRot()
600 LSL_Types.Quaternion llGetCameraRot();
601 //wiki: (deprecated)
602 void llSetPrimURL();
603 //wiki: (deprecated)
604 void llRefreshPrimURL();
605 //wiki: string llEscapeURL(string url)
606 string llEscapeURL(string url);
607 //wiki: string llUnescapeURL(string url)
608 string llUnescapeURL(string url);
609 //wiki: llMapDestination(string simname, vector pos, vector look_at)
610 void llMapDestination(string simname, LSL_Types.Vector3 pos, LSL_Types.Vector3 look_at);
611 //wiki: llAddToLandBanList(key avatar, double hours)
612 void llAddToLandBanList(string avatar, double hours);
613 //wiki: llRemoveFromLandPassList(key avatar)
614 void llRemoveFromLandPassList(string avatar);
615 //wiki: llRemoveFromLandBanList(key avatar)
616 void llRemoveFromLandBanList(string avatar);
617 //wiki: llSetCameraParams(list rules)
618 void llSetCameraParams(LSL_Types.list rules);
619 //wiki: llClearCameraParams()
620 void llClearCameraParams();
621 //wiki: double llListStatistics(integer operation, list src)
622 double llListStatistics(int operation, LSL_Types.list src);
623 //wiki: integer llGetUnixTime()
624 LSL_Types.LSLInteger llGetUnixTime();
625 //wiki: integer llGetParcelFlags(vector pos)
626 LSL_Types.LSLInteger llGetParcelFlags(LSL_Types.Vector3 pos);
627 //wiki: integer llGetRegionFlags()
628 LSL_Types.LSLInteger llGetRegionFlags();
629 //wiki: string llXorBase64StringsCorrect(string str1, string str2)
630 string llXorBase64StringsCorrect(string str1, string str2);
631 string llHTTPRequest(string url, LSL_Types.list parameters, string body);
632 //wiki: llResetLandBanList()
633 void llResetLandBanList();
634 //wiki: llResetLandPassList()
635 void llResetLandPassList();
636 //wiki: integer llGetParcelPrimCount(vector pos, integer category, integer sim_wide)
637 LSL_Types.LSLInteger llGetParcelPrimCount(LSL_Types.Vector3 pos, int category, int sim_wide);
638 //wiki: list llGetParcelPrimOwners(vector pos)
639 LSL_Types.list llGetParcelPrimOwners(LSL_Types.Vector3 pos);
640 //wiki: integer llGetObjectPrimCount(key object_id)
641 LSL_Types.LSLInteger llGetObjectPrimCount(string object_id);
642 //wiki: integer llGetParcelMaxPrims(vector pos, integer sim_wide)
643 LSL_Types.LSLInteger llGetParcelMaxPrims(LSL_Types.Vector3 pos, int sim_wide);
644 //wiki: llGetParcelDetails(vector pos, list params)
645 LSL_Types.list llGetParcelDetails(LSL_Types.Vector3 pos, LSL_Types.list param);
646 //wiki: llSetLinkTexture(integer linknumber, string texture, integer face)
647 void llSetLinkTexture(int linknumber, string texture, int face);
648 //wiki: string llStringTrim(string src, int type)
649 string llStringTrim(string src, int type);
650 //wiki: LSL_Types.list llGetObjectDetails(string id, LSL_Types.list args)
651 LSL_Types.list llGetObjectDetails(string id, LSL_Types.list args);
652 }
653}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Script/IOSSL_ScriptCommands.cs b/OpenSim/Region/ScriptEngine/XEngine/Script/IOSSL_ScriptCommands.cs
deleted file mode 100644
index 82d4673..0000000
--- a/OpenSim/Region/ScriptEngine/XEngine/Script/IOSSL_ScriptCommands.cs
+++ /dev/null
@@ -1,68 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28namespace OpenSim.Region.ScriptEngine.XEngine.Script
29{
30 public interface IOSSL_ScriptCommands
31 {
32 //OpenSim functions
33 string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, int timer);
34 string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams,
35 int timer, int alpha);
36 string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams, int timer);
37 string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams,
38 int timer, int alpha);
39 double osTerrainGetHeight(int x, int y);
40 int osTerrainSetHeight(int x, int y, double val);
41 int osRegionRestart(double seconds);
42 void osRegionNotice(string msg);
43 bool osConsoleCommand(string Command);
44 void osSetParcelMediaURL(string url);
45 void osSetPrimFloatOnWater(int floatYN);
46
47 // Animation commands
48 void osAvatarPlayAnimation(string avatar, string animation);
49 void osAvatarStopAnimation(string avatar, string animation);
50
51 //texture draw functions
52 string osMovePen(string drawList, int x, int y);
53 string osDrawLine(string drawList, int startX, int startY, int endX, int endY);
54 string osDrawLine(string drawList, int endX, int endY);
55 string osDrawText(string drawList, string text);
56 string osDrawEllipse(string drawList, int width, int height);
57 string osDrawRectangle(string drawList, int width, int height);
58 string osDrawFilledRectangle(string drawList, int width, int height);
59 string osSetFontSize(string drawList, int fontSize);
60 string osSetPenSize(string drawList, int penSize);
61 string osSetPenColour(string drawList, string colour);
62 string osDrawImage(string drawList, int width, int height, string imageUrl);
63 void osSetStateEvents(int events);
64
65 double osList2Double(LSL_Types.list src, int index);
66 void osSetRegionWaterHeight(double height);
67 }
68}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Script/IScript.cs b/OpenSim/Region/ScriptEngine/XEngine/Script/IScript.cs
deleted file mode 100644
index e5d0b33..0000000
--- a/OpenSim/Region/ScriptEngine/XEngine/Script/IScript.cs
+++ /dev/null
@@ -1,46 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Reflection;
29using System;
30using System.Collections;
31using System.Collections.Generic;
32using OpenSim.Region.Environment.Interfaces;
33
34namespace OpenSim.Region.ScriptEngine.XEngine.Script
35{
36 public interface IScript
37 {
38 Type Start(ILSL_ScriptCommands lsl, IOSSL_ScriptCommands ossl);
39
40 Dictionary<string, object> GetVars();
41 void SetVars(Dictionary<string, object> vars);
42 void ResetVars();
43
44 string State { get; set; }
45 }
46}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Script/LSL_Types.cs b/OpenSim/Region/ScriptEngine/XEngine/Script/LSL_Types.cs
deleted file mode 100644
index 8bd3d73..0000000
--- a/OpenSim/Region/ScriptEngine/XEngine/Script/LSL_Types.cs
+++ /dev/null
@@ -1,1512 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Text.RegularExpressions;
31
32namespace OpenSim.Region.ScriptEngine.XEngine.Script
33{
34 [Serializable]
35 public partial class LSL_Types
36 {
37 // Types are kept is separate .dll to avoid having to add whatever .dll it is in it to script AppDomain
38
39 [Serializable]
40 public struct Vector3
41 {
42 public double x;
43 public double y;
44 public double z;
45
46 #region Constructors
47
48 public Vector3(Vector3 vector)
49 {
50 x = (float)vector.x;
51 y = (float)vector.y;
52 z = (float)vector.z;
53 }
54
55 public Vector3(double X, double Y, double Z)
56 {
57 x = X;
58 y = Y;
59 z = Z;
60 }
61
62 public Vector3(string str)
63 {
64 str = str.Replace('<', ' ');
65 str = str.Replace('>', ' ');
66 string[] tmps = str.Split(new Char[] { ',', '<', '>' });
67 if (tmps.Length < 3)
68 {
69 x=y=z=0;
70 return;
71 }
72 bool res;
73 res = Double.TryParse(tmps[0], out x);
74 res = res & Double.TryParse(tmps[1], out y);
75 res = res & Double.TryParse(tmps[2], out z);
76 }
77
78 #endregion
79
80 #region Overriders
81
82 public override string ToString()
83 {
84 string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000}>", x, y, z);
85 return s;
86 }
87
88 public static explicit operator LSLString(Vector3 vec)
89 {
90 string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000}>", vec.x, vec.y, vec.z);
91 return new LSLString(s);
92 }
93
94 public static explicit operator string(Vector3 vec)
95 {
96 string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000}>", vec.x, vec.y, vec.z);
97 return s;
98 }
99
100 public static explicit operator Vector3(string s)
101 {
102 return new Vector3(s);
103 }
104
105 public static bool operator ==(Vector3 lhs, Vector3 rhs)
106 {
107 return (lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z);
108 }
109
110 public static bool operator !=(Vector3 lhs, Vector3 rhs)
111 {
112 return !(lhs == rhs);
113 }
114
115 public override int GetHashCode()
116 {
117 return (x.GetHashCode() ^ y.GetHashCode() ^ z.GetHashCode());
118 }
119
120 public override bool Equals(object o)
121 {
122 if (!(o is Vector3)) return false;
123
124 Vector3 vector = (Vector3)o;
125
126 return (x == vector.x && x == vector.x && z == vector.z);
127 }
128
129 #endregion
130
131 #region Vector & Vector Math
132
133 // Vector-Vector Math
134 public static Vector3 operator +(Vector3 lhs, Vector3 rhs)
135 {
136 return new Vector3(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z);
137 }
138
139 public static Vector3 operator -(Vector3 lhs, Vector3 rhs)
140 {
141 return new Vector3(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z);
142 }
143
144 public static Vector3 operator *(Vector3 lhs, Vector3 rhs)
145 {
146 return new Vector3(lhs.x * rhs.x, lhs.y * rhs.y, lhs.z * rhs.z);
147 }
148
149 public static Vector3 operator %(Vector3 v1, Vector3 v2)
150 {
151 //Cross product
152 Vector3 tv;
153 tv.x = (v1.y * v2.z) - (v1.z * v2.y);
154 tv.y = (v1.z * v2.x) - (v1.x * v2.z);
155 tv.z = (v1.x * v2.y) - (v1.y * v2.x);
156 return tv;
157 }
158
159 #endregion
160
161 #region Vector & Float Math
162
163 // Vector-Float and Float-Vector Math
164 public static Vector3 operator *(Vector3 vec, float val)
165 {
166 return new Vector3(vec.x * val, vec.y * val, vec.z * val);
167 }
168
169 public static Vector3 operator *(float val, Vector3 vec)
170 {
171 return new Vector3(vec.x * val, vec.y * val, vec.z * val);
172 }
173
174 public static Vector3 operator /(Vector3 v, float f)
175 {
176 v.x = v.x / f;
177 v.y = v.y / f;
178 v.z = v.z / f;
179 return v;
180 }
181
182 #endregion
183
184 #region Vector & Double Math
185
186 public static Vector3 operator *(Vector3 vec, double val)
187 {
188 return new Vector3(vec.x * val, vec.y * val, vec.z * val);
189 }
190
191 public static Vector3 operator *(double val, Vector3 vec)
192 {
193 return new Vector3(vec.x * val, vec.y * val, vec.z * val);
194 }
195
196 public static Vector3 operator /(Vector3 v, double f)
197 {
198 v.x = v.x / f;
199 v.y = v.y / f;
200 v.z = v.z / f;
201 return v;
202 }
203
204 #endregion
205
206 #region Vector & Rotation Math
207
208 // Vector-Rotation Math
209 public static Vector3 operator *(Vector3 v, Quaternion r)
210 {
211 Quaternion vq = new Quaternion(v.x, v.y, v.z, 0);
212 Quaternion nq = new Quaternion(-r.x, -r.y, -r.z, r.s);
213
214 // adapted for operator * computing "b * a"
215 Quaternion result = nq * (vq * r);
216
217 return new Vector3(result.x, result.y, result.z);
218 }
219
220 public static Vector3 operator /(Vector3 v, Quaternion r)
221 {
222 r.s = -r.s;
223 return v * r;
224 }
225
226 #endregion
227
228 #region Static Helper Functions
229
230 public static double Dot(Vector3 v1, Vector3 v2)
231 {
232 return (v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z);
233 }
234
235 public static Vector3 Cross(Vector3 v1, Vector3 v2)
236 {
237 return new Vector3
238 (
239 v1.y * v2.z - v1.z * v2.y,
240 v1.z * v2.x - v1.x * v2.z,
241 v1.x * v2.y - v1.y * v2.x
242 );
243 }
244
245 public static double Mag(Vector3 v)
246 {
247 return Math.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
248 }
249
250 public static Vector3 Norm(Vector3 vector)
251 {
252 double mag = Mag(vector);
253 return new Vector3(vector.x / mag, vector.y / mag, vector.z / mag);
254 }
255
256 #endregion
257 }
258
259 [Serializable]
260 public struct Quaternion
261 {
262 public double x;
263 public double y;
264 public double z;
265 public double s;
266
267 #region Constructors
268
269 public Quaternion(Quaternion Quat)
270 {
271 x = (float)Quat.x;
272 y = (float)Quat.y;
273 z = (float)Quat.z;
274 s = (float)Quat.s;
275 if (x == 0 && y == 0 && z == 0 && s == 0)
276 s = 1;
277 }
278
279 public Quaternion(double X, double Y, double Z, double S)
280 {
281 x = X;
282 y = Y;
283 z = Z;
284 s = S;
285 if (x == 0 && y == 0 && z == 0 && s == 0)
286 s = 1;
287 }
288
289 public Quaternion(string str)
290 {
291 str = str.Replace('<', ' ');
292 str = str.Replace('>', ' ');
293 string[] tmps = str.Split(new Char[] { ',', '<', '>' });
294 if (tmps.Length < 4)
295 {
296 x=y=z=s=0;
297 return;
298 }
299 bool res;
300 res = Double.TryParse(tmps[0], out x);
301 res = res & Double.TryParse(tmps[1], out y);
302 res = res & Double.TryParse(tmps[2], out z);
303 res = res & Double.TryParse(tmps[3], out s);
304 if (x == 0 && y == 0 && z == 0 && s == 0)
305 s = 1;
306 }
307
308 #endregion
309
310 #region Overriders
311
312 public override int GetHashCode()
313 {
314 return (x.GetHashCode() ^ y.GetHashCode() ^ z.GetHashCode() ^ s.GetHashCode());
315 }
316
317 public override bool Equals(object o)
318 {
319 if (!(o is Quaternion)) return false;
320
321 Quaternion quaternion = (Quaternion)o;
322
323 return x == quaternion.x && y == quaternion.y && z == quaternion.z && s == quaternion.s;
324 }
325
326 public override string ToString()
327 {
328 string st=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", x, y, z, s);
329 return st;
330 }
331
332 public static explicit operator string(Quaternion r)
333 {
334 string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", r.x, r.y, r.z, r.s);
335 return s;
336 }
337
338 public static explicit operator LSLString(Quaternion r)
339 {
340 string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", r.x, r.y, r.z, r.s);
341 return new LSLString(s);
342 }
343
344 public static explicit operator Quaternion(string s)
345 {
346 return new Quaternion(s);
347 }
348
349 public static bool operator ==(Quaternion lhs, Quaternion rhs)
350 {
351 // Return true if the fields match:
352 return lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z && lhs.s == rhs.s;
353 }
354
355 public static bool operator !=(Quaternion lhs, Quaternion rhs)
356 {
357 return !(lhs == rhs);
358 }
359
360 #endregion
361
362 public static Quaternion operator +(Quaternion a, Quaternion b)
363 {
364 return new Quaternion(a.x + b.x, a.y + b.y, a.z + b.z, a.s + b.s);
365 }
366
367 public static Quaternion operator /(Quaternion a, Quaternion b)
368 {
369 b.s = -b.s;
370 return a * b;
371 }
372
373 public static Quaternion operator -(Quaternion a, Quaternion b)
374 {
375 return new Quaternion(a.x - b.x, a.y - b.y, a.z - b.z, a.s - b.s);
376 }
377
378 // using the equations below, we need to do "b * a" to be compatible with LSL
379 public static Quaternion operator *(Quaternion b, Quaternion a)
380 {
381 Quaternion c;
382 c.x = a.s * b.x + a.x * b.s + a.y * b.z - a.z * b.y;
383 c.y = a.s * b.y + a.y * b.s + a.z * b.x - a.x * b.z;
384 c.z = a.s * b.z + a.z * b.s + a.x * b.y - a.y * b.x;
385 c.s = a.s * b.s - a.x * b.x - a.y * b.y - a.z * b.z;
386 return c;
387 }
388 }
389
390 [Serializable]
391 public class list
392 {
393 private object[] m_data;
394
395 public list(params object[] args)
396 {
397 m_data = new object[args.Length];
398 m_data = args;
399 }
400
401 public int Length
402 {
403 get {
404 if (m_data == null)
405 m_data=new Object[0];
406 return m_data.Length;
407 }
408 }
409
410 public object[] Data
411 {
412 get {
413 if (m_data == null)
414 m_data=new Object[0];
415 return m_data;
416 }
417 }
418
419 public static list operator +(list a, list b)
420 {
421 object[] tmp;
422 tmp = new object[a.Length + b.Length];
423 a.Data.CopyTo(tmp, 0);
424 b.Data.CopyTo(tmp, a.Length);
425 return new list(tmp);
426 }
427
428 private void ExtendAndAdd(object o)
429 {
430 Array.Resize(ref m_data, Length + 1);
431 m_data.SetValue(o, Length - 1);
432 }
433
434 public static list operator +(list a, string s)
435 {
436 a.ExtendAndAdd(s);
437 return a;
438 }
439
440 public static list operator +(list a, int i)
441 {
442 a.ExtendAndAdd(i);
443 return a;
444 }
445
446 public static list operator +(list a, double d)
447 {
448 a.ExtendAndAdd(d);
449 return a;
450 }
451
452 public void Add(object o)
453 {
454 object[] tmp;
455 tmp = new object[m_data.Length + 1];
456 m_data.CopyTo(tmp, 0);
457 tmp[m_data.Length] = o;
458 m_data = tmp;
459 }
460
461 public bool Contains(object o)
462 {
463 bool ret = false;
464 foreach (object i in Data)
465 {
466 if (i == o)
467 {
468 ret = true;
469 break;
470 }
471 }
472 return ret;
473 }
474
475 public list DeleteSublist(int start, int end)
476 {
477 // Not an easy one
478 // If start <= end, remove that part
479 // if either is negative, count from the end of the array
480 // if the resulting start > end, remove all BUT that part
481
482 Object[] ret;
483
484 if (start < 0)
485 start=m_data.Length-start;
486
487 if (start < 0)
488 start=0;
489
490 if (end < 0)
491 end=m_data.Length-end;
492 if (end < 0)
493 end=0;
494
495 if (start > end)
496 {
497 if (end >= m_data.Length)
498 return new list(new Object[0]);
499
500 if (start >= m_data.Length)
501 start=m_data.Length-1;
502
503 return GetSublist(end, start);
504 }
505
506 // start >= 0 && end >= 0 here
507 if (start >= m_data.Length)
508 {
509 ret=new Object[m_data.Length];
510 Array.Copy(m_data, 0, ret, 0, m_data.Length);
511
512 return new list(ret);
513 }
514
515 if (end >= m_data.Length)
516 end=m_data.Length-1;
517
518 // now, this makes the math easier
519 int remove=end+1-start;
520
521 ret=new Object[m_data.Length-remove];
522 if (ret.Length == 0)
523 return new list(ret);
524
525 int src;
526 int dest=0;
527
528 for (src = 0; src < m_data.Length; src++)
529 {
530 if (src < start || src > end)
531 ret[dest++]=m_data[src];
532 }
533
534 return new list(ret);
535 }
536
537 public list GetSublist(int start, int end)
538 {
539
540 object[] ret;
541
542 // Take care of neg start or end's
543 // NOTE that either index may still be negative after
544 // adding the length, so we must take additional
545 // measures to protect against this. Note also that
546 // after normalisation the negative indices are no
547 // longer relative to the end of the list.
548
549 if (start < 0)
550 {
551 start = m_data.Length + start;
552 }
553
554 if (end < 0)
555 {
556 end = m_data.Length + end;
557 }
558
559 // The conventional case is start <= end
560 // NOTE that the case of an empty list is
561 // dealt with by the initial test. Start
562 // less than end is taken to be the most
563 // common case.
564
565 if (start <= end)
566 {
567
568 // Start sublist beyond length
569 // Also deals with start AND end still negative
570 if (start >= m_data.Length || end < 0)
571 {
572 return new list();
573 }
574
575 // Sublist extends beyond the end of the supplied list
576 if (end >= m_data.Length)
577 {
578 end = m_data.Length - 1;
579 }
580
581 // Sublist still starts before the beginning of the list
582 if (start < 0)
583 {
584 start = 0;
585 }
586
587 ret = new object[end - start + 1];
588
589 Array.Copy(m_data, start, ret, 0, end - start + 1);
590
591 return new list(ret);
592
593 }
594
595 // Deal with the segmented case: 0->end + start->EOL
596
597 else
598 {
599
600 list result = null;
601
602 // If end is negative, then prefix list is empty
603 if (end < 0)
604 {
605 result = new list();
606 // If start is still negative, then the whole of
607 // the existing list is returned. This case is
608 // only admitted if end is also still negative.
609 if (start < 0)
610 {
611 return this;
612 }
613
614 }
615 else
616 {
617 result = GetSublist(0,end);
618 }
619
620 // If start is outside of list, then just return
621 // the prefix, whatever it is.
622 if (start >= m_data.Length)
623 {
624 return result;
625 }
626
627 return result + GetSublist(start, Data.Length);
628
629 }
630 }
631
632 public list Sort(int stride, int ascending)
633 {
634 if (Data.Length == 0)
635 return new list(); // Don't even bother
636
637 string[] keys;
638
639 if (stride == 1) // The simple case
640 {
641 Object[] ret=new Object[Data.Length];
642
643 Array.Copy(Data, 0, ret, 0, Data.Length);
644
645 keys=new string[Data.Length];
646
647 for (int k = 0; k < Data.Length; k++)
648 keys[k] = Data[k].ToString();
649
650 Array.Sort(keys, ret);
651
652 if (ascending == 0)
653 Array.Reverse(ret);
654 return new list(ret);
655 }
656
657 int src=0;
658
659 int len=(Data.Length+stride-1)/stride;
660
661 keys=new string[len];
662 Object[][] vals=new Object[len][];
663
664 int i;
665
666 while (src < Data.Length)
667 {
668 Object[] o=new Object[stride];
669
670 for (i = 0; i < stride; i++)
671 {
672 if (src < Data.Length)
673 o[i]=Data[src++];
674 else
675 {
676 o[i]=new Object();
677 src++;
678 }
679 }
680
681 int idx=src/stride-1;
682 keys[idx]=o[0].ToString();
683 vals[idx]=o;
684 }
685
686 Array.Sort(keys, vals);
687 if (ascending == 0)
688 {
689 Array.Reverse(vals);
690 }
691
692 Object[] sorted=new Object[stride*vals.Length];
693
694 for (i = 0; i < vals.Length; i++)
695 for (int j = 0; j < stride; j++)
696 sorted[i*stride+j] = vals[i][j];
697
698 return new list(sorted);
699 }
700
701 #region CSV Methods
702
703 public static list FromCSV(string csv)
704 {
705 return new list(csv.Split(','));
706 }
707
708 public string ToCSV()
709 {
710 string ret = "";
711 foreach (object o in this.Data)
712 {
713 if (ret == "")
714 {
715 ret = o.ToString();
716 }
717 else
718 {
719 ret = ret + ", " + o.ToString();
720 }
721 }
722 return ret;
723 }
724
725 private string ToSoup()
726 {
727 string output;
728 output = String.Empty;
729 if (m_data.Length == 0)
730 {
731 return String.Empty;
732 }
733 foreach (object o in m_data)
734 {
735 output = output + o.ToString();
736 }
737 return output;
738 }
739
740 public static explicit operator String(list l)
741 {
742 return l.ToSoup();
743 }
744
745 public static explicit operator LSLString(list l)
746 {
747 return new LSLString(l.ToSoup());
748 }
749
750 public override string ToString()
751 {
752 return ToSoup();
753 }
754
755 #endregion
756
757 #region Statistic Methods
758
759 public double Min()
760 {
761 double minimum = double.PositiveInfinity;
762 double entry;
763 for (int i = 0; i < Data.Length; i++)
764 {
765 if (double.TryParse(Data[i].ToString(), out entry))
766 {
767 if (entry < minimum) minimum = entry;
768 }
769 }
770 return minimum;
771 }
772
773 public double Max()
774 {
775 double maximum = double.NegativeInfinity;
776 double entry;
777 for (int i = 0; i < Data.Length; i++)
778 {
779 if (double.TryParse(Data[i].ToString(), out entry))
780 {
781 if (entry > maximum) maximum = entry;
782 }
783 }
784 return maximum;
785 }
786
787 public double Range()
788 {
789 return (this.Max() / this.Min());
790 }
791
792 public int NumericLength()
793 {
794 int count = 0;
795 double entry;
796 for (int i = 0; i < Data.Length; i++)
797 {
798 if (double.TryParse(Data[i].ToString(), out entry))
799 {
800 count++;
801 }
802 }
803 return count;
804 }
805
806 public static list ToDoubleList(list src)
807 {
808 list ret = new list();
809 double entry;
810 for (int i = 0; i < src.Data.Length - 1; i++)
811 {
812 if (double.TryParse(src.Data[i].ToString(), out entry))
813 {
814 ret.Add(entry);
815 }
816 }
817 return ret;
818 }
819
820 public double Sum()
821 {
822 double sum = 0;
823 double entry;
824 for (int i = 0; i < Data.Length; i++)
825 {
826 if (double.TryParse(Data[i].ToString(), out entry))
827 {
828 sum = sum + entry;
829 }
830 }
831 return sum;
832 }
833
834 public double SumSqrs()
835 {
836 double sum = 0;
837 double entry;
838 for (int i = 0; i < Data.Length; i++)
839 {
840 if (double.TryParse(Data[i].ToString(), out entry))
841 {
842 sum = sum + Math.Pow(entry, 2);
843 }
844 }
845 return sum;
846 }
847
848 public double Mean()
849 {
850 return (this.Sum() / this.NumericLength());
851 }
852
853 public void NumericSort()
854 {
855 IComparer Numeric = new NumericComparer();
856 Array.Sort(Data, Numeric);
857 }
858
859 public void AlphaSort()
860 {
861 IComparer Alpha = new AlphaCompare();
862 Array.Sort(Data, Alpha);
863 }
864
865 public double Median()
866 {
867 return Qi(0.5);
868 }
869
870 public double GeometricMean()
871 {
872 double ret = 1.0;
873 list nums = ToDoubleList(this);
874 for (int i = 0; i < nums.Data.Length; i++)
875 {
876 ret *= (double)nums.Data[i];
877 }
878 return Math.Exp(Math.Log(ret) / (double)nums.Data.Length);
879 }
880
881 public double HarmonicMean()
882 {
883 double ret = 0.0;
884 list nums = ToDoubleList(this);
885 for (int i = 0; i < nums.Data.Length; i++)
886 {
887 ret += 1.0 / (double)nums.Data[i];
888 }
889 return ((double)nums.Data.Length / ret);
890 }
891
892 public double Variance()
893 {
894 double s = 0;
895 list num = ToDoubleList(this);
896 for (int i = 0; i < num.Data.Length; i++)
897 {
898 s += Math.Pow((double)num.Data[i], 2);
899 }
900 return (s - num.Data.Length * Math.Pow(num.Mean(), 2)) / (num.Data.Length - 1);
901 }
902
903 public double StdDev()
904 {
905 return Math.Sqrt(this.Variance());
906 }
907
908 public double Qi(double i)
909 {
910 list j = this;
911 j.NumericSort();
912
913 if (Math.Ceiling(this.Length * i) == this.Length * i)
914 {
915 return (double)((double)j.Data[(int)(this.Length * i - 1)] + (double)j.Data[(int)(this.Length * i)]) / 2;
916 }
917 else
918 {
919 return (double)j.Data[((int)(Math.Ceiling(this.Length * i))) - 1];
920 }
921 }
922
923 #endregion
924
925 public string ToPrettyString()
926 {
927 string output;
928 if (m_data.Length == 0)
929 {
930 return "[]";
931 }
932 output = "[";
933 foreach (object o in m_data)
934 {
935 if (o is String)
936 {
937 output = output + "\"" + o + "\", ";
938 }
939 else
940 {
941 output = output + o.ToString() + ", ";
942 }
943 }
944 output = output.Substring(0, output.Length - 2);
945 output = output + "]";
946 return output;
947 }
948
949 public class AlphaCompare : IComparer
950 {
951 int IComparer.Compare(object x, object y)
952 {
953 return string.Compare(x.ToString(), y.ToString());
954 }
955 }
956
957 public class NumericComparer : IComparer
958 {
959 int IComparer.Compare(object x, object y)
960 {
961 double a;
962 double b;
963 if (!double.TryParse(x.ToString(), out a))
964 {
965 a = 0.0;
966 }
967 if (!double.TryParse(y.ToString(), out b))
968 {
969 b = 0.0;
970 }
971 if (a < b)
972 {
973 return -1;
974 }
975 else if (a == b)
976 {
977 return 0;
978 }
979 else
980 {
981 return 1;
982 }
983 }
984 }
985
986 }
987
988 //
989 // BELOW IS WORK IN PROGRESS... IT WILL CHANGE, SO DON'T USE YET! :)
990 //
991
992 public struct StringTest
993 {
994 // Our own little string
995 internal string actualString;
996 public static implicit operator bool(StringTest mString)
997 {
998 if (mString.actualString.Length == 0)
999 return true;
1000 return false;
1001 }
1002 public override string ToString()
1003 {
1004 return actualString;
1005 }
1006
1007 }
1008
1009 [Serializable]
1010 public struct key
1011 {
1012 public string value;
1013
1014 #region Constructors
1015 public key(string s)
1016 {
1017 value = s;
1018 }
1019
1020 #endregion
1021
1022 #region Methods
1023
1024 static public bool Parse2Key(string s)
1025 {
1026 Regex isuuid = new Regex(@"^[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}$", RegexOptions.Compiled);
1027 if (isuuid.IsMatch(s))
1028 {
1029 return true;
1030 }
1031 else
1032 {
1033 return false;
1034 }
1035 }
1036
1037 #endregion
1038
1039 #region Operators
1040
1041 static public implicit operator Boolean(key k)
1042 {
1043 if (k.value.Length == 0)
1044 {
1045 return false;
1046 }
1047
1048 if (k.value == "00000000-0000-0000-0000-000000000000")
1049 {
1050 return false;
1051 }
1052 Regex isuuid = new Regex(@"^[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}$", RegexOptions.Compiled);
1053 if (isuuid.IsMatch(k.value))
1054 {
1055 return true;
1056 }
1057 else
1058 {
1059 return false;
1060 }
1061 }
1062
1063 static public implicit operator key(string s)
1064 {
1065 return new key(s);
1066 }
1067
1068 static public implicit operator String(key k)
1069 {
1070 return k.value;
1071 }
1072
1073 public static bool operator ==(key k1, key k2)
1074 {
1075 return k1.value == k2.value;
1076 }
1077 public static bool operator !=(key k1, key k2)
1078 {
1079 return k1.value != k2.value;
1080 }
1081
1082 #endregion
1083
1084 #region Overriders
1085
1086 public override bool Equals(object o)
1087 {
1088 return o.ToString() == value;
1089 }
1090
1091 public override int GetHashCode()
1092 {
1093 return value.GetHashCode();
1094 }
1095
1096 #endregion
1097 }
1098
1099 [Serializable]
1100 public struct LSLString
1101 {
1102 public string m_string;
1103 #region Constructors
1104 public LSLString(string s)
1105 {
1106 m_string = s;
1107 }
1108
1109 public LSLString(int i)
1110 {
1111 m_string=i.ToString();
1112 }
1113
1114 public LSLString(double d)
1115 {
1116 string s=String.Format("{0:0.000000}", d);
1117 m_string=s;
1118 }
1119
1120 public LSLString(LSLFloat f)
1121 {
1122 string s=String.Format("{0:0.000000}", f.value);
1123 m_string=s;
1124 }
1125
1126 #endregion
1127
1128 #region Operators
1129 static public implicit operator Boolean(LSLString s)
1130 {
1131 if (s.m_string.Length == 0)
1132 {
1133 return false;
1134 }
1135 else
1136 {
1137 return true;
1138 }
1139 }
1140
1141
1142
1143 static public implicit operator String(LSLString s)
1144 {
1145 return s.m_string;
1146 }
1147
1148 static public implicit operator LSLString(string s)
1149 {
1150 return new LSLString(s);
1151 }
1152
1153 public static string ToString(LSLString s)
1154 {
1155 return s.m_string;
1156 }
1157
1158 public override string ToString()
1159 {
1160 return m_string;
1161 }
1162
1163 public static bool operator ==(LSLString s1, string s2)
1164 {
1165 return s1.m_string == s2;
1166 }
1167
1168 public static bool operator !=(LSLString s1, string s2)
1169 {
1170 return s1.m_string != s2;
1171 }
1172
1173 public static explicit operator double(LSLString s)
1174 {
1175 return Convert.ToDouble(s.m_string);
1176 }
1177
1178 public static explicit operator LSLInteger(LSLString s)
1179 {
1180 return new LSLInteger(Convert.ToInt32(s.m_string));
1181 }
1182
1183 public static explicit operator LSLString(int i)
1184 {
1185 return new LSLString(i);
1186 }
1187
1188 public static explicit operator LSLString(double d)
1189 {
1190 return new LSLString(d);
1191 }
1192
1193 public static explicit operator LSLString(LSLFloat f)
1194 {
1195 return new LSLString(f);
1196 }
1197
1198 public static implicit operator Vector3(LSLString s)
1199 {
1200 return new Vector3(s.m_string);
1201 }
1202
1203 #endregion
1204
1205 #region Overriders
1206 public override bool Equals(object o)
1207 {
1208 return m_string == o.ToString();
1209 }
1210
1211 public override int GetHashCode()
1212 {
1213 return m_string.GetHashCode();
1214 }
1215
1216 #endregion
1217
1218 #region " Standard string functions "
1219 //Clone,CompareTo,Contains
1220 //CopyTo,EndsWith,Equals,GetEnumerator,GetHashCode,GetType,GetTypeCode
1221 //IndexOf,IndexOfAny,Insert,IsNormalized,LastIndexOf,LastIndexOfAny
1222 //Length,Normalize,PadLeft,PadRight,Remove,Replace,Split,StartsWith,Substring,ToCharArray,ToLowerInvariant
1223 //ToString,ToUpper,ToUpperInvariant,Trim,TrimEnd,TrimStart
1224 public bool Contains(string value) { return m_string.Contains(value); }
1225 public int IndexOf(string value) { return m_string.IndexOf(value); }
1226 public int Length { get { return m_string.Length; } }
1227
1228
1229 #endregion
1230 }
1231
1232 [Serializable]
1233 public struct LSLInteger
1234 {
1235 public int value;
1236
1237 #region Constructors
1238 public LSLInteger(int i)
1239 {
1240 value = i;
1241 }
1242
1243 public LSLInteger(double d)
1244 {
1245 value = (int)d;
1246 }
1247
1248 public LSLInteger(Object o)
1249 {
1250 if (!(o is Int32))
1251 value = 0;
1252 else
1253 value = (int)o;
1254 }
1255
1256 public LSLInteger(string s)
1257 {
1258 value = int.Parse(s);
1259 }
1260
1261 #endregion
1262
1263 #region Operators
1264
1265 static public implicit operator int(LSLInteger i)
1266 {
1267 return i.value;
1268 }
1269
1270 static public implicit operator uint(LSLInteger i)
1271 {
1272 return (uint)i.value;
1273 }
1274
1275 static public explicit operator LSLString(LSLInteger i)
1276 {
1277 return new LSLString(i.ToString());
1278 }
1279
1280 static public explicit operator string(LSLInteger i)
1281 {
1282 return i.ToString();
1283 }
1284
1285 static public implicit operator Boolean(LSLInteger i)
1286 {
1287 if (i.value == 0)
1288 {
1289 return false;
1290 }
1291 else
1292 {
1293 return true;
1294 }
1295 }
1296
1297 static public implicit operator LSLInteger(int i)
1298 {
1299 return new LSLInteger(i);
1300 }
1301
1302 static public explicit operator LSLInteger(string s)
1303 {
1304 return new LSLInteger(int.Parse(s));
1305 }
1306
1307 static public implicit operator LSLInteger(double d)
1308 {
1309 return new LSLInteger(d);
1310 }
1311
1312 static public bool operator ==(LSLInteger i1, LSLInteger i2)
1313 {
1314 bool ret = i1.value == i2.value;
1315 return ret;
1316 }
1317
1318 static public bool operator !=(LSLInteger i1, LSLInteger i2)
1319 {
1320 bool ret = i1.value != i2.value;
1321 return ret;
1322 }
1323
1324 static public LSLInteger operator &(LSLInteger i1, LSLInteger i2)
1325 {
1326 int ret = i1.value & i2.value;
1327 return ret;
1328 }
1329
1330 public static LSLInteger operator ++(LSLInteger i)
1331 {
1332 i.value++;
1333 return i;
1334 }
1335
1336
1337 public static LSLInteger operator --(LSLInteger i)
1338 {
1339 i.value--;
1340 return i;
1341 }
1342
1343 static public implicit operator System.Double(LSLInteger i)
1344 {
1345 return (double)i.value;
1346 }
1347
1348 static public implicit operator LSLFloat(LSLInteger i)
1349 {
1350 return new LSLFloat((double)i.value);
1351 }
1352
1353 public static bool operator true(LSLInteger i)
1354 {
1355 return i.value != 0;
1356 }
1357
1358 public static bool operator false(LSLInteger i)
1359 {
1360 return i.value == 0;
1361 }
1362
1363 #endregion
1364
1365 #region Overriders
1366
1367 public override string ToString()
1368 {
1369 return this.value.ToString();
1370 }
1371
1372 public override bool Equals(object o)
1373 {
1374 if (o is Int32)
1375 {
1376 return value == (Int32)o;
1377 }
1378 if (o is LSLInteger)
1379 {
1380 return value == ((LSLInteger)o).value;
1381 }
1382 return false;
1383 }
1384
1385 public override int GetHashCode()
1386 {
1387 return value.GetHashCode();
1388 }
1389
1390 #endregion
1391 }
1392
1393 [Serializable]
1394 public struct LSLFloat
1395 {
1396 public double value;
1397
1398 #region Constructors
1399
1400 public LSLFloat(int i)
1401 {
1402 value = (double)i;
1403 }
1404
1405 public LSLFloat(double d)
1406 {
1407 value = d;
1408 }
1409
1410 public LSLFloat(string s)
1411 {
1412 value = double.Parse(s);
1413 }
1414
1415 public LSLFloat(Object o)
1416 {
1417 if (!((o is double) || (o is float)))
1418 {
1419 value = 0.0;
1420 return;
1421 }
1422
1423 value = (double)o;
1424 }
1425
1426 #endregion
1427
1428 #region Operators
1429
1430 static public implicit operator int(LSLFloat f)
1431 {
1432 return (int)f.value;
1433 }
1434
1435 static public implicit operator uint(LSLFloat f)
1436 {
1437 return (uint) Math.Abs(f.value);
1438 }
1439
1440 static public implicit operator Boolean(LSLFloat f)
1441 {
1442 if (f.value == 0.0)
1443 {
1444 return false;
1445 }
1446 else
1447 {
1448 return true;
1449 }
1450 }
1451
1452 static public implicit operator LSLFloat(int i)
1453 {
1454 return new LSLFloat(i);
1455 }
1456
1457 static public implicit operator LSLFloat(string s)
1458 {
1459 return new LSLFloat(double.Parse(s));
1460 }
1461
1462 static public implicit operator LSLFloat(double d)
1463 {
1464 return new LSLFloat(d);
1465 }
1466
1467 static public bool operator ==(LSLFloat f1, LSLFloat f2)
1468 {
1469 return f1.value == f2.value;
1470 }
1471
1472 static public bool operator !=(LSLFloat f1, LSLFloat f2)
1473 {
1474 return f1.value != f2.value;
1475 }
1476
1477 static public LSLFloat operator ++(LSLFloat f)
1478 {
1479 f.value++;
1480 return f;
1481 }
1482
1483 static public LSLFloat operator --(LSLFloat f)
1484 {
1485 f.value--;
1486 return f;
1487 }
1488
1489 static public implicit operator System.Double(LSLFloat f)
1490 {
1491 return f.value;
1492 }
1493
1494 static public explicit operator LSLString(LSLFloat f)
1495 {
1496 string v = String.Format("{0:0.000000}", f.value);
1497 return new LSLString(v);
1498 }
1499
1500 #endregion
1501
1502 #region Overriders
1503
1504 public override string ToString()
1505 {
1506 return String.Format("{0:0.000000}", this.value);
1507 }
1508
1509 #endregion
1510 }
1511 }
1512}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 0b0ff3d..709e3ee 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -14,11 +14,15 @@ using OpenSim.Framework;
14using OpenSim.Region.Environment; 14using OpenSim.Region.Environment;
15using OpenSim.Region.Environment.Scenes; 15using OpenSim.Region.Environment.Scenes;
16using OpenSim.Region.Environment.Interfaces; 16using OpenSim.Region.Environment.Interfaces;
17using OpenSim.Region.ScriptEngine.XEngine.Script; 17using OpenSim.Region.ScriptEngine.Shared;
18using OpenSim.Region.ScriptEngine.Shared.Api;
19using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
20using OpenSim.Region.ScriptEngine.Shared.CodeTools;
21using OpenSim.Region.ScriptEngine.Interfaces;
18 22
19namespace OpenSim.Region.ScriptEngine.XEngine 23namespace OpenSim.Region.ScriptEngine.XEngine
20{ 24{
21 public class XEngine : IRegionModule 25 public class XEngine : IRegionModule, IScriptEngine
22 { 26 {
23 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 27 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
24 28
@@ -30,10 +34,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
30 private EventManager m_EventManager; 34 private EventManager m_EventManager;
31 private int m_EventLimit; 35 private int m_EventLimit;
32 private bool m_KillTimedOutScripts; 36 private bool m_KillTimedOutScripts;
37 public AsyncCommandManager m_AsyncCommands;
33 38
34 private static List<XEngine> m_ScriptEngines = 39 private static List<XEngine> m_ScriptEngines =
35 new List<XEngine>(); 40 new List<XEngine>();
36 public AsyncCommandManager m_ASYNCLSLCommandManager;
37 41
38 // Maps the local id to the script inventory items in it 42 // Maps the local id to the script inventory items in it
39 43
@@ -87,11 +91,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine
87 string Script; 91 string Script;
88 } 92 }
89 93
90 public IConfig ScriptConfigSource 94 public IConfig Config
91 { 95 {
92 get { return m_ScriptConfig; } 96 get { return m_ScriptConfig; }
93 } 97 }
94 98
99 public Object AsyncCommands
100 {
101 get { return (Object)m_AsyncCommands; }
102 }
103
95 // 104 //
96 // IRegionModule functions 105 // IRegionModule functions
97 // 106 //
@@ -155,7 +164,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
155 } 164 }
156 165
157 m_EventManager = new EventManager(this); 166 m_EventManager = new EventManager(this);
158 m_ASYNCLSLCommandManager = new AsyncCommandManager(this);
159 167
160 StartEngine(minThreads, maxThreads, idleTimeout, prio, 168 StartEngine(minThreads, maxThreads, idleTimeout, prio,
161 maxScriptQueue, stackSize); 169 maxScriptQueue, stackSize);
@@ -166,6 +174,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
166 m_Scene.EventManager.OnRemoveScript += OnRemoveScript; 174 m_Scene.EventManager.OnRemoveScript += OnRemoveScript;
167 m_Scene.EventManager.OnScriptReset += OnScriptReset; 175 m_Scene.EventManager.OnScriptReset += OnScriptReset;
168 176
177 m_AsyncCommands = new AsyncCommandManager(this);
178
169 if (sleepTime > 0) 179 if (sleepTime > 0)
170 { 180 {
171 m_ThreadPool.QueueWorkItem(new WorkItemCallback( 181 m_ThreadPool.QueueWorkItem(new WorkItemCallback(
@@ -418,7 +428,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
418 if (!m_Scripts.ContainsKey(itemID)) 428 if (!m_Scripts.ContainsKey(itemID))
419 return; 429 return;
420 430
421 m_ASYNCLSLCommandManager.RemoveScript(localID, itemID); 431 m_AsyncCommands.RemoveScript(localID, itemID);
422 432
423 XScriptInstance instance=m_Scripts[itemID]; 433 XScriptInstance instance=m_Scripts[itemID];
424 m_Scripts.Remove(itemID); 434 m_Scripts.Remove(itemID);
@@ -552,7 +562,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
552 // 562 //
553 // Post event to an entire prim 563 // Post event to an entire prim
554 // 564 //
555 public bool PostObjectEvent(uint localID, XEventParams p) 565 public bool PostObjectEvent(uint localID, EventParams p)
556 { 566 {
557 bool result = false; 567 bool result = false;
558 568
@@ -577,7 +587,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
577 // 587 //
578 // Post an event to a single script 588 // Post an event to a single script
579 // 589 //
580 public bool PostScriptEvent(LLUUID itemID, XEventParams p) 590 public bool PostScriptEvent(LLUUID itemID, EventParams p)
581 { 591 {
582 if (m_Scripts.ContainsKey(itemID)) 592 if (m_Scripts.ContainsKey(itemID))
583 { 593 {
@@ -654,7 +664,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
654 instance.ResetScript(); 664 instance.ResetScript();
655 } 665 }
656 666
657 public XDetectParams GetDetectParams(LLUUID itemID, int idx) 667 public DetectParams GetDetectParams(LLUUID itemID, int idx)
658 { 668 {
659 XScriptInstance instance = GetInstance(itemID); 669 XScriptInstance instance = GetInstance(itemID);
660 if (instance != null) 670 if (instance != null)
@@ -669,115 +679,21 @@ namespace OpenSim.Region.ScriptEngine.XEngine
669 return instance.GetDetectID(idx); 679 return instance.GetDetectID(idx);
670 return LLUUID.Zero; 680 return LLUUID.Zero;
671 } 681 }
672 }
673
674 public class XDetectParams
675 {
676 public XDetectParams()
677 {
678 Key = LLUUID.Zero;
679 OffsetPos = new LSL_Types.Vector3();
680 LinkNum = 0;
681 Group = LLUUID.Zero;
682 Name = String.Empty;
683 Owner = LLUUID.Zero;
684 Position = new LSL_Types.Vector3();
685 Rotation = new LSL_Types.Quaternion();
686 Type = 0;
687 Velocity = new LSL_Types.Vector3();
688 }
689
690 public LLUUID Key;
691 public LSL_Types.Vector3 OffsetPos;
692 public int LinkNum;
693 public LLUUID Group;
694 public string Name;
695 public LLUUID Owner;
696 public LSL_Types.Vector3 Position;
697 public LSL_Types.Quaternion Rotation;
698 public int Type;
699 public LSL_Types.Vector3 Velocity;
700
701 public void Populate(Scene scene)
702 {
703 SceneObjectPart part = scene.GetSceneObjectPart(Key);
704 if (part == null) // Avatar, maybe?
705 {
706 ScenePresence presence = scene.GetScenePresence(Key);
707 if (presence == null)
708 return;
709
710 Name = presence.Firstname + " " + presence.Lastname;
711 Owner = Key;
712 Position = new LSL_Types.Vector3(
713 presence.AbsolutePosition.X,
714 presence.AbsolutePosition.X,
715 presence.AbsolutePosition.Z);
716 Rotation = new LSL_Types.Quaternion(
717 presence.Rotation.x,
718 presence.Rotation.y,
719 presence.Rotation.z,
720 presence.Rotation.w);
721 Velocity = new LSL_Types.Vector3(
722 presence.Velocity.X,
723 presence.Velocity.X,
724 presence.Velocity.Z);
725
726 Type = 0x01; // Avatar
727 if (presence.Velocity != LLVector3.Zero)
728 Type |= 0x02; // Active
729
730 Group = presence.ControllingClient.ActiveGroupId;
731 682
683 public void SetState(LLUUID itemID, string newState)
684 {
685 XScriptInstance instance = GetInstance(itemID);
686 if (instance == null)
732 return; 687 return;
733 } 688 instance.SetState(newState);
734
735 part=part.ParentGroup.RootPart; // We detect objects only
736
737 LinkNum = 0; // Not relevant
738
739 Group = part.GroupID;
740 Name = part.Name;
741 Owner = part.OwnerID;
742 if (part.Velocity == LLVector3.Zero)
743 Type = 0x04; // Passive
744 else
745 Type = 0x02; // Passive
746
747 foreach (SceneObjectPart p in part.ParentGroup.Children.Values)
748 {
749 if (part.ContainsScripts())
750 {
751 Type |= 0x08; // Scripted
752 break;
753 }
754 }
755
756 Position = new LSL_Types.Vector3(part.AbsolutePosition.X,
757 part.AbsolutePosition.Y,
758 part.AbsolutePosition.Z);
759
760 LLQuaternion wr = part.GetWorldRotation();
761 Rotation = new LSL_Types.Quaternion(wr.X, wr.Y, wr.Z, wr.W);
762
763 Velocity = new LSL_Types.Vector3(part.Velocity.X,
764 part.Velocity.Y,
765 part.Velocity.Z);
766 } 689 }
767 } 690 public string GetState(LLUUID itemID)
768
769 public class XEventParams
770 {
771 public XEventParams(string eventName, Object[] eventParams, XDetectParams[] detectParams)
772 { 691 {
773 EventName=eventName; 692 XScriptInstance instance = GetInstance(itemID);
774 Params=eventParams; 693 if (instance == null)
775 DetectParams=detectParams; 694 return "default";
695 return instance.State;
776 } 696 }
777
778 public string EventName;
779 public Object[] Params;
780 public XDetectParams[] DetectParams;
781 } 697 }
782 698
783 public class XScriptInstance 699 public class XScriptInstance
@@ -791,17 +707,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine
791 private LLUUID m_ObjectID; 707 private LLUUID m_ObjectID;
792 private LLUUID m_AssetID; 708 private LLUUID m_AssetID;
793 private IScript m_Script; 709 private IScript m_Script;
794 private LSL_ScriptCommands m_LSLCommands;
795 private OSSL_ScriptCommands m_OSSLCommands;
796 private Executor m_Executor; 710 private Executor m_Executor;
797 private LLUUID m_AppDomain; 711 private LLUUID m_AppDomain;
798 private XDetectParams[] m_DetectParams; 712 private DetectParams[] m_DetectParams;
799 private bool m_TimerQueued; 713 private bool m_TimerQueued;
800 private DateTime m_EventStart; 714 private DateTime m_EventStart;
801 private bool m_InEvent; 715 private bool m_InEvent;
802 private string m_PrimName; 716 private string m_PrimName;
803 private string m_ScriptName; 717 private string m_ScriptName;
804 private string m_Assembly; 718 private string m_Assembly;
719 private Dictionary<string,IScriptApi> m_Apis = new Dictionary<string,IScriptApi>();
805 720
806 public enum StateSource 721 public enum StateSource
807 { 722 {
@@ -893,6 +808,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
893 m_ScriptName = scriptName; 808 m_ScriptName = scriptName;
894 m_Assembly = assembly; 809 m_Assembly = assembly;
895 810
811 ApiManager am = new ApiManager();
812
896 SceneObjectPart part=engine.World.GetSceneObjectPart(localID); 813 SceneObjectPart part=engine.World.GetSceneObjectPart(localID);
897 if (part == null) 814 if (part == null)
898 { 815 {
@@ -900,10 +817,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
900 return; 817 return;
901 } 818 }
902 819
903 m_LSLCommands = new LSL_ScriptCommands(engine, this, part, localID, 820 foreach (string api in am.GetApis())
904 itemID); 821 {
905 m_OSSLCommands = new OSSL_ScriptCommands(engine, this, part, 822 m_Apis[api] = am.CreateApi(api);
906 localID, itemID); 823 m_Apis[api].Initialize(engine, part, localID, itemID);
824 }
907 825
908 try 826 try
909 { 827 {
@@ -918,14 +836,17 @@ namespace OpenSim.Region.ScriptEngine.XEngine
918 836
919 try 837 try
920 { 838 {
921 m_Script.Start(m_LSLCommands, m_OSSLCommands); 839 foreach (KeyValuePair<string,IScriptApi> kv in m_Apis)
840 {
841 m_Script.InitApi(kv.Key, kv.Value);
842 }
922 843
923 m_Executor = new Executor(m_Script); 844 m_Executor = new Executor(m_Script);
924 845
925// m_Engine.Log.Debug("[XEngine] Script instance created"); 846// m_Engine.Log.Debug("[XEngine] Script instance created");
926 847
927 part.SetScriptEvents(m_ItemID, 848 part.SetScriptEvents(m_ItemID,
928 (int)m_Executor.GetStateEventFlags()); 849 (int)m_Executor.GetStateEventFlags(State));
929 } 850 }
930 catch (Exception e) 851 catch (Exception e)
931 { 852 {
@@ -958,7 +879,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
958 879
959 ScriptSerializer.Deserialize(xml, this); 880 ScriptSerializer.Deserialize(xml, this);
960 881
961 m_Engine.m_ASYNCLSLCommandManager.CreateFromData( 882 m_Engine.m_AsyncCommands.CreateFromData(
962 m_LocalID, m_ItemID, m_ObjectID, 883 m_LocalID, m_ItemID, m_ObjectID,
963 PluginData); 884 PluginData);
964 885
@@ -976,32 +897,32 @@ namespace OpenSim.Region.ScriptEngine.XEngine
976 if (stateSource == StateSource.NewRez) 897 if (stateSource == StateSource.NewRez)
977 { 898 {
978// m_Engine.Log.Debug("[XEngine] Posted changed(CHANGED_REGION_RESTART) to script"); 899// m_Engine.Log.Debug("[XEngine] Posted changed(CHANGED_REGION_RESTART) to script");
979 PostEvent(new XEventParams("changed", 900 PostEvent(new EventParams("changed",
980 new Object[] {new LSL_Types.LSLInteger(256)}, new XDetectParams[0])); 901 new Object[] {new LSL_Types.LSLInteger(256)}, new DetectParams[0]));
981 } 902 }
982 } 903 }
983 } 904 }
984 else 905 else
985 { 906 {
986 m_Engine.Log.Error("[XEngine] Unable to load script state: Memory limit exceeded"); 907 m_Engine.Log.Error("[XEngine] Unable to load script state: Memory limit exceeded");
987 PostEvent(new XEventParams("state_entry", 908 PostEvent(new EventParams("state_entry",
988 new Object[0], new XDetectParams[0])); 909 new Object[0], new DetectParams[0]));
989 Start(); 910 Start();
990 } 911 }
991 } 912 }
992 catch (Exception e) 913 catch (Exception e)
993 { 914 {
994 m_Engine.Log.ErrorFormat("[XEngine] Unable to load script state from xml: {0}\n"+e.ToString(), xml); 915 m_Engine.Log.ErrorFormat("[XEngine] Unable to load script state from xml: {0}\n"+e.ToString(), xml);
995 PostEvent(new XEventParams("state_entry", 916 PostEvent(new EventParams("state_entry",
996 new Object[0], new XDetectParams[0])); 917 new Object[0], new DetectParams[0]));
997 Start(); 918 Start();
998 } 919 }
999 } 920 }
1000 else 921 else
1001 { 922 {
1002 m_Engine.Log.ErrorFormat("[XEngine] Unable to load script state, file not found"); 923 m_Engine.Log.ErrorFormat("[XEngine] Unable to load script state, file not found");
1003 PostEvent(new XEventParams("state_entry", 924 PostEvent(new EventParams("state_entry",
1004 new Object[0], new XDetectParams[0])); 925 new Object[0], new DetectParams[0]));
1005 Start(); 926 Start();
1006 } 927 }
1007 } 928 }
@@ -1100,15 +1021,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1100 1021
1101 public void SetState(string state) 1022 public void SetState(string state)
1102 { 1023 {
1103 PostEvent(new XEventParams("state_exit", new Object[0], 1024 PostEvent(new EventParams("state_exit", new Object[0],
1104 new XDetectParams[0])); 1025 new DetectParams[0]));
1105 PostEvent(new XEventParams("state", new Object[] { state }, 1026 PostEvent(new EventParams("state", new Object[] { state },
1106 new XDetectParams[0])); 1027 new DetectParams[0]));
1107 PostEvent(new XEventParams("state_entry", new Object[0], 1028 PostEvent(new EventParams("state_entry", new Object[0],
1108 new XDetectParams[0])); 1029 new DetectParams[0]));
1109 } 1030 }
1110 1031
1111 public void PostEvent(XEventParams data) 1032 public void PostEvent(EventParams data)
1112 { 1033 {
1113// m_Engine.Log.DebugFormat("[XEngine] Posted event {2} in state {3} to {0}.{1}", 1034// m_Engine.Log.DebugFormat("[XEngine] Posted event {2} in state {3} to {0}.{1}",
1114// m_PrimName, m_ScriptName, data.EventName, m_State); 1035// m_PrimName, m_ScriptName, data.EventName, m_State);
@@ -1137,11 +1058,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1137 1058
1138 public object EventProcessor() 1059 public object EventProcessor()
1139 { 1060 {
1140 XEventParams data = null; 1061 EventParams data = null;
1141 1062
1142 lock (m_EventQueue) 1063 lock (m_EventQueue)
1143 { 1064 {
1144 data = (XEventParams) m_EventQueue.Dequeue(); 1065 data = (EventParams) m_EventQueue.Dequeue();
1145 if (data == null) // Shouldn't happen 1066 if (data == null) // Shouldn't happen
1146 { 1067 {
1147 m_CurrentResult = null; 1068 m_CurrentResult = null;
@@ -1158,7 +1079,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1158// m_Engine.Log.DebugFormat("[XEngine] Script {0}.{1} state set to {2}", 1079// m_Engine.Log.DebugFormat("[XEngine] Script {0}.{1} state set to {2}",
1159// m_PrimName, m_ScriptName, data.Params[0].ToString()); 1080// m_PrimName, m_ScriptName, data.Params[0].ToString());
1160 m_State=data.Params[0].ToString(); 1081 m_State=data.Params[0].ToString();
1161 m_Engine.m_ASYNCLSLCommandManager.RemoveScript( 1082 m_Engine.m_AsyncCommands.RemoveScript(
1162 m_LocalID, m_ItemID); 1083 m_LocalID, m_ItemID);
1163 1084
1164 SceneObjectPart part = m_Engine.World.GetSceneObjectPart( 1085 SceneObjectPart part = m_Engine.World.GetSceneObjectPart(
@@ -1166,7 +1087,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1166 if (part != null) 1087 if (part != null)
1167 { 1088 {
1168 part.SetScriptEvents(m_ItemID, 1089 part.SetScriptEvents(m_ItemID,
1169 (int)m_Executor.GetStateEventFlags()); 1090 (int)m_Executor.GetStateEventFlags(State));
1170 } 1091 }
1171 } 1092 }
1172 else 1093 else
@@ -1181,7 +1102,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1181 { 1102 {
1182 m_EventStart = DateTime.Now; 1103 m_EventStart = DateTime.Now;
1183 m_InEvent = true; 1104 m_InEvent = true;
1184 m_Executor.ExecuteEvent(data.EventName, data.Params); 1105 m_Executor.ExecuteEvent(State, data.EventName, data.Params);
1185 m_InEvent = false; 1106 m_InEvent = false;
1186 } 1107 }
1187 catch (Exception e) 1108 catch (Exception e)
@@ -1259,14 +1180,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1259 bool running = Running; 1180 bool running = Running;
1260 1181
1261 Stop(0); 1182 Stop(0);
1262 m_Engine.m_ASYNCLSLCommandManager.RemoveScript(m_LocalID, m_ItemID); 1183 m_Engine.m_AsyncCommands.RemoveScript(m_LocalID, m_ItemID);
1263 m_EventQueue.Clear(); 1184 m_EventQueue.Clear();
1264 m_Script.ResetVars(); 1185 m_Script.ResetVars();
1265 m_State = "default"; 1186 m_State = "default";
1266 if (running) 1187 if (running)
1267 Start(); 1188 Start();
1268 PostEvent(new XEventParams("state_entry", 1189 PostEvent(new EventParams("state_entry",
1269 new Object[0], new XDetectParams[0])); 1190 new Object[0], new DetectParams[0]));
1270 } 1191 }
1271 1192
1272 public Dictionary<string, object> GetVars() 1193 public Dictionary<string, object> GetVars()
@@ -1279,7 +1200,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1279 m_Script.SetVars(vars); 1200 m_Script.SetVars(vars);
1280 } 1201 }
1281 1202
1282 public XDetectParams GetDetectParams(int idx) 1203 public DetectParams GetDetectParams(int idx)
1283 { 1204 {
1284 if (idx < 0 || idx >= m_DetectParams.Length) 1205 if (idx < 0 || idx >= m_DetectParams.Length)
1285 return null; 1206 return null;
@@ -1298,7 +1219,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1298 public void SaveState(string assembly) 1219 public void SaveState(string assembly)
1299 { 1220 {
1300 PluginData = 1221 PluginData =
1301 m_Engine.m_ASYNCLSLCommandManager.GetSerializationData( 1222 m_Engine.m_AsyncCommands.GetSerializationData(
1302 m_ItemID); 1223 m_ItemID);
1303 1224
1304 string xml = ScriptSerializer.Serialize(this); 1225 string xml = ScriptSerializer.Serialize(this);
@@ -1368,7 +1289,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1368 1289
1369 while (count > 0) 1290 while (count > 0)
1370 { 1291 {
1371 XEventParams ep = (XEventParams)instance.EventQueue.Dequeue(); 1292 EventParams ep = (EventParams)instance.EventQueue.Dequeue();
1372 instance.EventQueue.Enqueue(ep); 1293 instance.EventQueue.Enqueue(ep);
1373 count--; 1294 count--;
1374 1295
@@ -1387,7 +1308,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1387 1308
1388 XmlElement detect = xmldoc.CreateElement("", "Detected", ""); 1309 XmlElement detect = xmldoc.CreateElement("", "Detected", "");
1389 1310
1390 foreach (XDetectParams det in ep.DetectParams) 1311 foreach (DetectParams det in ep.DetectParams)
1391 { 1312 {
1392 XmlElement objectElem = xmldoc.CreateElement("", "Object", 1313 XmlElement objectElem = xmldoc.CreateElement("", "Object",
1393 ""); 1314 "");
@@ -1449,9 +1370,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1449 rootElement.AppendChild(queue); 1370 rootElement.AppendChild(queue);
1450 1371
1451 XmlNode plugins = xmldoc.CreateElement("", "Plugins", ""); 1372 XmlNode plugins = xmldoc.CreateElement("", "Plugins", "");
1452 if (instance.PluginData.Length > 0) 1373 DumpList(xmldoc, plugins,
1453 DumpList(xmldoc, plugins, 1374 new LSL_Types.list(instance.PluginData));
1454 new LSL_Types.list(instance.PluginData));
1455 1375
1456 rootElement.AppendChild(plugins); 1376 rootElement.AppendChild(plugins);
1457 1377
@@ -1510,8 +1430,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1510 foreach (XmlNode item in itemL) 1430 foreach (XmlNode item in itemL)
1511 { 1431 {
1512 List<Object> parms = new List<Object>(); 1432 List<Object> parms = new List<Object>();
1513 List<XDetectParams> detected = 1433 List<DetectParams> detected =
1514 new List<XDetectParams>(); 1434 new List<DetectParams>();
1515 1435
1516 string eventName = 1436 string eventName =
1517 item.Attributes.GetNamedItem("event").Value; 1437 item.Attributes.GetNamedItem("event").Value;
@@ -1595,7 +1515,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1595 LLUUID.TryParse(det.InnerText, 1515 LLUUID.TryParse(det.InnerText,
1596 out uuid); 1516 out uuid);
1597 1517
1598 XDetectParams d = new XDetectParams(); 1518 DetectParams d = new DetectParams();
1599 d.Key = uuid; 1519 d.Key = uuid;
1600 d.OffsetPos = v; 1520 d.OffsetPos = v;
1601 d.LinkNum = d_linkNum; 1521 d.LinkNum = d_linkNum;
@@ -1612,7 +1532,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1612 break; 1532 break;
1613 } 1533 }
1614 } 1534 }
1615 XEventParams ep = new XEventParams( 1535 EventParams ep = new EventParams(
1616 eventName, parms.ToArray(), 1536 eventName, parms.ToArray(),
1617 detected.ToArray()); 1537 detected.ToArray());
1618 instance.EventQueue.Enqueue(ep); 1538 instance.EventQueue.Enqueue(ep);