aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/DotNetEngine
diff options
context:
space:
mode:
authorTedd Hansen2008-01-12 14:30:22 +0000
committerTedd Hansen2008-01-12 14:30:22 +0000
commitbacbade369a5244f9bcc611488b59f3bd4c8a564 (patch)
tree2cd909eff401066a69dba96615cbf736fdd73be5 /OpenSim/Region/ScriptEngine/DotNetEngine
parent* Trying something to see if it helps teleports and border crossings (diff)
downloadopensim-SC_OLD-bacbade369a5244f9bcc611488b59f3bd4c8a564.zip
opensim-SC_OLD-bacbade369a5244f9bcc611488b59f3bd4c8a564.tar.gz
opensim-SC_OLD-bacbade369a5244f9bcc611488b59f3bd4c8a564.tar.bz2
opensim-SC_OLD-bacbade369a5244f9bcc611488b59f3bd4c8a564.tar.xz
Major reorganizing of DotNetEngine. Moved common script engine parts to ScriptEngine.Common, only .Net-specific code in DotNetEngine. AppDomains, event handling, event execution queue and multithreading, script load/unload queue, etc has been moved to ScriptEngine.Common.
Loads of things has been put into interfaces instead of the specific class. We are now one step closer to ScriptServer, and its very easy to implement new script languages. Just a few lines required to make them a OpenSim script module with all its glory.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs238
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Common.cs57
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs2154
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs3015
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs259
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs364
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs295
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs86
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs438
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/TempDotNetMicroThreadingCodeInjector.cs69
12 files changed, 83 insertions, 6898 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs
deleted file mode 100644
index 66153a7..0000000
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs
+++ /dev/null
@@ -1,238 +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;
31using System.Collections.Generic;
32using System.Reflection;
33using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL;
34
35namespace OpenSim.Region.ScriptEngine.DotNetEngine
36{
37 public class AppDomainManager
38 {
39
40 //
41 // This class does AppDomain handling and loading/unloading of scripts in it.
42 // It is instanced in "ScriptEngine" and controlled from "ScriptManager"
43 //
44 // 1. Create a new AppDomain if old one is full (or doesn't exist)
45 // 2. Load scripts into AppDomain
46 // 3. Unload scripts from AppDomain (stopping them and marking them as inactive)
47 // 4. Unload AppDomain completely when all scripts in it has stopped
48 //
49
50
51 private int maxScriptsPerAppDomain = 1;
52
53 /// <summary>
54 /// Internal list of all AppDomains
55 /// </summary>
56 private List<AppDomainStructure> appDomains = new List<AppDomainStructure>();
57
58 /// <summary>
59 /// Structure to keep track of data around AppDomain
60 /// </summary>
61 private class AppDomainStructure
62 {
63 /// <summary>
64 /// The AppDomain itself
65 /// </summary>
66 public AppDomain CurrentAppDomain;
67
68 /// <summary>
69 /// Number of scripts loaded into AppDomain
70 /// </summary>
71 public int ScriptsLoaded;
72
73 /// <summary>
74 /// Number of dead scripts
75 /// </summary>
76 public int ScriptsWaitingUnload;
77 }
78
79 /// <summary>
80 /// Current AppDomain
81 /// </summary>
82 private AppDomainStructure currentAD;
83
84 private object getLock = new object(); // Mutex
85 private object freeLock = new object(); // Mutex
86
87 //private ScriptEngine m_scriptEngine;
88 //public AppDomainManager(ScriptEngine scriptEngine)
89 public AppDomainManager()
90 {
91 //m_scriptEngine = scriptEngine;
92 }
93
94 /// <summary>
95 /// Find a free AppDomain, creating one if necessary
96 /// </summary>
97 /// <returns>Free AppDomain</returns>
98 private AppDomainStructure GetFreeAppDomain()
99 {
100 Console.WriteLine("Finding free AppDomain");
101 lock (getLock)
102 {
103 // Current full?
104 if (currentAD != null && currentAD.ScriptsLoaded >= maxScriptsPerAppDomain)
105 {
106 // Add it to AppDomains list and empty current
107 appDomains.Add(currentAD);
108 currentAD = null;
109 }
110 // No current
111 if (currentAD == null)
112 {
113 // Create a new current AppDomain
114 currentAD = new AppDomainStructure();
115 currentAD.CurrentAppDomain = PrepareNewAppDomain();
116 }
117
118 Console.WriteLine("Scripts loaded in this Appdomain: " + currentAD.ScriptsLoaded);
119 return currentAD;
120 } // lock
121 }
122
123 private int AppDomainNameCount;
124
125 /// <summary>
126 /// Create and prepare a new AppDomain for scripts
127 /// </summary>
128 /// <returns>The new AppDomain</returns>
129 private AppDomain PrepareNewAppDomain()
130 {
131 // Create and prepare a new AppDomain
132 AppDomainNameCount++;
133 // TODO: Currently security match current appdomain
134
135 // Construct and initialize settings for a second AppDomain.
136 AppDomainSetup ads = new AppDomainSetup();
137 ads.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
138 ads.DisallowBindingRedirects = false;
139 ads.DisallowCodeDownload = true;
140 ads.LoaderOptimization = LoaderOptimization.MultiDomain; // Sounds good ;)
141 ads.ShadowCopyFiles = "true"; // Enabled shadowing
142 ads.ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
143
144 AppDomain AD = AppDomain.CreateDomain("ScriptAppDomain_" + AppDomainNameCount, null, ads);
145 Console.WriteLine("Loading: " +
146 AssemblyName.GetAssemblyName("OpenSim.Region.ScriptEngine.Common.dll").ToString());
147 AD.Load(AssemblyName.GetAssemblyName("OpenSim.Region.ScriptEngine.Common.dll"));
148
149 // Return the new AppDomain
150 return AD;
151 }
152
153 /// <summary>
154 /// Unload appdomains that are full and have only dead scripts
155 /// </summary>
156 private void UnloadAppDomains()
157 {
158 lock (freeLock)
159 {
160 // Go through all
161 foreach (AppDomainStructure ads in new ArrayList(appDomains))
162 {
163 // Don't process current AppDomain
164 if (ads.CurrentAppDomain != currentAD.CurrentAppDomain)
165 {
166 // Not current AppDomain
167 // Is number of unloaded bigger or equal to number of loaded?
168 if (ads.ScriptsLoaded <= ads.ScriptsWaitingUnload)
169 {
170 Console.WriteLine("Found empty AppDomain, unloading");
171 // Remove from internal list
172 appDomains.Remove(ads);
173#if DEBUG
174 long m = GC.GetTotalMemory(true);
175#endif
176 // Unload
177 AppDomain.Unload(ads.CurrentAppDomain);
178#if DEBUG
179 Console.WriteLine("AppDomain unload freed " + (m - GC.GetTotalMemory(true)) +
180 " bytes of memory");
181#endif
182 }
183 }
184 } // foreach
185 } // lock
186 }
187
188
189 public LSL_BaseClass LoadScript(string FileName)
190 {
191 // Find next available AppDomain to put it in
192 AppDomainStructure FreeAppDomain = GetFreeAppDomain();
193
194 Console.WriteLine("Loading into AppDomain: " + FileName);
195 LSL_BaseClass mbrt =
196 (LSL_BaseClass)
197 FreeAppDomain.CurrentAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script");
198 //Console.WriteLine("ScriptEngine AppDomainManager: is proxy={0}", RemotingServices.IsTransparentProxy(mbrt));
199 FreeAppDomain.ScriptsLoaded++;
200
201 return mbrt;
202 }
203
204
205 /// <summary>
206 /// Increase "dead script" counter for an AppDomain
207 /// </summary>
208 /// <param name="ad"></param>
209 //[Obsolete("Needs fixing, needs a real purpose in life!!!")]
210 public void StopScript(AppDomain ad)
211 {
212 lock (freeLock)
213 {
214 Console.WriteLine("Stopping script in AppDomain");
215 // Check if it is current AppDomain
216 if (currentAD.CurrentAppDomain == ad)
217 {
218 // Yes - increase
219 currentAD.ScriptsWaitingUnload++;
220 return;
221 }
222
223 // Lopp through all AppDomains
224 foreach (AppDomainStructure ads in new ArrayList(appDomains))
225 {
226 if (ads.CurrentAppDomain == ad)
227 {
228 // Found it
229 ads.ScriptsWaitingUnload++;
230 break;
231 }
232 } // foreach
233 } // lock
234
235 UnloadAppDomains(); // Outsite lock, has its own GetLock
236 }
237 }
238} \ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Common.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Common.cs
deleted file mode 100644
index db9a535..0000000
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Common.cs
+++ /dev/null
@@ -1,57 +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/* Original code: Tedd Hansen */
29namespace OpenSim.Region.ScriptEngine.DotNetEngine
30{
31 public static class Common
32 {
33 public static bool debug = true;
34 public static ScriptEngine mySE;
35
36 // This class just contains some static log stuff used for debugging.
37
38 //public delegate void SendToDebugEventDelegate(string Message);
39 //public delegate void SendToLogEventDelegate(string Message);
40 //static public event SendToDebugEventDelegate SendToDebugEvent;
41 //static public event SendToLogEventDelegate SendToLogEvent;
42
43 public static void SendToDebug(string Message)
44 {
45 //if (Debug == true)
46 mySE.Log.Verbose("ScriptEngine", "Debug: " + Message);
47 //SendToDebugEvent("\r\n" + DateTime.Now.ToString("[HH:mm:ss] ") + Message);
48 }
49
50 public static void SendToLog(string Message)
51 {
52 //if (Debug == true)
53 mySE.Log.Verbose("ScriptEngine", "LOG: " + Message);
54 //SendToLogEvent("\r\n" + DateTime.Now.ToString("[HH:mm:ss] ") + Message);
55 }
56 }
57} \ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs
index 441c952..9cd22e2 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs
@@ -58,10 +58,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
58 { 58 {
59 case ".txt": 59 case ".txt":
60 case ".lsl": 60 case ".lsl":
61 Common.SendToDebug("Source code is LSL, converting to CS"); 61 Common.ScriptEngineBase.Common.SendToDebug("Source code is LSL, converting to CS");
62 return CompileFromLSLText(File.ReadAllText(LSOFileName)); 62 return CompileFromLSLText(File.ReadAllText(LSOFileName));
63 case ".cs": 63 case ".cs":
64 Common.SendToDebug("Source code is CS"); 64 Common.ScriptEngineBase.Common.SendToDebug("Source code is CS");
65 return CompileFromCSText(File.ReadAllText(LSOFileName)); 65 return CompileFromCSText(File.ReadAllText(LSOFileName));
66 default: 66 default:
67 throw new Exception("Unknown script type."); 67 throw new Exception("Unknown script type.");
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs
index dfdf8f4..724d8f5 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs
@@ -313,7 +313,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
313 "namespace SecondLife { "; 313 "namespace SecondLife { ";
314 Return += "" + 314 Return += "" +
315 //"[Serializable] " + 315 //"[Serializable] " +
316 "public class Script : OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass { "; 316 "public class Script : OpenSim.Region.ScriptEngine.Common.LSL_BaseClass { ";
317 Return += @"public Script() { } "; 317 Return += @"public Script() { } ";
318 Return += Script; 318 Return += Script;
319 Return += "} }\r\n"; 319 Return += "} }\r\n";
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs
deleted file mode 100644
index 7c1d66e..0000000
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs
+++ /dev/null
@@ -1,2154 +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.Runtime.Remoting.Lifetime;
32using System.Threading;
33using OpenSim.Region.ScriptEngine.Common;
34using integer = System.Int32;
35using key = System.String;
36using vector = OpenSim.Region.ScriptEngine.Common.LSL_Types.Vector3;
37using rotation = OpenSim.Region.ScriptEngine.Common.LSL_Types.Quaternion;
38
39namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
40{
41 //[Serializable]
42 public class LSL_BaseClass : MarshalByRefObject, LSL_BuiltIn_Commands_Interface, IScript
43 {
44
45 //
46 // Included as base for any LSL-script that is compiled.
47 // Any function added here will be accessible to the LSL script. But it must also be added to "LSL_BuiltIn_Commands_Interface" in "OpenSim.Region.ScriptEngine.Common" class.
48 //
49 // Security note: This script will be running inside an restricted AppDomain. Currently AppDomain is not very restricted.zxs
50 //
51
52 // Object never expires
53 public override Object InitializeLifetimeService()
54 {
55 //Console.WriteLine("LSL_BaseClass: InitializeLifetimeService()");
56 // return null;
57 ILease lease = (ILease)base.InitializeLifetimeService();
58
59 if (lease.CurrentState == LeaseState.Initial)
60 {
61 lease.InitialLeaseTime = TimeSpan.Zero; // TimeSpan.FromMinutes(1);
62 //lease.SponsorshipTimeout = TimeSpan.FromMinutes(2);
63 //lease.RenewOnCallTime = TimeSpan.FromSeconds(2);
64 }
65 return lease;
66 }
67
68
69 private Executor m_Exec;
70
71 public Executor Exec
72 {
73 get
74 {
75 if (m_Exec == null)
76 m_Exec = new Executor(this);
77 return m_Exec;
78 }
79 }
80
81 public LSL_BuiltIn_Commands_Interface m_LSL_Functions;
82 public string SourceCode = "";
83
84 public LSL_BaseClass()
85 {
86 }
87
88 public string State()
89 {
90 return m_LSL_Functions.State();
91 }
92
93
94 public void Start(LSL_BuiltIn_Commands_Interface LSL_Functions)
95 {
96 m_LSL_Functions = LSL_Functions;
97
98 //MainLog.Instance.Notice("ScriptEngine", "LSL_BaseClass.Start() called.");
99
100 // Get this AppDomain's settings and display some of them.
101 AppDomainSetup ads = AppDomain.CurrentDomain.SetupInformation;
102 Console.WriteLine("AppName={0}, AppBase={1}, ConfigFile={2}",
103 ads.ApplicationName,
104 ads.ApplicationBase,
105 ads.ConfigurationFile
106 );
107
108 // Display the name of the calling AppDomain and the name
109 // of the second domain.
110 // NOTE: The application's thread has transitioned between
111 // AppDomains.
112 Console.WriteLine("Calling to '{0}'.",
113 Thread.GetDomain().FriendlyName
114 );
115
116 return;
117 }
118
119
120 //
121 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
122 //
123 // They are only forwarders to LSL_BuiltIn_Commands.cs
124 //
125 public double llSin(double f)
126 {
127 return m_LSL_Functions.llSin(f);
128 }
129
130 public double llCos(double f)
131 {
132 return m_LSL_Functions.llCos(f);
133 }
134
135 public double llTan(double f)
136 {
137 return m_LSL_Functions.llTan(f);
138 }
139
140 public double llAtan2(double x, double y)
141 {
142 return m_LSL_Functions.llAtan2(x, y);
143 }
144
145 public double llSqrt(double f)
146 {
147 return m_LSL_Functions.llSqrt(f);
148 }
149
150 public double llPow(double fbase, double fexponent)
151 {
152 return m_LSL_Functions.llPow(fbase, fexponent);
153 }
154
155 public int llAbs(int i)
156 {
157 return m_LSL_Functions.llAbs(i);
158 }
159
160 public double llFabs(double f)
161 {
162 return m_LSL_Functions.llFabs(f);
163 }
164
165 public double llFrand(double mag)
166 {
167 return m_LSL_Functions.llFrand(mag);
168 }
169
170 public int llFloor(double f)
171 {
172 return m_LSL_Functions.llFloor(f);
173 }
174
175 public int llCeil(double f)
176 {
177 return m_LSL_Functions.llCeil(f);
178 }
179
180 public int llRound(double f)
181 {
182 return m_LSL_Functions.llRound(f);
183 }
184
185 public double llVecMag(vector v)
186 {
187 return m_LSL_Functions.llVecMag(v);
188 }
189
190 public vector llVecNorm(vector v)
191 {
192 return m_LSL_Functions.llVecNorm(v);
193 }
194
195 public double llVecDist(vector a, vector b)
196 {
197 return m_LSL_Functions.llVecDist(a, b);
198 }
199
200 public vector llRot2Euler(rotation r)
201 {
202 return m_LSL_Functions.llRot2Euler(r);
203 }
204
205 public rotation llEuler2Rot(vector v)
206 {
207 return m_LSL_Functions.llEuler2Rot(v);
208 }
209
210 public rotation llAxes2Rot(vector fwd, vector left, vector up)
211 {
212 return m_LSL_Functions.llAxes2Rot(fwd, left, up);
213 }
214
215 public vector llRot2Fwd(rotation r)
216 {
217 return m_LSL_Functions.llRot2Fwd(r);
218 }
219
220 public vector llRot2Left(rotation r)
221 {
222 return m_LSL_Functions.llRot2Left(r);
223 }
224
225 public vector llRot2Up(rotation r)
226 {
227 return m_LSL_Functions.llRot2Up(r);
228 }
229
230 public rotation llRotBetween(vector start, vector end)
231 {
232 return m_LSL_Functions.llRotBetween(start, end);
233 }
234
235 public void llWhisper(int channelID, string text)
236 {
237 m_LSL_Functions.llWhisper(channelID, text);
238 }
239
240 public void llSay(int channelID, string text)
241 {
242 m_LSL_Functions.llSay(channelID, text);
243 }
244
245 //
246 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
247 //
248 public void llShout(int channelID, string text)
249 {
250 m_LSL_Functions.llShout(channelID, text);
251 }
252
253 public int llListen(int channelID, string name, string ID, string msg)
254 {
255 return m_LSL_Functions.llListen(channelID, name, ID, msg);
256 }
257
258 public void llListenControl(int number, int active)
259 {
260 m_LSL_Functions.llListenControl(number, active);
261 }
262
263 public void llListenRemove(int number)
264 {
265 m_LSL_Functions.llListenRemove(number);
266 }
267
268 public void llSensor(string name, string id, int type, double range, double arc)
269 {
270 m_LSL_Functions.llSensor(name, id, type, range, arc);
271 }
272
273 public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate)
274 {
275 m_LSL_Functions.llSensorRepeat(name, id, type, range, arc, rate);
276 }
277
278 public void llSensorRemove()
279 {
280 m_LSL_Functions.llSensorRemove();
281 }
282
283 public string llDetectedName(int number)
284 {
285 return m_LSL_Functions.llDetectedName(number);
286 }
287
288 public string llDetectedKey(int number)
289 {
290 return m_LSL_Functions.llDetectedKey(number);
291 }
292
293 public string llDetectedOwner(int number)
294 {
295 return m_LSL_Functions.llDetectedOwner(number);
296 }
297
298 public int llDetectedType(int number)
299 {
300 return m_LSL_Functions.llDetectedType(number);
301 }
302
303 public vector llDetectedPos(int number)
304 {
305 return m_LSL_Functions.llDetectedPos(number);
306 }
307
308 public vector llDetectedVel(int number)
309 {
310 return m_LSL_Functions.llDetectedVel(number);
311 }
312
313 public vector llDetectedGrab(int number)
314 {
315 return m_LSL_Functions.llDetectedGrab(number);
316 }
317
318 public rotation llDetectedRot(int number)
319 {
320 return m_LSL_Functions.llDetectedRot(number);
321 }
322
323 public int llDetectedGroup(int number)
324 {
325 return m_LSL_Functions.llDetectedGroup(number);
326 }
327
328 public int llDetectedLinkNumber(int number)
329 {
330 return m_LSL_Functions.llDetectedLinkNumber(number);
331 }
332
333 //
334 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
335 //
336 public void llDie()
337 {
338 m_LSL_Functions.llDie();
339 }
340
341 public double llGround(vector offset)
342 {
343 return m_LSL_Functions.llGround(offset);
344 }
345
346 public double llCloud(vector offset)
347 {
348 return m_LSL_Functions.llCloud(offset);
349 }
350
351 public vector llWind(vector offset)
352 {
353 return m_LSL_Functions.llWind(offset);
354 }
355
356 public void llSetStatus(int status, int value)
357 {
358 m_LSL_Functions.llSetStatus(status, value);
359 }
360
361 public int llGetStatus(int status)
362 {
363 return m_LSL_Functions.llGetStatus(status);
364 }
365
366 public void llSetScale(vector scale)
367 {
368 m_LSL_Functions.llSetScale(scale);
369 }
370
371 public vector llGetScale()
372 {
373 return m_LSL_Functions.llGetScale();
374 }
375
376 public void llSetColor(vector color, int face)
377 {
378 m_LSL_Functions.llSetColor(color, face);
379 }
380
381 public double llGetAlpha(int face)
382 {
383 return m_LSL_Functions.llGetAlpha(face);
384 }
385
386 public void llSetAlpha(double alpha, int face)
387 {
388 m_LSL_Functions.llSetAlpha(alpha, face);
389 }
390
391 public vector llGetColor(int face)
392 {
393 return m_LSL_Functions.llGetColor(face);
394 }
395
396 public void llSetTexture(string texture, int face)
397 {
398 m_LSL_Functions.llSetTexture(texture, face);
399 }
400
401 public void llScaleTexture(double u, double v, int face)
402 {
403 m_LSL_Functions.llScaleTexture(u, v, face);
404 }
405
406 public void llOffsetTexture(double u, double v, int face)
407 {
408 m_LSL_Functions.llOffsetTexture(u, v, face);
409 }
410
411 public void llRotateTexture(double rotation, int face)
412 {
413 m_LSL_Functions.llRotateTexture(rotation, face);
414 }
415
416 public string llGetTexture(int face)
417 {
418 return m_LSL_Functions.llGetTexture(face);
419 }
420
421 //
422 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
423 //
424 public void llSetPos(vector pos)
425 {
426 m_LSL_Functions.llSetPos(pos);
427 }
428
429 public vector llGetPos()
430 {
431 return m_LSL_Functions.llGetPos();
432 }
433
434 public vector llGetLocalPos()
435 {
436 return m_LSL_Functions.llGetLocalPos();
437 }
438
439 public void llSetRot(rotation rot)
440 {
441 m_LSL_Functions.llSetRot(rot);
442 }
443
444 public rotation llGetRot()
445 {
446 return m_LSL_Functions.llGetRot();
447 }
448
449 public rotation llGetLocalRot()
450 {
451 return m_LSL_Functions.llGetLocalRot();
452 }
453
454 public void llSetForce(vector force, int local)
455 {
456 m_LSL_Functions.llSetForce(force, local);
457 }
458
459 public vector llGetForce()
460 {
461 return m_LSL_Functions.llGetForce();
462 }
463
464 public int llTarget(vector position, double range)
465 {
466 return m_LSL_Functions.llTarget(position, range);
467 }
468
469 public void llTargetRemove(int number)
470 {
471 m_LSL_Functions.llTargetRemove(number);
472 }
473
474 public int llRotTarget(rotation rot, double error)
475 {
476 return m_LSL_Functions.llRotTarget(rot, error);
477 }
478
479 public void llRotTargetRemove(int number)
480 {
481 m_LSL_Functions.llRotTargetRemove(number);
482 }
483
484 public void llMoveToTarget(vector target, double tau)
485 {
486 m_LSL_Functions.llMoveToTarget(target, tau);
487 }
488
489 public void llStopMoveToTarget()
490 {
491 m_LSL_Functions.llStopMoveToTarget();
492 }
493
494 public void llApplyImpulse(vector force, int local)
495 {
496 m_LSL_Functions.llApplyImpulse(force, local);
497 }
498
499 //
500 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
501 //
502 public void llApplyRotationalImpulse(vector force, int local)
503 {
504 m_LSL_Functions.llApplyRotationalImpulse(force, local);
505 }
506
507 public void llSetTorque(vector torque, int local)
508 {
509 m_LSL_Functions.llSetTorque(torque, local);
510 }
511
512 public vector llGetTorque()
513 {
514 return m_LSL_Functions.llGetTorque();
515 }
516
517 public void llSetForceAndTorque(vector force, vector torque, int local)
518 {
519 m_LSL_Functions.llSetForceAndTorque(force, torque, local);
520 }
521
522 public vector llGetVel()
523 {
524 return m_LSL_Functions.llGetVel();
525 }
526
527 public vector llGetAccel()
528 {
529 return m_LSL_Functions.llGetAccel();
530 }
531
532 public vector llGetOmega()
533 {
534 return m_LSL_Functions.llGetOmega();
535 }
536
537 public double llGetTimeOfDay()
538 {
539 return m_LSL_Functions.llGetTimeOfDay();
540 }
541
542 public double llGetWallclock()
543 {
544 return m_LSL_Functions.llGetWallclock();
545 }
546
547 public double llGetTime()
548 {
549 return m_LSL_Functions.llGetTime();
550 }
551
552 public void llResetTime()
553 {
554 m_LSL_Functions.llResetTime();
555 }
556
557 public double llGetAndResetTime()
558 {
559 return m_LSL_Functions.llGetAndResetTime();
560 }
561
562 public void llSound()
563 {
564 m_LSL_Functions.llSound();
565 }
566
567 public void llPlaySound(string sound, double volume)
568 {
569 m_LSL_Functions.llPlaySound(sound, volume);
570 }
571
572 public void llLoopSound(string sound, double volume)
573 {
574 m_LSL_Functions.llLoopSound(sound, volume);
575 }
576
577 public void llLoopSoundMaster(string sound, double volume)
578 {
579 m_LSL_Functions.llLoopSoundMaster(sound, volume);
580 }
581
582 public void llLoopSoundSlave(string sound, double volume)
583 {
584 m_LSL_Functions.llLoopSoundSlave(sound, volume);
585 }
586
587 public void llPlaySoundSlave(string sound, double volume)
588 {
589 m_LSL_Functions.llPlaySoundSlave(sound, volume);
590 }
591
592 //
593 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
594 //
595 public void llTriggerSound(string sound, double volume)
596 {
597 m_LSL_Functions.llTriggerSound(sound, volume);
598 }
599
600 public void llStopSound()
601 {
602 m_LSL_Functions.llStopSound();
603 }
604
605 public void llPreloadSound(string sound)
606 {
607 m_LSL_Functions.llPreloadSound(sound);
608 }
609
610 public string llGetSubString(string src, int start, int end)
611 {
612 return m_LSL_Functions.llGetSubString(src, start, end);
613 }
614
615 public string llDeleteSubString(string src, int start, int end)
616 {
617 return m_LSL_Functions.llDeleteSubString(src, start, end);
618 }
619
620 public string llInsertString(string dst, int position, string src)
621 {
622 return m_LSL_Functions.llInsertString(dst, position, src);
623 }
624
625 public string llToUpper(string source)
626 {
627 return m_LSL_Functions.llToUpper(source);
628 }
629
630 public string llToLower(string source)
631 {
632 return m_LSL_Functions.llToLower(source);
633 }
634
635 public int llGiveMoney(string destination, int amount)
636 {
637 return m_LSL_Functions.llGiveMoney(destination, amount);
638 }
639
640 public void llMakeExplosion()
641 {
642 m_LSL_Functions.llMakeExplosion();
643 }
644
645 public void llMakeFountain()
646 {
647 m_LSL_Functions.llMakeFountain();
648 }
649
650 public void llMakeSmoke()
651 {
652 m_LSL_Functions.llMakeSmoke();
653 }
654
655 public void llMakeFire()
656 {
657 m_LSL_Functions.llMakeFire();
658 }
659
660 public void llRezObject(string inventory, vector pos, rotation rot, int param)
661 {
662 m_LSL_Functions.llRezObject(inventory, pos, rot, param);
663 }
664
665 public void llLookAt(vector target, double strength, double damping)
666 {
667 m_LSL_Functions.llLookAt(target, strength, damping);
668 }
669
670 public void llStopLookAt()
671 {
672 m_LSL_Functions.llStopLookAt();
673 }
674
675 public void llSetTimerEvent(double sec)
676 {
677 m_LSL_Functions.llSetTimerEvent(sec);
678 }
679
680 public void llSleep(double sec)
681 {
682 m_LSL_Functions.llSleep(sec);
683 }
684
685 //
686 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
687 //
688 public double llGetMass()
689 {
690 return m_LSL_Functions.llGetMass();
691 }
692
693 public void llCollisionFilter(string name, string id, int accept)
694 {
695 m_LSL_Functions.llCollisionFilter(name, id, accept);
696 }
697
698 public void llTakeControls(int controls, int accept, int pass_on)
699 {
700 m_LSL_Functions.llTakeControls(controls, accept, pass_on);
701 }
702
703 public void llReleaseControls()
704 {
705 m_LSL_Functions.llReleaseControls();
706 }
707
708 public void llAttachToAvatar(int attachment)
709 {
710 m_LSL_Functions.llAttachToAvatar(attachment);
711 }
712
713 public void llDetachFromAvatar()
714 {
715 m_LSL_Functions.llDetachFromAvatar();
716 }
717
718 public void llTakeCamera()
719 {
720 m_LSL_Functions.llTakeCamera();
721 }
722
723 public void llReleaseCamera()
724 {
725 m_LSL_Functions.llReleaseCamera();
726 }
727
728 public string llGetOwner()
729 {
730 return m_LSL_Functions.llGetOwner();
731 }
732
733 public void llInstantMessage(string user, string message)
734 {
735 m_LSL_Functions.llInstantMessage(user, message);
736 }
737
738 public void llEmail(string address, string subject, string message)
739 {
740 m_LSL_Functions.llEmail(address, subject, message);
741 }
742
743 public void llGetNextEmail(string address, string subject)
744 {
745 m_LSL_Functions.llGetNextEmail(address, subject);
746 }
747
748 public string llGetKey()
749 {
750 return m_LSL_Functions.llGetKey();
751 }
752
753 public void llSetBuoyancy(double buoyancy)
754 {
755 m_LSL_Functions.llSetBuoyancy(buoyancy);
756 }
757
758 public void llSetHoverHeight(double height, int water, double tau)
759 {
760 m_LSL_Functions.llSetHoverHeight(height, water, tau);
761 }
762
763 public void llStopHover()
764 {
765 m_LSL_Functions.llStopHover();
766 }
767
768 public void llMinEventDelay(double delay)
769 {
770 m_LSL_Functions.llMinEventDelay(delay);
771 }
772
773 public void llSoundPreload()
774 {
775 m_LSL_Functions.llSoundPreload();
776 }
777
778 public void llRotLookAt(rotation target, double strength, double damping)
779 {
780 m_LSL_Functions.llRotLookAt(target, strength, damping);
781 }
782
783 //
784 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
785 //
786 public int llStringLength(string str)
787 {
788 return m_LSL_Functions.llStringLength(str);
789 }
790
791 public void llStartAnimation(string anim)
792 {
793 m_LSL_Functions.llStartAnimation(anim);
794 }
795
796 public void llStopAnimation(string anim)
797 {
798 m_LSL_Functions.llStopAnimation(anim);
799 }
800
801 public void llPointAt()
802 {
803 m_LSL_Functions.llPointAt();
804 }
805
806 public void llStopPointAt()
807 {
808 m_LSL_Functions.llStopPointAt();
809 }
810
811 public void llTargetOmega(vector axis, double spinrate, double gain)
812 {
813 m_LSL_Functions.llTargetOmega(axis, spinrate, gain);
814 }
815
816 public int llGetStartParameter()
817 {
818 return m_LSL_Functions.llGetStartParameter();
819 }
820
821 public void llGodLikeRezObject(string inventory, vector pos)
822 {
823 m_LSL_Functions.llGodLikeRezObject(inventory, pos);
824 }
825
826 public void llRequestPermissions(string agent, int perm)
827 {
828 m_LSL_Functions.llRequestPermissions(agent, perm);
829 }
830
831 public string llGetPermissionsKey()
832 {
833 return m_LSL_Functions.llGetPermissionsKey();
834 }
835
836 public int llGetPermissions()
837 {
838 return m_LSL_Functions.llGetPermissions();
839 }
840
841 public int llGetLinkNumber()
842 {
843 return m_LSL_Functions.llGetLinkNumber();
844 }
845
846 public void llSetLinkColor(int linknumber, vector color, int face)
847 {
848 m_LSL_Functions.llSetLinkColor(linknumber, color, face);
849 }
850
851 public void llCreateLink(string target, int parent)
852 {
853 m_LSL_Functions.llCreateLink(target, parent);
854 }
855
856 public void llBreakLink(int linknum)
857 {
858 m_LSL_Functions.llBreakLink(linknum);
859 }
860
861 public void llBreakAllLinks()
862 {
863 m_LSL_Functions.llBreakAllLinks();
864 }
865
866 public string llGetLinkKey(int linknum)
867 {
868 return m_LSL_Functions.llGetLinkKey(linknum);
869 }
870
871 public string llGetLinkName(int linknum)
872 {
873 return m_LSL_Functions.llGetLinkName(linknum);
874 }
875
876 public int llGetInventoryNumber(int type)
877 {
878 return m_LSL_Functions.llGetInventoryNumber(type);
879 }
880
881 public string llGetInventoryName(int type, int number)
882 {
883 return m_LSL_Functions.llGetInventoryName(type, number);
884 }
885
886 //
887 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
888 //
889 public void llSetScriptState(string name, int run)
890 {
891 m_LSL_Functions.llSetScriptState(name, run);
892 }
893
894 public double llGetEnergy()
895 {
896 return m_LSL_Functions.llGetEnergy();
897 }
898
899 public void llGiveInventory(string destination, string inventory)
900 {
901 m_LSL_Functions.llGiveInventory(destination, inventory);
902 }
903
904 public void llRemoveInventory(string item)
905 {
906 m_LSL_Functions.llRemoveInventory(item);
907 }
908
909 public void llSetText(string text, vector color, double alpha)
910 {
911 m_LSL_Functions.llSetText(text, color, alpha);
912 }
913
914 public double llWater(vector offset)
915 {
916 return m_LSL_Functions.llWater(offset);
917 }
918
919 public void llPassTouches(int pass)
920 {
921 m_LSL_Functions.llPassTouches(pass);
922 }
923
924 public string llRequestAgentData(string id, int data)
925 {
926 return m_LSL_Functions.llRequestAgentData(id, data);
927 }
928
929 public string llRequestInventoryData(string name)
930 {
931 return m_LSL_Functions.llRequestInventoryData(name);
932 }
933
934 public void llSetDamage(double damage)
935 {
936 m_LSL_Functions.llSetDamage(damage);
937 }
938
939 public void llTeleportAgentHome(string agent)
940 {
941 m_LSL_Functions.llTeleportAgentHome(agent);
942 }
943
944 public void llModifyLand(int action, int brush)
945 {
946 m_LSL_Functions.llModifyLand(action, brush);
947 }
948
949 public void llCollisionSound(string impact_sound, double impact_volume)
950 {
951 m_LSL_Functions.llCollisionSound(impact_sound, impact_volume);
952 }
953
954 public void llCollisionSprite(string impact_sprite)
955 {
956 m_LSL_Functions.llCollisionSprite(impact_sprite);
957 }
958
959 public string llGetAnimation(string id)
960 {
961 return m_LSL_Functions.llGetAnimation(id);
962 }
963
964 public void llResetScript()
965 {
966 m_LSL_Functions.llResetScript();
967 }
968
969 public void llMessageLinked(int linknum, int num, string str, string id)
970 {
971 m_LSL_Functions.llMessageLinked(linknum, num, str, id);
972 }
973
974 public void llPushObject(string target, vector impulse, vector ang_impulse, int local)
975 {
976 m_LSL_Functions.llPushObject(target, impulse, ang_impulse, local);
977 }
978
979 public void llPassCollisions(int pass)
980 {
981 m_LSL_Functions.llPassCollisions(pass);
982 }
983
984 public string llGetScriptName()
985 {
986 return m_LSL_Functions.llGetScriptName();
987 }
988
989 public int llGetNumberOfSides()
990 {
991 return m_LSL_Functions.llGetNumberOfSides();
992 }
993
994 //
995 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
996 //
997 public rotation llAxisAngle2Rot(vector axis, double angle)
998 {
999 return m_LSL_Functions.llAxisAngle2Rot(axis, angle);
1000 }
1001
1002 public vector llRot2Axis(rotation rot)
1003 {
1004 return m_LSL_Functions.llRot2Axis(rot);
1005 }
1006
1007 public void llRot2Angle()
1008 {
1009 m_LSL_Functions.llRot2Angle();
1010 }
1011
1012 public double llAcos(double val)
1013 {
1014 return m_LSL_Functions.llAcos(val);
1015 }
1016
1017 public double llAsin(double val)
1018 {
1019 return m_LSL_Functions.llAsin(val);
1020 }
1021
1022 public double llAngleBetween(rotation a, rotation b)
1023 {
1024 return m_LSL_Functions.llAngleBetween(a, b);
1025 }
1026
1027 public string llGetInventoryKey(string name)
1028 {
1029 return m_LSL_Functions.llGetInventoryKey(name);
1030 }
1031
1032 public void llAllowInventoryDrop(int add)
1033 {
1034 m_LSL_Functions.llAllowInventoryDrop(add);
1035 }
1036
1037 public vector llGetSunDirection()
1038 {
1039 return m_LSL_Functions.llGetSunDirection();
1040 }
1041
1042 public vector llGetTextureOffset(int face)
1043 {
1044 return m_LSL_Functions.llGetTextureOffset(face);
1045 }
1046
1047 public vector llGetTextureScale(int side)
1048 {
1049 return m_LSL_Functions.llGetTextureScale(side);
1050 }
1051
1052 public double llGetTextureRot(int side)
1053 {
1054 return m_LSL_Functions.llGetTextureRot(side);
1055 }
1056
1057 public int llSubStringIndex(string source, string pattern)
1058 {
1059 return m_LSL_Functions.llSubStringIndex(source, pattern);
1060 }
1061
1062 public string llGetOwnerKey(string id)
1063 {
1064 return m_LSL_Functions.llGetOwnerKey(id);
1065 }
1066
1067 public vector llGetCenterOfMass()
1068 {
1069 return m_LSL_Functions.llGetCenterOfMass();
1070 }
1071
1072 public LSL_Types.list llListSort(LSL_Types.list src, int stride, int ascending)
1073 {
1074 return m_LSL_Functions.llListSort(src, stride, ascending);
1075 }
1076
1077 public int llGetListLength(LSL_Types.list src)
1078 {
1079 return m_LSL_Functions.llGetListLength(src);
1080 }
1081
1082 //
1083 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
1084 //
1085 public int llList2Integer(LSL_Types.list src, int index)
1086 {
1087 return m_LSL_Functions.llList2Integer(src, index);
1088 }
1089
1090 public double osList2Double(LSL_Types.list src, int index)
1091 {
1092 return m_LSL_Functions.osList2Double(src, index);
1093 }
1094
1095 public string llList2String(LSL_Types.list src, int index)
1096 {
1097 return m_LSL_Functions.llList2String(src, index);
1098 }
1099
1100 public string llList2Key(LSL_Types.list src, int index)
1101 {
1102 return m_LSL_Functions.llList2Key(src, index);
1103 }
1104
1105 public vector llList2Vector(LSL_Types.list src, int index)
1106 {
1107 return m_LSL_Functions.llList2Vector(src, index);
1108 }
1109
1110 public rotation llList2Rot(LSL_Types.list src, int index)
1111 {
1112 return m_LSL_Functions.llList2Rot(src, index);
1113 }
1114
1115 public LSL_Types.list llList2List(LSL_Types.list src, int start, int end)
1116 {
1117 return m_LSL_Functions.llList2List(src, start, end);
1118 }
1119
1120 public LSL_Types.list llDeleteSubList(LSL_Types.list src, int start, int end)
1121 {
1122 return m_LSL_Functions.llDeleteSubList(src, start, end);
1123 }
1124
1125 public int llGetListEntryType(LSL_Types.list src, int index)
1126 {
1127 return m_LSL_Functions.llGetListEntryType(src, index);
1128 }
1129
1130 public string llList2CSV(LSL_Types.list src)
1131 {
1132 return m_LSL_Functions.llList2CSV(src);
1133 }
1134
1135 public LSL_Types.list llCSV2List(string src)
1136 {
1137 return m_LSL_Functions.llCSV2List(src);
1138 }
1139
1140 public LSL_Types.list llListRandomize(LSL_Types.list src, int stride)
1141 {
1142 return m_LSL_Functions.llListRandomize(src, stride);
1143 }
1144
1145 public LSL_Types.list llList2ListStrided(LSL_Types.list src, int start, int end, int stride)
1146 {
1147 return m_LSL_Functions.llList2ListStrided(src, start, end, stride);
1148 }
1149
1150 public vector llGetRegionCorner()
1151 {
1152 return m_LSL_Functions.llGetRegionCorner();
1153 }
1154
1155 public LSL_Types.list llListInsertList(LSL_Types.list dest, LSL_Types.list src, int start)
1156 {
1157 return m_LSL_Functions.llListInsertList(dest, src, start);
1158 }
1159
1160 public int llListFindList(LSL_Types.list src, LSL_Types.list test)
1161 {
1162 return m_LSL_Functions.llListFindList(src, test);
1163 }
1164
1165 public string llGetObjectName()
1166 {
1167 return m_LSL_Functions.llGetObjectName();
1168 }
1169
1170 public void llSetObjectName(string name)
1171 {
1172 m_LSL_Functions.llSetObjectName(name);
1173 }
1174
1175 public string llGetDate()
1176 {
1177 return m_LSL_Functions.llGetDate();
1178 }
1179
1180 public int llEdgeOfWorld(vector pos, vector dir)
1181 {
1182 return m_LSL_Functions.llEdgeOfWorld(pos, dir);
1183 }
1184
1185 public int llGetAgentInfo(string id)
1186 {
1187 return m_LSL_Functions.llGetAgentInfo(id);
1188 }
1189
1190 //
1191 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
1192 //
1193 public void llAdjustSoundVolume(double volume)
1194 {
1195 m_LSL_Functions.llAdjustSoundVolume(volume);
1196 }
1197
1198 public void llSetSoundQueueing(int queue)
1199 {
1200 m_LSL_Functions.llSetSoundQueueing(queue);
1201 }
1202
1203 public void llSetSoundRadius(double radius)
1204 {
1205 m_LSL_Functions.llSetSoundRadius(radius);
1206 }
1207
1208 public string llKey2Name(string id)
1209 {
1210 return m_LSL_Functions.llKey2Name(id);
1211 }
1212
1213 public void llSetTextureAnim(int mode, int face, int sizex, int sizey, double start, double length, double rate)
1214 {
1215 m_LSL_Functions.llSetTextureAnim(mode, face, sizex, sizey, start, length, rate);
1216 }
1217
1218 public void llTriggerSoundLimited(string sound, double volume, vector top_north_east, vector bottom_south_west)
1219 {
1220 m_LSL_Functions.llTriggerSoundLimited(sound, volume, top_north_east, bottom_south_west);
1221 }
1222
1223 public void llEjectFromLand(string pest)
1224 {
1225 m_LSL_Functions.llEjectFromLand(pest);
1226 }
1227
1228 public void llParseString2List()
1229 {
1230 m_LSL_Functions.llParseString2List();
1231 }
1232
1233 public int llOverMyLand(string id)
1234 {
1235 return m_LSL_Functions.llOverMyLand(id);
1236 }
1237
1238 public string llGetLandOwnerAt(vector pos)
1239 {
1240 return m_LSL_Functions.llGetLandOwnerAt(pos);
1241 }
1242
1243 public string llGetNotecardLine(string name, int line)
1244 {
1245 return m_LSL_Functions.llGetNotecardLine(name, line);
1246 }
1247
1248 public vector llGetAgentSize(string id)
1249 {
1250 return m_LSL_Functions.llGetAgentSize(id);
1251 }
1252
1253 public int llSameGroup(string agent)
1254 {
1255 return m_LSL_Functions.llSameGroup(agent);
1256 }
1257
1258 public void llUnSit(string id)
1259 {
1260 m_LSL_Functions.llUnSit(id);
1261 }
1262
1263 public vector llGroundSlope(vector offset)
1264 {
1265 return m_LSL_Functions.llGroundSlope(offset);
1266 }
1267
1268 public vector llGroundNormal(vector offset)
1269 {
1270 return m_LSL_Functions.llGroundNormal(offset);
1271 }
1272
1273 public vector llGroundContour(vector offset)
1274 {
1275 return m_LSL_Functions.llGroundContour(offset);
1276 }
1277
1278 public int llGetAttached()
1279 {
1280 return m_LSL_Functions.llGetAttached();
1281 }
1282
1283 public int llGetFreeMemory()
1284 {
1285 return m_LSL_Functions.llGetFreeMemory();
1286 }
1287
1288 public string llGetRegionName()
1289 {
1290 return m_LSL_Functions.llGetRegionName();
1291 }
1292
1293 public double llGetRegionTimeDilation()
1294 {
1295 return m_LSL_Functions.llGetRegionTimeDilation();
1296 }
1297
1298 public double llGetRegionFPS()
1299 {
1300 return m_LSL_Functions.llGetRegionFPS();
1301 }
1302
1303 //
1304 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
1305 //
1306 public void llParticleSystem(List<Object> rules)
1307 {
1308 m_LSL_Functions.llParticleSystem(rules);
1309 }
1310
1311 public void llGroundRepel(double height, int water, double tau)
1312 {
1313 m_LSL_Functions.llGroundRepel(height, water, tau);
1314 }
1315
1316 public void llGiveInventoryList()
1317 {
1318 m_LSL_Functions.llGiveInventoryList();
1319 }
1320
1321 public void llSetVehicleType(int type)
1322 {
1323 m_LSL_Functions.llSetVehicleType(type);
1324 }
1325
1326 public void llSetVehicledoubleParam(int param, double value)
1327 {
1328 m_LSL_Functions.llSetVehicledoubleParam(param, value);
1329 }
1330
1331 public void llSetVehicleVectorParam(int param, vector vec)
1332 {
1333 m_LSL_Functions.llSetVehicleVectorParam(param, vec);
1334 }
1335
1336 public void llSetVehicleRotationParam(int param, rotation rot)
1337 {
1338 m_LSL_Functions.llSetVehicleRotationParam(param, rot);
1339 }
1340
1341 public void llSetVehicleFlags(int flags)
1342 {
1343 m_LSL_Functions.llSetVehicleFlags(flags);
1344 }
1345
1346 public void llRemoveVehicleFlags(int flags)
1347 {
1348 m_LSL_Functions.llRemoveVehicleFlags(flags);
1349 }
1350
1351 public void llSitTarget(vector offset, rotation rot)
1352 {
1353 m_LSL_Functions.llSitTarget(offset, rot);
1354 }
1355
1356 public string llAvatarOnSitTarget()
1357 {
1358 return m_LSL_Functions.llAvatarOnSitTarget();
1359 }
1360
1361 public void llAddToLandPassList(string avatar, double hours)
1362 {
1363 m_LSL_Functions.llAddToLandPassList(avatar, hours);
1364 }
1365
1366 public void llSetTouchText(string text)
1367 {
1368 m_LSL_Functions.llSetTouchText(text);
1369 }
1370
1371 public void llSetSitText(string text)
1372 {
1373 m_LSL_Functions.llSetSitText(text);
1374 }
1375
1376 public void llSetCameraEyeOffset(vector offset)
1377 {
1378 m_LSL_Functions.llSetCameraEyeOffset(offset);
1379 }
1380
1381 public void llSetCameraAtOffset(vector offset)
1382 {
1383 m_LSL_Functions.llSetCameraAtOffset(offset);
1384 }
1385
1386 public string llDumpList2String(LSL_Types.list src, string seperator)
1387 {
1388 return m_LSL_Functions.llDumpList2String(src, seperator);
1389 }
1390
1391 public void llScriptDanger(vector pos)
1392 {
1393 m_LSL_Functions.llScriptDanger(pos);
1394 }
1395
1396 public void llDialog(string avatar, string message, LSL_Types.list buttons, int chat_channel)
1397 {
1398 m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel);
1399 }
1400
1401 public void llVolumeDetect(int detect)
1402 {
1403 m_LSL_Functions.llVolumeDetect(detect);
1404 }
1405
1406 public void llResetOtherScript(string name)
1407 {
1408 m_LSL_Functions.llResetOtherScript(name);
1409 }
1410
1411 public int llGetScriptState(string name)
1412 {
1413 return m_LSL_Functions.llGetScriptState(name);
1414 }
1415
1416 public void llRemoteLoadScript()
1417 {
1418 m_LSL_Functions.llRemoteLoadScript();
1419 }
1420
1421 public void llSetRemoteScriptAccessPin(int pin)
1422 {
1423 m_LSL_Functions.llSetRemoteScriptAccessPin(pin);
1424 }
1425
1426 public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param)
1427 {
1428 m_LSL_Functions.llRemoteLoadScriptPin(target, name, pin, running, start_param);
1429 }
1430
1431 //
1432 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
1433 //
1434 public void llOpenRemoteDataChannel()
1435 {
1436 m_LSL_Functions.llOpenRemoteDataChannel();
1437 }
1438
1439 public string llSendRemoteData(string channel, string dest, int idata, string sdata)
1440 {
1441 return m_LSL_Functions.llSendRemoteData(channel, dest, idata, sdata);
1442 }
1443
1444 public void llRemoteDataReply(string channel, string message_id, string sdata, int idata)
1445 {
1446 m_LSL_Functions.llRemoteDataReply(channel, message_id, sdata, idata);
1447 }
1448
1449 public void llCloseRemoteDataChannel(string channel)
1450 {
1451 m_LSL_Functions.llCloseRemoteDataChannel(channel);
1452 }
1453
1454 public string llMD5String(string src, int nonce)
1455 {
1456 return m_LSL_Functions.llMD5String(src, nonce);
1457 }
1458
1459 public void llSetPrimitiveParams(LSL_Types.list rules)
1460 {
1461 m_LSL_Functions.llSetPrimitiveParams(rules);
1462 }
1463
1464 public string llStringToBase64(string str)
1465 {
1466 return m_LSL_Functions.llStringToBase64(str);
1467 }
1468
1469 public string llBase64ToString(string str)
1470 {
1471 return m_LSL_Functions.llBase64ToString(str);
1472 }
1473
1474 public void llXorBase64Strings()
1475 {
1476 m_LSL_Functions.llXorBase64Strings();
1477 }
1478
1479 public void llRemoteDataSetRegion()
1480 {
1481 m_LSL_Functions.llRemoteDataSetRegion();
1482 }
1483
1484 public double llLog10(double val)
1485 {
1486 return m_LSL_Functions.llLog10(val);
1487 }
1488
1489 public double llLog(double val)
1490 {
1491 return m_LSL_Functions.llLog(val);
1492 }
1493
1494 public LSL_Types.list llGetAnimationList(string id)
1495 {
1496 return m_LSL_Functions.llGetAnimationList(id);
1497 }
1498
1499 public void llSetParcelMusicURL(string url)
1500 {
1501 m_LSL_Functions.llSetParcelMusicURL(url);
1502 }
1503
1504 public vector llGetRootPosition()
1505 {
1506 return m_LSL_Functions.llGetRootPosition();
1507 }
1508
1509 public rotation llGetRootRotation()
1510 {
1511 return m_LSL_Functions.llGetRootRotation();
1512 }
1513
1514 public string llGetObjectDesc()
1515 {
1516 return m_LSL_Functions.llGetObjectDesc();
1517 }
1518
1519 public void llSetObjectDesc(string desc)
1520 {
1521 m_LSL_Functions.llSetObjectDesc(desc);
1522 }
1523
1524 public string llGetCreator()
1525 {
1526 return m_LSL_Functions.llGetCreator();
1527 }
1528
1529 public string llGetTimestamp()
1530 {
1531 return m_LSL_Functions.llGetTimestamp();
1532 }
1533
1534 public void llSetLinkAlpha(int linknumber, double alpha, int face)
1535 {
1536 m_LSL_Functions.llSetLinkAlpha(linknumber, alpha, face);
1537 }
1538
1539 public int llGetNumberOfPrims()
1540 {
1541 return m_LSL_Functions.llGetNumberOfPrims();
1542 }
1543
1544 public string llGetNumberOfNotecardLines(string name)
1545 {
1546 return m_LSL_Functions.llGetNumberOfNotecardLines(name);
1547 }
1548
1549 public LSL_Types.list llGetBoundingBox(string obj)
1550 {
1551 return m_LSL_Functions.llGetBoundingBox(obj);
1552 }
1553
1554 public vector llGetGeometricCenter()
1555 {
1556 return m_LSL_Functions.llGetGeometricCenter();
1557 }
1558
1559 public void llGetPrimitiveParams()
1560 {
1561 m_LSL_Functions.llGetPrimitiveParams();
1562 }
1563
1564 //
1565 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
1566 //
1567 public string llIntegerToBase64(int number)
1568 {
1569 return m_LSL_Functions.llIntegerToBase64(number);
1570 }
1571
1572 public int llBase64ToInteger(string str)
1573 {
1574 return m_LSL_Functions.llBase64ToInteger(str);
1575 }
1576
1577 public double llGetGMTclock()
1578 {
1579 return m_LSL_Functions.llGetGMTclock();
1580 }
1581
1582 public string llGetSimulatorHostname()
1583 {
1584 return m_LSL_Functions.llGetSimulatorHostname();
1585 }
1586
1587 public void llSetLocalRot(rotation rot)
1588 {
1589 m_LSL_Functions.llSetLocalRot(rot);
1590 }
1591
1592 public LSL_Types.list llParseStringKeepNulls(string src, LSL_Types.list seperators, LSL_Types.list spacers)
1593 {
1594 return m_LSL_Functions.llParseStringKeepNulls(src, seperators, spacers);
1595 }
1596
1597 public void llRezAtRoot(string inventory, vector position, vector velocity, rotation rot, int param)
1598 {
1599 m_LSL_Functions.llRezAtRoot(inventory, position, velocity, rot, param);
1600 }
1601
1602 public int llGetObjectPermMask(int mask)
1603 {
1604 return m_LSL_Functions.llGetObjectPermMask(mask);
1605 }
1606
1607 public void llSetObjectPermMask(int mask, int value)
1608 {
1609 m_LSL_Functions.llSetObjectPermMask(mask, value);
1610 }
1611
1612 public void llGetInventoryPermMask(string item, int mask)
1613 {
1614 m_LSL_Functions.llGetInventoryPermMask(item, mask);
1615 }
1616
1617 public void llSetInventoryPermMask(string item, int mask, int value)
1618 {
1619 m_LSL_Functions.llSetInventoryPermMask(item, mask, value);
1620 }
1621
1622 public string llGetInventoryCreator(string item)
1623 {
1624 return m_LSL_Functions.llGetInventoryCreator(item);
1625 }
1626
1627 public void llOwnerSay(string msg)
1628 {
1629 m_LSL_Functions.llOwnerSay(msg);
1630 }
1631
1632 public void llRequestSimulatorData(string simulator, int data)
1633 {
1634 m_LSL_Functions.llRequestSimulatorData(simulator, data);
1635 }
1636
1637 public void llForceMouselook(int mouselook)
1638 {
1639 m_LSL_Functions.llForceMouselook(mouselook);
1640 }
1641
1642 public double llGetObjectMass(string id)
1643 {
1644 return m_LSL_Functions.llGetObjectMass(id);
1645 }
1646
1647 public LSL_Types.list llListReplaceList(LSL_Types.list dest, LSL_Types.list src, int start, int end)
1648 {
1649 return m_LSL_Functions.llListReplaceList(dest, src, start, end);
1650 }
1651
1652 public void llLoadURL(string avatar_id, string message, string url)
1653 {
1654 m_LSL_Functions.llLoadURL(avatar_id, message, url);
1655 }
1656
1657 public void llParcelMediaCommandList(LSL_Types.list commandList)
1658 {
1659 m_LSL_Functions.llParcelMediaCommandList(commandList);
1660 }
1661
1662 public void llParcelMediaQuery()
1663 {
1664 m_LSL_Functions.llParcelMediaQuery();
1665 }
1666
1667 public int llModPow(int a, int b, int c)
1668 {
1669 return m_LSL_Functions.llModPow(a, b, c);
1670 }
1671
1672 //
1673 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
1674 //
1675 public int llGetInventoryType(string name)
1676 {
1677 return m_LSL_Functions.llGetInventoryType(name);
1678 }
1679
1680 public void llSetPayPrice(int price, LSL_Types.list quick_pay_buttons)
1681 {
1682 m_LSL_Functions.llSetPayPrice(price, quick_pay_buttons);
1683 }
1684
1685 public vector llGetCameraPos()
1686 {
1687 return m_LSL_Functions.llGetCameraPos();
1688 }
1689
1690 public rotation llGetCameraRot()
1691 {
1692 return m_LSL_Functions.llGetCameraRot();
1693 }
1694
1695 public void llSetPrimURL()
1696 {
1697 m_LSL_Functions.llSetPrimURL();
1698 }
1699
1700 public void llRefreshPrimURL()
1701 {
1702 m_LSL_Functions.llRefreshPrimURL();
1703 }
1704
1705 public string llEscapeURL(string url)
1706 {
1707 return m_LSL_Functions.llEscapeURL(url);
1708 }
1709
1710 public string llUnescapeURL(string url)
1711 {
1712 return m_LSL_Functions.llUnescapeURL(url);
1713 }
1714
1715 public void llMapDestination(string simname, vector pos, vector look_at)
1716 {
1717 m_LSL_Functions.llMapDestination(simname, pos, look_at);
1718 }
1719
1720 public void llAddToLandBanList(string avatar, double hours)
1721 {
1722 m_LSL_Functions.llAddToLandBanList(avatar, hours);
1723 }
1724
1725 public void llRemoveFromLandPassList(string avatar)
1726 {
1727 m_LSL_Functions.llRemoveFromLandPassList(avatar);
1728 }
1729
1730 public void llRemoveFromLandBanList(string avatar)
1731 {
1732 m_LSL_Functions.llRemoveFromLandBanList(avatar);
1733 }
1734
1735 public void llSetCameraParams(LSL_Types.list rules)
1736 {
1737 m_LSL_Functions.llSetCameraParams(rules);
1738 }
1739
1740 public void llClearCameraParams()
1741 {
1742 m_LSL_Functions.llClearCameraParams();
1743 }
1744
1745 public double llListStatistics(int operation, LSL_Types.list src)
1746 {
1747 return m_LSL_Functions.llListStatistics(operation, src);
1748 }
1749
1750 public int llGetUnixTime()
1751 {
1752 return m_LSL_Functions.llGetUnixTime();
1753 }
1754
1755 public int llGetParcelFlags(vector pos)
1756 {
1757 return m_LSL_Functions.llGetParcelFlags(pos);
1758 }
1759
1760 public int llGetRegionFlags()
1761 {
1762 return m_LSL_Functions.llGetRegionFlags();
1763 }
1764
1765 public string llXorBase64StringsCorrect(string str1, string str2)
1766 {
1767 return m_LSL_Functions.llXorBase64StringsCorrect(str1, str2);
1768 }
1769
1770 public string llHTTPRequest(string url, LSL_Types.list parameters, string body)
1771 {
1772 return m_LSL_Functions.llHTTPRequest(url, parameters, body);
1773 }
1774
1775 public void llResetLandBanList()
1776 {
1777 m_LSL_Functions.llResetLandBanList();
1778 }
1779
1780 public void llResetLandPassList()
1781 {
1782 m_LSL_Functions.llResetLandPassList();
1783 }
1784
1785 public int llGetParcelPrimCount(vector pos, int category, int sim_wide)
1786 {
1787 return m_LSL_Functions.llGetParcelPrimCount(pos, category, sim_wide);
1788 }
1789
1790 public LSL_Types.list llGetParcelPrimOwners(vector pos)
1791 {
1792 return m_LSL_Functions.llGetParcelPrimOwners(pos);
1793 }
1794
1795 public int llGetObjectPrimCount(string object_id)
1796 {
1797 return m_LSL_Functions.llGetObjectPrimCount(object_id);
1798 }
1799
1800 //
1801 // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs
1802 //
1803 public int llGetParcelMaxPrims(vector pos, int sim_wide)
1804 {
1805 return m_LSL_Functions.llGetParcelMaxPrims(pos, sim_wide);
1806 }
1807
1808 public LSL_Types.list llGetParcelDetails(vector pos, LSL_Types.list param)
1809 {
1810 return m_LSL_Functions.llGetParcelDetails(pos, param);
1811 }
1812
1813 //
1814 // OpenSim Functions
1815 //
1816 public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams,
1817 int timer)
1818 {
1819 return m_LSL_Functions.osSetDynamicTextureURL(dynamicID, contentType, url, extraParams, timer);
1820 }
1821
1822 public double osTerrainGetHeight(int x, int y)
1823 {
1824 return m_LSL_Functions.osTerrainGetHeight(x, y);
1825 }
1826
1827 public int osTerrainSetHeight(int x, int y, double val)
1828 {
1829 return m_LSL_Functions.osTerrainSetHeight(x, y, val);
1830 }
1831
1832 public int osRegionRestart(double seconds)
1833 {
1834 return m_LSL_Functions.osRegionRestart(seconds);
1835 }
1836
1837 // LSL CONSTANTS
1838 public const int TRUE = 1;
1839 public const int FALSE = 0;
1840 public const int STATUS_PHYSICS = 1;
1841 public const int STATUS_ROTATE_X = 2;
1842 public const int STATUS_ROTATE_Y = 4;
1843 public const int STATUS_ROTATE_Z = 8;
1844 public const int STATUS_PHANTOM = 16;
1845 public const int STATUS_SANDBOX = 32;
1846 public const int STATUS_BLOCK_GRAB = 64;
1847 public const int STATUS_DIE_AT_EDGE = 128;
1848 public const int STATUS_RETURN_AT_EDGE = 256;
1849 public const int AGENT = 1;
1850 public const int ACTIVE = 2;
1851 public const int PASSIVE = 4;
1852 public const int SCRIPTED = 8;
1853 public const int CONTROL_FWD = 1;
1854 public const int CONTROL_BACK = 2;
1855 public const int CONTROL_LEFT = 4;
1856 public const int CONTROL_RIGHT = 8;
1857 public const int CONTROL_UP = 16;
1858 public const int CONTROL_DOWN = 32;
1859 public const int CONTROL_ROT_LEFT = 256;
1860 public const int CONTROL_ROT_RIGHT = 512;
1861 public const int CONTROL_LBUTTON = 268435456;
1862 public const int CONTROL_ML_LBUTTON = 1073741824;
1863 public const int PERMISSION_DEBIT = 2;
1864 public const int PERMISSION_TAKE_CONTROLS = 4;
1865 public const int PERMISSION_REMAP_CONTROLS = 8;
1866 public const int PERMISSION_TRIGGER_ANIMATION = 16;
1867 public const int PERMISSION_ATTACH = 32;
1868 public const int PERMISSION_RELEASE_OWNERSHIP = 64;
1869 public const int PERMISSION_CHANGE_LINKS = 128;
1870 public const int PERMISSION_CHANGE_JOINTS = 256;
1871 public const int PERMISSION_CHANGE_PERMISSIONS = 512;
1872 public const int PERMISSION_TRACK_CAMERA = 1024;
1873 public const int AGENT_FLYING = 1;
1874 public const int AGENT_ATTACHMENTS = 2;
1875 public const int AGENT_SCRIPTED = 4;
1876 public const int AGENT_MOUSELOOK = 8;
1877 public const int AGENT_SITTING = 16;
1878 public const int AGENT_ON_OBJECT = 32;
1879 public const int AGENT_AWAY = 64;
1880 public const int AGENT_WALKING = 128;
1881 public const int AGENT_IN_AIR = 256;
1882 public const int AGENT_TYPING = 512;
1883 public const int AGENT_CROUCHING = 1024;
1884 public const int AGENT_BUSY = 2048;
1885 public const int AGENT_ALWAYS_RUN = 4096;
1886 public const int PSYS_PART_INTERP_COLOR_MASK = 1;
1887 public const int PSYS_PART_INTERP_SCALE_MASK = 2;
1888 public const int PSYS_PART_BOUNCE_MASK = 4;
1889 public const int PSYS_PART_WIND_MASK = 8;
1890 public const int PSYS_PART_FOLLOW_SRC_MASK = 16;
1891 public const int PSYS_PART_FOLLOW_VELOCITY_MASK = 32;
1892 public const int PSYS_PART_TARGET_POS_MASK = 64;
1893 public const int PSYS_PART_TARGET_LINEAR_MASK = 128;
1894 public const int PSYS_PART_EMISSIVE_MASK = 256;
1895 public const int PSYS_PART_FLAGS = 0;
1896 public const int PSYS_PART_START_COLOR = 1;
1897 public const int PSYS_PART_START_ALPHA = 2;
1898 public const int PSYS_PART_END_COLOR = 3;
1899 public const int PSYS_PART_END_ALPHA = 4;
1900 public const int PSYS_PART_START_SCALE = 5;
1901 public const int PSYS_PART_END_SCALE = 6;
1902 public const int PSYS_PART_MAX_AGE = 7;
1903 public const int PSYS_SRC_ACCEL = 8;
1904 public const int PSYS_SRC_PATTERN = 9;
1905 public const int PSYS_SRC_INNERANGLE = 10;
1906 public const int PSYS_SRC_OUTERANGLE = 11;
1907 public const int PSYS_SRC_TEXTURE = 12;
1908 public const int PSYS_SRC_BURST_RATE = 13;
1909 public const int PSYS_SRC_BURST_PART_COUNT = 15;
1910 public const int PSYS_SRC_BURST_RADIUS = 16;
1911 public const int PSYS_SRC_BURST_SPEED_MIN = 17;
1912 public const int PSYS_SRC_BURST_SPEED_MAX = 18;
1913 public const int PSYS_SRC_MAX_AGE = 19;
1914 public const int PSYS_SRC_TARGET_KEY = 20;
1915 public const int PSYS_SRC_OMEGA = 21;
1916 public const int PSYS_SRC_ANGLE_BEGIN = 22;
1917 public const int PSYS_SRC_ANGLE_END = 23;
1918 public const int PSYS_SRC_PATTERN_DROP = 1;
1919 public const int PSYS_SRC_PATTERN_EXPLODE = 2;
1920 public const int PSYS_SRC_PATTERN_ANGLE = 4;
1921 public const int PSYS_SRC_PATTERN_ANGLE_CONE = 8;
1922 public const int PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY = 16;
1923 public const int VEHICLE_TYPE_NONE = 0;
1924 public const int VEHICLE_TYPE_SLED = 1;
1925 public const int VEHICLE_TYPE_CAR = 2;
1926 public const int VEHICLE_TYPE_BOAT = 3;
1927 public const int VEHICLE_TYPE_AIRPLANE = 4;
1928 public const int VEHICLE_TYPE_BALLOON = 5;
1929 public const int VEHICLE_LINEAR_FRICTION_TIMESCALE = 16;
1930 public const int VEHICLE_ANGULAR_FRICTION_TIMESCALE = 17;
1931 public const int VEHICLE_LINEAR_MOTOR_DIRECTION = 18;
1932 public const int VEHICLE_LINEAR_MOTOR_OFFSET = 20;
1933 public const int VEHICLE_ANGULAR_MOTOR_DIRECTION = 19;
1934 public const int VEHICLE_HOVER_HEIGHT = 24;
1935 public const int VEHICLE_HOVER_EFFICIENCY = 25;
1936 public const int VEHICLE_HOVER_TIMESCALE = 26;
1937 public const int VEHICLE_BUOYANCY = 27;
1938 public const int VEHICLE_LINEAR_DEFLECTION_EFFICIENCY = 28;
1939 public const int VEHICLE_LINEAR_DEFLECTION_TIMESCALE = 29;
1940 public const int VEHICLE_LINEAR_MOTOR_TIMESCALE = 30;
1941 public const int VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE = 31;
1942 public const int VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY = 32;
1943 public const int VEHICLE_ANGULAR_DEFLECTION_TIMESCALE = 33;
1944 public const int VEHICLE_ANGULAR_MOTOR_TIMESCALE = 34;
1945 public const int VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE = 35;
1946 public const int VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY = 36;
1947 public const int VEHICLE_VERTICAL_ATTRACTION_TIMESCALE = 37;
1948 public const int VEHICLE_BANKING_EFFICIENCY = 38;
1949 public const int VEHICLE_BANKING_MIX = 39;
1950 public const int VEHICLE_BANKING_TIMESCALE = 40;
1951 public const int VEHICLE_REFERENCE_FRAME = 44;
1952 public const int VEHICLE_FLAG_NO_DEFLECTION_UP = 1;
1953 public const int VEHICLE_FLAG_LIMIT_ROLL_ONLY = 2;
1954 public const int VEHICLE_FLAG_HOVER_WATER_ONLY = 4;
1955 public const int VEHICLE_FLAG_HOVER_TERRAIN_ONLY = 8;
1956 public const int VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT = 16;
1957 public const int VEHICLE_FLAG_HOVER_UP_ONLY = 32;
1958 public const int VEHICLE_FLAG_LIMIT_MOTOR_UP = 64;
1959 public const int VEHICLE_FLAG_MOUSELOOK_STEER = 128;
1960 public const int VEHICLE_FLAG_MOUSELOOK_BANK = 256;
1961 public const int VEHICLE_FLAG_CAMERA_DECOUPLED = 512;
1962 public const int INVENTORY_ALL = -1;
1963 public const int INVENTORY_NONE = -1;
1964 public const int INVENTORY_TEXTURE = 0;
1965 public const int INVENTORY_SOUND = 1;
1966 public const int INVENTORY_LANDMARK = 3;
1967 public const int INVENTORY_CLOTHING = 5;
1968 public const int INVENTORY_OBJECT = 6;
1969 public const int INVENTORY_NOTECARD = 7;
1970 public const int INVENTORY_SCRIPT = 10;
1971 public const int INVENTORY_BODYPART = 13;
1972 public const int INVENTORY_ANIMATION = 20;
1973 public const int INVENTORY_GESTURE = 21;
1974 public const int ATTACH_CHEST = 1;
1975 public const int ATTACH_HEAD = 2;
1976 public const int ATTACH_LSHOULDER = 3;
1977 public const int ATTACH_RSHOULDER = 4;
1978 public const int ATTACH_LHAND = 5;
1979 public const int ATTACH_RHAND = 6;
1980 public const int ATTACH_LFOOT = 7;
1981 public const int ATTACH_RFOOT = 8;
1982 public const int ATTACH_BACK = 9;
1983 public const int ATTACH_PELVIS = 10;
1984 public const int ATTACH_MOUTH = 11;
1985 public const int ATTACH_CHIN = 12;
1986 public const int ATTACH_LEAR = 13;
1987 public const int ATTACH_REAR = 14;
1988 public const int ATTACH_LEYE = 15;
1989 public const int ATTACH_REYE = 16;
1990 public const int ATTACH_NOSE = 17;
1991 public const int ATTACH_RUARM = 18;
1992 public const int ATTACH_RLARM = 19;
1993 public const int ATTACH_LUARM = 20;
1994 public const int ATTACH_LLARM = 21;
1995 public const int ATTACH_RHIP = 22;
1996 public const int ATTACH_RULEG = 23;
1997 public const int ATTACH_RLLEG = 24;
1998 public const int ATTACH_LHIP = 25;
1999 public const int ATTACH_LULEG = 26;
2000 public const int ATTACH_LLLEG = 27;
2001 public const int ATTACH_BELLY = 28;
2002 public const int ATTACH_RPEC = 29;
2003 public const int ATTACH_LPEC = 30;
2004 public const int LAND_LEVEL = 0;
2005 public const int LAND_RAISE = 1;
2006 public const int LAND_LOWER = 2;
2007 public const int LAND_SMOOTH = 3;
2008 public const int LAND_NOISE = 4;
2009 public const int LAND_REVERT = 5;
2010 public const int LAND_SMALL_BRUSH = 1;
2011 public const int LAND_MEDIUM_BRUSH = 2;
2012 public const int LAND_LARGE_BRUSH = 3;
2013 public const int DATA_ONLINE = 1;
2014 public const int DATA_NAME = 2;
2015 public const int DATA_BORN = 3;
2016 public const int DATA_RATING = 4;
2017 public const int DATA_SIM_POS = 5;
2018 public const int DATA_SIM_STATUS = 6;
2019 public const int DATA_SIM_RATING = 7;
2020 public const int ANIM_ON = 1;
2021 public const int LOOP = 2;
2022 public const int REVERSE = 4;
2023 public const int PING_PONG = 8;
2024 public const int SMOOTH = 16;
2025 public const int ROTATE = 32;
2026 public const int SCALE = 64;
2027 public const int ALL_SIDES = -1;
2028 public const int LINK_SET = -1;
2029 public const int LINK_ROOT = 1;
2030 public const int LINK_ALL_OTHERS = -2;
2031 public const int LINK_ALL_CHILDREN = -3;
2032 public const int LINK_THIS = -4;
2033 public const int CHANGED_INVENTORY = 1;
2034 public const int CHANGED_COLOR = 2;
2035 public const int CHANGED_SHAPE = 4;
2036 public const int CHANGED_SCALE = 8;
2037 public const int CHANGED_TEXTURE = 16;
2038 public const int CHANGED_LINK = 32;
2039 public const int CHANGED_ALLOWED_DROP = 64;
2040 public const int CHANGED_OWNER = 128;
2041 public const int TYPE_INVALID = 0;
2042 public const int TYPE_INTEGER = 1;
2043 public const int TYPE_double = 2;
2044 public const int TYPE_STRING = 3;
2045 public const int TYPE_KEY = 4;
2046 public const int TYPE_VECTOR = 5;
2047 public const int TYPE_ROTATION = 6;
2048 public const int REMOTE_DATA_CHANNEL = 1;
2049 public const int REMOTE_DATA_REQUEST = 2;
2050 public const int REMOTE_DATA_REPLY = 3;
2051
2052 public const int PRIM_MATERIAL = 2;
2053 public const int PRIM_PHYSICS = 3;
2054 public const int PRIM_TEMP_ON_REZ = 4;
2055 public const int PRIM_PHANTOM = 5;
2056 public const int PRIM_POSITION = 6;
2057 public const int PRIM_SIZE = 7;
2058 public const int PRIM_ROTATION = 8;
2059 public const int PRIM_TYPE = 9;
2060 public const int PRIM_TEXTURE = 17;
2061 public const int PRIM_COLOR = 18;
2062 public const int PRIM_BUMP_SHINY = 19;
2063 public const int PRIM_FULLBRIGHT = 20;
2064 public const int PRIM_FLEXIBLE = 21;
2065 public const int PRIM_TEXGEN = 22;
2066 public const int PRIM_CAST_SHADOWS = 24; // Not implemented, here for completeness sake
2067 public const int PRIM_POINT_LIGHT = 23; // Huh?
2068 public const int PRIM_TEXGEN_DEFAULT = 0;
2069 public const int PRIM_TEXGEN_PLANAR = 1;
2070 public const int PRIM_TYPE_BOX = 0;
2071 public const int PRIM_TYPE_CYLINDER = 1;
2072 public const int PRIM_TYPE_PRISM = 2;
2073 public const int PRIM_TYPE_SPHERE = 3;
2074 public const int PRIM_TYPE_TORUS = 4;
2075 public const int PRIM_TYPE_TUBE = 5;
2076 public const int PRIM_TYPE_RING = 6;
2077 public const int PRIM_TYPE_SCULPT = 7;
2078 public const int PRIM_HOLE_DEFAULT = 0;
2079 public const int PRIM_HOLE_CIRCLE = 16;
2080 public const int PRIM_HOLE_SQUARE = 32;
2081 public const int PRIM_HOLE_TRIANGLE = 48;
2082 public const int PRIM_MATERIAL_STONE = 0;
2083 public const int PRIM_MATERIAL_METAL = 1;
2084 public const int PRIM_MATERIAL_GLASS = 2;
2085 public const int PRIM_MATERIAL_WOOD = 3;
2086 public const int PRIM_MATERIAL_FLESH = 4;
2087 public const int PRIM_MATERIAL_PLASTIC = 5;
2088 public const int PRIM_MATERIAL_RUBBER = 6;
2089 public const int PRIM_MATERIAL_LIGHT = 7;
2090 public const int PRIM_SHINY_NONE = 0;
2091 public const int PRIM_SHINY_LOW = 1;
2092 public const int PRIM_SHINY_MEDIUM = 2;
2093 public const int PRIM_SHINY_HIGH = 3;
2094 public const int PRIM_BUMP_NONE = 0;
2095 public const int PRIM_BUMP_BRIGHT = 1;
2096 public const int PRIM_BUMP_DARK = 2;
2097 public const int PRIM_BUMP_WOOD = 3;
2098 public const int PRIM_BUMP_BARK = 4;
2099 public const int PRIM_BUMP_BRICKS = 5;
2100 public const int PRIM_BUMP_CHECKER = 6;
2101 public const int PRIM_BUMP_CONCRETE = 7;
2102 public const int PRIM_BUMP_TILE = 8;
2103 public const int PRIM_BUMP_STONE = 9;
2104 public const int PRIM_BUMP_DISKS = 10;
2105 public const int PRIM_BUMP_GRAVEL = 11;
2106 public const int PRIM_BUMP_BLOBS = 12;
2107 public const int PRIM_BUMP_SIDING = 13;
2108 public const int PRIM_BUMP_LARGETILE = 14;
2109 public const int PRIM_BUMP_STUCCO = 15;
2110 public const int PRIM_BUMP_SUCTION = 16;
2111 public const int PRIM_BUMP_WEAVE = 17;
2112
2113 public const int PRIM_SCULPT_TYPE_SPHERE = 1;
2114 public const int PRIM_SCULPT_TYPE_TORUS = 2;
2115 public const int PRIM_SCULPT_TYPE_PLANE = 3;
2116 public const int PRIM_SCULPT_TYPE_CYLINDER = 4;
2117
2118
2119 public const int MASK_BASE = 0;
2120 public const int MASK_OWNER = 1;
2121 public const int MASK_GROUP = 2;
2122 public const int MASK_EVERYONE = 3;
2123 public const int MASK_NEXT = 4;
2124 public const int PERM_TRANSFER = 8192;
2125 public const int PERM_MODIFY = 16384;
2126 public const int PERM_COPY = 32768;
2127 public const int PERM_MOVE = 524288;
2128 public const int PERM_ALL = 2147483647;
2129 public const int PARCEL_MEDIA_COMMAND_STOP = 0;
2130 public const int PARCEL_MEDIA_COMMAND_PAUSE = 1;
2131 public const int PARCEL_MEDIA_COMMAND_PLAY = 2;
2132 public const int PARCEL_MEDIA_COMMAND_LOOP = 3;
2133 public const int PARCEL_MEDIA_COMMAND_TEXTURE = 4;
2134 public const int PARCEL_MEDIA_COMMAND_URL = 5;
2135 public const int PARCEL_MEDIA_COMMAND_TIME = 6;
2136 public const int PARCEL_MEDIA_COMMAND_AGENT = 7;
2137 public const int PARCEL_MEDIA_COMMAND_UNLOAD = 8;
2138 public const int PARCEL_MEDIA_COMMAND_AUTO_ALIGN = 9;
2139 public const int PAY_HIDE = -1;
2140 public const int PAY_DEFAULT = -2;
2141 public const string NULL_KEY = "00000000-0000-0000-0000-000000000000";
2142 public const string EOF = "\n\n\n";
2143 public const double PI = 3.14159274f;
2144 public const double TWO_PI = 6.28318548f;
2145 public const double PI_BY_TWO = 1.57079637f;
2146 public const double DEG_TO_RAD = 0.01745329238f;
2147 public const double RAD_TO_DEG = 57.29578f;
2148 public const double SQRT2 = 1.414213538f;
2149
2150 // Can not be public const?
2151 public vector ZERO_VECTOR = new vector(0, 0, 0);
2152 public rotation ZERO_ROTATION = new rotation(0, 0, 0, 0);
2153 }
2154} \ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs
deleted file mode 100644
index 1d9ca96..0000000
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs
+++ /dev/null
@@ -1,3015 +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.Runtime.Remoting.Lifetime;
32using System.Text;
33using System.Threading;
34using Axiom.Math;
35using libsecondlife;
36using OpenSim.Framework;
37using OpenSim.Region.Environment.Interfaces;
38using OpenSim.Region.Environment.Scenes;
39using OpenSim.Region.ScriptEngine.Common;
40using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL;
41
42namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
43{
44 //
45 // !!!IMPORTANT!!!
46 //
47 // REMEMBER TO UPDATE http://opensimulator.org/wiki/LlFunction_implementation_status
48 //
49
50 // Notes:
51 // * If any function here needs to execute a LSL event in the script, use instance of "EventQueueManager" in "ScriptEngine".
52 // * If any function here needs to do some more advanced stuff like waiting for IO callbacks or similar that takes a long time then use "llSetTimerEvent" function as example.
53 // There is a class called "LSLLongCmdHandler" that is used for long LSL commands.
54
55
56 /// <summary>
57 /// Contains all LSL ll-functions. This class will be in Default AppDomain.
58 /// </summary>
59 public class LSL_BuiltIn_Commands : MarshalByRefObject, LSL_BuiltIn_Commands_Interface
60 {
61 private ASCIIEncoding enc = new ASCIIEncoding();
62 private ScriptEngine m_ScriptEngine;
63 private SceneObjectPart m_host;
64 private uint m_localID;
65 private LLUUID m_itemID;
66 private bool throwErrorOnNotImplemented = true;
67
68 public LSL_BuiltIn_Commands(ScriptEngine ScriptEngine, SceneObjectPart host, uint localID, LLUUID itemID)
69 {
70 m_ScriptEngine = ScriptEngine;
71 m_host = host;
72 m_localID = localID;
73 m_itemID = itemID;
74
75 //MainLog.Instance.Notice("ScriptEngine", "LSL_BaseClass.Start() called. Hosted by [" + m_host.Name + ":" + m_host.UUID + "@" + m_host.AbsolutePosition + "]");
76 }
77
78 private DateTime m_timer = DateTime.Now;
79 private string m_state = "default";
80
81 public string State()
82 {
83 return m_state;
84 }
85
86 // Object never expires
87 public override Object InitializeLifetimeService()
88 {
89 //Console.WriteLine("LSL_BuiltIn_Commands: InitializeLifetimeService()");
90 // return null;
91 ILease lease = (ILease)base.InitializeLifetimeService();
92
93 if (lease.CurrentState == LeaseState.Initial)
94 {
95 lease.InitialLeaseTime = TimeSpan.Zero; // TimeSpan.FromMinutes(1);
96 // lease.SponsorshipTimeout = TimeSpan.FromMinutes(2);
97 // lease.RenewOnCallTime = TimeSpan.FromSeconds(2);
98 }
99 return lease;
100 }
101
102 public Scene World
103 {
104 get { return m_ScriptEngine.World; }
105 }
106
107 //These are the implementations of the various ll-functions used by the LSL scripts.
108 //starting out, we use the System.Math library for trig functions. - ckrinke 8-14-07
109 public double llSin(double f)
110 {
111
112 return (double)Math.Sin(f);
113 }
114
115 public double llCos(double f)
116 {
117 return (double)Math.Cos(f);
118 }
119
120 public double llTan(double f)
121 {
122 return (double)Math.Tan(f);
123 }
124
125 public double llAtan2(double x, double y)
126 {
127 return (double)Math.Atan2(y, x);
128 }
129
130 public double llSqrt(double f)
131 {
132 return (double)Math.Sqrt(f);
133 }
134
135 public double llPow(double fbase, double fexponent)
136 {
137 return (double)Math.Pow(fbase, fexponent);
138 }
139
140 public int llAbs(int i)
141 {
142 return (int)Math.Abs(i);
143 }
144
145 public double llFabs(double f)
146 {
147 return (double)Math.Abs(f);
148 }
149
150 public double llFrand(double mag)
151 {
152 lock (Util.RandomClass)
153 {
154 return Util.RandomClass.NextDouble() * mag;
155 }
156 }
157
158 public int llFloor(double f)
159 {
160 return (int)Math.Floor(f);
161 }
162
163 public int llCeil(double f)
164 {
165 return (int)Math.Ceiling(f);
166 }
167
168 public int llRound(double f)
169 {
170 return (int)Math.Round(f, 0);
171 }
172
173 //This next group are vector operations involving squaring and square root. ckrinke
174 public double llVecMag(LSL_Types.Vector3 v)
175 {
176 return (v.x * v.x + v.y * v.y + v.z * v.z);
177 }
178
179 public LSL_Types.Vector3 llVecNorm(LSL_Types.Vector3 v)
180 {
181 double mag = v.x * v.x + v.y * v.y + v.z * v.z;
182 LSL_Types.Vector3 nor = new LSL_Types.Vector3();
183 nor.x = v.x / mag;
184 nor.y = v.y / mag;
185 nor.z = v.z / mag;
186 return nor;
187 }
188
189 public double llVecDist(LSL_Types.Vector3 a, LSL_Types.Vector3 b)
190 {
191 double dx = a.x - b.x;
192 double dy = a.y - b.y;
193 double dz = a.z - b.z;
194 return Math.Sqrt(dx * dx + dy * dy + dz * dz);
195 }
196
197 //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke
198 public LSL_Types.Vector3 llRot2Euler(LSL_Types.Quaternion r)
199 {
200 //This implementation is from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions. ckrinke
201 LSL_Types.Quaternion t = new LSL_Types.Quaternion(r.x * r.x, r.y * r.y, r.z * r.z, r.s * r.s);
202 double m = (t.x + t.y + t.z + t.s);
203 if (m == 0) return new LSL_Types.Vector3();
204 double n = 2 * (r.y * r.s + r.x * r.z);
205 double p = m * m - n * n;
206 if (p > 0)
207 return new LSL_Types.Vector3(Math.Atan2(2.0 * (r.x * r.s - r.y * r.z), (-t.x - t.y + t.z + t.s)),
208 Math.Atan2(n, Math.Sqrt(p)),
209 Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s)));
210 else if (n > 0)
211 return new LSL_Types.Vector3(0.0, Math.PI / 2, Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z));
212 else
213 return new LSL_Types.Vector3(0.0, -Math.PI / 2, Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z));
214 }
215
216 public LSL_Types.Quaternion llEuler2Rot(LSL_Types.Vector3 v)
217 {
218 //this comes from from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions but is incomplete as of 8/19/07
219 float err = 0.00001f;
220 double ax = Math.Sin(v.x / 2);
221 double aw = Math.Cos(v.x / 2);
222 double by = Math.Sin(v.y / 2);
223 double bw = Math.Cos(v.y / 2);
224 double cz = Math.Sin(v.z / 2);
225 double cw = Math.Cos(v.z / 2);
226 LSL_Types.Quaternion a1 = new LSL_Types.Quaternion(0.0, 0.0, cz, cw);
227 LSL_Types.Quaternion a2 = new LSL_Types.Quaternion(0.0, by, 0.0, bw);
228 LSL_Types.Quaternion a3 = new LSL_Types.Quaternion(ax, 0.0, 0.0, aw);
229 LSL_Types.Quaternion a = (a1 * a2) * a3;
230 //This multiplication doesnt compile, yet. a = a1 * a2 * a3;
231 LSL_Types.Quaternion b = new LSL_Types.Quaternion(ax * bw * cw + aw * by * cz,
232 aw * by * cw - ax * bw * cz, aw * bw * cz + ax * by * cw,
233 aw * bw * cw - ax * by * cz);
234 LSL_Types.Quaternion c = new LSL_Types.Quaternion();
235 //This addition doesnt compile yet c = a + b;
236 LSL_Types.Quaternion d = new LSL_Types.Quaternion();
237 //This addition doesnt compile yet d = a - b;
238 if ((Math.Abs(c.x) > err && Math.Abs(d.x) > err) ||
239 (Math.Abs(c.y) > err && Math.Abs(d.y) > err) ||
240 (Math.Abs(c.z) > err && Math.Abs(d.z) > err) ||
241 (Math.Abs(c.s) > err && Math.Abs(d.s) > err))
242 {
243 return b;
244 //return a new Quaternion that is null until I figure this out
245 // return b;
246 // return a;
247 }
248 return a;
249 }
250
251 public LSL_Types.Quaternion llAxes2Rot(LSL_Types.Vector3 fwd, LSL_Types.Vector3 left, LSL_Types.Vector3 up)
252 {
253 return new LSL_Types.Quaternion();
254 }
255
256 public LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r)
257 {
258 return new LSL_Types.Vector3();
259 }
260
261 public LSL_Types.Vector3 llRot2Left(LSL_Types.Quaternion r)
262 {
263 return new LSL_Types.Vector3();
264 }
265
266 public LSL_Types.Vector3 llRot2Up(LSL_Types.Quaternion r)
267 {
268 return new LSL_Types.Vector3();
269 }
270 public LSL_Types.Quaternion llRotBetween(LSL_Types.Vector3 a, LSL_Types.Vector3 b)
271 {
272 //A and B should both be normalized
273
274 double dotProduct = LSL_Types.Vector3.Dot(a, b);
275 LSL_Types.Vector3 crossProduct = LSL_Types.Vector3.Cross(a, b);
276 double magProduct = LSL_Types.Vector3.Mag(a) * LSL_Types.Vector3.Mag(b);
277 double angle = Math.Acos(dotProduct / magProduct);
278 LSL_Types.Vector3 axis = LSL_Types.Vector3.Norm(crossProduct);
279 double s = Math.Sin(angle / 2);
280
281 return new LSL_Types.Quaternion(axis.x * s, axis.y * s, axis.z * s, (float)Math.Cos(angle / 2));
282 }
283 public void llWhisper(int channelID, string text)
284 {
285 World.SimChat(Helpers.StringToField(text),
286 ChatTypeEnum.Whisper, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID);
287
288 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
289 wComm.DeliverMessage(m_host.UUID.ToString(), ChatTypeEnum.Whisper, channelID, m_host.Name, text);
290 }
291
292 public void llSay(int channelID, string text)
293 {
294 World.SimChat(Helpers.StringToField(text),
295 ChatTypeEnum.Say, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID);
296
297 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
298 wComm.DeliverMessage(m_host.UUID.ToString(), ChatTypeEnum.Say, channelID, m_host.Name, text);
299 }
300
301 public void llShout(int channelID, string text)
302 {
303 World.SimChat(Helpers.StringToField(text),
304 ChatTypeEnum.Shout, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID);
305
306 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
307 wComm.DeliverMessage(m_host.UUID.ToString(), ChatTypeEnum.Shout, channelID, m_host.Name, text);
308 }
309
310 public int llListen(int channelID, string name, string ID, string msg)
311 {
312 if (ID == "")
313 {
314 ID = LLUUID.Zero.ToString();
315 }
316 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
317 return wComm.Listen(m_localID, m_itemID, m_host.UUID, channelID, name, ID, msg);
318 }
319
320 public void llListenControl(int number, int active)
321 {
322 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
323 wComm.ListenControl(number, active);
324 }
325
326 public void llListenRemove(int number)
327 {
328 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
329 wComm.ListenRemove(number);
330 }
331
332 public void llSensor(string name, string id, int type, double range, double arc)
333 {
334 NotImplemented("llSensor");
335 return;
336 }
337
338 public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate)
339 {
340 NotImplemented("llSensorRepeat");
341 return;
342 }
343
344 public void llSensorRemove()
345 {
346 NotImplemented("llSensorRemove");
347 return;
348 }
349
350 public string llDetectedName(int number)
351 {
352 NotImplemented("llDetectedName");
353 return "";
354 }
355
356 public string llDetectedKey(int number)
357 {
358 NotImplemented("llDetectedKey");
359 return "";
360 }
361
362 public string llDetectedOwner(int number)
363 {
364 NotImplemented("llDetectedOwner");
365 return "";
366 }
367
368 public int llDetectedType(int number)
369 {
370 NotImplemented("llDetectedType");
371 return 0;
372 }
373
374 public LSL_Types.Vector3 llDetectedPos(int number)
375 {
376 NotImplemented("llDetectedPos");
377 return new LSL_Types.Vector3();
378 }
379
380 public LSL_Types.Vector3 llDetectedVel(int number)
381 {
382 NotImplemented("llDetectedVel");
383 return new LSL_Types.Vector3();
384 }
385
386 public LSL_Types.Vector3 llDetectedGrab(int number)
387 {
388 NotImplemented("llDetectedGrab");
389 return new LSL_Types.Vector3();
390 }
391
392 public LSL_Types.Quaternion llDetectedRot(int number)
393 {
394 NotImplemented("llDetectedRot");
395 return new LSL_Types.Quaternion();
396 }
397
398 public int llDetectedGroup(int number)
399 {
400 NotImplemented("llDetectedGroup");
401 return 0;
402 }
403
404 public int llDetectedLinkNumber(int number)
405 {
406 NotImplemented("llDetectedLinkNumber");
407 return 0;
408 }
409
410 public void llDie()
411 {
412 World.DeleteSceneObjectGroup(m_host.ParentGroup);
413 return;
414 }
415
416 public double llGround(LSL_Types.Vector3 offset)
417 {
418 int x = (int)(m_host.AbsolutePosition.X + offset.x);
419 int y = (int)(m_host.AbsolutePosition.Y + offset.y);
420 return World.GetLandHeight(x, y);
421 }
422
423 public double llCloud(LSL_Types.Vector3 offset)
424 {
425 NotImplemented("llCloud");
426 return 0;
427 }
428
429 public LSL_Types.Vector3 llWind(LSL_Types.Vector3 offset)
430 {
431 NotImplemented("llWind");
432 return new LSL_Types.Vector3();
433 }
434
435 public void llSetStatus(int status, int value)
436 {
437 NotImplemented("llSetStatus");
438 return;
439 }
440
441 public int llGetStatus(int status)
442 {
443 NotImplemented("llGetStatus");
444 return 0;
445 }
446
447 public void llSetScale(LSL_Types.Vector3 scale)
448 {
449 // TODO: this needs to trigger a persistance save as well
450 LLVector3 tmp = m_host.Scale;
451 tmp.X = (float)scale.x;
452 tmp.Y = (float)scale.y;
453 tmp.Z = (float)scale.z;
454 m_host.Scale = tmp;
455 m_host.SendFullUpdateToAllClients();
456 return;
457 }
458
459 public LSL_Types.Vector3 llGetScale()
460 {
461 return new LSL_Types.Vector3(m_host.Scale.X, m_host.Scale.Y, m_host.Scale.Z);
462 }
463
464 public void llSetColor(LSL_Types.Vector3 color, int face)
465 {
466 LLObject.TextureEntry tex = m_host.Shape.Textures;
467 LLColor texcolor;
468 if (face > -1)
469 {
470 texcolor = tex.CreateFace((uint)face).RGBA;
471 texcolor.R = (float)Math.Abs(color.x - 1);
472 texcolor.G = (float)Math.Abs(color.y - 1);
473 texcolor.B = (float)Math.Abs(color.z - 1);
474 tex.FaceTextures[face].RGBA = texcolor;
475 m_host.UpdateTexture(tex);
476 return;
477 }
478 else if (face == -1)
479 {
480 for (uint i = 0; i < 32; i++)
481 {
482 if (tex.FaceTextures[i] != null)
483 {
484 texcolor = tex.FaceTextures[i].RGBA;
485 texcolor.R = (float)Math.Abs(color.x - 1);
486 texcolor.G = (float)Math.Abs(color.y - 1);
487 texcolor.B = (float)Math.Abs(color.z - 1);
488 tex.FaceTextures[i].RGBA = texcolor;
489 }
490 texcolor = tex.DefaultTexture.RGBA;
491 texcolor.R = (float)Math.Abs(color.x - 1);
492 texcolor.G = (float)Math.Abs(color.y - 1);
493 texcolor.B = (float)Math.Abs(color.z - 1);
494 tex.DefaultTexture.RGBA = texcolor;
495 }
496 m_host.UpdateTexture(tex);
497 return;
498 }
499 NotImplemented("llSetColor");
500 return;
501 }
502
503 public double llGetAlpha(int face)
504 {
505 LLObject.TextureEntry tex = m_host.Shape.Textures;
506 if (face == -1) // TMP: Until we can determine number of sides, ALL_SIDES (-1) will return default color
507 {
508 return (double)((tex.DefaultTexture.RGBA.A * 255) / 255);
509 }
510 if (face > -1)
511 {
512 return (double)((tex.GetFace((uint)face).RGBA.A * 255) / 255);
513 }
514 return 0;
515 }
516
517 public void llSetAlpha(double alpha, int face)
518 {
519 LLObject.TextureEntry tex = m_host.Shape.Textures;
520 LLColor texcolor;
521 if (face > -1)
522 {
523 texcolor = tex.CreateFace((uint)face).RGBA;
524 texcolor.A = (float)Math.Abs(alpha - 1);
525 tex.FaceTextures[face].RGBA = texcolor;
526 m_host.UpdateTexture(tex);
527 return;
528 }
529 else if (face == -1)
530 {
531 for (int i = 0; i < 32; i++)
532 {
533 if (tex.FaceTextures[i] != null)
534 {
535 texcolor = tex.FaceTextures[i].RGBA;
536 texcolor.A = (float)Math.Abs(alpha - 1);
537 tex.FaceTextures[i].RGBA = texcolor;
538 }
539 }
540 texcolor = tex.DefaultTexture.RGBA;
541 texcolor.A = (float)Math.Abs(alpha - 1);
542 tex.DefaultTexture.RGBA = texcolor;
543 m_host.UpdateTexture(tex);
544 return;
545 }
546 NotImplemented("llSetAlpha");
547 return;
548 }
549
550 public LSL_Types.Vector3 llGetColor(int face)
551 {
552 LLObject.TextureEntry tex = m_host.Shape.Textures;
553 LLColor texcolor;
554 LSL_Types.Vector3 rgb;
555 if (face == -1) // TMP: Until we can determine number of sides, ALL_SIDES (-1) will return default color
556 {
557 texcolor = tex.DefaultTexture.RGBA;
558 rgb.x = (255 - (texcolor.R * 255)) / 255;
559 rgb.y = (255 - (texcolor.G * 255)) / 255;
560 rgb.z = (255 - (texcolor.B * 255)) / 255;
561 return rgb;
562 }
563 if (face > -1)
564 {
565 texcolor = tex.GetFace((uint)face).RGBA;
566 rgb.x = (255 - (texcolor.R * 255)) / 255;
567 rgb.y = (255 - (texcolor.G * 255)) / 255;
568 rgb.z = (255 - (texcolor.B * 255)) / 255;
569 return rgb;
570 }
571 NotImplemented("llGetColor");
572 return new LSL_Types.Vector3();
573 }
574
575 public void llSetTexture(string texture, int face)
576 {
577 LLObject.TextureEntry tex = m_host.Shape.Textures;
578
579 if (face > -1)
580 {
581 LLObject.TextureEntryFace texface = tex.CreateFace((uint)face);
582 texface.TextureID = new LLUUID(texture);
583 tex.FaceTextures[face] = texface;
584 m_host.UpdateTexture(tex);
585 return;
586 }
587 else if (face == -1)
588 {
589 for (uint i = 0; i < 32; i++)
590 {
591 if (tex.FaceTextures[i] != null)
592 {
593 tex.FaceTextures[i].TextureID = new LLUUID(texture);
594 }
595 }
596 tex.DefaultTexture.TextureID = new LLUUID(texture);
597 m_host.UpdateTexture(tex);
598 return;
599 }
600 NotImplemented("llSetTexture");
601 return;
602 }
603
604 public void llScaleTexture(double u, double v, int face)
605 {
606 LLObject.TextureEntry tex = m_host.Shape.Textures;
607 if (face > -1)
608 {
609 LLObject.TextureEntryFace texface = tex.CreateFace((uint)face);
610 texface.RepeatU = (float)u;
611 texface.RepeatV = (float)v;
612 tex.FaceTextures[face] = texface;
613 m_host.UpdateTexture(tex);
614 return;
615 }
616 if (face == -1)
617 {
618 for (int i = 0; i < 32; i++)
619 {
620 if (tex.FaceTextures[i] != null)
621 {
622 tex.FaceTextures[i].RepeatU = (float)u;
623 tex.FaceTextures[i].RepeatV = (float)v;
624 }
625 }
626 tex.DefaultTexture.RepeatU = (float)u;
627 tex.DefaultTexture.RepeatV = (float)v;
628 m_host.UpdateTexture(tex);
629 return;
630 }
631 NotImplemented("llScaleTexture");
632 return;
633 }
634
635 public void llOffsetTexture(double u, double v, int face)
636 {
637 LLObject.TextureEntry tex = m_host.Shape.Textures;
638 if (face > -1)
639 {
640 LLObject.TextureEntryFace texface = tex.CreateFace((uint)face);
641 texface.OffsetU = (float)u;
642 texface.OffsetV = (float)v;
643 tex.FaceTextures[face] = texface;
644 m_host.UpdateTexture(tex);
645 return;
646 }
647 if (face == -1)
648 {
649 for (int i = 0; i < 32; i++)
650 {
651 if (tex.FaceTextures[i] != null)
652 {
653 tex.FaceTextures[i].OffsetU = (float)u;
654 tex.FaceTextures[i].OffsetV = (float)v;
655 }
656 }
657 tex.DefaultTexture.OffsetU = (float)u;
658 tex.DefaultTexture.OffsetV = (float)v;
659 m_host.UpdateTexture(tex);
660 return;
661 }
662 NotImplemented("llOffsetTexture");
663 return;
664 }
665
666 public void llRotateTexture(double rotation, int face)
667 {
668 LLObject.TextureEntry tex = m_host.Shape.Textures;
669 if (face > -1)
670 {
671 LLObject.TextureEntryFace texface = tex.CreateFace((uint)face);
672 texface.Rotation = (float)rotation;
673 tex.FaceTextures[face] = texface;
674 m_host.UpdateTexture(tex);
675 return;
676 }
677 if (face == -1)
678 {
679 for (int i = 0; i < 32; i++)
680 {
681 if (tex.FaceTextures[i] != null)
682 {
683 tex.FaceTextures[i].Rotation = (float)rotation;
684 }
685 }
686 tex.DefaultTexture.Rotation = (float)rotation;
687 m_host.UpdateTexture(tex);
688 return;
689 }
690 NotImplemented("llRotateTexture");
691 return;
692 }
693
694 public string llGetTexture(int face)
695 {
696 LLObject.TextureEntry tex = m_host.Shape.Textures;
697 if (face == -1)
698 {
699 face = 0;
700 }
701 if (face > -1)
702 {
703 LLObject.TextureEntryFace texface;
704 texface = tex.GetFace((uint)face);
705 return texface.TextureID.ToString();
706 }
707 NotImplemented("llGetTexture");
708 return "";
709 }
710
711 public void llSetPos(LSL_Types.Vector3 pos)
712 {
713 if (m_host.ParentID != 0)
714 {
715 m_host.UpdateOffSet(new LLVector3((float)pos.x, (float)pos.y, (float)pos.z));
716 }
717 else
718 {
719 m_host.UpdateGroupPosition(new LLVector3((float)pos.x, (float)pos.y, (float)pos.z));
720 }
721 }
722
723 public LSL_Types.Vector3 llGetPos()
724 {
725 return new LSL_Types.Vector3(m_host.AbsolutePosition.X,
726 m_host.AbsolutePosition.Y,
727 m_host.AbsolutePosition.Z);
728 }
729
730 public LSL_Types.Vector3 llGetLocalPos()
731 {
732 if (m_host.ParentID != 0)
733 {
734 return new LSL_Types.Vector3(m_host.OffsetPosition.X,
735 m_host.OffsetPosition.Y,
736 m_host.OffsetPosition.Z);
737 }
738 else
739 {
740 return new LSL_Types.Vector3(m_host.AbsolutePosition.X,
741 m_host.AbsolutePosition.Y,
742 m_host.AbsolutePosition.Z);
743 }
744 }
745
746 public void llSetRot(LSL_Types.Quaternion rot)
747 {
748 m_host.UpdateRotation(new LLQuaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s));
749 }
750
751 public LSL_Types.Quaternion llGetRot()
752 {
753 LLQuaternion q = m_host.RotationOffset;
754 return new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W);
755 }
756
757 public LSL_Types.Quaternion llGetLocalRot()
758 {
759 return new LSL_Types.Quaternion(m_host.RotationOffset.X, m_host.RotationOffset.Y, m_host.RotationOffset.Z, m_host.RotationOffset.W);
760 }
761
762 public void llSetForce(LSL_Types.Vector3 force, int local)
763 {
764 NotImplemented("llSetForce");
765 }
766
767 public LSL_Types.Vector3 llGetForce()
768 {
769 NotImplemented("llGetForce");
770 return new LSL_Types.Vector3();
771 }
772
773 public int llTarget(LSL_Types.Vector3 position, double range)
774 {
775 NotImplemented("llTarget");
776 return 0;
777 }
778
779 public void llTargetRemove(int number)
780 {
781 NotImplemented("llTargetRemove");
782 }
783
784 public int llRotTarget(LSL_Types.Quaternion rot, double error)
785 {
786 NotImplemented("llRotTarget");
787 return 0;
788 }
789
790 public void llRotTargetRemove(int number)
791 {
792 NotImplemented("llRotTargetRemove");
793 }
794
795 public void llMoveToTarget(LSL_Types.Vector3 target, double tau)
796 {
797 NotImplemented("llMoveToTarget");
798 }
799
800 public void llStopMoveToTarget()
801 {
802 NotImplemented("llStopMoveToTarget");
803 }
804
805 public void llApplyImpulse(LSL_Types.Vector3 force, int local)
806 {
807 NotImplemented("llApplyImpulse");
808 }
809
810 public void llApplyRotationalImpulse(LSL_Types.Vector3 force, int local)
811 {
812 NotImplemented("llApplyRotationalImpulse");
813 }
814
815 public void llSetTorque(LSL_Types.Vector3 torque, int local)
816 {
817 NotImplemented("llSetTorque");
818 }
819
820 public LSL_Types.Vector3 llGetTorque()
821 {
822 NotImplemented("llGetTorque");
823 return new LSL_Types.Vector3();
824 }
825
826 public void llSetForceAndTorque(LSL_Types.Vector3 force, LSL_Types.Vector3 torque, int local)
827 {
828 NotImplemented("llSetForceAndTorque");
829 }
830
831 public LSL_Types.Vector3 llGetVel()
832 {
833 return new LSL_Types.Vector3(m_host.Velocity.X, m_host.Velocity.Y, m_host.Velocity.Z);
834 }
835
836 public LSL_Types.Vector3 llGetAccel()
837 {
838 return new LSL_Types.Vector3(m_host.Acceleration.X, m_host.Acceleration.Y, m_host.Acceleration.Z);
839 }
840
841 public LSL_Types.Vector3 llGetOmega()
842 {
843 NotImplemented("llGetOmega");
844 return new LSL_Types.Vector3();
845 }
846
847 public double llGetTimeOfDay()
848 {
849 NotImplemented("llGetTimeOfDay");
850 return 0;
851 }
852
853 public double llGetWallclock()
854 {
855 return DateTime.Now.TimeOfDay.TotalSeconds;
856 }
857
858 public double llGetTime()
859 {
860 TimeSpan ScriptTime = DateTime.Now - m_timer;
861 return (double)(ScriptTime.TotalMilliseconds / 1000);
862 }
863
864 public void llResetTime()
865 {
866 m_timer = DateTime.Now;
867 }
868
869 public double llGetAndResetTime()
870 {
871 TimeSpan ScriptTime = DateTime.Now - m_timer;
872 m_timer = DateTime.Now;
873 return (double)(ScriptTime.TotalMilliseconds / 1000);
874 }
875
876 public void llSound()
877 {
878 NotImplemented("llSound");
879 }
880
881 public void llPlaySound(string sound, double volume)
882 {
883 NotImplemented("llPlaySound");
884 }
885
886 public void llLoopSound(string sound, double volume)
887 {
888 NotImplemented("llLoopSound");
889 }
890
891 public void llLoopSoundMaster(string sound, double volume)
892 {
893 NotImplemented("llLoopSoundMaster");
894 }
895
896 public void llLoopSoundSlave(string sound, double volume)
897 {
898 NotImplemented("llLoopSoundSlave");
899 }
900
901 public void llPlaySoundSlave(string sound, double volume)
902 {
903 NotImplemented("llPlaySoundSlave");
904 }
905
906 public void llTriggerSound(string sound, double volume)
907 {
908 NotImplemented("llTriggerSound");
909 }
910
911 public void llStopSound()
912 {
913 NotImplemented("llStopSound");
914 }
915
916 public void llPreloadSound(string sound)
917 {
918 NotImplemented("llPreloadSound");
919 }
920
921 public string llGetSubString(string src, int start, int end)
922 {
923 return src.Substring(start, end);
924 }
925
926 public string llDeleteSubString(string src, int start, int end)
927 {
928 return src.Remove(start, end - start);
929 }
930
931 public string llInsertString(string dst, int position, string src)
932 {
933 return dst.Insert(position, src);
934 }
935
936 public string llToUpper(string src)
937 {
938 return src.ToUpper();
939 }
940
941 public string llToLower(string src)
942 {
943 return src.ToLower();
944 }
945
946 public int llGiveMoney(string destination, int amount)
947 {
948 NotImplemented("llGiveMoney");
949 return 0;
950 }
951
952 public void llMakeExplosion()
953 {
954 NotImplemented("llMakeExplosion");
955 }
956
957 public void llMakeFountain()
958 {
959 NotImplemented("llMakeFountain");
960 }
961
962 public void llMakeSmoke()
963 {
964 NotImplemented("llMakeSmoke");
965 }
966
967 public void llMakeFire()
968 {
969 NotImplemented("llMakeFire");
970 }
971
972 public void llRezObject(string inventory, LSL_Types.Vector3 pos, LSL_Types.Quaternion rot, int param)
973 {
974 NotImplemented("llRezObject");
975 }
976
977 public void llLookAt(LSL_Types.Vector3 target, double strength, double damping)
978 {
979 NotImplemented("llLookAt");
980 }
981
982 public void llStopLookAt()
983 {
984 NotImplemented("llStopLookAt");
985 }
986
987 public void llSetTimerEvent(double sec)
988 {
989 // Setting timer repeat
990 m_ScriptEngine.m_LSLLongCmdHandler.SetTimerEvent(m_localID, m_itemID, sec);
991 }
992
993 public void llSleep(double sec)
994 {
995 Thread.Sleep((int)(sec * 1000));
996 }
997
998 public double llGetMass()
999 {
1000 return m_host.GetMass();
1001 }
1002
1003 public void llCollisionFilter(string name, string id, int accept)
1004 {
1005 NotImplemented("llCollisionFilter");
1006 }
1007
1008 public void llTakeControls(int controls, int accept, int pass_on)
1009 {
1010 NotImplemented("llTakeControls");
1011 }
1012
1013 public void llReleaseControls()
1014 {
1015 NotImplemented("llReleaseControls");
1016 }
1017
1018 public void llAttachToAvatar(int attachment)
1019 {
1020 NotImplemented("llAttachToAvatar");
1021 }
1022
1023 public void llDetachFromAvatar()
1024 {
1025 NotImplemented("llDetachFromAvatar");
1026 }
1027
1028 public void llTakeCamera()
1029 {
1030 NotImplemented("llTakeCamera");
1031 }
1032
1033 public void llReleaseCamera()
1034 {
1035 NotImplemented("llReleaseCamera");
1036 }
1037
1038 public string llGetOwner()
1039 {
1040 return m_host.ObjectOwner.ToString();
1041 }
1042
1043 public void llInstantMessage(string user, string message)
1044 {
1045 NotImplemented("llInstantMessage");
1046
1047 // We may be able to use ClientView.SendInstantMessage here, but we need a client instance.
1048 // InstantMessageModule.OnInstantMessage searches through a list of scenes for a client matching the toAgent,
1049 // but I don't think we have a list of scenes available from here.
1050 // (We also don't want to duplicate the code in OnInstantMessage if we can avoid it.)
1051
1052 // TODO: figure out values for client, fromSession, and imSessionID
1053 // client.SendInstantMessage(m_host.UUID, fromSession, message, user, imSessionID, m_host.Name, AgentManager.InstantMessageDialog.MessageFromAgent, (uint)Util.UnixTimeSinceEpoch());
1054 }
1055
1056 public void llEmail(string address, string subject, string message)
1057 {
1058 NotImplemented("llEmail");
1059 }
1060
1061 public void llGetNextEmail(string address, string subject)
1062 {
1063 NotImplemented("llGetNextEmail");
1064 }
1065
1066 public string llGetKey()
1067 {
1068 return m_host.UUID.ToString();
1069 }
1070
1071 public void llSetBuoyancy(double buoyancy)
1072 {
1073 NotImplemented("llSetBuoyancy");
1074 }
1075
1076 public void llSetHoverHeight(double height, int water, double tau)
1077 {
1078 NotImplemented("llSetHoverHeight");
1079 }
1080
1081 public void llStopHover()
1082 {
1083 NotImplemented("llStopHover");
1084 }
1085
1086 public void llMinEventDelay(double delay)
1087 {
1088 NotImplemented("llMinEventDelay");
1089 }
1090
1091 public void llSoundPreload()
1092 {
1093 NotImplemented("llSoundPreload");
1094 }
1095
1096 public void llRotLookAt(LSL_Types.Quaternion target, double strength, double damping)
1097 {
1098 NotImplemented("llRotLookAt");
1099 }
1100
1101 public int llStringLength(string str)
1102 {
1103 if (str.Length > 0)
1104 {
1105 return str.Length;
1106 }
1107 else
1108 {
1109 return 0;
1110 }
1111 }
1112
1113 public void llStartAnimation(string anim)
1114 {
1115 NotImplemented("llStartAnimation");
1116 }
1117
1118 public void llStopAnimation(string anim)
1119 {
1120 NotImplemented("llStopAnimation");
1121 }
1122
1123 public void llPointAt()
1124 {
1125 NotImplemented("llPointAt");
1126 }
1127
1128 public void llStopPointAt()
1129 {
1130 NotImplemented("llStopPointAt");
1131 }
1132
1133 public void llTargetOmega(LSL_Types.Vector3 axis, double spinrate, double gain)
1134 {
1135 m_host.RotationalVelocity = new LLVector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate));
1136 m_host.AngularVelocity = new LLVector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate));
1137 m_host.ScheduleTerseUpdate();
1138 m_host.SendTerseUpdateToAllClients();
1139 //NotImplemented("llTargetOmega");
1140 }
1141
1142 public int llGetStartParameter()
1143 {
1144 NotImplemented("llGetStartParameter");
1145 return 0;
1146 }
1147
1148 public void llGodLikeRezObject(string inventory, LSL_Types.Vector3 pos)
1149 {
1150 NotImplemented("llGodLikeRezObject");
1151 }
1152
1153 public void llRequestPermissions(string agent, int perm)
1154 {
1155 NotImplemented("llRequestPermissions");
1156 }
1157
1158 public string llGetPermissionsKey()
1159 {
1160 NotImplemented("llGetPermissionsKey");
1161 return "";
1162 }
1163
1164 public int llGetPermissions()
1165 {
1166 NotImplemented("llGetPermissions");
1167 return 0;
1168 }
1169
1170 public int llGetLinkNumber()
1171 {
1172 return m_host.LinkNum;
1173 }
1174
1175 public void llSetLinkColor(int linknumber, LSL_Types.Vector3 color, int face)
1176 {
1177 SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknumber);
1178 if (linknumber > -1)
1179 {
1180 LLObject.TextureEntry tex = part.Shape.Textures;
1181 LLColor texcolor;
1182 if (face > -1)
1183 {
1184 texcolor = tex.CreateFace((uint)face).RGBA;
1185 texcolor.R = (float)Math.Abs(color.x - 1);
1186 texcolor.G = (float)Math.Abs(color.y - 1);
1187 texcolor.B = (float)Math.Abs(color.z - 1);
1188 tex.FaceTextures[face].RGBA = texcolor;
1189 part.UpdateTexture(tex);
1190 return;
1191 }
1192 else if (face == -1)
1193 {
1194 texcolor = tex.DefaultTexture.RGBA;
1195 texcolor.R = (float)Math.Abs(color.x - 1);
1196 texcolor.G = (float)Math.Abs(color.y - 1);
1197 texcolor.B = (float)Math.Abs(color.z - 1);
1198 tex.DefaultTexture.RGBA = texcolor;
1199 for (uint i = 0; i < 32; i++)
1200 {
1201 if (tex.FaceTextures[i] != null)
1202 {
1203 texcolor = tex.FaceTextures[i].RGBA;
1204 texcolor.R = (float)Math.Abs(color.x - 1);
1205 texcolor.G = (float)Math.Abs(color.y - 1);
1206 texcolor.B = (float)Math.Abs(color.z - 1);
1207 tex.FaceTextures[i].RGBA = texcolor;
1208 }
1209 }
1210 texcolor = tex.DefaultTexture.RGBA;
1211 texcolor.R = (float)Math.Abs(color.x - 1);
1212 texcolor.G = (float)Math.Abs(color.y - 1);
1213 texcolor.B = (float)Math.Abs(color.z - 1);
1214 tex.DefaultTexture.RGBA = texcolor;
1215 part.UpdateTexture(tex);
1216 return;
1217 }
1218 return;
1219 }
1220 else if (linknumber == -1)
1221 {
1222 int num = m_host.ParentGroup.PrimCount;
1223 for (int w = 0; w < num; w++)
1224 {
1225 linknumber = w;
1226 part = m_host.ParentGroup.GetLinkNumPart(linknumber);
1227 LLObject.TextureEntry tex = part.Shape.Textures;
1228 LLColor texcolor;
1229 if (face > -1)
1230 {
1231 texcolor = tex.CreateFace((uint)face).RGBA;
1232 texcolor.R = (float)Math.Abs(color.x - 1);
1233 texcolor.G = (float)Math.Abs(color.y - 1);
1234 texcolor.B = (float)Math.Abs(color.z - 1);
1235 tex.FaceTextures[face].RGBA = texcolor;
1236 part.UpdateTexture(tex);
1237 }
1238 else if (face == -1)
1239 {
1240 texcolor = tex.DefaultTexture.RGBA;
1241 texcolor.R = (float)Math.Abs(color.x - 1);
1242 texcolor.G = (float)Math.Abs(color.y - 1);
1243 texcolor.B = (float)Math.Abs(color.z - 1);
1244 tex.DefaultTexture.RGBA = texcolor;
1245 for (uint i = 0; i < 32; i++)
1246 {
1247 if (tex.FaceTextures[i] != null)
1248 {
1249 texcolor = tex.FaceTextures[i].RGBA;
1250 texcolor.R = (float)Math.Abs(color.x - 1);
1251 texcolor.G = (float)Math.Abs(color.y - 1);
1252 texcolor.B = (float)Math.Abs(color.z - 1);
1253 tex.FaceTextures[i].RGBA = texcolor;
1254 }
1255 }
1256 texcolor = tex.DefaultTexture.RGBA;
1257 texcolor.R = (float)Math.Abs(color.x - 1);
1258 texcolor.G = (float)Math.Abs(color.y - 1);
1259 texcolor.B = (float)Math.Abs(color.z - 1);
1260 tex.DefaultTexture.RGBA = texcolor;
1261 part.UpdateTexture(tex);
1262 }
1263 }
1264 return;
1265 }
1266 else
1267 {
1268 NotImplemented("llSetLinkColor");
1269 }
1270 }
1271
1272 public void llCreateLink(string target, int parent)
1273 {
1274 NotImplemented("llCreateLink");
1275 }
1276
1277 public void llBreakLink(int linknum)
1278 {
1279 NotImplemented("llBreakLink");
1280 }
1281
1282 public void llBreakAllLinks()
1283 {
1284 NotImplemented("llBreakAllLinks");
1285 }
1286
1287 public string llGetLinkKey(int linknum)
1288 {
1289 SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknum);
1290 if (part != null)
1291 {
1292 return part.UUID.ToString();
1293 }
1294 else
1295 {
1296 return "00000000-0000-0000-0000-000000000000";
1297 }
1298 }
1299
1300 public string llGetLinkName(int linknum)
1301 {
1302 SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknum);
1303 if (part != null)
1304 {
1305 return part.Name;
1306 }
1307 else
1308 {
1309 return "00000000-0000-0000-0000-000000000000";
1310 }
1311 }
1312
1313 public int llGetInventoryNumber(int type)
1314 {
1315 NotImplemented("llGetInventoryNumber");
1316 return 0;
1317 }
1318
1319 public string llGetInventoryName(int type, int number)
1320 {
1321 NotImplemented("llGetInventoryName");
1322 return "";
1323 }
1324
1325 public void llSetScriptState(string name, int run)
1326 {
1327 NotImplemented("llSetScriptState");
1328 }
1329
1330 public double llGetEnergy()
1331 {
1332 return 1.0f;
1333 }
1334
1335 public void llGiveInventory(string destination, string inventory)
1336 {
1337 NotImplemented("llGiveInventory");
1338 }
1339
1340 public void llRemoveInventory(string item)
1341 {
1342 NotImplemented("llRemoveInventory");
1343 }
1344
1345 public void llSetText(string text, LSL_Types.Vector3 color, double alpha)
1346 {
1347 Vector3 av3 = new Vector3((float)color.x, (float)color.y, (float)color.z);
1348 m_host.SetText(text, av3, alpha);
1349 }
1350
1351 public double llWater(LSL_Types.Vector3 offset)
1352 {
1353 return World.RegionInfo.EstateSettings.waterHeight;
1354 }
1355
1356 public void llPassTouches(int pass)
1357 {
1358 NotImplemented("llPassTouches");
1359 }
1360
1361 public string llRequestAgentData(string id, int data)
1362 {
1363 NotImplemented("llRequestAgentData");
1364 return "";
1365 }
1366
1367 public string llRequestInventoryData(string name)
1368 {
1369 NotImplemented("llRequestInventoryData");
1370 return "";
1371 }
1372
1373 public void llSetDamage(double damage)
1374 {
1375 NotImplemented("llSetDamage");
1376 }
1377
1378 public void llTeleportAgentHome(string agent)
1379 {
1380 NotImplemented("llTeleportAgentHome");
1381 }
1382
1383 public void llModifyLand(int action, int brush)
1384 {
1385 double dsize;
1386 if (World.PermissionsMngr.CanTerraform(m_host.OwnerID, new LLVector3(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, 0)))
1387 {
1388 switch (brush)
1389 {
1390 case 1:
1391 dsize = 2;
1392 break;
1393 case 2:
1394 dsize = 4;
1395 break;
1396 case 3:
1397 dsize = 8;
1398 break;
1399 default:
1400 if (brush < 0)
1401 {
1402 dsize = (double)(-1 * brush);
1403 }
1404 else
1405 {
1406 LSLError("Invalid brush size");
1407 dsize = 0; // Should cease execution, but get unassigned local variable dsize on compile.
1408 }
1409 break;
1410 }
1411 switch (action)
1412 {
1413 case 0:
1414 if (World.Terrain.GetHeight((int)m_host.AbsolutePosition.X, (int)m_host.AbsolutePosition.Y) < m_host.AbsolutePosition.Z)
1415 {
1416 World.Terrain.FlattenTerrain(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, dsize, 1);
1417 }
1418 break;
1419 case 1:
1420 if (World.Terrain.GetHeight((int)m_host.AbsolutePosition.X, (int)m_host.AbsolutePosition.Y) < (double)m_host.AbsolutePosition.Z)
1421 {
1422 World.Terrain.RaiseTerrain(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, dsize, 0.1);
1423 }
1424 break;
1425 case 2:
1426 if (World.Terrain.GetHeight((int)m_host.AbsolutePosition.X, (int)m_host.AbsolutePosition.Y) > 0)
1427 {
1428 World.Terrain.LowerTerrain(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, dsize, 1);
1429 }
1430 break;
1431 case 3:
1432 World.Terrain.SmoothTerrain(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, dsize, 1);
1433 break;
1434 case 4:
1435 World.Terrain.NoiseTerrain(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, dsize, 1);
1436 break;
1437 case 5:
1438 World.Terrain.RevertTerrain(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, dsize, 1);
1439 break;
1440 default:
1441 break;
1442 }
1443 }
1444 }
1445
1446 public void llCollisionSound(string impact_sound, double impact_volume)
1447 {
1448 NotImplemented("llCollisionSound");
1449 }
1450
1451 public void llCollisionSprite(string impact_sprite)
1452 {
1453 NotImplemented("llCollisionSprite");
1454 }
1455
1456 public string llGetAnimation(string id)
1457 {
1458 NotImplemented("llGetAnimation");
1459 return "";
1460 }
1461
1462 public void llResetScript()
1463 {
1464 m_ScriptEngine.m_ScriptManager.ResetScript(m_localID, m_itemID);
1465 }
1466
1467 public void llMessageLinked(int linknum, int num, string str, string id)
1468 {
1469 }
1470
1471 public void llPushObject(string target, LSL_Types.Vector3 impulse, LSL_Types.Vector3 ang_impulse, int local)
1472 {
1473 }
1474
1475 public void llPassCollisions(int pass)
1476 {
1477 }
1478
1479 public string llGetScriptName()
1480 {
1481 return "";
1482 }
1483
1484 public int llGetNumberOfSides()
1485 {
1486 return 0;
1487 }
1488
1489 public LSL_Types.Quaternion llAxisAngle2Rot(LSL_Types.Vector3 axis, double angle)
1490 {
1491 return new LSL_Types.Quaternion();
1492 }
1493
1494 public LSL_Types.Vector3 llRot2Axis(LSL_Types.Quaternion rot)
1495 {
1496 return new LSL_Types.Vector3();
1497 }
1498
1499 public void llRot2Angle()
1500 {
1501 }
1502
1503 public double llAcos(double val)
1504 {
1505 return (double)Math.Acos(val);
1506 }
1507
1508 public double llAsin(double val)
1509 {
1510 return (double)Math.Asin(val);
1511 }
1512
1513 public double llAngleBetween(LSL_Types.Quaternion a, LSL_Types.Quaternion b)
1514 {
1515 return 0;
1516 }
1517
1518 public string llGetInventoryKey(string name)
1519 {
1520 return "";
1521 }
1522
1523 public void llAllowInventoryDrop(int add)
1524 {
1525 }
1526
1527 public LSL_Types.Vector3 llGetSunDirection()
1528 {
1529 return new LSL_Types.Vector3();
1530 }
1531
1532 public LSL_Types.Vector3 llGetTextureOffset(int face)
1533 {
1534 LLObject.TextureEntry tex = m_host.Shape.Textures;
1535 LSL_Types.Vector3 offset;
1536 if (face == -1)
1537 {
1538 face = 0;
1539 }
1540 offset.x = tex.GetFace((uint)face).OffsetU;
1541 offset.y = tex.GetFace((uint)face).OffsetV;
1542 offset.z = 0.0;
1543 return offset;
1544 }
1545
1546 public LSL_Types.Vector3 llGetTextureScale(int side)
1547 {
1548 LLObject.TextureEntry tex = m_host.Shape.Textures;
1549 LSL_Types.Vector3 scale;
1550 if (side == -1)
1551 {
1552 side = 0;
1553 }
1554 scale.x = tex.GetFace((uint)side).RepeatU;
1555 scale.y = tex.GetFace((uint)side).RepeatV;
1556 scale.z = 0.0;
1557 return scale;
1558 }
1559
1560 public double llGetTextureRot(int face)
1561 {
1562 LLObject.TextureEntry tex = m_host.Shape.Textures;
1563 if (face == -1)
1564 {
1565 face = 0;
1566 }
1567 return tex.GetFace((uint)face).Rotation;
1568 }
1569
1570 public int llSubStringIndex(string source, string pattern)
1571 {
1572 return source.IndexOf(pattern);
1573 }
1574
1575 public string llGetOwnerKey(string id)
1576 {
1577 NotImplemented("llGetOwnerKey");
1578 return "";
1579 }
1580
1581 public LSL_Types.Vector3 llGetCenterOfMass()
1582 {
1583 NotImplemented("llGetCenterOfMass");
1584 return new LSL_Types.Vector3();
1585 }
1586
1587 public LSL_Types.list llListSort(LSL_Types.list src, int stride, int ascending)
1588 {
1589 // SortedList<string, LSL_Types.list> sorted = new SortedList<string, LSL_Types.list>();
1590 // Add chunks to an array
1591 //int s = stride;
1592 //if (s < 1)
1593 // s = 1;
1594 //int c = 0;
1595 //LSL_Types.list chunk = new LSL_Types.list();
1596 //string chunkString = "";
1597 //foreach (string element in src)
1598 //{
1599 // c++;
1600 // if (c > s)
1601 // {
1602 // sorted.Add(chunkString, chunk);
1603 // chunkString = "";
1604 // chunk = new LSL_Types.list();
1605 // c = 0;
1606 // }
1607 // chunk.Add(element);
1608 // chunkString += element.ToString();
1609 //}
1610 //if (chunk.Count > 0)
1611 // sorted.Add(chunkString, chunk);
1612
1613 //LSL_Types.list ret = new LSL_Types.list();
1614 //foreach (LSL_Types.list ls in sorted.Values)
1615 //{
1616 // ret.AddRange(ls);
1617 //}
1618
1619 //if (ascending == LSL_BaseClass.TRUE)
1620 // return ret;
1621 //ret.Reverse();
1622 //return ret;
1623 NotImplemented("llListSort");
1624 return new LSL_Types.list();
1625 }
1626
1627 public int llGetListLength(LSL_Types.list src)
1628 {
1629 return src.Length;
1630 }
1631
1632 public int llList2Integer(LSL_Types.list src, int index)
1633 {
1634 if (index < 0)
1635 {
1636 index = src.Length + index;
1637 }
1638 if (index >= src.Length)
1639 {
1640 return 0;
1641 }
1642 return Convert.ToInt32(src.Data[index]);
1643 }
1644
1645 public double osList2Double(LSL_Types.list src, int index)
1646 {
1647 if (index < 0)
1648 {
1649 index = src.Length + index;
1650 }
1651 if (index >= src.Length)
1652 {
1653 return 0.0;
1654 }
1655 return Convert.ToDouble(src.Data[index]);
1656 }
1657
1658 public double llList2Float(LSL_Types.list src, int index)
1659 {
1660 if (index < 0)
1661 {
1662 index = src.Length + index;
1663 }
1664 if (index >= src.Length)
1665 {
1666 return 0.0;
1667 }
1668 return Convert.ToSingle(src.Data[index]);
1669 }
1670
1671 public string llList2String(LSL_Types.list src, int index)
1672 {
1673 if (index < 0)
1674 {
1675 index = src.Length + index;
1676 }
1677 if (index >= src.Length)
1678 {
1679 return "";
1680 }
1681 return src.Data[index].ToString();
1682 }
1683
1684 public string llList2Key(LSL_Types.list src, int index)
1685 {
1686 if (index < 0)
1687 {
1688 index = src.Length + index;
1689 }
1690 if (index >= src.Length)
1691 {
1692 return "00000000-0000-0000-0000-000000000000";
1693 }
1694 //return OpenSim.Framework.ToString(src[index]);
1695 LLUUID tmpkey;
1696 if (LLUUID.TryParse(src.Data[index].ToString(), out tmpkey))
1697 {
1698 return tmpkey.ToString();
1699 }
1700 else
1701 {
1702 return "00000000-0000-0000-0000-000000000000";
1703 }
1704 }
1705
1706 public LSL_Types.Vector3 llList2Vector(LSL_Types.list src, int index)
1707 {
1708 if (index < 0)
1709 {
1710 index = src.Length + index;
1711 }
1712 if (index >= src.Length)
1713 {
1714 return new LSL_Types.Vector3(0, 0, 0);
1715 }
1716 if (src.Data[index].GetType() == typeof(OpenSim.Region.ScriptEngine.Common.LSL_Types.Vector3))
1717 {
1718 return (LSL_Types.Vector3)src.Data[index];
1719 }
1720 else
1721 {
1722 return new LSL_Types.Vector3(0, 0, 0);
1723 }
1724 }
1725
1726 public LSL_Types.Quaternion llList2Rot(LSL_Types.list src, int index)
1727 {
1728 if (index < 0)
1729 {
1730 index = src.Length + index;
1731 }
1732 if (index >= src.Length)
1733 {
1734 return new LSL_Types.Quaternion(0, 0, 0, 1);
1735 }
1736 if (src.Data[index].GetType() == typeof(OpenSim.Region.ScriptEngine.Common.LSL_Types.Quaternion))
1737 {
1738 return (LSL_Types.Quaternion)src.Data[index];
1739 }
1740 else
1741 {
1742 return new LSL_Types.Quaternion(0, 0, 0, 1);
1743 }
1744 }
1745
1746 public LSL_Types.list llList2List(LSL_Types.list src, int start, int end)
1747 {
1748 return src.GetSublist(start, end);
1749 }
1750
1751 public LSL_Types.list llDeleteSubList(LSL_Types.list src, int start, int end)
1752 {
1753 //LSL_Types.list ret = new LSL_Types.list(src);
1754 //ret.RemoveRange(start, end - start);
1755 //return ret;
1756
1757 // Just a hunch - needs testing
1758 return src.GetSublist(end, start);
1759 }
1760
1761 public int llGetListEntryType(LSL_Types.list src, int index)
1762 {
1763 if (index < 0)
1764 {
1765 index = src.Length + index;
1766 }
1767 if (index >= src.Length)
1768 {
1769 return 0;
1770 }
1771
1772 if (src.Data[index] is System.Int32)
1773 return 1;
1774 if (src.Data[index] is System.Double)
1775 return 2;
1776 if (src.Data[index] is System.String)
1777 {
1778 LLUUID tuuid;
1779 if (LLUUID.TryParse(src.Data[index].ToString(), out tuuid))
1780 {
1781 return 3;
1782 }
1783 else
1784 {
1785 return 4;
1786 }
1787 }
1788 if (src.Data[index] is OpenSim.Region.ScriptEngine.Common.LSL_Types.Vector3)
1789 return 5;
1790 if (src.Data[index] is OpenSim.Region.ScriptEngine.Common.LSL_Types.Quaternion)
1791 return 6;
1792 if (src.Data[index] is OpenSim.Region.ScriptEngine.Common.LSL_Types.list)
1793 return 7;
1794 return 0;
1795
1796 }
1797
1798 public string llList2CSV(LSL_Types.list src)
1799 {
1800 string ret = "";
1801 foreach (object o in src.Data)
1802 {
1803 ret = ret + o.ToString() + ",";
1804 }
1805 ret = ret.Substring(0, ret.Length - 2);
1806 return ret;
1807 }
1808
1809 public LSL_Types.list llCSV2List(string src)
1810 {
1811 return new LSL_Types.list(src.Split(",".ToCharArray()));
1812 }
1813
1814 public LSL_Types.list llListRandomize(LSL_Types.list src, int stride)
1815 {
1816 //int s = stride;
1817 //if (s < 1)
1818 // s = 1;
1819
1820 // This is a cowardly way of doing it ;)
1821 // TODO: Instead, randomize and check if random is mod stride or if it can not be, then array.removerange
1822 //List<LSL_Types.list> tmp = new List<LSL_Types.list>();
1823
1824 // Add chunks to an array
1825 //int c = 0;
1826 //LSL_Types.list chunk = new LSL_Types.list();
1827 //foreach (string element in src)
1828 //{
1829 // c++;
1830 // if (c > s)
1831 // {
1832 // tmp.Add(chunk);
1833 // chunk = new LSL_Types.list();
1834 // c = 0;
1835 // }
1836 // chunk.Add(element);
1837 //}
1838 //if (chunk.Count > 0)
1839 // tmp.Add(chunk);
1840
1841 // Decreate (<- what kind of word is that? :D ) array back into a list
1842 //int rnd;
1843 //LSL_Types.list ret = new LSL_Types.list();
1844 //while (tmp.Count > 0)
1845 //{
1846 // rnd = Util.RandomClass.Next(tmp.Count);
1847 // foreach (string str in tmp[rnd])
1848 // {
1849 // ret.Add(str);
1850 // }
1851 // tmp.RemoveAt(rnd);
1852 //}
1853
1854 //return ret;
1855 NotImplemented("llListRandomize");
1856 return new LSL_Types.list();
1857 }
1858
1859 public LSL_Types.list llList2ListStrided(LSL_Types.list src, int start, int end, int stride)
1860 {
1861 LSL_Types.list ret = new LSL_Types.list();
1862 //int s = stride;
1863 //if (s < 1)
1864 // s = 1;
1865
1866 //int sc = s;
1867 //for (int i = start; i < src.Count; i++)
1868 //{
1869 // sc--;
1870 // if (sc == 0)
1871 // {
1872 // sc = s;
1873 // // Addthis
1874 // ret.Add(src[i]);
1875 // }
1876 // if (i == end)
1877 // break;
1878 //}
1879 NotImplemented("llList2ListStrided");
1880 return ret;
1881 }
1882
1883 public LSL_Types.Vector3 llGetRegionCorner()
1884 {
1885 return new LSL_Types.Vector3(World.RegionInfo.RegionLocX * 256, World.RegionInfo.RegionLocY * 256, 0);
1886 }
1887
1888 public LSL_Types.list llListInsertList(LSL_Types.list dest, LSL_Types.list src, int start)
1889 {
1890 return dest.GetSublist(0, start - 1) + src + dest.GetSublist(start, -1);
1891 }
1892
1893 public int llListFindList(LSL_Types.list src, LSL_Types.list test)
1894 {
1895 //foreach (string s in test)
1896 //{
1897 // for (int ci = 0; ci < src.Count; ci++)
1898 // {
1899 // if (s == src[ci])
1900 // return ci;
1901 // }
1902 //}
1903 NotImplemented("llListFindList");
1904 return -1;
1905 }
1906
1907 public string llGetObjectName()
1908 {
1909 return m_host.Name;
1910 }
1911
1912 public void llSetObjectName(string name)
1913 {
1914 m_host.Name = name;
1915 }
1916
1917 public string llGetDate()
1918 {
1919 DateTime date = DateTime.Now.ToUniversalTime();
1920 string result = date.ToString("yyyy-MM-dd");
1921 return result;
1922 }
1923
1924 public int llEdgeOfWorld(LSL_Types.Vector3 pos, LSL_Types.Vector3 dir)
1925 {
1926 NotImplemented("llEdgeOfWorld");
1927 return 0;
1928 }
1929
1930 public int llGetAgentInfo(string id)
1931 {
1932 NotImplemented("llGetAgentInfo");
1933 return 0;
1934 }
1935
1936 public void llAdjustSoundVolume(double volume)
1937 {
1938 NotImplemented("llAdjustSoundVolume");
1939 }
1940
1941 public void llSetSoundQueueing(int queue)
1942 {
1943 NotImplemented("llSetSoundQueueing");
1944 }
1945
1946 public void llSetSoundRadius(double radius)
1947 {
1948 NotImplemented("llSetSoundRadius");
1949 }
1950
1951 public string llKey2Name(string id)
1952 {
1953 NotImplemented("llKey2Name");
1954 return "";
1955 }
1956
1957 public void llSetTextureAnim(int mode, int face, int sizex, int sizey, double start, double length, double rate)
1958 {
1959 NotImplemented("llSetTextureAnim");
1960 }
1961
1962 public void llTriggerSoundLimited(string sound, double volume, LSL_Types.Vector3 top_north_east,
1963 LSL_Types.Vector3 bottom_south_west)
1964 {
1965 NotImplemented("llTriggerSoundLimited");
1966 }
1967
1968 public void llEjectFromLand(string pest)
1969 {
1970 NotImplemented("llEjectFromLand");
1971 }
1972
1973 public void llParseString2List()
1974 {
1975 NotImplemented("llParseString2List");
1976 }
1977
1978 public int llOverMyLand(string id)
1979 {
1980 NotImplemented("llOverMyLand");
1981 return 0;
1982 }
1983
1984 public string llGetLandOwnerAt(LSL_Types.Vector3 pos)
1985 {
1986 return World.GetLandOwner((float)pos.x, (float)pos.y).ToString();
1987 }
1988
1989 public string llGetNotecardLine(string name, int line)
1990 {
1991 NotImplemented("llGetNotecardLine");
1992 return "";
1993 }
1994
1995 public LSL_Types.Vector3 llGetAgentSize(string id)
1996 {
1997 NotImplemented("llGetAgentSize");
1998 return new LSL_Types.Vector3();
1999 }
2000
2001 public int llSameGroup(string agent)
2002 {
2003 NotImplemented("llSameGroup");
2004 return 0;
2005 }
2006
2007 public void llUnSit(string id)
2008 {
2009 NotImplemented("llUnSit");
2010 }
2011
2012 public LSL_Types.Vector3 llGroundSlope(LSL_Types.Vector3 offset)
2013 {
2014 NotImplemented("llGroundSlope");
2015 return new LSL_Types.Vector3();
2016 }
2017
2018 public LSL_Types.Vector3 llGroundNormal(LSL_Types.Vector3 offset)
2019 {
2020 NotImplemented("llGroundNormal");
2021 return new LSL_Types.Vector3();
2022 }
2023
2024 public LSL_Types.Vector3 llGroundContour(LSL_Types.Vector3 offset)
2025 {
2026 NotImplemented("llGroundContour");
2027 return new LSL_Types.Vector3();
2028 }
2029
2030 public int llGetAttached()
2031 {
2032 NotImplemented("llGetAttached");
2033 return 0;
2034 }
2035
2036 public int llGetFreeMemory()
2037 {
2038 NotImplemented("llGetFreeMemory");
2039 return 0;
2040 }
2041
2042 public string llGetRegionName()
2043 {
2044 return World.RegionInfo.RegionName;
2045 }
2046
2047 public double llGetRegionTimeDilation()
2048 {
2049 return (double)World.TimeDilation;
2050 }
2051
2052 public double llGetRegionFPS()
2053 {
2054 return 10.0f;
2055 }
2056
2057 /* particle system rules should be coming into this routine as doubles, that is
2058 rule[0] should be an integer from this list and rule[1] should be the arg
2059 for the same integer. wiki.secondlife.com has most of this mapping, but some
2060 came from http://www.caligari-designs.com/p4u2
2061
2062 We iterate through the list for 'Count' elements, incrementing by two for each
2063 iteration and set the members of Primitive.ParticleSystem, one at a time.
2064 */
2065
2066 public enum PrimitiveRule : int
2067 {
2068 PSYS_PART_FLAGS = 0,
2069 PSYS_PART_START_COLOR = 1,
2070 PSYS_PART_START_ALPHA = 2,
2071 PSYS_PART_END_COLOR = 3,
2072 PSYS_PART_END_ALPHA = 4,
2073 PSYS_PART_START_SCALE = 5,
2074 PSYS_PART_END_SCALE = 6,
2075 PSYS_PART_MAX_AGE = 7,
2076 PSYS_SRC_ACCEL = 8,
2077 PSYS_SRC_PATTERN = 9,
2078 PSYS_SRC_TEXTURE = 12,
2079 PSYS_SRC_BURST_RATE = 13,
2080 PSYS_SRC_BURST_PART_COUNT = 15,
2081 PSYS_SRC_BURST_RADIUS = 16,
2082 PSYS_SRC_BURST_SPEED_MIN = 17,
2083 PSYS_SRC_BURST_SPEED_MAX = 18,
2084 PSYS_SRC_MAX_AGE = 19,
2085 PSYS_SRC_TARGET_KEY = 20,
2086 PSYS_SRC_OMEGA = 21,
2087 PSYS_SRC_ANGLE_BEGIN = 22,
2088 PSYS_SRC_ANGLE_END = 23
2089 }
2090
2091 public void llParticleSystem(List<Object> rules)
2092 {
2093 Primitive.ParticleSystem prules = new Primitive.ParticleSystem();
2094 for (int i = 0; i < rules.Count; i += 2)
2095 {
2096 switch ((int)rules[i])
2097 {
2098 case (int)LSL_BaseClass.PSYS_PART_FLAGS:
2099 prules.PartFlags = (uint)rules[i + 1];
2100 break;
2101
2102 case (int)LSL_BaseClass.PSYS_PART_START_COLOR:
2103 prules.PartStartColor = (LLColor)rules[i + 1];
2104 break;
2105
2106 case (int)LSL_BaseClass.PSYS_PART_START_ALPHA:
2107 //what is the cast? prules.PartStartColor = (LSL_Types.Vec)rules[i + 1];
2108 break;
2109
2110 case (int)LSL_BaseClass.PSYS_PART_END_COLOR:
2111 prules.PartEndColor = (LLColor)rules[i + 1];
2112 break;
2113
2114 case (int)LSL_BaseClass.PSYS_PART_END_ALPHA:
2115 //what is the cast? prules.PartStartColor = (LLColor)rules[i + 1];
2116 break;
2117
2118 case (int)LSL_BaseClass.PSYS_PART_START_SCALE:
2119 //what is the cast? prules.PartStartColor = (LLColor)rules[i + 1];
2120 break;
2121
2122 case (int)LSL_BaseClass.PSYS_PART_END_SCALE:
2123 //what is the cast? prules.PartStartColor = (LLColor)rules[i + 1];
2124 break;
2125
2126 case (int)LSL_BaseClass.PSYS_PART_MAX_AGE:
2127 prules.MaxAge = (float)rules[i + 1];
2128 break;
2129
2130 case (int)LSL_BaseClass.PSYS_SRC_ACCEL:
2131 //what is the cast? prules.PartStartColor = (LLColor)rules[i + 1];
2132 break;
2133
2134 case (int)LSL_BaseClass.PSYS_SRC_PATTERN:
2135 //what is the cast? prules.PartStartColor = (LLColor)rules[i + 1];
2136 break;
2137
2138 case (int)LSL_BaseClass.PSYS_SRC_TEXTURE:
2139 prules.Texture = (LLUUID)rules[i + 1];
2140 break;
2141
2142 case (int)LSL_BaseClass.PSYS_SRC_BURST_RATE:
2143 prules.BurstRate = (float)rules[i + 1];
2144 break;
2145
2146 case (int)LSL_BaseClass.PSYS_SRC_BURST_PART_COUNT:
2147 prules.BurstPartCount = (byte)rules[i + 1];
2148 break;
2149
2150 case (int)LSL_BaseClass.PSYS_SRC_BURST_RADIUS:
2151 prules.BurstRadius = (float)rules[i + 1];
2152 break;
2153
2154 case (int)LSL_BaseClass.PSYS_SRC_BURST_SPEED_MIN:
2155 prules.BurstSpeedMin = (float)rules[i + 1];
2156 break;
2157
2158 case (int)LSL_BaseClass.PSYS_SRC_BURST_SPEED_MAX:
2159 prules.BurstSpeedMax = (float)rules[i + 1];
2160 break;
2161
2162 case (int)LSL_BaseClass.PSYS_SRC_MAX_AGE:
2163 prules.MaxAge = (float)rules[i + 1];
2164 break;
2165
2166 case (int)LSL_BaseClass.PSYS_SRC_TARGET_KEY:
2167 prules.Target = (LLUUID)rules[i + 1];
2168 break;
2169
2170 case (int)LSL_BaseClass.PSYS_SRC_OMEGA:
2171 //cast?? prules.MaxAge = (float)rules[i + 1];
2172 break;
2173
2174 case (int)LSL_BaseClass.PSYS_SRC_ANGLE_BEGIN:
2175 prules.InnerAngle = (float)rules[i + 1];
2176 break;
2177
2178 case (int)LSL_BaseClass.PSYS_SRC_ANGLE_END:
2179 prules.OuterAngle = (float)rules[i + 1];
2180 break;
2181 }
2182 }
2183
2184 m_host.AddNewParticleSystem(prules);
2185 }
2186
2187 public void llGroundRepel(double height, int water, double tau)
2188 {
2189 NotImplemented("llGroundRepel");
2190 }
2191
2192 public void llGiveInventoryList()
2193 {
2194 NotImplemented("llGiveInventoryList");
2195 }
2196
2197 public void llSetVehicleType(int type)
2198 {
2199 NotImplemented("llSetVehicleType");
2200 }
2201
2202 public void llSetVehicledoubleParam(int param, double value)
2203 {
2204 NotImplemented("llSetVehicledoubleParam");
2205 }
2206
2207 public void llSetVehicleVectorParam(int param, LSL_Types.Vector3 vec)
2208 {
2209 NotImplemented("llSetVehicleVectorParam");
2210 }
2211
2212 public void llSetVehicleRotationParam(int param, LSL_Types.Quaternion rot)
2213 {
2214 NotImplemented("llSetVehicleRotationParam");
2215 }
2216
2217 public void llSetVehicleFlags(int flags)
2218 {
2219 NotImplemented("llSetVehicleFlags");
2220 }
2221
2222 public void llRemoveVehicleFlags(int flags)
2223 {
2224 NotImplemented("llRemoveVehicleFlags");
2225 }
2226
2227 public void llSitTarget(LSL_Types.Vector3 offset, LSL_Types.Quaternion rot)
2228 {
2229 // LSL quaternions can normalize to 0, normal Quaternions can't.
2230 if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0)
2231 rot.z = 1; // ZERO_ROTATION = 0,0,0,1
2232
2233 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));
2234 }
2235
2236 public string llAvatarOnSitTarget()
2237 {
2238 LLUUID AVID = m_host.GetAvatarOnSitTarget();
2239
2240 if (AVID != LLUUID.Zero)
2241 return AVID.ToString();
2242 else
2243 return "";
2244 }
2245
2246 public void llAddToLandPassList(string avatar, double hours)
2247 {
2248 NotImplemented("llAddToLandPassList");
2249 }
2250
2251 public void llSetTouchText(string text)
2252 {
2253 m_host.TouchName = text;
2254 }
2255
2256 public void llSetSitText(string text)
2257 {
2258 m_host.SitName = text;
2259 }
2260
2261 public void llSetCameraEyeOffset(LSL_Types.Vector3 offset)
2262 {
2263 NotImplemented("llSetCameraEyeOffset");
2264 }
2265
2266 public void llSetCameraAtOffset(LSL_Types.Vector3 offset)
2267 {
2268 NotImplemented("llSetCameraAtOffset");
2269 }
2270
2271 public string llDumpList2String(LSL_Types.list src, string seperator)
2272 {
2273 if (src.Length == 0)
2274 {
2275 return "";
2276 }
2277 string ret = "";
2278 foreach (object o in src.Data)
2279 {
2280 ret = ret + o.ToString() + seperator;
2281 }
2282 ret = ret.Substring(0, ret.Length - seperator.Length);
2283 return ret;
2284 }
2285
2286 public void llScriptDanger(LSL_Types.Vector3 pos)
2287 {
2288 NotImplemented("llScriptDanger");
2289 }
2290
2291 public void llDialog(string avatar, string message, LSL_Types.list buttons, int chat_channel)
2292 {
2293 NotImplemented("llDialog");
2294 }
2295
2296 public void llVolumeDetect(int detect)
2297 {
2298 NotImplemented("llVolumeDetect");
2299 }
2300
2301 public void llResetOtherScript(string name)
2302 {
2303 NotImplemented("llResetOtherScript");
2304 }
2305
2306 public int llGetScriptState(string name)
2307 {
2308 NotImplemented("llGetScriptState");
2309 return 0;
2310 }
2311
2312 public void llRemoteLoadScript()
2313 {
2314 NotImplemented("llRemoteLoadScript");
2315 }
2316
2317 public void llSetRemoteScriptAccessPin(int pin)
2318 {
2319 NotImplemented("llSetRemoteScriptAccessPin");
2320 }
2321
2322 public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param)
2323 {
2324 NotImplemented("llRemoteLoadScriptPin");
2325 }
2326
2327 // remote_data(integer type, key channel, key message_id, string sender, integer ival, string sval)
2328 // Not sure where these constants should live:
2329 // REMOTE_DATA_CHANNEL = 1
2330 // REMOTE_DATA_REQUEST = 2
2331 // REMOTE_DATA_REPLY = 3
2332 public void llOpenRemoteDataChannel()
2333 {
2334 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
2335 if (xmlrpcMod.IsEnabled())
2336 {
2337 LLUUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_localID, m_itemID);
2338 object[] resobj = new object[] { 1, channelID.ToString(), LLUUID.Zero.ToString(), "", 0, "" };
2339 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(m_localID, m_itemID, "remote_data", resobj);
2340 }
2341 }
2342
2343 public string llSendRemoteData(string channel, string dest, int idata, string sdata)
2344 {
2345 NotImplemented("llSendRemoteData");
2346 return "";
2347 }
2348
2349 public void llRemoteDataReply(string channel, string message_id, string sdata, int idata)
2350 {
2351 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
2352 xmlrpcMod.RemoteDataReply(channel, message_id, sdata, idata);
2353 }
2354
2355 public void llCloseRemoteDataChannel(string channel)
2356 {
2357 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
2358 xmlrpcMod.CloseXMLRPCChannel(channel);
2359 }
2360
2361 public string llMD5String(string src, int nonce)
2362 {
2363 return Util.Md5Hash(src + ":" + nonce.ToString());
2364 }
2365
2366 public void llSetPrimitiveParams(LSL_Types.list rules)
2367 {
2368 NotImplemented("llSetPrimitiveParams");
2369 }
2370
2371 public string llStringToBase64(string str)
2372 {
2373 try
2374 {
2375 byte[] encData_byte = new byte[str.Length];
2376 encData_byte = Encoding.UTF8.GetBytes(str);
2377 string encodedData = Convert.ToBase64String(encData_byte);
2378 return encodedData;
2379 }
2380 catch (Exception e)
2381 {
2382 throw new Exception("Error in base64Encode" + e.Message);
2383 }
2384 }
2385
2386 public string llBase64ToString(string str)
2387 {
2388 UTF8Encoding encoder = new UTF8Encoding();
2389 Decoder utf8Decode = encoder.GetDecoder();
2390 try
2391 {
2392 byte[] todecode_byte = Convert.FromBase64String(str);
2393 int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
2394 char[] decoded_char = new char[charCount];
2395 utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
2396 string result = new String(decoded_char);
2397 return result;
2398 }
2399 catch (Exception e)
2400 {
2401 throw new Exception("Error in base64Decode" + e.Message);
2402 }
2403 }
2404
2405 public void llXorBase64Strings()
2406 {
2407 throw new Exception("Command deprecated! Use llXorBase64StringsCorrect instead.");
2408 }
2409
2410 public void llRemoteDataSetRegion()
2411 {
2412 NotImplemented("llRemoteDataSetRegion");
2413 }
2414
2415 public double llLog10(double val)
2416 {
2417 return (double)Math.Log10(val);
2418 }
2419
2420 public double llLog(double val)
2421 {
2422 return (double)Math.Log(val);
2423 }
2424
2425 public LSL_Types.list llGetAnimationList(string id)
2426 {
2427 NotImplemented("llGetAnimationList");
2428 return new LSL_Types.list();
2429 }
2430
2431 public void llSetParcelMusicURL(string url)
2432 {
2433 LLUUID landowner = World.GetLandOwner(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y);
2434 if (landowner.Equals(null))
2435 {
2436 return;
2437 }
2438 if (landowner != m_host.ObjectOwner)
2439 {
2440 return;
2441 }
2442 World.SetLandMusicURL(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, url);
2443 }
2444
2445 public LSL_Types.Vector3 llGetRootPosition()
2446 {
2447 return new LSL_Types.Vector3(m_host.ParentGroup.AbsolutePosition.X, m_host.ParentGroup.AbsolutePosition.Y, m_host.ParentGroup.AbsolutePosition.Z);
2448 }
2449
2450 public LSL_Types.Quaternion llGetRootRotation()
2451 {
2452 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);
2453 }
2454
2455 public string llGetObjectDesc()
2456 {
2457 return m_host.Description;
2458 }
2459
2460 public void llSetObjectDesc(string desc)
2461 {
2462 m_host.Description = desc;
2463 }
2464
2465 public string llGetCreator()
2466 {
2467 return m_host.ObjectCreator.ToString();
2468 }
2469
2470 public string llGetTimestamp()
2471 {
2472 return DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ");
2473 }
2474
2475 public void llSetLinkAlpha(int linknumber, double alpha, int face)
2476 {
2477 SceneObjectPart part = m_host.ParentGroup.GetLinkNumPart(linknumber);
2478 if (linknumber > -1)
2479 {
2480 LLObject.TextureEntry tex = part.Shape.Textures;
2481 LLColor texcolor;
2482 if (face > -1)
2483 {
2484 texcolor = tex.CreateFace((uint)face).RGBA;
2485 texcolor.A = (float)Math.Abs(alpha - 1);
2486 tex.FaceTextures[face].RGBA = texcolor;
2487 part.UpdateTexture(tex);
2488 return;
2489 }
2490 else if (face == -1)
2491 {
2492 texcolor = tex.DefaultTexture.RGBA;
2493 texcolor.A = (float)Math.Abs(alpha - 1);
2494 tex.DefaultTexture.RGBA = texcolor;
2495 for (uint i = 0; i < 32; i++)
2496 {
2497 if (tex.FaceTextures[i] != null)
2498 {
2499 texcolor = tex.FaceTextures[i].RGBA;
2500 texcolor.A = (float)Math.Abs(alpha - 1);
2501 tex.FaceTextures[i].RGBA = texcolor;
2502 }
2503 }
2504 texcolor = tex.DefaultTexture.RGBA;
2505 texcolor.A = (float)Math.Abs(alpha - 1);
2506 tex.DefaultTexture.RGBA = texcolor;
2507 part.UpdateTexture(tex);
2508 return;
2509 }
2510 return;
2511 }
2512 else if (linknumber == -1)
2513 {
2514 int num = m_host.ParentGroup.PrimCount;
2515 for (int w = 0; w < num; w++)
2516 {
2517 linknumber = w;
2518 part = m_host.ParentGroup.GetLinkNumPart(linknumber);
2519 LLObject.TextureEntry tex = part.Shape.Textures;
2520 LLColor texcolor;
2521 if (face > -1)
2522 {
2523 texcolor = tex.CreateFace((uint)face).RGBA;
2524 texcolor.A = (float)Math.Abs(alpha - 1);
2525 tex.FaceTextures[face].RGBA = texcolor;
2526 part.UpdateTexture(tex);
2527 }
2528 else if (face == -1)
2529 {
2530 texcolor = tex.DefaultTexture.RGBA;
2531 texcolor.A = (float)Math.Abs(alpha - 1);
2532 tex.DefaultTexture.RGBA = texcolor;
2533 for (uint i = 0; i < 32; i++)
2534 {
2535 if (tex.FaceTextures[i] != null)
2536 {
2537 texcolor = tex.FaceTextures[i].RGBA;
2538 texcolor.A = (float)Math.Abs(alpha - 1);
2539 tex.FaceTextures[i].RGBA = texcolor;
2540 }
2541 }
2542 texcolor = tex.DefaultTexture.RGBA;
2543 texcolor.A = (float)Math.Abs(alpha - 1);
2544 tex.DefaultTexture.RGBA = texcolor;
2545 part.UpdateTexture(tex);
2546 }
2547 }
2548 return;
2549 }
2550 else
2551 {
2552 NotImplemented("llSetLinkAlpha");
2553 }
2554 }
2555
2556 public int llGetNumberOfPrims()
2557 {
2558 return m_host.ParentGroup.PrimCount;
2559 }
2560
2561 public string llGetNumberOfNotecardLines(string name)
2562 {
2563 NotImplemented("llGetNumberOfNotecardLines");
2564 return "";
2565 }
2566
2567 public LSL_Types.list llGetBoundingBox(string obj)
2568 {
2569 NotImplemented("llGetBoundingBox");
2570 return new LSL_Types.list();
2571 }
2572
2573 public LSL_Types.Vector3 llGetGeometricCenter()
2574 {
2575 return new LSL_Types.Vector3(m_host.GetGeometricCenter().X, m_host.GetGeometricCenter().Y, m_host.GetGeometricCenter().Z);
2576 }
2577
2578 public void llGetPrimitiveParams()
2579 {
2580 NotImplemented("llGetPrimitiveParams");
2581 }
2582
2583 public string llIntegerToBase64(int number)
2584 {
2585 NotImplemented("llIntegerToBase64");
2586 return "";
2587 }
2588
2589 public int llBase64ToInteger(string str)
2590 {
2591 NotImplemented("llBase64ToInteger");
2592 return 0;
2593 }
2594
2595 public double llGetGMTclock()
2596 {
2597 return DateTime.UtcNow.TimeOfDay.TotalSeconds;
2598 }
2599
2600 public string llGetSimulatorHostname()
2601 {
2602 return System.Environment.MachineName;
2603 }
2604
2605 public void llSetLocalRot(LSL_Types.Quaternion rot)
2606 {
2607 m_host.RotationOffset = new LLQuaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s);
2608 }
2609
2610 public LSL_Types.list llParseStringKeepNulls(string src, LSL_Types.list seperators, LSL_Types.list spacers)
2611 {
2612 NotImplemented("llParseStringKeepNulls");
2613 return new LSL_Types.list();
2614 }
2615
2616 public void llRezAtRoot(string inventory, LSL_Types.Vector3 position, LSL_Types.Vector3 velocity,
2617 LSL_Types.Quaternion rot, int param)
2618 {
2619 NotImplemented("llRezAtRoot");
2620 }
2621
2622 public int llGetObjectPermMask(int mask)
2623 {
2624 NotImplemented("llGetObjectPermMask");
2625 return 0;
2626 }
2627
2628 public void llSetObjectPermMask(int mask, int value)
2629 {
2630 NotImplemented("llSetObjectPermMask");
2631 }
2632
2633 public void llGetInventoryPermMask(string item, int mask)
2634 {
2635 NotImplemented("llGetInventoryPermMask");
2636 }
2637
2638 public void llSetInventoryPermMask(string item, int mask, int value)
2639 {
2640 NotImplemented("llSetInventoryPermMask");
2641 }
2642
2643 public string llGetInventoryCreator(string item)
2644 {
2645 NotImplemented("llGetInventoryCreator");
2646 return "";
2647 }
2648
2649 public void llOwnerSay(string msg)
2650 {
2651 //temp fix so that lsl wiki examples aren't annoying to use to test other functions
2652 World.SimChat(Helpers.StringToField(msg), ChatTypeEnum.Say, 0, m_host.AbsolutePosition, m_host.Name, m_host.UUID);
2653 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
2654 wComm.DeliverMessage(m_host.UUID.ToString(), ChatTypeEnum.Say, 0, m_host.Name, msg);
2655 }
2656
2657 public void llRequestSimulatorData(string simulator, int data)
2658 {
2659 NotImplemented("llRequestSimulatorData");
2660 }
2661
2662 public void llForceMouselook(int mouselook)
2663 {
2664 NotImplemented("llForceMouselook");
2665 }
2666
2667 public double llGetObjectMass(string id)
2668 {
2669 NotImplemented("llGetObjectMass");
2670 return 0;
2671 }
2672
2673 public LSL_Types.list llListReplaceList(LSL_Types.list dest, LSL_Types.list src, int start, int end)
2674 {
2675 return dest.GetSublist(0, start - 1) + src + dest.GetSublist(end + 1, -1);
2676 }
2677
2678 public void llLoadURL(string avatar_id, string message, string url)
2679 {
2680 LLUUID avatarId = new LLUUID(avatar_id);
2681 m_ScriptEngine.World.SendUrlToUser(avatarId, m_host.Name, m_host.UUID, m_host.ObjectOwner, false, message,
2682 url);
2683 }
2684
2685 public void llParcelMediaCommandList(LSL_Types.list commandList)
2686 {
2687 NotImplemented("llParcelMediaCommandList");
2688 }
2689
2690 public void llParcelMediaQuery()
2691 {
2692 NotImplemented("llParcelMediaQuery");
2693 }
2694
2695 public int llModPow(int a, int b, int c)
2696 {
2697 Int64 tmp = 0;
2698 Int64 val = Math.DivRem(Convert.ToInt64(Math.Pow(a, b)), c, out tmp);
2699 return Convert.ToInt32(tmp);
2700 }
2701
2702 public int llGetInventoryType(string name)
2703 {
2704 NotImplemented("llGetInventoryType");
2705 return 0;
2706 }
2707
2708 public void llSetPayPrice(int price, LSL_Types.list quick_pay_buttons)
2709 {
2710 NotImplemented("llSetPayPrice");
2711 }
2712
2713 public LSL_Types.Vector3 llGetCameraPos()
2714 {
2715 NotImplemented("llGetCameraPos");
2716 return new LSL_Types.Vector3();
2717 }
2718
2719 public LSL_Types.Quaternion llGetCameraRot()
2720 {
2721 NotImplemented("llGetCameraRot");
2722 return new LSL_Types.Quaternion();
2723 }
2724
2725 public void llSetPrimURL()
2726 {
2727 NotImplemented("llSetPrimURL");
2728 }
2729
2730 public void llRefreshPrimURL()
2731 {
2732 NotImplemented("llRefreshPrimURL");
2733 }
2734
2735 public string llEscapeURL(string url)
2736 {
2737 try
2738 {
2739 return Uri.EscapeUriString(url);
2740 }
2741 catch (Exception ex)
2742 {
2743 return "llEscapeURL: " + ex.ToString();
2744 }
2745 }
2746
2747 public string llUnescapeURL(string url)
2748 {
2749 try
2750 {
2751 return Uri.UnescapeDataString(url);
2752 }
2753 catch (Exception ex)
2754 {
2755 return "llUnescapeURL: " + ex.ToString();
2756 }
2757 }
2758
2759 public void llMapDestination(string simname, LSL_Types.Vector3 pos, LSL_Types.Vector3 look_at)
2760 {
2761 NotImplemented("llMapDestination");
2762 }
2763
2764 public void llAddToLandBanList(string avatar, double hours)
2765 {
2766 NotImplemented("llAddToLandBanList");
2767 }
2768
2769 public void llRemoveFromLandPassList(string avatar)
2770 {
2771 NotImplemented("llRemoveFromLandPassList");
2772 }
2773
2774 public void llRemoveFromLandBanList(string avatar)
2775 {
2776 NotImplemented("llRemoveFromLandBanList");
2777 }
2778
2779 public void llSetCameraParams(LSL_Types.list rules)
2780 {
2781 NotImplemented("llSetCameraParams");
2782 }
2783
2784 public void llClearCameraParams()
2785 {
2786 NotImplemented("llClearCameraParams");
2787 }
2788
2789 public double llListStatistics(int operation, LSL_Types.list src)
2790 {
2791 NotImplemented("llListStatistics");
2792 return 0;
2793 }
2794
2795 public int llGetUnixTime()
2796 {
2797 return Util.UnixTimeSinceEpoch();
2798 }
2799
2800 public int llGetParcelFlags(LSL_Types.Vector3 pos)
2801 {
2802 NotImplemented("llGetParcelFlags");
2803 return 0;
2804 }
2805
2806 public int llGetRegionFlags()
2807 {
2808 NotImplemented("llGetRegionFlags");
2809 return 0;
2810 }
2811
2812 public string llXorBase64StringsCorrect(string str1, string str2)
2813 {
2814 string ret = "";
2815 string src1 = llBase64ToString(str1);
2816 string src2 = llBase64ToString(str2);
2817 int c = 0;
2818 for (int i = 0; i < src1.Length; i++)
2819 {
2820 ret += src1[i] ^ src2[c];
2821
2822 c++;
2823 if (c > src2.Length)
2824 c = 0;
2825 }
2826 return llStringToBase64(ret);
2827 }
2828
2829 public string llHTTPRequest(string url, LSL_Types.list parameters, string body)
2830 {
2831 IHttpRequests httpScriptMod =
2832 m_ScriptEngine.World.RequestModuleInterface<IHttpRequests>();
2833 List<string> param = new List<string>();
2834 foreach (object o in parameters.Data)
2835 {
2836 param.Add(o.ToString());
2837 }
2838 LLUUID reqID = httpScriptMod.
2839 StartHttpRequest(m_localID, m_itemID, url, param, body);
2840
2841 if (!reqID.Equals(null))
2842 return reqID.ToString();
2843 else
2844 return null;
2845 }
2846
2847 public void llResetLandBanList()
2848 {
2849 NotImplemented("llResetLandBanList");
2850 }
2851
2852 public void llResetLandPassList()
2853 {
2854 NotImplemented("llResetLandPassList");
2855 }
2856
2857 public int llGetParcelPrimCount(LSL_Types.Vector3 pos, int category, int sim_wide)
2858 {
2859 NotImplemented("llGetParcelPrimCount");
2860 return 0;
2861 }
2862
2863 public LSL_Types.list llGetParcelPrimOwners(LSL_Types.Vector3 pos)
2864 {
2865 NotImplemented("llGetParcelPrimOwners");
2866 return new LSL_Types.list();
2867 }
2868
2869 public int llGetObjectPrimCount(string object_id)
2870 {
2871 SceneObjectPart part = World.GetSceneObjectPart(new LLUUID(object_id));
2872 if (part == null)
2873 {
2874 return 0;
2875 }
2876 else
2877 {
2878 return part.ParentGroup.Children.Count;
2879 }
2880 }
2881
2882 public int llGetParcelMaxPrims(LSL_Types.Vector3 pos, int sim_wide)
2883 {
2884 // Alondria: This currently just is utilizing the normal grid's 0.22 prims/m2 calculation
2885 // Which probably will be irrelevent in OpenSim....
2886 LandData land = World.GetLandData((float)pos.x, (float)pos.y);
2887 float bonusfactor = World.RegionInfo.EstateSettings.objectBonusFactor;
2888 if (land == null)
2889 {
2890 return 0;
2891 }
2892 if (sim_wide == 1)
2893 {
2894 decimal v = land.simwideArea * (decimal)(0.22) * (decimal)bonusfactor;
2895 return (int)v;
2896 }
2897 else
2898 {
2899 decimal v = land.area * (decimal)(0.22) * (decimal)bonusfactor;
2900 return (int)v;
2901 }
2902
2903 }
2904
2905 public LSL_Types.list llGetParcelDetails(LSL_Types.Vector3 pos, LSL_Types.list param)
2906 {
2907 LandData land = World.GetLandData((float)pos.x, (float)pos.y);
2908 if (land == null)
2909 {
2910 return new LSL_Types.list(0);
2911 }
2912 LSL_Types.list ret = new LSL_Types.list();
2913 foreach (object o in param.Data)
2914 {
2915 switch (o.ToString())
2916 {
2917 case "0":
2918 ret = ret + new LSL_Types.list(land.landName);
2919 break;
2920 case "1":
2921 ret = ret + new LSL_Types.list(land.landDesc);
2922 break;
2923 case "2":
2924 ret = ret + new LSL_Types.list(land.ownerID.ToString());
2925 break;
2926 case "3":
2927 ret = ret + new LSL_Types.list(land.groupID.ToString());
2928 break;
2929 case "4":
2930 ret = ret + new LSL_Types.list(land.area);
2931 break;
2932 default:
2933 ret = ret + new LSL_Types.list(0);
2934 break;
2935 }
2936 }
2937 return ret;
2938 }
2939
2940 //
2941 // OpenSim functions
2942 //
2943 public int osTerrainSetHeight(int x, int y, double val)
2944 {
2945 if (x > 255 || x < 0 || y > 255 || y < 0)
2946 LSLError("osTerrainSetHeight: Coordinate out of bounds");
2947
2948 if (World.PermissionsMngr.CanTerraform(m_host.OwnerID, new LLVector3(x, y, 0)))
2949 {
2950 World.Terrain.Set(x, y, val);
2951 return 1;
2952 }
2953 else
2954 {
2955 return 0;
2956 }
2957 }
2958
2959 public double osTerrainGetHeight(int x, int y)
2960 {
2961 if (x > 255 || x < 0 || y > 255 || y < 0)
2962 LSLError("osTerrainGetHeight: Coordinate out of bounds");
2963
2964 return World.Terrain.GetHeight(x, y);
2965 }
2966
2967 public int osRegionRestart(double seconds)
2968 {
2969 if (World.PermissionsMngr.CanRestartSim(m_host.OwnerID))
2970 {
2971 World.Restart((float)seconds);
2972 return 1;
2973 }
2974 else
2975 {
2976 return 0;
2977 }
2978 }
2979
2980 public void osRegionNotice(string msg)
2981 {
2982 World.SendGeneralAlert(msg);
2983 }
2984
2985 public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams,
2986 int timer)
2987 {
2988 if (dynamicID == "")
2989 {
2990 IDynamicTextureManager textureManager = World.RequestModuleInterface<IDynamicTextureManager>();
2991 LLUUID createdTexture =
2992 textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, contentType, url,
2993 extraParams, timer);
2994 return createdTexture.ToString();
2995 }
2996 else
2997 {
2998 //TODO update existing dynamic textures
2999 }
3000
3001 return LLUUID.Zero.ToString();
3002 }
3003
3004 private void NotImplemented(string Command)
3005 {
3006 if (throwErrorOnNotImplemented)
3007 throw new NotImplementedException("Command not implemented: " + Command);
3008 }
3009
3010 private void LSLError(string msg)
3011 {
3012 throw new Exception("LSL Runtime Error: " + msg);
3013 }
3014 }
3015}
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs
deleted file mode 100644
index a36691d..0000000
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs
+++ /dev/null
@@ -1,259 +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/* Original code: Tedd Hansen */
29using System;
30using libsecondlife;
31using OpenSim.Framework;
32
33namespace OpenSim.Region.ScriptEngine.DotNetEngine
34{
35 /// <summary>
36 /// Prepares events so they can be directly executed upon a script by EventQueueManager, then queues it.
37 /// </summary>
38 [Serializable]
39 public class EventManager : OpenSim.Region.ScriptEngine.Common.ScriptServerInterfaces.RemoteEvents
40 {
41
42 //
43 // Class is instanced in "ScriptEngine" and Uses "EventQueueManager" that is also instanced in "ScriptEngine".
44 // This class needs a bit of explaining:
45 //
46 // This class it the link between an event inside OpenSim and the corresponding event in a user script being executed.
47 //
48 // For example when an user touches an object then the "myScriptEngine.World.EventManager.OnObjectGrab" event is fired inside OpenSim.
49 // We hook up to this event and queue a touch_start in EventQueueManager with the proper LSL parameters.
50 // It will then be delivered to the script by EventQueueManager.
51 //
52 // You can check debug C# dump of an LSL script if you need to verify what exact parameters are needed.
53 //
54
55
56 private ScriptEngine myScriptEngine;
57 //public IScriptHost TEMP_OBJECT_ID;
58 public EventManager(ScriptEngine _ScriptEngine, bool performHookUp)
59 {
60 myScriptEngine = _ScriptEngine;
61
62 // Hook up to events from OpenSim
63 // We may not want to do it because someone is controlling us and will deliver events to us
64 if (performHookUp)
65 {
66 myScriptEngine.Log.Verbose("ScriptEngine", "Hooking up to server events");
67 myScriptEngine.World.EventManager.OnObjectGrab += touch_start;
68 myScriptEngine.World.EventManager.OnRezScript += OnRezScript;
69 myScriptEngine.World.EventManager.OnRemoveScript += OnRemoveScript;
70 // TODO: HOOK ALL EVENTS UP TO SERVER!
71 }
72 }
73
74 public void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient)
75 {
76 // Add to queue for all scripts in ObjectID object
77 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_start", new object[] {(int) 1});
78 }
79
80 public void OnRezScript(uint localID, LLUUID itemID, string script)
81 {
82 Console.WriteLine("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " +
83 script.Length);
84 myScriptEngine.m_ScriptManager.StartScript(localID, itemID, script);
85 }
86
87 public void OnRemoveScript(uint localID, LLUUID itemID)
88 {
89 Console.WriteLine("OnRemoveScript localID: " + localID + " LLUID: " + itemID.ToString());
90 myScriptEngine.m_ScriptManager.StopScript(
91 localID,
92 itemID
93 );
94 }
95
96 // TODO: Replace placeholders below
97 // NOTE! THE PARAMETERS FOR THESE FUNCTIONS ARE NOT CORRECT!
98 // These needs to be hooked up to OpenSim during init of this class
99 // then queued in EventQueueManager.
100 // When queued in EventQueueManager they need to be LSL compatible (name and params)
101
102 public void state_exit(uint localID, LLUUID itemID)
103 {
104 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_exit");
105 }
106
107 public void touch(uint localID, LLUUID itemID)
108 {
109 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "touch");
110 }
111
112 public void touch_end(uint localID, LLUUID itemID)
113 {
114 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "touch_end");
115 }
116
117 public void collision_start(uint localID, LLUUID itemID)
118 {
119 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision_start");
120 }
121
122 public void collision(uint localID, LLUUID itemID)
123 {
124 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision");
125 }
126
127 public void collision_end(uint localID, LLUUID itemID)
128 {
129 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision_end");
130 }
131
132 public void land_collision_start(uint localID, LLUUID itemID)
133 {
134 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision_start");
135 }
136
137 public void land_collision(uint localID, LLUUID itemID)
138 {
139 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision");
140 }
141
142 public void land_collision_end(uint localID, LLUUID itemID)
143 {
144 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision_end");
145 }
146
147 // Handled by long commands
148 public void timer(uint localID, LLUUID itemID)
149 {
150 //myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "");
151 }
152
153 public void listen(uint localID, LLUUID itemID)
154 {
155 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "listen");
156 }
157
158 public void on_rez(uint localID, LLUUID itemID)
159 {
160 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "on_rez");
161 }
162
163 public void sensor(uint localID, LLUUID itemID)
164 {
165 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "sensor");
166 }
167
168 public void no_sensor(uint localID, LLUUID itemID)
169 {
170 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "no_sensor");
171 }
172
173 public void control(uint localID, LLUUID itemID)
174 {
175 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "control");
176 }
177
178 public void money(uint localID, LLUUID itemID)
179 {
180 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "money");
181 }
182
183 public void email(uint localID, LLUUID itemID)
184 {
185 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "email");
186 }
187
188 public void at_target(uint localID, LLUUID itemID)
189 {
190 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "at_target");
191 }
192
193 public void not_at_target(uint localID, LLUUID itemID)
194 {
195 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "not_at_target");
196 }
197
198 public void at_rot_target(uint localID, LLUUID itemID)
199 {
200 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "at_rot_target");
201 }
202
203 public void not_at_rot_target(uint localID, LLUUID itemID)
204 {
205 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "not_at_rot_target");
206 }
207
208 public void run_time_permissions(uint localID, LLUUID itemID)
209 {
210 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "run_time_permissions");
211 }
212
213 public void changed(uint localID, LLUUID itemID)
214 {
215 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "changed");
216 }
217
218 public void attach(uint localID, LLUUID itemID)
219 {
220 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "attach");
221 }
222
223 public void dataserver(uint localID, LLUUID itemID)
224 {
225 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "dataserver");
226 }
227
228 public void link_message(uint localID, LLUUID itemID)
229 {
230 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "link_message");
231 }
232
233 public void moving_start(uint localID, LLUUID itemID)
234 {
235 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "moving_start");
236 }
237
238 public void moving_end(uint localID, LLUUID itemID)
239 {
240 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "moving_end");
241 }
242
243 public void object_rez(uint localID, LLUUID itemID)
244 {
245 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "object_rez");
246 }
247
248 public void remote_data(uint localID, LLUUID itemID)
249 {
250 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "remote_data");
251 }
252
253 // Handled by long commands
254 public void http_response(uint localID, LLUUID itemID)
255 {
256 // myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "http_response");
257 }
258 }
259} \ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs
deleted file mode 100644
index e7cb489..0000000
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs
+++ /dev/null
@@ -1,364 +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/* Original code: Tedd Hansen */
29using System;
30using System.Collections;
31using System.Collections.Generic;
32using System.Threading;
33using libsecondlife;
34using OpenSim.Framework;
35using OpenSim.Region.Environment.Scenes.Scripting;
36using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL;
37
38namespace OpenSim.Region.ScriptEngine.DotNetEngine
39{
40 /// <summary>
41 /// EventQueueManager handles event queues
42 /// Events are queued and executed in separate thread
43 /// </summary>
44 [Serializable]
45 internal class EventQueueManager
46 {
47
48 //
49 // Class is instanced in "ScriptEngine" and used by "EventManager" also instanced in "ScriptEngine".
50 //
51 // Class purpose is to queue and execute functions that are received by "EventManager":
52 // - allowing "EventManager" to release its event thread immediately, thus not interrupting server execution.
53 // - allowing us to prioritize and control execution of script functions.
54 // Class can use multiple threads for simultaneous execution. Mutexes are used for thread safety.
55 //
56 // 1. Hold an execution queue for scripts
57 // 2. Use threads to process queue, each thread executes one script function on each pass.
58 // 3. Catch any script error and process it
59 //
60 //
61 // Notes:
62 // * Current execution load balancing is optimized for 1 thread, and can cause unfair execute balancing between scripts.
63 // Not noticeable unless server is under high load.
64 // * This class contains the number of threads used for script executions. Since we are not microthreading scripts yet,
65 // increase number of threads to allow more concurrent script executions in OpenSim.
66 //
67
68
69 /// <summary>
70 /// List of threads processing event queue
71 /// </summary>
72 private List<Thread> eventQueueThreads = new List<Thread>();
73
74 private object queueLock = new object(); // Mutex lock object
75
76 /// <summary>
77 /// How many ms to sleep if queue is empty
78 /// </summary>
79 private int nothingToDoSleepms = 50;
80
81 /// <summary>
82 /// How many threads to process queue with
83 /// </summary>
84 private int numberOfThreads = 2;
85
86 /// <summary>
87 /// Queue containing events waiting to be executed
88 /// </summary>
89 private Queue<QueueItemStruct> eventQueue = new Queue<QueueItemStruct>();
90
91 /// <summary>
92 /// Queue item structure
93 /// </summary>
94 private struct QueueItemStruct
95 {
96 public uint localID;
97 public LLUUID itemID;
98 public string functionName;
99 public object[] param;
100 }
101
102 /// <summary>
103 /// List of localID locks for mutex processing of script events
104 /// </summary>
105 private List<uint> objectLocks = new List<uint>();
106
107 private object tryLockLock = new object(); // Mutex lock object
108
109 private ScriptEngine m_ScriptEngine;
110
111 public EventQueueManager(ScriptEngine _ScriptEngine)
112 {
113 m_ScriptEngine = _ScriptEngine;
114
115 //
116 // Start event queue processing threads (worker threads)
117 //
118 for (int ThreadCount = 0; ThreadCount <= numberOfThreads; ThreadCount++)
119 {
120 Thread EventQueueThread = new Thread(EventQueueThreadLoop);
121 eventQueueThreads.Add(EventQueueThread);
122 EventQueueThread.IsBackground = true;
123 EventQueueThread.Priority = ThreadPriority.BelowNormal;
124 EventQueueThread.Name = "EventQueueManagerThread_" + ThreadCount;
125 EventQueueThread.Start();
126 }
127 }
128
129 ~EventQueueManager()
130 {
131 // Kill worker threads
132 foreach (Thread EventQueueThread in new ArrayList(eventQueueThreads))
133 {
134 if (EventQueueThread != null && EventQueueThread.IsAlive == true)
135 {
136 try
137 {
138 EventQueueThread.Abort();
139 EventQueueThread.Join();
140 }
141 catch (Exception)
142 {
143 //myScriptEngine.Log.Verbose("ScriptEngine", "EventQueueManager Exception killing worker thread: " + e.ToString());
144 }
145 }
146 }
147 eventQueueThreads.Clear();
148 // Todo: Clean up our queues
149 eventQueue.Clear();
150 }
151
152 /// <summary>
153 /// Queue processing thread loop
154 /// </summary>
155 private void EventQueueThreadLoop()
156 {
157 //myScriptEngine.m_logger.Verbose("ScriptEngine", "EventQueueManager Worker thread spawned");
158 try
159 {
160 QueueItemStruct BlankQIS = new QueueItemStruct();
161 while (true)
162 {
163 try
164 {
165 QueueItemStruct QIS = BlankQIS;
166 bool GotItem = false;
167
168 if (eventQueue.Count == 0)
169 {
170 // Nothing to do? Sleep a bit waiting for something to do
171 Thread.Sleep(nothingToDoSleepms);
172 }
173 else
174 {
175 // Something in queue, process
176 //myScriptEngine.m_logger.Verbose("ScriptEngine", "Processing event for localID: " + QIS.localID + ", itemID: " + QIS.itemID + ", FunctionName: " + QIS.FunctionName);
177
178 // OBJECT BASED LOCK - TWO THREADS WORKING ON SAME OBJECT IS NOT GOOD
179 lock (queueLock)
180 {
181 GotItem = false;
182 for (int qc = 0; qc < eventQueue.Count; qc++)
183 {
184 // Get queue item
185 QIS = eventQueue.Dequeue();
186
187 // Check if object is being processed by someone else
188 if (TryLock(QIS.localID) == false)
189 {
190 // Object is already being processed, requeue it
191 eventQueue.Enqueue(QIS);
192 }
193 else
194 {
195 // We have lock on an object and can process it
196 GotItem = true;
197 break;
198 }
199 } // go through queue
200 } // lock
201
202 if (GotItem == true)
203 {
204 // Execute function
205 try
206 {
207#if DEBUG
208 m_ScriptEngine.Log.Debug("ScriptEngine", "Executing event:\r\n"
209 + "QIS.localID: " + QIS.localID
210 + ", QIS.itemID: " + QIS.itemID
211 + ", QIS.functionName: " + QIS.functionName);
212#endif
213 m_ScriptEngine.m_ScriptManager.ExecuteEvent(QIS.localID, QIS.itemID,
214 QIS.functionName, QIS.param);
215 }
216 catch (Exception e)
217 {
218 // DISPLAY ERROR INWORLD
219 string text = "Error executing script function \"" + QIS.functionName + "\":\r\n";
220 //if (e.InnerException != null)
221 //{
222 // Send inner exception
223 text += e.InnerException.Message.ToString();
224 //}
225 //else
226 //{
227 text += "\r\n";
228 // Send normal
229 text += e.Message.ToString();
230 //}
231 try
232 {
233 if (text.Length > 1500)
234 text = text.Substring(0, 1500);
235 IScriptHost m_host = m_ScriptEngine.World.GetSceneObjectPart(QIS.localID);
236 //if (m_host != null)
237 //{
238 m_ScriptEngine.World.SimChat(Helpers.StringToField(text), ChatTypeEnum.Say, 0,
239 m_host.AbsolutePosition, m_host.Name, m_host.UUID);
240 }
241 catch
242 {
243 //}
244 //else
245 //{
246 // T oconsole
247 m_ScriptEngine.Log.Error("ScriptEngine",
248 "Unable to send text in-world:\r\n" + text);
249 }
250 }
251 finally
252 {
253 ReleaseLock(QIS.localID);
254 }
255 }
256 } // Something in queue
257 }
258 catch (ThreadAbortException tae)
259 {
260 throw tae;
261 }
262 catch (Exception e)
263 {
264 m_ScriptEngine.Log.Error("ScriptEngine", "Exception in EventQueueThreadLoop: " + e.ToString());
265 }
266 } // while
267 } // try
268 catch (ThreadAbortException)
269 {
270 //myScriptEngine.Log.Verbose("ScriptEngine", "EventQueueManager Worker thread killed: " + tae.Message);
271 }
272 }
273
274 /// <summary>
275 /// Try to get a mutex lock on localID
276 /// </summary>
277 /// <param name="localID"></param>
278 /// <returns></returns>
279 private bool TryLock(uint localID)
280 {
281 lock (tryLockLock)
282 {
283 if (objectLocks.Contains(localID) == true)
284 {
285 return false;
286 }
287 else
288 {
289 objectLocks.Add(localID);
290 return true;
291 }
292 }
293 }
294
295 /// <summary>
296 /// Release mutex lock on localID
297 /// </summary>
298 /// <param name="localID"></param>
299 private void ReleaseLock(uint localID)
300 {
301 lock (tryLockLock)
302 {
303 if (objectLocks.Contains(localID) == true)
304 {
305 objectLocks.Remove(localID);
306 }
307 }
308 }
309
310
311 /// <summary>
312 /// Add event to event execution queue
313 /// </summary>
314 /// <param name="localID"></param>
315 /// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param>
316 /// <param name="param">Array of parameters to match event mask</param>
317 public void AddToObjectQueue(uint localID, string FunctionName, params object[] param)
318 {
319 // Determine all scripts in Object and add to their queue
320 //myScriptEngine.m_logger.Verbose("ScriptEngine", "EventQueueManager Adding localID: " + localID + ", FunctionName: " + FunctionName);
321
322
323 // Do we have any scripts in this object at all? If not, return
324 if (m_ScriptEngine.m_ScriptManager.Scripts.ContainsKey(localID) == false)
325 {
326 //Console.WriteLine("Event \"" + FunctionName + "\" for localID: " + localID + ". No scripts found on this localID.");
327 return;
328 }
329
330 Dictionary<LLUUID, LSL_BaseClass>.KeyCollection scriptKeys =
331 m_ScriptEngine.m_ScriptManager.GetScriptKeys(localID);
332
333 foreach (LLUUID itemID in scriptKeys)
334 {
335 // Add to each script in that object
336 // TODO: Some scripts may not subscribe to this event. Should we NOT add it? Does it matter?
337 AddToScriptQueue(localID, itemID, FunctionName, param);
338 }
339 }
340
341 /// <summary>
342 /// Add event to event execution queue
343 /// </summary>
344 /// <param name="localID"></param>
345 /// <param name="itemID"></param>
346 /// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param>
347 /// <param name="param">Array of parameters to match event mask</param>
348 public void AddToScriptQueue(uint localID, LLUUID itemID, string FunctionName, params object[] param)
349 {
350 lock (queueLock)
351 {
352 // Create a structure and add data
353 QueueItemStruct QIS = new QueueItemStruct();
354 QIS.localID = localID;
355 QIS.itemID = itemID;
356 QIS.functionName = FunctionName;
357 QIS.param = param;
358
359 // Add it to queue
360 eventQueue.Enqueue(QIS);
361 }
362 }
363 }
364} \ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs
deleted file mode 100644
index 1e4dc99..0000000
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs
+++ /dev/null
@@ -1,295 +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.Threading;
32using libsecondlife;
33using OpenSim.Region.Environment.Interfaces;
34using OpenSim.Region.Environment.Modules;
35
36namespace OpenSim.Region.ScriptEngine.DotNetEngine
37{
38 /// <summary>
39 /// Handles LSL commands that takes long time and returns an event, for example timers, HTTP requests, etc.
40 /// </summary>
41 internal class LSLLongCmdHandler
42 {
43 private Thread cmdHandlerThread;
44 private int cmdHandlerThreadCycleSleepms = 100;
45
46 private ScriptEngine m_ScriptEngine;
47
48 public LSLLongCmdHandler(ScriptEngine _ScriptEngine)
49 {
50 m_ScriptEngine = _ScriptEngine;
51
52 // Start the thread that will be doing the work
53 cmdHandlerThread = new Thread(CmdHandlerThreadLoop);
54 cmdHandlerThread.Name = "CmdHandlerThread";
55 cmdHandlerThread.Priority = ThreadPriority.BelowNormal;
56 cmdHandlerThread.IsBackground = true;
57 cmdHandlerThread.Start();
58 }
59
60 ~LSLLongCmdHandler()
61 {
62 // Shut down thread
63 try
64 {
65 if (cmdHandlerThread != null)
66 {
67 if (cmdHandlerThread.IsAlive == true)
68 {
69 cmdHandlerThread.Abort();
70 cmdHandlerThread.Join();
71 }
72 }
73 }
74 catch
75 {
76 }
77 }
78
79 private void CmdHandlerThreadLoop()
80 {
81 while (true)
82 {
83 // Check timers
84 CheckTimerEvents();
85 Thread.Sleep(25);
86 // Check HttpRequests
87 CheckHttpRequests();
88 Thread.Sleep(25);
89 // Check XMLRPCRequests
90 CheckXMLRPCRequests();
91 Thread.Sleep(25);
92 // Check Listeners
93 CheckListeners();
94 Thread.Sleep(25);
95
96 // Sleep before next cycle
97 //Thread.Sleep(cmdHandlerThreadCycleSleepms);
98 }
99 }
100
101 /// <summary>
102 /// Remove a specific script (and all its pending commands)
103 /// </summary>
104 /// <param name="m_localID"></param>
105 /// <param name="m_itemID"></param>
106 public void RemoveScript(uint localID, LLUUID itemID)
107 {
108 // Remove a specific script
109
110 // Remove from: Timers
111 UnSetTimerEvents(localID, itemID);
112 // Remove from: HttpRequest
113 IHttpRequests iHttpReq =
114 m_ScriptEngine.World.RequestModuleInterface<IHttpRequests>();
115 iHttpReq.StopHttpRequest(localID, itemID);
116 }
117
118 #region TIMER
119
120 //
121 // TIMER
122 //
123 private class TimerClass
124 {
125 public uint localID;
126 public LLUUID itemID;
127 public double interval;
128 public DateTime next;
129 }
130
131 private List<TimerClass> Timers = new List<TimerClass>();
132 private object TimerListLock = new object();
133
134 public void SetTimerEvent(uint m_localID, LLUUID m_itemID, double sec)
135 {
136 Console.WriteLine("SetTimerEvent");
137
138 // Always remove first, in case this is a re-set
139 UnSetTimerEvents(m_localID, m_itemID);
140 if (sec == 0) // Disabling timer
141 return;
142
143 // Add to timer
144 TimerClass ts = new TimerClass();
145 ts.localID = m_localID;
146 ts.itemID = m_itemID;
147 ts.interval = sec;
148 ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
149 lock (TimerListLock)
150 {
151 Timers.Add(ts);
152 }
153 }
154
155 public void UnSetTimerEvents(uint m_localID, LLUUID m_itemID)
156 {
157 // Remove from timer
158 lock (TimerListLock)
159 {
160 List<TimerClass> NewTimers = new List<TimerClass>();
161 foreach (TimerClass ts in Timers)
162 {
163 if (ts.localID != m_localID && ts.itemID != m_itemID)
164 {
165 NewTimers.Add(ts);
166 }
167 }
168 Timers.Clear();
169 Timers = NewTimers;
170 }
171 }
172
173 public void CheckTimerEvents()
174 {
175 // Nothing to do here?
176 if (Timers.Count == 0)
177 return;
178
179 lock (TimerListLock)
180 {
181 // Go through all timers
182 foreach (TimerClass ts in Timers)
183 {
184 // Time has passed?
185 if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime())
186 {
187 // Add it to queue
188 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer",
189 new object[] {});
190 // set next interval
191
192
193 ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
194 }
195 }
196 } // lock
197 }
198
199 #endregion
200
201 #region HTTP REQUEST
202
203 public void CheckHttpRequests()
204 {
205 if (m_ScriptEngine.World == null)
206 return;
207
208 IHttpRequests iHttpReq =
209 m_ScriptEngine.World.RequestModuleInterface<IHttpRequests>();
210
211 HttpRequestClass httpInfo = null;
212
213 if (iHttpReq != null)
214 httpInfo = iHttpReq.GetNextCompletedRequest();
215
216 while (httpInfo != null)
217 {
218 //Console.WriteLine("PICKED HTTP REQ:" + httpInfo.response_body + httpInfo.status);
219
220 // Deliver data to prim's remote_data handler
221 //
222 // TODO: Returning null for metadata, since the lsl function
223 // only returns the byte for HTTP_BODY_TRUNCATED, which is not
224 // implemented here yet anyway. Should be fixed if/when maxsize
225 // is supported
226
227 object[] resobj = new object[]
228 {
229 httpInfo.reqID.ToString(), httpInfo.status, null, httpInfo.response_body
230 };
231
232 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
233 httpInfo.localID, httpInfo.itemID, "http_response", resobj
234 );
235
236 httpInfo.Stop();
237 httpInfo = null;
238
239 httpInfo = iHttpReq.GetNextCompletedRequest();
240 }
241 }
242
243 #endregion
244
245 public void CheckXMLRPCRequests()
246 {
247 if (m_ScriptEngine.World == null)
248 return;
249
250 IXMLRPC xmlrpc = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
251
252 if (xmlrpc != null)
253 {
254 while (xmlrpc.hasRequests())
255 {
256 RPCRequestInfo rInfo = xmlrpc.GetNextRequest();
257 //Console.WriteLine("PICKED REQUEST");
258
259 //Deliver data to prim's remote_data handler
260 object[] resobj = new object[]
261 {
262 2, rInfo.GetChannelKey().ToString(), rInfo.GetMessageID().ToString(), "",
263 rInfo.GetIntValue(),
264 rInfo.GetStrVal()
265 };
266 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
267 rInfo.GetLocalID(), rInfo.GetItemID(), "remote_data", resobj
268 );
269 }
270 }
271 }
272
273 public void CheckListeners()
274 {
275 if (m_ScriptEngine.World == null)
276 return;
277 IWorldComm comms = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
278
279 while (comms.HasMessages())
280 {
281 ListenerInfo lInfo = comms.GetNextMessage();
282
283 //Deliver data to prim's listen handler
284 object[] resobj = new object[]
285 {
286 lInfo.GetChannel(), lInfo.GetName(), lInfo.GetID().ToString(), lInfo.GetMessage()
287 };
288
289 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
290 lInfo.GetLocalID(), lInfo.GetItemID(), "listen", resobj
291 );
292 }
293 }
294 }
295} \ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
index c3cb34d..191d3b2 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
@@ -32,93 +32,23 @@ using OpenSim.Framework.Console;
32using OpenSim.Region.Environment.Interfaces; 32using OpenSim.Region.Environment.Interfaces;
33using OpenSim.Region.Environment.Scenes; 33using OpenSim.Region.Environment.Scenes;
34using OpenSim.Region.ScriptEngine.Common; 34using OpenSim.Region.ScriptEngine.Common;
35using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase;
36using EventManager=OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.EventManager;
35 37
36namespace OpenSim.Region.ScriptEngine.DotNetEngine 38namespace OpenSim.Region.ScriptEngine.DotNetEngine
37{ 39{
38 /// <summary>
39 /// This is the root object for ScriptEngine. Objects access each other trough this class.
40 /// </summary>
41 ///
42 [Serializable] 40 [Serializable]
43 public class ScriptEngine : IRegionModule, OpenSim.Region.ScriptEngine.Common.ScriptServerInterfaces.ScriptEngine 41 public class ScriptEngine : OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.ScriptEngine
44 { 42 {
45 public Scene World; 43 // We need to override a few things for our DotNetEngine
46 public EventManager m_EventManager; // Handles and queues incoming events from OpenSim 44 public override void Initialise(Scene scene, IConfigSource config)
47 internal EventQueueManager m_EventQueueManager; // Executes events
48 public ScriptManager m_ScriptManager; // Load, unload and execute scripts
49 internal AppDomainManager m_AppDomainManager;
50 internal LSLLongCmdHandler m_LSLLongCmdHandler;
51
52 private LogBase m_log;
53
54 public ScriptEngine()
55 {
56 //Common.SendToDebug("ScriptEngine Object Initialized");
57 Common.mySE = this;
58 }
59
60 public LogBase Log
61 {
62 get { return m_log; }
63 }
64
65 public void InitializeEngine(Scene Sceneworld, LogBase logger, bool HookUpToServer)
66 {
67 World = Sceneworld;
68 m_log = logger;
69
70 Log.Verbose("ScriptEngine", "DotNet & LSL ScriptEngine initializing");
71
72 //m_logger.Status("ScriptEngine", "InitializeEngine");
73
74 // Create all objects we'll be using
75 m_EventQueueManager = new EventQueueManager(this);
76 m_EventManager = new EventManager(this, HookUpToServer);
77 m_ScriptManager = new ScriptManager(this);
78 m_AppDomainManager = new AppDomainManager();
79 m_LSLLongCmdHandler = new LSLLongCmdHandler(this);
80
81 // Should we iterate the region for scripts that needs starting?
82 // Or can we assume we are loaded before anything else so we can use proper events?
83 }
84
85 public void Shutdown()
86 {
87 // We are shutting down
88 }
89
90 ScriptServerInterfaces.RemoteEvents ScriptServerInterfaces.ScriptEngine.EventManager()
91 {
92 return this.m_EventManager;
93 }
94
95
96 #region IRegionModule
97
98 public void Initialise(Scene scene, IConfigSource config)
99 {
100 InitializeEngine(scene, MainLog.Instance, true);
101 }
102
103 public void PostInitialise()
104 { 45 {
46 InitializeEngine(scene, MainLog.Instance, true, GetScriptManager());
105 } 47 }
106 48
107 public void Close() 49 public override OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.ScriptManager _GetScriptManager()
108 { 50 {
51 return new ScriptManager(this);
109 } 52 }
110
111 public string Name
112 {
113 get { return "DotNetEngine"; }
114 }
115
116 public bool IsSharedModule
117 {
118 get { return false; }
119 }
120
121 #endregion
122
123 } 53 }
124} \ No newline at end of file 54} \ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
index 223bb8f..0c28ac7 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
@@ -35,421 +35,127 @@ using System.Threading;
35using libsecondlife; 35using libsecondlife;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Region.Environment.Scenes; 37using OpenSim.Region.Environment.Scenes;
38using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler; 38using OpenSim.Region.ScriptEngine.Common;
39using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL; 39using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL;
40 40
41namespace OpenSim.Region.ScriptEngine.DotNetEngine 41namespace OpenSim.Region.ScriptEngine.DotNetEngine
42{ 42{
43 /// <summary> 43 public class ScriptManager : OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.ScriptManager
44 /// Loads scripts
45 /// Compiles them if necessary
46 /// Execute functions for EventQueueManager (Sends them to script on other AppDomain for execution)
47 /// </summary>
48 ///
49
50 // This class is as close as you get to the script without being inside script class. It handles all the dirty work for other classes.
51 // * Keeps track of running scripts
52 // * Compiles script if necessary (through "Compiler")
53 // * Loads script (through "AppDomainManager" called from for example "EventQueueManager")
54 // * Executes functions inside script (called from for example "EventQueueManager" class)
55 // * Unloads script (through "AppDomainManager" called from for example "EventQueueManager")
56 // * Dedicated load/unload thread, and queues loading/unloading.
57 // This so that scripts starting or stopping will not slow down other theads or whole system.
58 //
59 [Serializable]
60 public class ScriptManager
61 { 44 {
62 #region Declares 45 public ScriptManager(Common.ScriptEngineBase.ScriptEngine scriptEngine)
63 46 : base(scriptEngine)
64 private Thread scriptLoadUnloadThread;
65 private int scriptLoadUnloadThread_IdleSleepms = 100;
66 private Queue<LUStruct> LUQueue = new Queue<LUStruct>();
67
68
69 // Load/Unload structure
70 private struct LUStruct
71 { 47 {
72 public uint localID; 48 base.m_scriptEngine = scriptEngine;
73 public LLUUID itemID;
74 public string script;
75 public LUType Action;
76 }
77
78 private enum LUType
79 {
80 Unknown = 0,
81 Load = 1,
82 Unload = 2
83 }
84 49
85 // Object<string, Script<string, script>>
86 // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory.
87 // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead!
88 internal Dictionary<uint, Dictionary<LLUUID, LSL_BaseClass>> Scripts =
89 new Dictionary<uint, Dictionary<LLUUID, LSL_BaseClass>>();
90
91 public Scene World
92 {
93 get { return m_scriptEngine.World; }
94 } 50 }
95 51
96 #endregion 52 // KEEP TRACK OF SCRIPTS <int id, whatever script>
97 53 //internal Dictionary<uint, Dictionary<LLUUID, LSL_BaseClass>> Scripts = new Dictionary<uint, Dictionary<LLUUID, LSL_BaseClass>>();
98 #region Object init/shutdown 54 // LOAD SCRIPT
99 55 // UNLOAD SCRIPT
100 private ScriptEngine m_scriptEngine; 56 // PROVIDE SCRIPT WITH ITS INTERFACE TO OpenSim
101 57
102 public ScriptManager(ScriptEngine scriptEngine) 58 private Compiler.LSL.Compiler LSLCompiler = new Compiler.LSL.Compiler();
103 {
104 m_scriptEngine = scriptEngine;
105 AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
106 scriptLoadUnloadThread = new Thread(ScriptLoadUnloadThreadLoop);
107 scriptLoadUnloadThread.Name = "ScriptLoadUnloadThread";
108 scriptLoadUnloadThread.IsBackground = true;
109 scriptLoadUnloadThread.Priority = ThreadPriority.BelowNormal;
110 scriptLoadUnloadThread.Start();
111 }
112 59
113 ~ScriptManager() 60 public override void _StartScript(uint localID, LLUUID itemID, string Script)
114 { 61 {
115 // Abort load/unload thread 62 //IScriptHost root = host.GetRoot();
116 try 63 Console.WriteLine("ScriptManager StartScript: localID: " + localID + ", itemID: " + itemID);
117 {
118 if (scriptLoadUnloadThread != null)
119 {
120 if (scriptLoadUnloadThread.IsAlive == true)
121 {
122 scriptLoadUnloadThread.Abort();
123 scriptLoadUnloadThread.Join();
124 }
125 }
126 }
127 catch
128 {
129 }
130 }
131 64
132 #endregion 65 // We will initialize and start the script.
66 // It will be up to the script itself to hook up the correct events.
67 string ScriptSource = "";
133 68
134 #region Load / Unload scripts (Thread loop) 69 SceneObjectPart m_host = World.GetSceneObjectPart(localID);
135 70
136 private void ScriptLoadUnloadThreadLoop()
137 {
138 try 71 try
139 { 72 {
140 while (true) 73 // Compile (We assume LSL)
141 { 74 ScriptSource = LSLCompiler.CompileFromLSLText(Script);
142 if (LUQueue.Count == 0)
143 Thread.Sleep(scriptLoadUnloadThread_IdleSleepms);
144 if (LUQueue.Count > 0)
145 {
146 LUStruct item = LUQueue.Dequeue();
147 if (item.Action == LUType.Unload)
148 _StopScript(item.localID, item.itemID);
149 if (item.Action == LUType.Load)
150 _StartScript(item.localID, item.itemID, item.script);
151 }
152 }
153 }
154 catch (ThreadAbortException tae)
155 {
156 string a = tae.ToString();
157 a = "";
158 // Expected
159 }
160 }
161
162 #endregion
163
164 #region Helper functions
165
166 private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
167 {
168 //Console.WriteLine("ScriptManager.CurrentDomain_AssemblyResolve: " + args.Name);
169 return Assembly.GetExecutingAssembly().FullName == args.Name ? Assembly.GetExecutingAssembly() : null;
170 }
171
172 #endregion
173
174 #region Internal functions to keep track of script
175
176 internal Dictionary<LLUUID, LSL_BaseClass>.KeyCollection GetScriptKeys(uint localID)
177 {
178 if (Scripts.ContainsKey(localID) == false)
179 return null;
180
181 Dictionary<LLUUID, LSL_BaseClass> Obj;
182 Scripts.TryGetValue(localID, out Obj);
183
184 return Obj.Keys;
185 }
186
187 internal LSL_BaseClass GetScript(uint localID, LLUUID itemID)
188 {
189 if (Scripts.ContainsKey(localID) == false)
190 return null;
191
192 Dictionary<LLUUID, LSL_BaseClass> Obj;
193 Scripts.TryGetValue(localID, out Obj);
194 if (Obj.ContainsKey(itemID) == false)
195 return null;
196
197 // Get script
198 LSL_BaseClass Script;
199 Obj.TryGetValue(itemID, out Script);
200
201 return Script;
202 }
203
204 internal void SetScript(uint localID, LLUUID itemID, LSL_BaseClass Script)
205 {
206 // Create object if it doesn't exist
207 if (Scripts.ContainsKey(localID) == false)
208 {
209 Scripts.Add(localID, new Dictionary<LLUUID, LSL_BaseClass>());
210 }
211
212 // Delete script if it exists
213 Dictionary<LLUUID, LSL_BaseClass> Obj;
214 Scripts.TryGetValue(localID, out Obj);
215 if (Obj.ContainsKey(itemID) == true)
216 Obj.Remove(itemID);
217
218 // Add to object
219 Obj.Add(itemID, Script);
220 }
221
222 internal void RemoveScript(uint localID, LLUUID itemID)
223 {
224 // Don't have that object?
225 if (Scripts.ContainsKey(localID) == false)
226 return;
227
228 // Delete script if it exists
229 Dictionary<LLUUID, LSL_BaseClass> Obj;
230 Scripts.TryGetValue(localID, out Obj);
231 if (Obj.ContainsKey(itemID) == true)
232 Obj.Remove(itemID);
233 }
234
235 #endregion
236
237 #region Start/Stop/Reset script
238
239 private Object startStopLock = new Object();
240
241 /// <summary>
242 /// Fetches, loads and hooks up a script to an objects events
243 /// </summary>
244 /// <param name="itemID"></param>
245 /// <param name="localID"></param>
246 public void StartScript(uint localID, LLUUID itemID, string Script)
247 {
248 LUStruct ls = new LUStruct();
249 ls.localID = localID;
250 ls.itemID = itemID;
251 ls.script = Script;
252 ls.Action = LUType.Load;
253 LUQueue.Enqueue(ls);
254 }
255
256 /// <summary>
257 /// Disables and unloads a script
258 /// </summary>
259 /// <param name="localID"></param>
260 /// <param name="itemID"></param>
261 public void StopScript(uint localID, LLUUID itemID)
262 {
263 LUStruct ls = new LUStruct();
264 ls.localID = localID;
265 ls.itemID = itemID;
266 ls.Action = LUType.Unload;
267 LUQueue.Enqueue(ls);
268 }
269
270 public void ResetScript(uint localID, LLUUID itemID)
271 {
272 string script = GetScript(localID, itemID).SourceCode;
273 StopScript(localID, itemID);
274 StartScript(localID, itemID, script);
275 }
276
277 // Create a new instance of the compiler (reuse)
278 private Compiler.LSL.Compiler LSLCompiler = new Compiler.LSL.Compiler();
279
280 private void _StartScript(uint localID, LLUUID itemID, string Script)
281 {
282 lock (startStopLock)
283 {
284 //IScriptHost root = host.GetRoot();
285 Console.WriteLine("ScriptManager StartScript: localID: " + localID + ", itemID: " + itemID);
286
287 // We will initialize and start the script.
288 // It will be up to the script itself to hook up the correct events.
289 string ScriptSource = "";
290
291 SceneObjectPart m_host = World.GetSceneObjectPart(localID);
292
293 try
294 {
295 if (!Script.EndsWith("dll"))
296 {
297 // Compile (We assume LSL)
298 ScriptSource = LSLCompiler.CompileFromLSLText(Script);
299 //Console.WriteLine("Compilation of " + FileName + " done");
300 // * Insert yield into code
301 ScriptSource = ProcessYield(ScriptSource);
302 }
303 else
304 {
305 ScriptSource = Script;
306 }
307 75
308#if DEBUG 76#if DEBUG
309 long before; 77 long before;
310 before = GC.GetTotalMemory(true); 78 before = GC.GetTotalMemory(true);
311#endif 79#endif
312 80
313 LSL_BaseClass CompiledScript; 81 IScript CompiledScript;
314 CompiledScript = m_scriptEngine.m_AppDomainManager.LoadScript(ScriptSource); 82 CompiledScript = m_scriptEngine.m_AppDomainManager.LoadScript(ScriptSource);
315 83
316#if DEBUG 84#if DEBUG
317 Console.WriteLine("Script " + itemID + " occupies {0} bytes", GC.GetTotalMemory(true) - before); 85 Console.WriteLine("Script " + itemID + " occupies {0} bytes", GC.GetTotalMemory(true) - before);
318#endif 86#endif
319 87
320 CompiledScript.SourceCode = ScriptSource; 88 CompiledScript.Source = ScriptSource;
321 // Add it to our script memstruct 89 // Add it to our script memstruct
322 SetScript(localID, itemID, CompiledScript); 90 SetScript(localID, itemID, CompiledScript);
323 91
324 // We need to give (untrusted) assembly a private instance of BuiltIns 92 // We need to give (untrusted) assembly a private instance of BuiltIns
325 // this private copy will contain Read-Only FullitemID so that it can bring that on to the server whenever needed. 93 // this private copy will contain Read-Only FullitemID so that it can bring that on to the server whenever needed.
326 94
327 95
328 LSL_BuiltIn_Commands LSLB = new LSL_BuiltIn_Commands(m_scriptEngine, m_host, localID, itemID); 96 LSL_BuiltIn_Commands LSLB = new LSL_BuiltIn_Commands(m_scriptEngine, m_host, localID, itemID);
329 97
330 // Start the script - giving it BuiltIns 98 // Start the script - giving it BuiltIns
331 CompiledScript.Start(LSLB); 99 CompiledScript.Start(LSLB);
332 100
333 // Fire the first start-event 101 // Fire the first start-event
334 m_scriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_entry", new object[] {}); 102 m_scriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_entry", new object[] { });
335 }
336 catch (Exception e)
337 {
338 //m_scriptEngine.Log.Error("ScriptEngine", "Error compiling script: " + e.ToString());
339 try
340 {
341 // DISPLAY ERROR INWORLD
342 string text = "Error compiling script:\r\n" + e.Message.ToString();
343 if (text.Length > 1500)
344 text = text.Substring(0, 1500);
345 World.SimChat(Helpers.StringToField(text), ChatTypeEnum.Say, 0, m_host.AbsolutePosition,
346 m_host.Name, m_host.UUID);
347 }
348 catch (Exception e2)
349 {
350 m_scriptEngine.Log.Error("ScriptEngine", "Error displaying error in-world: " + e2.ToString());
351 m_scriptEngine.Log.Error("ScriptEngine",
352 "Errormessage: Error compiling script:\r\n" + e.Message.ToString());
353 }
354 }
355 } 103 }
356 } 104 catch (Exception e)
357
358 private void _StopScript(uint localID, LLUUID itemID)
359 {
360 lock (startStopLock)
361 { 105 {
362 // Stop script 106 //m_scriptEngine.Log.Error("ScriptEngine", "Error compiling script: " + e.ToString());
363 Console.WriteLine("Stop script localID: " + localID + " LLUID: " + itemID.ToString());
364
365
366 // Stop long command on script
367 m_scriptEngine.m_LSLLongCmdHandler.RemoveScript(localID, itemID);
368
369 LSL_BaseClass LSLBC = GetScript(localID, itemID);
370 if (LSLBC == null)
371 return;
372
373 // TEMP: First serialize it
374 //GetSerializedScript(localID, itemID);
375
376
377 try 107 try
378 { 108 {
379 // Get AppDomain 109 // DISPLAY ERROR INWORLD
380 AppDomain ad = LSLBC.Exec.GetAppDomain(); 110 string text = "Error compiling script:\r\n" + e.Message.ToString();
381 // Tell script not to accept new requests 111 if (text.Length > 1500)
382 GetScript(localID, itemID).Exec.StopScript(); 112 text = text.Substring(0, 1500);
383 // Remove from internal structure 113 World.SimChat(Helpers.StringToField(text), ChatTypeEnum.Say, 0, m_host.AbsolutePosition,
384 RemoveScript(localID, itemID); 114 m_host.Name, m_host.UUID);
385 // Tell AppDomain that we have stopped script
386 m_scriptEngine.m_AppDomainManager.StopScript(ad);
387 } 115 }
388 catch (Exception e) 116 catch (Exception e2)
389 { 117 {
390 Console.WriteLine("Exception stopping script localID: " + localID + " LLUID: " + itemID.ToString() + 118 m_scriptEngine.Log.Error("ScriptEngine", "Error displaying error in-world: " + e2.ToString());
391 ": " + e.ToString()); 119 m_scriptEngine.Log.Error("ScriptEngine",
120 "Errormessage: Error compiling script:\r\n" + e.Message.ToString());
392 } 121 }
393 } 122 }
394 } 123 }
395 124
396 private string ProcessYield(string FileName) 125 public override void _StopScript(uint localID, LLUUID itemID)
397 { 126 {
398 // TODO: Create a new assembly and copy old but insert Yield Code 127 // Stop script
399 //return TempDotNetMicroThreadingCodeInjector.TestFix(FileName); 128 Console.WriteLine("Stop script localID: " + localID + " LLUID: " + itemID.ToString());
400 return FileName;
401 }
402 129
403 #endregion
404 130
405 #region Perform event execution in script 131 // Stop long command on script
132 m_scriptEngine.m_LSLLongCmdHandler.RemoveScript(localID, itemID);
406 133
407 /// <summary> 134 IScript LSLBC = GetScript(localID, itemID);
408 /// Execute a LL-event-function in Script 135 if (LSLBC == null)
409 /// </summary>
410 /// <param name="localID">Object the script is located in</param>
411 /// <param name="itemID">Script ID</param>
412 /// <param name="FunctionName">Name of function</param>
413 /// <param name="args">Arguments to pass to function</param>
414 internal void ExecuteEvent(uint localID, LLUUID itemID, string FunctionName, object[] args)
415 {
416#if DEBUG
417 Console.WriteLine("ScriptEngine: Inside ExecuteEvent for event " + FunctionName);
418#endif
419 // Execute a function in the script
420 //m_scriptEngine.Log.Verbose("ScriptEngine", "Executing Function localID: " + localID + ", itemID: " + itemID + ", FunctionName: " + FunctionName);
421 LSL_BaseClass Script = m_scriptEngine.m_ScriptManager.GetScript(localID, itemID);
422 if (Script == null)
423 return; 136 return;
424 137
425#if DEBUG 138 // TEMP: First serialize it
426 Console.WriteLine("ScriptEngine: Executing event: " + FunctionName); 139 //GetSerializedScript(localID, itemID);
427#endif
428 // Must be done in correct AppDomain, so leaving it up to the script itself
429 Script.Exec.ExecuteEvent(FunctionName, args);
430 }
431 140
432 #endregion
433 141
434 #region Script serialization/deserialization 142 try
435 143 {
436 public void GetSerializedScript(uint localID, LLUUID itemID) 144 // Get AppDomain
437 { 145 AppDomain ad = LSLBC.Exec.GetAppDomain();
438 // Serialize the script and return it 146 // Tell script not to accept new requests
439 // Should not be a problem 147 GetScript(localID, itemID).Exec.StopScript();
440 FileStream fs = File.Create("SERIALIZED_SCRIPT_" + itemID); 148 // Remove from internal structure
441 BinaryFormatter b = new BinaryFormatter(); 149 RemoveScript(localID, itemID);
442 b.Serialize(fs, GetScript(localID, itemID)); 150 // Tell AppDomain that we have stopped script
443 fs.Close(); 151 m_scriptEngine.m_AppDomainManager.StopScript(ad);
444 } 152 }
445 153 catch (Exception e)
446 public void PutSerializedScript(uint localID, LLUUID itemID) 154 {
447 { 155 Console.WriteLine("Exception stopping script localID: " + localID + " LLUID: " + itemID.ToString() +
448 // Deserialize the script and inject it into an AppDomain 156 ": " + e.ToString());
449 157 }
450 // How to inject into an AppDomain?
451 } 158 }
452 159
453 #endregion
454 } 160 }
455} \ No newline at end of file 161} \ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/TempDotNetMicroThreadingCodeInjector.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/TempDotNetMicroThreadingCodeInjector.cs
deleted file mode 100644
index 072c249..0000000
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/TempDotNetMicroThreadingCodeInjector.cs
+++ /dev/null
@@ -1,69 +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.IO;
31using Rail.Reflect;
32using Rail.Transformation;
33
34namespace OpenSim.Region.ScriptEngine.DotNetEngine
35{
36 /// <summary>
37 /// Tedds Sandbox for RAIL/microtrheading. This class is only for testing purposes!
38 /// Its offspring will be the actual implementation.
39 /// </summary>
40 internal class TempDotNetMicroThreadingCodeInjector
41 {
42 public static string TestFix(string FileName)
43 {
44 string ret = Path.GetFileNameWithoutExtension(FileName + "_fixed.dll");
45
46 Console.WriteLine("Loading: \"" + FileName + "\"");
47 RAssemblyDef rAssembly = RAssemblyDef.LoadAssembly(FileName);
48
49
50 //Get the type of the method to copy from assembly Teste2.exe to assembly Teste.exe
51 RTypeDef type = (RTypeDef) rAssembly.RModuleDef.GetType("SecondLife.Script");
52
53 //Get the methods in the type
54 RMethod[] m = type.GetMethods();
55
56 //Create a MethodPrologueAdder visitor object with the method to add
57 //and with the flag that enables local variable creation set to true
58 MethodPrologueAdder mpa = new MethodPrologueAdder((RMethodDef) m[0], true);
59
60 //Apply the changes to the assembly
61 rAssembly.Accept(mpa);
62
63 //Save the new assembly
64 rAssembly.SaveAssembly(ret);
65
66 return ret;
67 }
68 }
69} \ No newline at end of file