aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/XEngine
diff options
context:
space:
mode:
authorJeff Ames2008-06-04 09:59:27 +0000
committerJeff Ames2008-06-04 09:59:27 +0000
commit4ec4e16c809cf86a63b736d2b7b6ad7291595a5f (patch)
treecfa896ef9057228171e2ee39c4807060101ba90b /OpenSim/Region/ScriptEngine/XEngine
parent* If a ThreadAbortException reaches AuthUser() then let it pass through unmol... (diff)
downloadopensim-SC_OLD-4ec4e16c809cf86a63b736d2b7b6ad7291595a5f.zip
opensim-SC_OLD-4ec4e16c809cf86a63b736d2b7b6ad7291595a5f.tar.gz
opensim-SC_OLD-4ec4e16c809cf86a63b736d2b7b6ad7291595a5f.tar.bz2
opensim-SC_OLD-4ec4e16c809cf86a63b736d2b7b6ad7291595a5f.tar.xz
Formatting cleanup, minor refactoring, svn properties.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/AsyncCommandManager.cs22
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Dataserver.cs20
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Eventstream.cs7
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/HttpRequest.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/SensorRepeat.cs20
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Timer.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/XmlRequest.cs12
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/Compiler.cs43
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/EventManager.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/Executor.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs300
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/Script/AssemblyResolver.cs14
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/Script/BuiltIn_Commands_BaseClass.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/Script/LSL_Types.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs420
15 files changed, 448 insertions, 439 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandManager.cs
index 4ec7916..fdad5b0 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandManager.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandManager.cs
@@ -184,7 +184,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
184 List<Object> data = new List<Object>(); 184 List<Object> data = new List<Object>();
185 185
186 Object[] listeners=m_Listener.GetSerializationData(itemID); 186 Object[] listeners=m_Listener.GetSerializationData(itemID);
187 if(listeners.Length > 0) 187 if (listeners.Length > 0)
188 { 188 {
189 data.Add("listener"); 189 data.Add("listener");
190 data.Add(listeners.Length); 190 data.Add(listeners.Length);
@@ -192,7 +192,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
192 } 192 }
193 193
194 Object[] timers=m_Timer.GetSerializationData(itemID); 194 Object[] timers=m_Timer.GetSerializationData(itemID);
195 if(timers.Length > 0) 195 if (timers.Length > 0)
196 { 196 {
197 data.Add("timer"); 197 data.Add("timer");
198 data.Add(timers.Length); 198 data.Add(timers.Length);
@@ -200,7 +200,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
200 } 200 }
201 201
202 Object[] sensors=m_SensorRepeat.GetSerializationData(itemID); 202 Object[] sensors=m_SensorRepeat.GetSerializationData(itemID);
203 if(sensors.Length > 0) 203 if (sensors.Length > 0)
204 { 204 {
205 data.Add("sensor"); 205 data.Add("sensor");
206 data.Add(sensors.Length); 206 data.Add(sensors.Length);
@@ -211,36 +211,36 @@ namespace OpenSim.Region.ScriptEngine.XEngine
211 } 211 }
212 212
213 public void CreateFromData(uint localID, LLUUID itemID, LLUUID hostID, 213 public void CreateFromData(uint localID, LLUUID itemID, LLUUID hostID,
214 Object[] data) 214 Object[] data)
215 { 215 {
216 int idx=0; 216 int idx = 0;
217 int len; 217 int len;
218 218
219 while(idx < data.Length) 219 while (idx < data.Length)
220 { 220 {
221 string type = data[idx].ToString(); 221 string type = data[idx].ToString();
222 len = (int)data[idx+1]; 222 len = (int)data[idx+1];
223 idx+=2; 223 idx+=2;
224 224
225 if(len > 0) 225 if (len > 0)
226 { 226 {
227 Object[] item = new Object[len]; 227 Object[] item = new Object[len];
228 Array.Copy(data, idx, item, 0, len); 228 Array.Copy(data, idx, item, 0, len);
229 229
230 idx+=len; 230 idx+=len;
231 231
232 switch(type) 232 switch (type)
233 { 233 {
234 case "listener": 234 case "listener":
235 m_Listener.CreateFromData(localID, itemID, hostID, 235 m_Listener.CreateFromData(localID, itemID, hostID,
236 item); 236 item);
237 break; 237 break;
238 case "timer": 238 case "timer":
239 m_Timer.CreateFromData(localID, itemID, hostID, item); 239 m_Timer.CreateFromData(localID, itemID, hostID, item);
240 break; 240 break;
241 case "sensor": 241 case "sensor":
242 m_SensorRepeat.CreateFromData(localID, itemID, hostID, 242 m_SensorRepeat.CreateFromData(localID, itemID, hostID,
243 item); 243 item);
244 break; 244 break;
245 } 245 }
246 } 246 }
@@ -249,12 +249,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
249 249
250 #region Check llRemoteData channels 250 #region Check llRemoteData channels
251 251
252
253 #endregion 252 #endregion
254 253
255 #region Check llListeners 254 #region Check llListeners
256 255
257
258 #endregion 256 #endregion
259 257
260 /// <summary> 258 /// <summary>
diff --git a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Dataserver.cs b/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Dataserver.cs
index 794a015..47ab420 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Dataserver.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Dataserver.cs
@@ -57,11 +57,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
57 } 57 }
58 58
59 public LLUUID RegisterRequest(uint localID, LLUUID itemID, 59 public LLUUID RegisterRequest(uint localID, LLUUID itemID,
60 string identifier) 60 string identifier)
61 { 61 {
62 lock(DataserverRequests) 62 lock (DataserverRequests)
63 { 63 {
64 if(DataserverRequests.ContainsKey(identifier)) 64 if (DataserverRequests.ContainsKey(identifier))
65 return LLUUID.Zero; 65 return LLUUID.Zero;
66 66
67 DataserverRequest ds = new DataserverRequest(); 67 DataserverRequest ds = new DataserverRequest();
@@ -84,9 +84,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
84 { 84 {
85 DataserverRequest ds; 85 DataserverRequest ds;
86 86
87 lock(DataserverRequests) 87 lock (DataserverRequests)
88 { 88 {
89 if(!DataserverRequests.ContainsKey(identifier)) 89 if (!DataserverRequests.ContainsKey(identifier))
90 return; 90 return;
91 91
92 ds=DataserverRequests[identifier]; 92 ds=DataserverRequests[identifier];
@@ -94,7 +94,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
94 } 94 }
95 95
96 m_CmdManager.m_ScriptEngine.PostObjectEvent(ds.localID, 96 m_CmdManager.m_ScriptEngine.PostObjectEvent(ds.localID,
97 new XEventParams( "dataserver", new Object[] 97 new XEventParams("dataserver", new Object[]
98 { new LSL_Types.LSLString(ds.ID.ToString()), 98 { new LSL_Types.LSLString(ds.ID.ToString()),
99 new LSL_Types.LSLString(reply)}, 99 new LSL_Types.LSLString(reply)},
100 new XDetectParams[0])); 100 new XDetectParams[0]));
@@ -102,11 +102,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
102 102
103 public void RemoveEvents(uint localID, LLUUID itemID) 103 public void RemoveEvents(uint localID, LLUUID itemID)
104 { 104 {
105 lock(DataserverRequests) 105 lock (DataserverRequests)
106 { 106 {
107 foreach (DataserverRequest ds in new List<DataserverRequest>(DataserverRequests.Values)) 107 foreach (DataserverRequest ds in new List<DataserverRequest>(DataserverRequests.Values))
108 { 108 {
109 if(ds.itemID == itemID) 109 if (ds.itemID == itemID)
110 DataserverRequests.Remove(ds.handle); 110 DataserverRequests.Remove(ds.handle);
111 } 111 }
112 } 112 }
@@ -114,11 +114,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
114 114
115 public void ExpireRequests() 115 public void ExpireRequests()
116 { 116 {
117 lock(DataserverRequests) 117 lock (DataserverRequests)
118 { 118 {
119 foreach (DataserverRequest ds in new List<DataserverRequest>(DataserverRequests.Values)) 119 foreach (DataserverRequest ds in new List<DataserverRequest>(DataserverRequests.Values))
120 { 120 {
121 if(ds.startTime > DateTime.Now.AddSeconds(30)) 121 if (ds.startTime > DateTime.Now.AddSeconds(30))
122 DataserverRequests.Remove(ds.handle); 122 DataserverRequests.Remove(ds.handle);
123 } 123 }
124 } 124 }
diff --git a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Eventstream.cs b/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Eventstream.cs
index 9112b9c..dab7a0a 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Eventstream.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Eventstream.cs
@@ -55,14 +55,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
55 public void AddObjectEvent(uint localID, string eventName, XDetectParams det) 55 public void AddObjectEvent(uint localID, string eventName, XDetectParams det)
56 { 56 {
57 SceneObjectPart part = m_CmdManager.m_ScriptEngine.World. 57 SceneObjectPart part = m_CmdManager.m_ScriptEngine.World.
58 GetSceneObjectPart(localID); 58 GetSceneObjectPart(localID);
59 59
60 if(part == null) // Can't register events for non-prims 60 if (part == null) // Can't register events for non-prims
61 return; 61 return;
62 62
63 if(!part.ContainsScripts()) 63 if (!part.ContainsScripts())
64 return; 64 return;
65
66 } 65 }
67 66
68 public void RemoveObjectEvent(uint localID, string eventName, LLUUID id) 67 public void RemoveObjectEvent(uint localID, string eventName, LLUUID id)
diff --git a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/HttpRequest.cs b/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/HttpRequest.cs
index 977e3f9..089e016 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/HttpRequest.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/HttpRequest.cs
@@ -77,7 +77,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
77 77
78 foreach (XEngine xe in XEngine.ScriptEngines) 78 foreach (XEngine xe in XEngine.ScriptEngines)
79 { 79 {
80 if(xe.PostObjectEvent(httpInfo.localID, 80 if (xe.PostObjectEvent(httpInfo.localID,
81 new XEventParams("http_response", 81 new XEventParams("http_response",
82 resobj, new XDetectParams[0]))) 82 resobj, new XDetectParams[0])))
83 break; 83 break;
diff --git a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/SensorRepeat.cs
index 5a87bb0..dbd6c33 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/SensorRepeat.cs
@@ -69,7 +69,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
69 private object SenseRepeatListLock = new object(); 69 private object SenseRepeatListLock = new object();
70 70
71 public void SetSenseRepeatEvent(uint m_localID, LLUUID m_itemID, 71 public void SetSenseRepeatEvent(uint m_localID, LLUUID m_itemID,
72 string name, LLUUID keyID, int type, double range, double arc, double sec, SceneObjectPart host) 72 string name, LLUUID keyID, int type, double range,
73 double arc, double sec, SceneObjectPart host)
73 { 74 {
74 Console.WriteLine("SetSensorEvent"); 75 Console.WriteLine("SetSensorEvent");
75 76
@@ -319,7 +320,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
319 new XDetectParams[SensedObjects.Length]; 320 new XDetectParams[SensedObjects.Length];
320 321
321 int idx; 322 int idx;
322 for(idx = 0 ; idx < SensedObjects.Length; idx++) 323 for (idx = 0; idx < SensedObjects.Length; idx++)
323 { 324 {
324 detect[idx].Key=(LLUUID)(SensedObjects.Data[idx]); 325 detect[idx].Key=(LLUUID)(SensedObjects.Data[idx]);
325 } 326 }
@@ -339,7 +340,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
339 340
340 foreach (SenseRepeatClass ts in SenseRepeaters) 341 foreach (SenseRepeatClass ts in SenseRepeaters)
341 { 342 {
342 if(ts.itemID == itemID) 343 if (ts.itemID == itemID)
343 { 344 {
344 data.Add(ts.interval); 345 data.Add(ts.interval);
345 data.Add(ts.name); 346 data.Add(ts.name);
@@ -353,18 +354,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
353 } 354 }
354 355
355 public void CreateFromData(uint localID, LLUUID itemID, LLUUID objectID, 356 public void CreateFromData(uint localID, LLUUID itemID, LLUUID objectID,
356 Object[] data) 357 Object[] data)
357 { 358 {
358 SceneObjectPart part = 359 SceneObjectPart part =
359 m_CmdManager.m_ScriptEngine.World.GetSceneObjectPart( 360 m_CmdManager.m_ScriptEngine.World.GetSceneObjectPart(
360 objectID); 361 objectID);
361 362
362 if(part == null) 363 if (part == null)
363 return; 364 return;
364 365
365 int idx=0; 366 int idx = 0;
366 367
367 while(idx < data.Length) 368 while (idx < data.Length)
368 { 369 {
369 SenseRepeatClass ts = new SenseRepeatClass(); 370 SenseRepeatClass ts = new SenseRepeatClass();
370 371
@@ -380,12 +381,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
380 ts.host = part; 381 ts.host = part;
381 382
382 ts.next = 383 ts.next =
383 DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); 384 DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
384 385
385 SenseRepeaters.Add(ts); 386 SenseRepeaters.Add(ts);
386 idx += 6; 387 idx += 6;
387 } 388 }
388 } 389 }
389
390 } 390 }
391} 391}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Timer.cs b/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Timer.cs
index 09a5818..99be290 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Timer.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Timer.cs
@@ -131,7 +131,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
131 { 131 {
132 foreach (TimerClass ts in Timers) 132 foreach (TimerClass ts in Timers)
133 { 133 {
134 if(ts.itemID == itemID) 134 if (ts.itemID == itemID)
135 { 135 {
136 data.Add(ts.interval); 136 data.Add(ts.interval);
137 data.Add(ts.next-DateTime.Now.Ticks); 137 data.Add(ts.next-DateTime.Now.Ticks);
@@ -142,11 +142,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
142 } 142 }
143 143
144 public void CreateFromData(uint localID, LLUUID itemID, LLUUID objectID, 144 public void CreateFromData(uint localID, LLUUID itemID, LLUUID objectID,
145 Object[] data) 145 Object[] data)
146 { 146 {
147 int idx=0; 147 int idx = 0;
148 148
149 while(idx < data.Length) 149 while (idx < data.Length)
150 { 150 {
151 TimerClass ts = new TimerClass(); 151 TimerClass ts = new TimerClass();
152 152
diff --git a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/XmlRequest.cs b/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/XmlRequest.cs
index 2714d11..288349e 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/XmlRequest.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/XmlRequest.cs
@@ -71,10 +71,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
71 71
72 foreach (XEngine xe in XEngine.ScriptEngines) 72 foreach (XEngine xe in XEngine.ScriptEngines)
73 { 73 {
74 if(xe.PostScriptEvent( 74 if (xe.PostScriptEvent(
75 rInfo.GetItemID(), new XEventParams( 75 rInfo.GetItemID(), new XEventParams(
76 "remote_data", resobj, 76 "remote_data", resobj,
77 new XDetectParams[0]))) 77 new XDetectParams[0])))
78 break; 78 break;
79 } 79 }
80 80
@@ -100,10 +100,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
100 100
101 foreach (XEngine xe in XEngine.ScriptEngines) 101 foreach (XEngine xe in XEngine.ScriptEngines)
102 { 102 {
103 if(xe.PostScriptEvent( 103 if (xe.PostScriptEvent(
104 srdInfo.m_itemID, new XEventParams( 104 srdInfo.m_itemID, new XEventParams(
105 "remote_data", resobj, 105 "remote_data", resobj,
106 new XDetectParams[0]))) 106 new XDetectParams[0])))
107 break; 107 break;
108 } 108 }
109 109
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Compiler.cs b/OpenSim/Region/ScriptEngine/XEngine/Compiler.cs
index 980d9e6..3ff7ce0 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/Compiler.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/Compiler.cs
@@ -253,10 +253,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
253 string OutFile = Path.Combine(ScriptEnginesPath, Path.Combine( 253 string OutFile = Path.Combine(ScriptEnginesPath, Path.Combine(
254 m_scriptEngine.World.RegionInfo.RegionID.ToString(), 254 m_scriptEngine.World.RegionInfo.RegionID.ToString(),
255 FilePrefix + "_compiled_" + asset + ".dll")); 255 FilePrefix + "_compiled_" + asset + ".dll"));
256// string OutFile = Path.Combine(ScriptEnginesPath, 256// string OutFile = Path.Combine(ScriptEnginesPath,
257// FilePrefix + "_compiled_" + asset + ".dll"); 257// FilePrefix + "_compiled_" + asset + ".dll");
258 258
259 if(File.Exists(OutFile)) 259 if (File.Exists(OutFile))
260 return OutFile; 260 return OutFile;
261 261
262 if (!Directory.Exists(ScriptEnginesPath)) 262 if (!Directory.Exists(ScriptEnginesPath))
@@ -271,7 +271,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
271 } 271 }
272 272
273 if (!Directory.Exists(Path.Combine(ScriptEnginesPath, 273 if (!Directory.Exists(Path.Combine(ScriptEnginesPath,
274 m_scriptEngine.World.RegionInfo.RegionID.ToString()))) 274 m_scriptEngine.World.RegionInfo.RegionID.ToString())))
275 { 275 {
276 try 276 try
277 { 277 {
@@ -284,7 +284,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
284 284
285 enumCompileType l = DefaultCompileLanguage; 285 enumCompileType l = DefaultCompileLanguage;
286 286
287
288 if (Script.StartsWith("//c#", true, CultureInfo.InvariantCulture)) 287 if (Script.StartsWith("//c#", true, CultureInfo.InvariantCulture))
289 l = enumCompileType.cs; 288 l = enumCompileType.cs;
290 if (Script.StartsWith("//vb", true, CultureInfo.InvariantCulture)) 289 if (Script.StartsWith("//vb", true, CultureInfo.InvariantCulture))
@@ -334,7 +333,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
334 333
335 // End of insert 334 // End of insert
336 335
337
338 switch (l) 336 switch (l)
339 { 337 {
340 case enumCompileType.cs: 338 case enumCompileType.cs:
@@ -368,27 +366,25 @@ namespace OpenSim.Region.ScriptEngine.XEngine
368 366
369 private static string CreateCSCompilerScript(string compileScript) 367 private static string CreateCSCompilerScript(string compileScript)
370 { 368 {
371
372
373 compileScript = String.Empty + 369 compileScript = String.Empty +
374 "using OpenSim.Region.ScriptEngine.XEngine.Script; using System.Collections.Generic;\r\n" + 370 "using OpenSim.Region.ScriptEngine.XEngine.Script; using System.Collections.Generic;\r\n" +
375 String.Empty + "namespace SecondLife { " + 371 String.Empty + "namespace SecondLife { " +
376 String.Empty + "public class Script : OpenSim.Region.ScriptEngine.XEngine.Script.BuiltIn_Commands_BaseClass { \r\n" + 372 String.Empty + "public class Script : OpenSim.Region.ScriptEngine.XEngine.Script.BuiltIn_Commands_BaseClass { \r\n" +
377 @"public Script() { } " + 373 @"public Script() { } " +
378 compileScript + 374 compileScript +
379 "} }\r\n"; 375 "} }\r\n";
380 return compileScript; 376 return compileScript;
381 } 377 }
382 378
383 private static string CreateVBCompilerScript(string compileScript) 379 private static string CreateVBCompilerScript(string compileScript)
384 { 380 {
385 compileScript = String.Empty + 381 compileScript = String.Empty +
386 "Imports OpenSim.Region.ScriptEngine.XEngine.Script: Imports System.Collections.Generic: " + 382 "Imports OpenSim.Region.ScriptEngine.XEngine.Script: Imports System.Collections.Generic: " +
387 String.Empty + "NameSpace SecondLife:" + 383 String.Empty + "NameSpace SecondLife:" +
388 String.Empty + "Public Class Script: Inherits OpenSim.Region.ScriptEngine.XEngine.Script.BuiltIn_Commands_BaseClass: " + 384 String.Empty + "Public Class Script: Inherits OpenSim.Region.ScriptEngine.XEngine.Script.BuiltIn_Commands_BaseClass: " +
389 "\r\nPublic Sub New()\r\nEnd Sub: " + 385 "\r\nPublic Sub New()\r\nEnd Sub: " +
390 compileScript + 386 compileScript +
391 ":End Class :End Namespace\r\n"; 387 ":End Class :End Namespace\r\n";
392 return compileScript; 388 return compileScript;
393 } 389 }
394 390
@@ -404,8 +400,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
404 // Output assembly name 400 // Output assembly name
405 scriptCompileCounter++; 401 scriptCompileCounter++;
406 string OutFile = Path.Combine(ScriptEnginesPath, Path.Combine( 402 string OutFile = Path.Combine(ScriptEnginesPath, Path.Combine(
407 m_scriptEngine.World.RegionInfo.RegionID.ToString(), 403 m_scriptEngine.World.RegionInfo.RegionID.ToString(),
408 FilePrefix + "_compiled_" + asset + ".dll")); 404 FilePrefix + "_compiled_" + asset + ".dll"));
409#if DEBUG 405#if DEBUG
410// m_scriptEngine.Log.Debug("[" + m_scriptEngine.ScriptEngineName + "]: Starting compile of \"" + OutFile + "\"."); 406// m_scriptEngine.Log.Debug("[" + m_scriptEngine.ScriptEngineName + "]: Starting compile of \"" + OutFile + "\".");
411#endif 407#endif
@@ -490,8 +486,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
490 foreach (CompilerError CompErr in results.Errors) 486 foreach (CompilerError CompErr in results.Errors)
491 { 487 {
492 errtext += "Line number " + (CompErr.Line - LinesToRemoveOnError) + 488 errtext += "Line number " + (CompErr.Line - LinesToRemoveOnError) +
493 ", Error Number: " + CompErr.ErrorNumber + 489 ", Error Number: " + CompErr.ErrorNumber +
494 ", '" + CompErr.ErrorText + "'\r\n"; 490 ", '" + CompErr.ErrorText + "'\r\n";
495 } 491 }
496 if (!File.Exists(OutFile)) 492 if (!File.Exists(OutFile))
497 { 493 {
@@ -499,7 +495,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
499 } 495 }
500 } 496 }
501 497
502
503 // 498 //
504 // NO ERRORS, BUT NO COMPILED FILE 499 // NO ERRORS, BUT NO COMPILED FILE
505 // 500 //
diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
index 734c837..e9ec4be 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
@@ -199,7 +199,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
199 public void on_rez(uint localID, LLUUID itemID, int startParam) 199 public void on_rez(uint localID, LLUUID itemID, int startParam)
200 { 200 {
201 myScriptEngine.PostObjectEvent(localID, new XEventParams( 201 myScriptEngine.PostObjectEvent(localID, new XEventParams(
202 "on_rez",new object[] { 202 "on_rez",new object[] {
203 new LSL_Types.LSLInteger(startParam)}, 203 new LSL_Types.LSLInteger(startParam)},
204 new XDetectParams[0])); 204 new XDetectParams[0]));
205 } 205 }
@@ -207,7 +207,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
207 public void control(uint localID, LLUUID itemID, LLUUID agentID, uint held, uint change) 207 public void control(uint localID, LLUUID itemID, LLUUID agentID, uint held, uint change)
208 { 208 {
209 myScriptEngine.PostObjectEvent(localID, new XEventParams( 209 myScriptEngine.PostObjectEvent(localID, new XEventParams(
210 "control",new object[] { 210 "control",new object[] {
211 new LSL_Types.LSLString(agentID.ToString()), 211 new LSL_Types.LSLString(agentID.ToString()),
212 new LSL_Types.LSLInteger(held), 212 new LSL_Types.LSLInteger(held),
213 new LSL_Types.LSLInteger(change)}, 213 new LSL_Types.LSLInteger(change)},
@@ -218,7 +218,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
218 string address, string subject, string message, int numLeft) 218 string address, string subject, string message, int numLeft)
219 { 219 {
220 myScriptEngine.PostObjectEvent(localID, new XEventParams( 220 myScriptEngine.PostObjectEvent(localID, new XEventParams(
221 "email",new object[] { 221 "email",new object[] {
222 new LSL_Types.LSLString(timeSent), 222 new LSL_Types.LSLString(timeSent),
223 new LSL_Types.LSLString(address), 223 new LSL_Types.LSLString(address),
224 new LSL_Types.LSLString(subject), 224 new LSL_Types.LSLString(subject),
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Executor.cs b/OpenSim/Region/ScriptEngine/XEngine/Executor.cs
index 40075ec..29336ac 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/Executor.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/Executor.cs
@@ -79,7 +79,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
79 } 79 }
80 80
81 // Save the flags we just computed and return the result 81 // Save the flags we just computed and return the result
82 if(eventFlags != 0) 82 if (eventFlags != 0)
83 m_stateEvents.Add(m_Script.State, eventFlags); 83 m_stateEvents.Add(m_Script.State, eventFlags);
84 84
85 //Console.WriteLine("Returning {0:x}", eventFlags); 85 //Console.WriteLine("Returning {0:x}", eventFlags);
@@ -130,7 +130,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
130#endif 130#endif
131 // Found 131 // Found
132 ev.Invoke(m_Script, args); 132 ev.Invoke(m_Script, args);
133
134 } 133 }
135 } 134 }
136} 135}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs b/OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs
index ca209b6..0f2d2a5 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs
@@ -111,8 +111,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
111 { 111 {
112 m_host.AddScriptLPS(1); 112 m_host.AddScriptLPS(1);
113 113
114 if(text.Length > 1023) 114 if (text.Length > 1023)
115 text=text.Substring(0, 1023); 115 text = text.Substring(0, 1023);
116 116
117 World.SimChat(Helpers.StringToField(text), 117 World.SimChat(Helpers.StringToField(text),
118 ChatTypeEnum.Say, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID, false); 118 ChatTypeEnum.Say, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID, false);
@@ -129,13 +129,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
129 129
130 private LLUUID InventorySelf() 130 private LLUUID InventorySelf()
131 { 131 {
132 LLUUID invItemID=new LLUUID(); 132 LLUUID invItemID = new LLUUID();
133 133
134 foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory) 134 foreach (KeyValuePair<LLUUID, TaskInventoryItem> inv in m_host.TaskInventory)
135 { 135 {
136 if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID) 136 if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID)
137 { 137 {
138 invItemID=inv.Key; 138 invItemID = inv.Key;
139 break; 139 break;
140 } 140 }
141 } 141 }
@@ -300,7 +300,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
300 return angle; 300 return angle;
301 } 301 }
302 302
303
304 // Old implementation of llRot2Euler, now normalized 303 // Old implementation of llRot2Euler, now normalized
305 304
306 public LSL_Types.Vector3 llRot2Euler(LSL_Types.Quaternion r) 305 public LSL_Types.Vector3 llRot2Euler(LSL_Types.Quaternion r)
@@ -322,7 +321,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
322 return new LSL_Types.Vector3(0.0, -Math.PI / 2, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z))); 321 return new LSL_Types.Vector3(0.0, -Math.PI / 2, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)));
323 } 322 }
324 323
325
326 // Xantor's newer llEuler2Rot() *try the second* inverted quaternions (-x,-y,-z,w) as LL seems to like 324 // Xantor's newer llEuler2Rot() *try the second* inverted quaternions (-x,-y,-z,w) as LL seems to like
327 // New and improved, now actually works as described. Prim rotates as expected as does llRot2Euler. 325 // New and improved, now actually works as described. Prim rotates as expected as does llRot2Euler.
328 326
@@ -363,7 +361,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
363 return new LSL_Types.Quaternion(x, y, z, s); 361 return new LSL_Types.Quaternion(x, y, z, s);
364 } 362 }
365 363
366
367 public LSL_Types.Quaternion llAxes2Rot(LSL_Types.Vector3 fwd, LSL_Types.Vector3 left, LSL_Types.Vector3 up) 364 public LSL_Types.Quaternion llAxes2Rot(LSL_Types.Vector3 fwd, LSL_Types.Vector3 left, LSL_Types.Vector3 up)
368 { 365 {
369 m_host.AddScriptLPS(1); 366 m_host.AddScriptLPS(1);
@@ -388,6 +385,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
388 m_host.AddScriptLPS(1); 385 m_host.AddScriptLPS(1);
389 return (new LSL_Types.Vector3(0, 0, 1) * r); 386 return (new LSL_Types.Vector3(0, 0, 1) * r);
390 } 387 }
388
391 public LSL_Types.Quaternion llRotBetween(LSL_Types.Vector3 a, LSL_Types.Vector3 b) 389 public LSL_Types.Quaternion llRotBetween(LSL_Types.Vector3 a, LSL_Types.Vector3 b)
392 { 390 {
393 //A and B should both be normalized 391 //A and B should both be normalized
@@ -401,12 +399,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
401 399
402 return new LSL_Types.Quaternion(axis.x * s, axis.y * s, axis.z * s, (float)Math.Cos(angle / 2)); 400 return new LSL_Types.Quaternion(axis.x * s, axis.y * s, axis.z * s, (float)Math.Cos(angle / 2));
403 } 401 }
402
404 public void llWhisper(int channelID, string text) 403 public void llWhisper(int channelID, string text)
405 { 404 {
406 m_host.AddScriptLPS(1); 405 m_host.AddScriptLPS(1);
407 406
408 if(text.Length > 1023) 407 if (text.Length > 1023)
409 text=text.Substring(0, 1023); 408 text = text.Substring(0, 1023);
410 409
411 World.SimChat(Helpers.StringToField(text), 410 World.SimChat(Helpers.StringToField(text),
412 ChatTypeEnum.Whisper, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID, false); 411 ChatTypeEnum.Whisper, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID, false);
@@ -419,8 +418,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
419 { 418 {
420 m_host.AddScriptLPS(1); 419 m_host.AddScriptLPS(1);
421 420
422 if(text.Length > 1023) 421 if (text.Length > 1023)
423 text=text.Substring(0, 1023); 422 text = text.Substring(0, 1023);
424 423
425 World.SimChat(Helpers.StringToField(text), 424 World.SimChat(Helpers.StringToField(text),
426 ChatTypeEnum.Shout, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID, true); 425 ChatTypeEnum.Shout, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID, true);
@@ -437,9 +436,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
437 return; 436 return;
438 } 437 }
439 438
440 439 if (text.Length > 1023)
441 if(text.Length > 1023) 440 text = text.Substring(0, 1023);
442 text=text.Substring(0, 1023);
443 441
444 m_host.AddScriptLPS(1); 442 m_host.AddScriptLPS(1);
445 443
@@ -486,7 +484,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
486 LLUUID.TryParse(id, out keyID); 484 LLUUID.TryParse(id, out keyID);
487 485
488 m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.SetSenseRepeatEvent(m_localID, m_itemID, name, keyID, type, range, arc, rate, m_host); 486 m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.SetSenseRepeatEvent(m_localID, m_itemID, name, keyID, type, range, arc, rate, m_host);
489 } 487 }
490 488
491 public void llSensorRemove() 489 public void llSensorRemove()
492 { 490 {
@@ -520,17 +518,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine
520 if (SensedObject == null) 518 if (SensedObject == null)
521 return String.Empty; 519 return String.Empty;
522 return SensedObject.Name; 520 return SensedObject.Name;
523
524 } 521 }
525 522
526 public string llDetectedName(int number) 523 public string llDetectedName(int number)
527 { 524 {
528 m_host.AddScriptLPS(1); 525 m_host.AddScriptLPS(1);
529 LLUUID sensedUUID = m_ScriptEngine.GetDetectID(m_itemID, number); 526 LLUUID sensedUUID = m_ScriptEngine.GetDetectID(m_itemID, number);
530 if(sensedUUID != null) 527 if (sensedUUID != null)
531 return resolveName(sensedUUID); 528 return resolveName(sensedUUID);
532 return String.Empty; 529 return String.Empty;
533 } 530 }
534 531
535 public LLUUID uuidDetectedKey(int number) 532 public LLUUID uuidDetectedKey(int number)
536 { 533 {
@@ -540,7 +537,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
540 public EntityBase entityDetectedKey(int number) 537 public EntityBase entityDetectedKey(int number)
541 { 538 {
542 LLUUID sensedUUID = m_ScriptEngine.GetDetectID(m_itemID, number); 539 LLUUID sensedUUID = m_ScriptEngine.GetDetectID(m_itemID, number);
543 if(sensedUUID != null) 540 if (sensedUUID != null)
544 { 541 {
545 EntityBase SensedObject = null; 542 EntityBase SensedObject = null;
546 lock (World.Entities) 543 lock (World.Entities)
@@ -567,7 +564,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
567 // returns UUID of owner of object detected 564 // returns UUID of owner of object detected
568 m_host.AddScriptLPS(1); 565 m_host.AddScriptLPS(1);
569 EntityBase SensedObject = entityDetectedKey(number); 566 EntityBase SensedObject = entityDetectedKey(number);
570 if (SensedObject ==null) 567 if (SensedObject == null)
571 return String.Empty; 568 return String.Empty;
572 LLUUID SensedUUID = uuidDetectedKey(number); 569 LLUUID SensedUUID = uuidDetectedKey(number);
573 if (World.GetScenePresence(SensedUUID) == null) 570 if (World.GetScenePresence(SensedUUID) == null)
@@ -575,7 +572,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
575 // sensed object is not an avatar 572 // sensed object is not an avatar
576 // so get the owner of the sensed object 573 // so get the owner of the sensed object
577 SceneObjectPart SOP = World.GetSceneObjectPart(SensedUUID); 574 SceneObjectPart SOP = World.GetSceneObjectPart(SensedUUID);
578 if (SOP != null) { return SOP.ObjectOwner.ToString(); } 575 if (SOP != null)
576 {
577 return SOP.ObjectOwner.ToString();
578 }
579 } 579 }
580 else 580 else
581 { 581 {
@@ -583,9 +583,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
583 return SensedUUID.ToString(); 583 return SensedUUID.ToString();
584 } 584 }
585 585
586
587 return String.Empty; 586 return String.Empty;
588
589 } 587 }
590 588
591 public LSL_Types.LSLInteger llDetectedType(int number) 589 public LSL_Types.LSLInteger llDetectedType(int number)
@@ -599,14 +597,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine
599 LLUUID SensedUUID = uuidDetectedKey(number); 597 LLUUID SensedUUID = uuidDetectedKey(number);
600 LSL_Types.Vector3 ZeroVector = new LSL_Types.Vector3(0, 0, 0); 598 LSL_Types.Vector3 ZeroVector = new LSL_Types.Vector3(0, 0, 0);
601 599
602 if (World.GetScenePresence(SensedUUID) != null) mask |= 0x01; // actor 600 if (World.GetScenePresence(SensedUUID) != null)
601 mask |= 0x01; // actor
602
603 if (SensedObject.Velocity.Equals(ZeroVector)) 603 if (SensedObject.Velocity.Equals(ZeroVector))
604 mask |= 0x04; // passive non-moving 604 mask |= 0x04; // passive non-moving
605 else 605 else
606 mask |= 0x02; // active moving 606 mask |= 0x02; // active moving
607 if (SensedObject is IScript) mask |= 0x08; // Scripted. It COULD have one hidden ...
608 return mask;
609 607
608 if (SensedObject is IScript)
609 mask |= 0x08; // Scripted. It COULD have one hidden ...
610
611 return mask;
610 } 612 }
611 613
612 public LSL_Types.Vector3 llDetectedPos(int number) 614 public LSL_Types.Vector3 llDetectedPos(int number)
@@ -627,7 +629,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
627 return new LSL_Types.Vector3(0, 0, 0); 629 return new LSL_Types.Vector3(0, 0, 0);
628 630
629 return new LSL_Types.Vector3(SensedObject.Velocity.X, SensedObject.Velocity.Y, SensedObject.Velocity.Z); 631 return new LSL_Types.Vector3(SensedObject.Velocity.X, SensedObject.Velocity.Y, SensedObject.Velocity.Z);
630 // return new LSL_Types.Vector3(); 632 // return new LSL_Types.Vector3();
631 } 633 }
632 634
633 public LSL_Types.Vector3 llDetectedGrab(int number) 635 public LSL_Types.Vector3 llDetectedGrab(int number)
@@ -702,8 +704,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
702 m_host.ScriptSetPhysicsStatus(true); 704 m_host.ScriptSetPhysicsStatus(true);
703 else 705 else
704 m_host.ScriptSetPhysicsStatus(false); 706 m_host.ScriptSetPhysicsStatus(false);
705
706 } 707 }
708
707 if ((status & BuiltIn_Commands_BaseClass.STATUS_PHANTOM) == BuiltIn_Commands_BaseClass.STATUS_PHANTOM) 709 if ((status & BuiltIn_Commands_BaseClass.STATUS_PHANTOM) == BuiltIn_Commands_BaseClass.STATUS_PHANTOM)
708 { 710 {
709 if (value == 1) 711 if (value == 1)
@@ -711,27 +713,32 @@ namespace OpenSim.Region.ScriptEngine.XEngine
711 else 713 else
712 m_host.ScriptSetPhantomStatus(false); 714 m_host.ScriptSetPhantomStatus(false);
713 } 715 }
716
714 if ((status & BuiltIn_Commands_BaseClass.STATUS_CAST_SHADOWS) == BuiltIn_Commands_BaseClass.STATUS_CAST_SHADOWS) 717 if ((status & BuiltIn_Commands_BaseClass.STATUS_CAST_SHADOWS) == BuiltIn_Commands_BaseClass.STATUS_CAST_SHADOWS)
715 { 718 {
716 m_host.AddFlag(LLObject.ObjectFlags.CastShadows); 719 m_host.AddFlag(LLObject.ObjectFlags.CastShadows);
717 } 720 }
721
718 if ((status & BuiltIn_Commands_BaseClass.STATUS_ROTATE_X) == BuiltIn_Commands_BaseClass.STATUS_ROTATE_X) 722 if ((status & BuiltIn_Commands_BaseClass.STATUS_ROTATE_X) == BuiltIn_Commands_BaseClass.STATUS_ROTATE_X)
719 { 723 {
720 statusrotationaxis |= BuiltIn_Commands_BaseClass.STATUS_ROTATE_X; 724 statusrotationaxis |= BuiltIn_Commands_BaseClass.STATUS_ROTATE_X;
721
722 } 725 }
726
723 if ((status & BuiltIn_Commands_BaseClass.STATUS_ROTATE_Y) == BuiltIn_Commands_BaseClass.STATUS_ROTATE_Y) 727 if ((status & BuiltIn_Commands_BaseClass.STATUS_ROTATE_Y) == BuiltIn_Commands_BaseClass.STATUS_ROTATE_Y)
724 { 728 {
725 statusrotationaxis |= BuiltIn_Commands_BaseClass.STATUS_ROTATE_Y; 729 statusrotationaxis |= BuiltIn_Commands_BaseClass.STATUS_ROTATE_Y;
726 } 730 }
731
727 if ((status & BuiltIn_Commands_BaseClass.STATUS_ROTATE_Z) == BuiltIn_Commands_BaseClass.STATUS_ROTATE_Z) 732 if ((status & BuiltIn_Commands_BaseClass.STATUS_ROTATE_Z) == BuiltIn_Commands_BaseClass.STATUS_ROTATE_Z)
728 { 733 {
729 statusrotationaxis |= BuiltIn_Commands_BaseClass.STATUS_ROTATE_Z; 734 statusrotationaxis |= BuiltIn_Commands_BaseClass.STATUS_ROTATE_Z;
730 } 735 }
736
731 if ((status & BuiltIn_Commands_BaseClass.STATUS_BLOCK_GRAB) == BuiltIn_Commands_BaseClass.STATUS_BLOCK_GRAB) 737 if ((status & BuiltIn_Commands_BaseClass.STATUS_BLOCK_GRAB) == BuiltIn_Commands_BaseClass.STATUS_BLOCK_GRAB)
732 { 738 {
733 NotImplemented("llSetStatus - STATUS_BLOCK_GRAB"); 739 NotImplemented("llSetStatus - STATUS_BLOCK_GRAB");
734 } 740 }
741
735 if ((status & BuiltIn_Commands_BaseClass.STATUS_DIE_AT_EDGE) == BuiltIn_Commands_BaseClass.STATUS_DIE_AT_EDGE) 742 if ((status & BuiltIn_Commands_BaseClass.STATUS_DIE_AT_EDGE) == BuiltIn_Commands_BaseClass.STATUS_DIE_AT_EDGE)
736 { 743 {
737 if (value == 1) 744 if (value == 1)
@@ -739,18 +746,20 @@ namespace OpenSim.Region.ScriptEngine.XEngine
739 else 746 else
740 m_host.SetDieAtEdge(false); 747 m_host.SetDieAtEdge(false);
741 } 748 }
749
742 if ((status & BuiltIn_Commands_BaseClass.STATUS_RETURN_AT_EDGE) == BuiltIn_Commands_BaseClass.STATUS_RETURN_AT_EDGE) 750 if ((status & BuiltIn_Commands_BaseClass.STATUS_RETURN_AT_EDGE) == BuiltIn_Commands_BaseClass.STATUS_RETURN_AT_EDGE)
743 { 751 {
744 NotImplemented("llSetStatus - STATUS_RETURN_AT_EDGE"); 752 NotImplemented("llSetStatus - STATUS_RETURN_AT_EDGE");
745 } 753 }
754
746 if ((status & BuiltIn_Commands_BaseClass.STATUS_SANDBOX) == BuiltIn_Commands_BaseClass.STATUS_SANDBOX) 755 if ((status & BuiltIn_Commands_BaseClass.STATUS_SANDBOX) == BuiltIn_Commands_BaseClass.STATUS_SANDBOX)
747 { 756 {
748 NotImplemented("llSetStatus - STATUS_SANDBOX"); 757 NotImplemented("llSetStatus - STATUS_SANDBOX");
749 } 758 }
759
750 if (statusrotationaxis != 0) 760 if (statusrotationaxis != 0)
751 { 761 {
752 m_host.SetAxisRotation(statusrotationaxis, value); 762 m_host.SetAxisRotation(statusrotationaxis, value);
753
754 } 763 }
755 } 764 }
756 765
@@ -766,23 +775,26 @@ namespace OpenSim.Region.ScriptEngine.XEngine
766 return 1; 775 return 1;
767 } 776 }
768 return 0; 777 return 0;
778
769 case BuiltIn_Commands_BaseClass.STATUS_PHANTOM: 779 case BuiltIn_Commands_BaseClass.STATUS_PHANTOM:
770 if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Phantom) == (uint)LLObject.ObjectFlags.Phantom) 780 if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.Phantom) == (uint)LLObject.ObjectFlags.Phantom)
771 { 781 {
772 return 1; 782 return 1;
773 } 783 }
774 return 0; 784 return 0;
785
775 case BuiltIn_Commands_BaseClass.STATUS_CAST_SHADOWS: 786 case BuiltIn_Commands_BaseClass.STATUS_CAST_SHADOWS:
776 if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.CastShadows) == (uint)LLObject.ObjectFlags.CastShadows) 787 if ((m_host.GetEffectiveObjectFlags() & (uint)LLObject.ObjectFlags.CastShadows) == (uint)LLObject.ObjectFlags.CastShadows)
777 { 788 {
778 return 1; 789 return 1;
779 } 790 }
780 return 0; 791 return 0;
792
781 case BuiltIn_Commands_BaseClass.STATUS_BLOCK_GRAB: 793 case BuiltIn_Commands_BaseClass.STATUS_BLOCK_GRAB:
782 NotImplemented("llGetStatus - STATUS_BLOCK_GRAB"); 794 NotImplemented("llGetStatus - STATUS_BLOCK_GRAB");
783 return 0; 795 return 0;
784 case BuiltIn_Commands_BaseClass.STATUS_DIE_AT_EDGE:
785 796
797 case BuiltIn_Commands_BaseClass.STATUS_DIE_AT_EDGE:
786 if (m_host.GetDieAtEdge()) 798 if (m_host.GetDieAtEdge())
787 return 1; 799 return 1;
788 else 800 else
@@ -791,15 +803,19 @@ namespace OpenSim.Region.ScriptEngine.XEngine
791 case BuiltIn_Commands_BaseClass.STATUS_RETURN_AT_EDGE: 803 case BuiltIn_Commands_BaseClass.STATUS_RETURN_AT_EDGE:
792 NotImplemented("llGetStatus - STATUS_RETURN_AT_EDGE"); 804 NotImplemented("llGetStatus - STATUS_RETURN_AT_EDGE");
793 return 0; 805 return 0;
806
794 case BuiltIn_Commands_BaseClass.STATUS_ROTATE_X: 807 case BuiltIn_Commands_BaseClass.STATUS_ROTATE_X:
795 NotImplemented("llGetStatus - STATUS_ROTATE_X"); 808 NotImplemented("llGetStatus - STATUS_ROTATE_X");
796 return 0; 809 return 0;
810
797 case BuiltIn_Commands_BaseClass.STATUS_ROTATE_Y: 811 case BuiltIn_Commands_BaseClass.STATUS_ROTATE_Y:
798 NotImplemented("llGetStatus - STATUS_ROTATE_Y"); 812 NotImplemented("llGetStatus - STATUS_ROTATE_Y");
799 return 0; 813 return 0;
814
800 case BuiltIn_Commands_BaseClass.STATUS_ROTATE_Z: 815 case BuiltIn_Commands_BaseClass.STATUS_ROTATE_Z:
801 NotImplemented("llGetStatus - STATUS_ROTATE_Z"); 816 NotImplemented("llGetStatus - STATUS_ROTATE_Z");
802 return 0; 817 return 0;
818
803 case BuiltIn_Commands_BaseClass.STATUS_SANDBOX: 819 case BuiltIn_Commands_BaseClass.STATUS_SANDBOX:
804 NotImplemented("llGetStatus - STATUS_SANDBOX"); 820 NotImplemented("llGetStatus - STATUS_SANDBOX");
805 return 0; 821 return 0;
@@ -2499,17 +2515,17 @@ namespace OpenSim.Region.ScriptEngine.XEngine
2499 2515
2500 string reply = String.Empty; 2516 string reply = String.Empty;
2501 2517
2502 switch(data) 2518 switch (data)
2503 { 2519 {
2504 case 1: // DATA_ONLINE (0|1) 2520 case 1: // DATA_ONLINE (0|1)
2505 // TODO: implement fetching of this information 2521 // TODO: implement fetching of this information
2506// if(userProfile.CurrentAgent.AgentOnline) 2522// if (userProfile.CurrentAgent.AgentOnline)
2507// reply = "1"; 2523// reply = "1";
2508// else 2524// else
2509 reply = "0"; 2525 reply = "0";
2510 break; 2526 break;
2511 case 2: // DATA_NAME (First Last) 2527 case 2: // DATA_NAME (First Last)
2512 reply = userProfile.FirstName+" "+userProfile.SurName; 2528 reply = userProfile.FirstName + " " + userProfile.SurName;
2513 break; 2529 break;
2514 case 3: // DATA_BORN (YYYY-MM-DD) 2530 case 3: // DATA_BORN (YYYY-MM-DD)
2515 DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0); 2531 DateTime born = new DateTime(1970, 1, 1, 0, 0, 0, 0);
@@ -2529,8 +2545,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
2529 LLUUID rq = LLUUID.Random(); 2545 LLUUID rq = LLUUID.Random();
2530 2546
2531 LLUUID tid = m_ScriptEngine.m_ASYNCLSLCommandManager. 2547 LLUUID tid = m_ScriptEngine.m_ASYNCLSLCommandManager.
2532 m_Dataserver.RegisterRequest(m_localID, 2548 m_Dataserver.RegisterRequest(m_localID,
2533 m_itemID, rq.ToString()); 2549 m_itemID, rq.ToString());
2534 2550
2535 m_ScriptEngine.m_ASYNCLSLCommandManager. 2551 m_ScriptEngine.m_ASYNCLSLCommandManager.
2536 m_Dataserver.DataserverReply(rq.ToString(), reply); 2552 m_Dataserver.DataserverReply(rq.ToString(), reply);
@@ -2547,8 +2563,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
2547 if (item.Type == 3 && item.Name == name) 2563 if (item.Type == 3 && item.Name == name)
2548 { 2564 {
2549 LLUUID tid = m_ScriptEngine.m_ASYNCLSLCommandManager. 2565 LLUUID tid = m_ScriptEngine.m_ASYNCLSLCommandManager.
2550 m_Dataserver.RegisterRequest(m_localID, 2566 m_Dataserver.RegisterRequest(m_localID,
2551 m_itemID, item.AssetID.ToString()); 2567 m_itemID, item.AssetID.ToString());
2552 2568
2553 LLVector3 region = new LLVector3( 2569 LLVector3 region = new LLVector3(
2554 World.RegionInfo.RegionLocX * Constants.RegionSize, 2570 World.RegionInfo.RegionLocX * Constants.RegionSize,
@@ -2565,8 +2581,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
2565 string reply = region.ToString(); 2581 string reply = region.ToString();
2566 2582
2567 m_ScriptEngine.m_ASYNCLSLCommandManager. 2583 m_ScriptEngine.m_ASYNCLSLCommandManager.
2568 m_Dataserver.DataserverReply(i.ToString(), 2584 m_Dataserver.DataserverReply(i.ToString(),
2569 reply); 2585 reply);
2570 }, false); 2586 }, false);
2571 2587
2572 return tid.ToString(); 2588 return tid.ToString();
@@ -3314,25 +3330,28 @@ namespace OpenSim.Region.ScriptEngine.XEngine
3314 { 3330 {
3315 switch (src[i]) 3331 switch (src[i])
3316 { 3332 {
3317 case '<' : 3333 case '<':
3318 parens++; 3334 parens++;
3319 length++; 3335 length++;
3320 break; 3336 break;
3321 case '>' : 3337 case '>':
3322 if (parens > 0) 3338 if (parens > 0)
3323 parens--; 3339 parens--;
3324 length++; 3340 length++;
3325 break; 3341 break;
3326 case ',' : 3342 case ',':
3327 if (parens == 0) 3343 if (parens == 0)
3328 { 3344 {
3329 result.Add(src.Substring(start,length).Trim()); 3345 result.Add(src.Substring(start,length).Trim());
3330 start += length+1; 3346 start += length+1;
3331 length = 0; 3347 length = 0;
3332 } else 3348 }
3349 else
3350 {
3333 length++; 3351 length++;
3352 }
3334 break; 3353 break;
3335 default : 3354 default:
3336 length++; 3355 length++;
3337 break; 3356 break;
3338 } 3357 }
@@ -3341,7 +3360,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
3341 result.Add(src.Substring(start,length).Trim()); 3360 result.Add(src.Substring(start,length).Trim());
3342 3361
3343 return result; 3362 return result;
3344
3345 } 3363 }
3346 3364
3347 /// <summary> 3365 /// <summary>
@@ -5290,11 +5308,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
5290 if (active[j]) 5308 if (active[j])
5291 { 5309 {
5292 // scan all of the markers 5310 // scan all of the markers
5293 if ((offset[j] = src.IndexOf((string)spcarray[j-seplen],beginning)) == -1) 5311 if ((offset[j] = src.IndexOf((string)spcarray[j-seplen], beginning)) == -1)
5294 { 5312 {
5295 // not present at all 5313 // not present at all
5296 active[j] = false; 5314 active[j] = false;
5297 } else 5315 }
5316 else
5298 { 5317 {
5299 // present and correct 5318 // present and correct
5300 if (offset[j] < offset[best]) 5319 if (offset[j] < offset[best])
@@ -5313,7 +5332,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
5313 { 5332 {
5314 // no markers were found on this pass 5333 // no markers were found on this pass
5315 // so we're pretty much done 5334 // so we're pretty much done
5316 tokens.Add(src.Substring(beginning, srclen-beginning)); 5335 tokens.Add(src.Substring(beginning, srclen - beginning));
5317 break; 5336 break;
5318 } 5337 }
5319 5338
@@ -5322,15 +5341,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
5322 5341
5323 tokens.Add(src.Substring(beginning,offset[best]-beginning)); 5342 tokens.Add(src.Substring(beginning,offset[best]-beginning));
5324 5343
5325 if (best<seplen) 5344 if (best < seplen)
5326 { 5345 {
5327 beginning = offset[best]+((string)separray[best]).Length; 5346 beginning = offset[best] + ((string)separray[best]).Length;
5328 } else 5347 }
5348 else
5329 { 5349 {
5330 beginning = offset[best]+((string)spcarray[best-seplen]).Length; 5350 beginning = offset[best] + ((string)spcarray[best - seplen]).Length;
5331 tokens.Add(spcarray[best-seplen]); 5351 tokens.Add(spcarray[best - seplen]);
5332 } 5352 }
5333
5334 } 5353 }
5335 5354
5336 // This an awkward an not very intuitive boundary case. If the 5355 // This an awkward an not very intuitive boundary case. If the
@@ -5475,60 +5494,60 @@ namespace OpenSim.Region.ScriptEngine.XEngine
5475 5494
5476 public string llRequestSimulatorData(string simulator, int data) 5495 public string llRequestSimulatorData(string simulator, int data)
5477 { 5496 {
5478try 5497 try
5479{ 5498 {
5480 m_host.AddScriptLPS(1); 5499 m_host.AddScriptLPS(1);
5481 5500
5482 string reply = String.Empty; 5501 string reply = String.Empty;
5483 5502
5484 RegionInfo info = m_ScriptEngine.World.RequestClosestRegion(simulator); 5503 RegionInfo info = m_ScriptEngine.World.RequestClosestRegion(simulator);
5485 5504
5486 switch(data) 5505 switch (data)
5487 { 5506 {
5488 case 5: // DATA_SIM_POS 5507 case 5: // DATA_SIM_POS
5489 if(info == null) 5508 if (info == null)
5490 return LLUUID.Zero.ToString(); 5509 return LLUUID.Zero.ToString();
5491 reply = new LSL_Types.Vector3( 5510 reply = new LSL_Types.Vector3(
5492 info.RegionLocX * Constants.RegionSize, 5511 info.RegionLocX * Constants.RegionSize,
5493 info.RegionLocY * Constants.RegionSize, 5512 info.RegionLocY * Constants.RegionSize,
5494 0).ToString(); 5513 0).ToString();
5495 break; 5514 break;
5496 case 6: // DATA_SIM_STATUS 5515 case 6: // DATA_SIM_STATUS
5497 if(info != null) 5516 if (info != null)
5498 reply = "up"; // Duh! 5517 reply = "up"; // Duh!
5499 else 5518 else
5500 reply = "unknown"; 5519 reply = "unknown";
5501 break; 5520 break;
5502 case 7: // DATA_SIM_RATING 5521 case 7: // DATA_SIM_RATING
5503 if(info == null) 5522 if (info == null)
5504 return LLUUID.Zero.ToString(); 5523 return LLUUID.Zero.ToString();
5505 int access = (int)info.EstateSettings.simAccess; 5524 int access = (int)info.EstateSettings.simAccess;
5506 if(access == 21) 5525 if (access == 21)
5507 reply = "MATURE"; 5526 reply = "MATURE";
5508 else if(access == 13) 5527 else if (access == 13)
5509 reply = "MATURE"; 5528 reply = "MATURE";
5510 else 5529 else
5511 reply = "UNKNOWN"; 5530 reply = "UNKNOWN";
5512 break; 5531 break;
5513 default: 5532 default:
5514 return LLUUID.Zero.ToString(); // Raise no event 5533 return LLUUID.Zero.ToString(); // Raise no event
5515 } 5534 }
5516 LLUUID rq = LLUUID.Random(); 5535 LLUUID rq = LLUUID.Random();
5517 5536
5518 LLUUID tid = m_ScriptEngine.m_ASYNCLSLCommandManager. 5537 LLUUID tid = m_ScriptEngine.m_ASYNCLSLCommandManager.
5519 m_Dataserver.RegisterRequest(m_localID, 5538 m_Dataserver.RegisterRequest(m_localID,
5520 m_itemID, rq.ToString()); 5539 m_itemID, rq.ToString());
5521 5540
5522 m_ScriptEngine.m_ASYNCLSLCommandManager. 5541 m_ScriptEngine.m_ASYNCLSLCommandManager.
5523 m_Dataserver.DataserverReply(rq.ToString(), reply); 5542 m_Dataserver.DataserverReply(rq.ToString(), reply);
5524 5543
5525 return tid.ToString(); 5544 return tid.ToString();
5526} 5545 }
5527catch(Exception e) 5546 catch(Exception e)
5528{ 5547 {
5529Console.WriteLine(e.ToString()); 5548 Console.WriteLine(e.ToString());
5530return LLUUID.Zero.ToString(); 5549 return LLUUID.Zero.ToString();
5531} 5550 }
5532 } 5551 }
5533 5552
5534 public void llForceMouselook(int mouselook) 5553 public void llForceMouselook(int mouselook)
@@ -5543,7 +5562,7 @@ return LLUUID.Zero.ToString();
5543 LLUUID key = new LLUUID(); 5562 LLUUID key = new LLUUID();
5544 if (LLUUID.TryParse(id,out key)) 5563 if (LLUUID.TryParse(id,out key))
5545 { 5564 {
5546 return (double)World.GetSceneObjectPart(World.Entities[key].LocalId).GetMass(); 5565 return (double) World.GetSceneObjectPart(World.Entities[key].LocalId).GetMass();
5547 } 5566 }
5548 return 0; 5567 return 0;
5549 } 5568 }
@@ -5562,7 +5581,6 @@ return LLUUID.Zero.ToString();
5562 5581
5563 public LSL_Types.list llListReplaceList(LSL_Types.list dest, LSL_Types.list src, int start, int end) 5582 public LSL_Types.list llListReplaceList(LSL_Types.list dest, LSL_Types.list src, int start, int end)
5564 { 5583 {
5565
5566 LSL_Types.list pref = null; 5584 LSL_Types.list pref = null;
5567 5585
5568 m_host.AddScriptLPS(1); 5586 m_host.AddScriptLPS(1);
@@ -5592,9 +5610,9 @@ return LLUUID.Zero.ToString();
5592 pref = dest.GetSublist(0,start-1); 5610 pref = dest.GetSublist(0,start-1);
5593 // Only add a suffix if there is something 5611 // Only add a suffix if there is something
5594 // beyond the end index (it's inclusive too). 5612 // beyond the end index (it's inclusive too).
5595 if (end+1 < dest.Length) 5613 if (end + 1 < dest.Length)
5596 { 5614 {
5597 return pref + src + dest.GetSublist(end+1,-1); 5615 return pref + src + dest.GetSublist(end + 1, -1);
5598 } 5616 }
5599 else 5617 else
5600 { 5618 {
@@ -5609,9 +5627,9 @@ return LLUUID.Zero.ToString();
5609 // is removed. 5627 // is removed.
5610 else 5628 else
5611 { 5629 {
5612 if (end+1 < dest.Length) 5630 if (end + 1 < dest.Length)
5613 { 5631 {
5614 return src + dest.GetSublist(end+1,-1); 5632 return src + dest.GetSublist(end + 1, -1);
5615 } 5633 }
5616 else 5634 else
5617 { 5635 {
@@ -5627,7 +5645,7 @@ return LLUUID.Zero.ToString();
5627 // might have been negative. 5645 // might have been negative.
5628 else 5646 else
5629 { 5647 {
5630 return dest.GetSublist(end+1,start-1)+src; 5648 return dest.GetSublist(end + 1, start - 1) + src;
5631 } 5649 }
5632 } 5650 }
5633 5651
@@ -6250,7 +6268,7 @@ return LLUUID.Zero.ToString();
6250 LLUUID tid = m_ScriptEngine.m_ASYNCLSLCommandManager. 6268 LLUUID tid = m_ScriptEngine.m_ASYNCLSLCommandManager.
6251 m_Dataserver.RegisterRequest(m_localID, 6269 m_Dataserver.RegisterRequest(m_localID,
6252 m_itemID, item.AssetID.ToString()); 6270 m_itemID, item.AssetID.ToString());
6253 if(NotecardCache.IsCached(item.AssetID)) 6271 if (NotecardCache.IsCached(item.AssetID))
6254 { 6272 {
6255 m_ScriptEngine.m_ASYNCLSLCommandManager. 6273 m_ScriptEngine.m_ASYNCLSLCommandManager.
6256 m_Dataserver.DataserverReply(item.AssetID.ToString(), 6274 m_Dataserver.DataserverReply(item.AssetID.ToString(),
@@ -6286,7 +6304,7 @@ return LLUUID.Zero.ToString();
6286 LLUUID tid = m_ScriptEngine.m_ASYNCLSLCommandManager. 6304 LLUUID tid = m_ScriptEngine.m_ASYNCLSLCommandManager.
6287 m_Dataserver.RegisterRequest(m_localID, 6305 m_Dataserver.RegisterRequest(m_localID,
6288 m_itemID, item.AssetID.ToString()); 6306 m_itemID, item.AssetID.ToString());
6289 if(NotecardCache.IsCached(item.AssetID)) 6307 if (NotecardCache.IsCached(item.AssetID))
6290 { 6308 {
6291 m_ScriptEngine.m_ASYNCLSLCommandManager. 6309 m_ScriptEngine.m_ASYNCLSLCommandManager.
6292 m_Dataserver.DataserverReply(item.AssetID.ToString(), 6310 m_Dataserver.DataserverReply(item.AssetID.ToString(),
@@ -6329,13 +6347,13 @@ return LLUUID.Zero.ToString();
6329 { 6347 {
6330 CacheCheck(); 6348 CacheCheck();
6331 6349
6332 lock(m_Notecards) 6350 lock (m_Notecards)
6333 { 6351 {
6334 if(m_Notecards.ContainsKey(assetID)) 6352 if (m_Notecards.ContainsKey(assetID))
6335 return; 6353 return;
6336 6354
6337 Notecard nc = new Notecard(); 6355 Notecard nc = new Notecard();
6338 nc.lastRef=DateTime.Now; 6356 nc.lastRef = DateTime.Now;
6339 nc.text = ParseText(text.Replace("\r", "").Split('\n')); 6357 nc.text = ParseText(text.Replace("\r", "").Split('\n'));
6340 m_Notecards[assetID] = nc; 6358 m_Notecards[assetID] = nc;
6341 } 6359 }
@@ -6343,56 +6361,57 @@ return LLUUID.Zero.ToString();
6343 6361
6344 private static string[] ParseText(string[] input) 6362 private static string[] ParseText(string[] input)
6345 { 6363 {
6346 int idx=0; 6364 int idx = 0;
6347 int level=0; 6365 int level = 0;
6348 List<string> output = new List<string>(); 6366 List<string> output = new List<string>();
6349 string[] words; 6367 string[] words;
6350 6368
6351 while(idx < input.Length) 6369 while (idx < input.Length)
6352 { 6370 {
6353 if(input[idx] == "{") 6371 if (input[idx] == "{")
6354 { 6372 {
6355 level++; 6373 level++;
6356 idx++; 6374 idx++;
6357 continue; 6375 continue;
6358 } 6376 }
6359 if(input[idx]== "}") 6377
6378 if (input[idx]== "}")
6360 { 6379 {
6361 level--; 6380 level--;
6362 idx++; 6381 idx++;
6363 continue; 6382 continue;
6364 } 6383 }
6365 6384
6366 switch(level) 6385 switch (level)
6367 { 6386 {
6368 case 0: 6387 case 0:
6369 words = input[idx].Split(' '); // Linden text ver 6388 words = input[idx].Split(' '); // Linden text ver
6370 int version = int.Parse(words[3]); 6389 int version = int.Parse(words[3]);
6371 if(version != 2) 6390 if (version != 2)
6372 return new String[0]; 6391 return new String[0];
6373 break; 6392 break;
6374 case 1: 6393 case 1:
6375 words = input[idx].Split(' '); 6394 words = input[idx].Split(' ');
6376 if(words[0] == "LLEmbeddedItems") 6395 if (words[0] == "LLEmbeddedItems")
6377 break; 6396 break;
6378 if(words[0] == "Text") 6397 if (words[0] == "Text")
6379 { 6398 {
6380 int len = int.Parse(words[2]); 6399 int len = int.Parse(words[2]);
6381 idx++; 6400 idx++;
6382 6401
6383 int count=-1; 6402 int count = -1;
6384 6403
6385 while(count < len) 6404 while (count < len)
6386 { 6405 {
6387 int l = input[idx].Length; 6406 int l = input[idx].Length;
6388 string ln = input[idx]; 6407 string ln = input[idx];
6389 6408
6390 int need = len-count-1; 6409 int need = len-count-1;
6391 if(ln.Length > need) 6410 if (ln.Length > need)
6392 ln=ln.Substring(0, need); 6411 ln = ln.Substring(0, need);
6393 6412
6394 output.Add(ln); 6413 output.Add(ln);
6395 count+=ln.Length+1; 6414 count += ln.Length + 1;
6396 idx++; 6415 idx++;
6397 } 6416 }
6398 6417
@@ -6401,10 +6420,10 @@ return LLUUID.Zero.ToString();
6401 break; 6420 break;
6402 case 2: 6421 case 2:
6403 words = input[idx].Split(' '); // count 6422 words = input[idx].Split(' '); // count
6404 if(words[0] == "count") 6423 if (words[0] == "count")
6405 { 6424 {
6406 int c = int.Parse(words[1]); 6425 int c = int.Parse(words[1]);
6407 if(c > 0) 6426 if (c > 0)
6408 return new String[0]; 6427 return new String[0];
6409 break; 6428 break;
6410 } 6429 }
@@ -6417,7 +6436,7 @@ return LLUUID.Zero.ToString();
6417 6436
6418 public static bool IsCached(LLUUID assetID) 6437 public static bool IsCached(LLUUID assetID)
6419 { 6438 {
6420 lock(m_Notecards) 6439 lock (m_Notecards)
6421 { 6440 {
6422 return m_Notecards.ContainsKey(assetID); 6441 return m_Notecards.ContainsKey(assetID);
6423 } 6442 }
@@ -6425,10 +6444,10 @@ return LLUUID.Zero.ToString();
6425 6444
6426 public static int GetLines(LLUUID assetID) 6445 public static int GetLines(LLUUID assetID)
6427 { 6446 {
6428 if(!IsCached(assetID)) 6447 if (!IsCached(assetID))
6429 return -1; 6448 return -1;
6430 6449
6431 lock(m_Notecards) 6450 lock (m_Notecards)
6432 { 6451 {
6433 m_Notecards[assetID].lastRef = DateTime.Now; 6452 m_Notecards[assetID].lastRef = DateTime.Now;
6434 return m_Notecards[assetID].text.Length; 6453 return m_Notecards[assetID].text.Length;
@@ -6437,23 +6456,23 @@ return LLUUID.Zero.ToString();
6437 6456
6438 public static string GetLine(LLUUID assetID, int line) 6457 public static string GetLine(LLUUID assetID, int line)
6439 { 6458 {
6440 if(line < 0) 6459 if (line < 0)
6441 return ""; 6460 return "";
6442 6461
6443 string data; 6462 string data;
6444 6463
6445 if(!IsCached(assetID)) 6464 if (!IsCached(assetID))
6446 return ""; 6465 return "";
6447 6466
6448 lock(m_Notecards) 6467 lock (m_Notecards)
6449 { 6468 {
6450 m_Notecards[assetID].lastRef = DateTime.Now; 6469 m_Notecards[assetID].lastRef = DateTime.Now;
6451 6470
6452 if(line >= m_Notecards[assetID].text.Length) 6471 if (line >= m_Notecards[assetID].text.Length)
6453 return "\n\n\n"; 6472 return "\n\n\n";
6454 6473
6455 data=m_Notecards[assetID].text[line]; 6474 data = m_Notecards[assetID].text[line];
6456 if(data.Length > 255) 6475 if (data.Length > 255)
6457 data = data.Substring(0, 255); 6476 data = data.Substring(0, 255);
6458 6477
6459 return data; 6478 return data;
@@ -6465,10 +6484,9 @@ return LLUUID.Zero.ToString();
6465 foreach (LLUUID key in new List<LLUUID>(m_Notecards.Keys)) 6484 foreach (LLUUID key in new List<LLUUID>(m_Notecards.Keys))
6466 { 6485 {
6467 Notecard nc = m_Notecards[key]; 6486 Notecard nc = m_Notecards[key];
6468 if(nc.lastRef.AddSeconds(30) < DateTime.Now) 6487 if (nc.lastRef.AddSeconds(30) < DateTime.Now)
6469 m_Notecards.Remove(key); 6488 m_Notecards.Remove(key);
6470 } 6489 }
6471 } 6490 }
6472
6473 } 6491 }
6474} 6492}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Script/AssemblyResolver.cs b/OpenSim/Region/ScriptEngine/XEngine/Script/AssemblyResolver.cs
index 8107788..cf15b67 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/Script/AssemblyResolver.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/Script/AssemblyResolver.cs
@@ -37,25 +37,25 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script
37 public static Assembly OnAssemblyResolve(object sender, 37 public static Assembly OnAssemblyResolve(object sender,
38 ResolveEventArgs args) 38 ResolveEventArgs args)
39 { 39 {
40 if(!(sender is System.AppDomain)) 40 if (!(sender is System.AppDomain))
41 return null; 41 return null;
42 42
43 AppDomain myDomain = (AppDomain)sender; 43 AppDomain myDomain = (AppDomain)sender;
44 string dirName = myDomain.FriendlyName; 44 string dirName = myDomain.FriendlyName;
45 45
46 string[] pathList=new string[] {"bin", "ScriptEngines", 46 string[] pathList = new string[] {"bin", "ScriptEngines",
47 Path.Combine("ScriptEngines", dirName)}; 47 Path.Combine("ScriptEngines", dirName)};
48 48
49 string assemblyName = args.Name; 49 string assemblyName = args.Name;
50 if(assemblyName.IndexOf(",") != -1) 50 if (assemblyName.IndexOf(",") != -1)
51 assemblyName=args.Name.Substring(0, args.Name.IndexOf(",")); 51 assemblyName = args.Name.Substring(0, args.Name.IndexOf(","));
52 52
53 foreach (string s in pathList) 53 foreach (string s in pathList)
54 { 54 {
55 string path=Path.Combine(Directory.GetCurrentDirectory(), 55 string path = Path.Combine(Directory.GetCurrentDirectory(),
56 Path.Combine(s, assemblyName))+".dll"; 56 Path.Combine(s, assemblyName))+".dll";
57 57
58 if(File.Exists(path)) 58 if (File.Exists(path))
59 return Assembly.LoadFrom(path); 59 return Assembly.LoadFrom(path);
60 } 60 }
61 61
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Script/BuiltIn_Commands_BaseClass.cs b/OpenSim/Region/ScriptEngine/XEngine/Script/BuiltIn_Commands_BaseClass.cs
index bae8192..ebe4fc5 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/Script/BuiltIn_Commands_BaseClass.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/Script/BuiltIn_Commands_BaseClass.cs
@@ -106,7 +106,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script
106 { 106 {
107 foreach (KeyValuePair<string, object> var in vars) 107 foreach (KeyValuePair<string, object> var in vars)
108 { 108 {
109 if(m_Fields.ContainsKey(var.Key)) 109 if (m_Fields.ContainsKey(var.Key))
110 { 110 {
111 m_Fields[var.Key].SetValue(this, var.Value); 111 m_Fields[var.Key].SetValue(this, var.Value);
112 } 112 }
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Script/LSL_Types.cs b/OpenSim/Region/ScriptEngine/XEngine/Script/LSL_Types.cs
index 2d5d2b8..a3dcfaf 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/Script/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/Script/LSL_Types.cs
@@ -1212,8 +1212,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script
1212 1212
1213 public LSLInteger(Object o) 1213 public LSLInteger(Object o)
1214 { 1214 {
1215 if(!(o is Int32)) 1215 if (!(o is Int32))
1216 value=0; 1216 value = 0;
1217 else 1217 else
1218 value = (int)o; 1218 value = (int)o;
1219 } 1219 }
@@ -1327,11 +1327,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script
1327 1327
1328 public override bool Equals(object o) 1328 public override bool Equals(object o)
1329 { 1329 {
1330 if(o is Int32) 1330 if (o is Int32)
1331 { 1331 {
1332 return value == (Int32)o; 1332 return value == (Int32)o;
1333 } 1333 }
1334 if(o is LSLInteger) 1334 if (o is LSLInteger)
1335 { 1335 {
1336 return value == ((LSLInteger)o).value; 1336 return value == ((LSLInteger)o).value;
1337 } 1337 }
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index cbcf5ea..0fe1f46 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -106,7 +106,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
106 106
107 m_ScriptConfig = configSource.Configs["XEngine"]; 107 m_ScriptConfig = configSource.Configs["XEngine"];
108 108
109 if(m_ScriptConfig == null) 109 if (m_ScriptConfig == null)
110 { 110 {
111 m_log.ErrorFormat("[XEngine] No script configuration found. Scripts disabled"); 111 m_log.ErrorFormat("[XEngine] No script configuration found. Scripts disabled");
112 return; 112 return;
@@ -126,7 +126,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
126 int saveTime = m_ScriptConfig.GetInt("SaveInterval", 300)*1000; 126 int saveTime = m_ScriptConfig.GetInt("SaveInterval", 300)*1000;
127 127
128 ThreadPriority prio = ThreadPriority.BelowNormal; 128 ThreadPriority prio = ThreadPriority.BelowNormal;
129 switch(priority) 129 switch (priority)
130 { 130 {
131 case "Lowest": 131 case "Lowest":
132 prio=ThreadPriority.Lowest; 132 prio=ThreadPriority.Lowest;
@@ -149,7 +149,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
149 break; 149 break;
150 } 150 }
151 151
152 lock(m_ScriptEngines) 152 lock (m_ScriptEngines)
153 { 153 {
154 m_ScriptEngines.Add(this); 154 m_ScriptEngines.Add(this);
155 } 155 }
@@ -166,17 +166,17 @@ namespace OpenSim.Region.ScriptEngine.XEngine
166 m_Scene.EventManager.OnRemoveScript += OnRemoveScript; 166 m_Scene.EventManager.OnRemoveScript += OnRemoveScript;
167 m_Scene.EventManager.OnScriptReset += OnScriptReset; 167 m_Scene.EventManager.OnScriptReset += OnScriptReset;
168 168
169 if(sleepTime > 0) 169 if (sleepTime > 0)
170 { 170 {
171 m_ThreadPool.QueueWorkItem(new WorkItemCallback( 171 m_ThreadPool.QueueWorkItem(new WorkItemCallback(
172 this.DoMaintenance), new Object[] 172 this.DoMaintenance), new Object[]
173 { sleepTime }); 173 { sleepTime });
174 } 174 }
175 175
176 if(saveTime > 0) 176 if (saveTime > 0)
177 { 177 {
178 m_ThreadPool.QueueWorkItem(new WorkItemCallback( 178 m_ThreadPool.QueueWorkItem(new WorkItemCallback(
179 this.DoBackup), new Object[] { saveTime }); 179 this.DoBackup), new Object[] { saveTime });
180 } 180 }
181 } 181 }
182 182
@@ -187,9 +187,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
187 187
188 public void Close() 188 public void Close()
189 { 189 {
190 lock(m_ScriptEngines) 190 lock (m_ScriptEngines)
191 { 191 {
192 if(m_ScriptEngines.Contains(this)) 192 if (m_ScriptEngines.Contains(this))
193 m_ScriptEngines.Remove(this); 193 m_ScriptEngines.Remove(this);
194 } 194 }
195 } 195 }
@@ -205,7 +205,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
205 205
206 List<XScriptInstance> instances = new List<XScriptInstance>(); 206 List<XScriptInstance> instances = new List<XScriptInstance>();
207 207
208 lock(m_Scripts) 208 lock (m_Scripts)
209 { 209 {
210 foreach (XScriptInstance instance in m_Scripts.Values) 210 foreach (XScriptInstance instance in m_Scripts.Values)
211 instances.Add(instance); 211 instances.Add(instance);
@@ -215,9 +215,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
215 { 215 {
216 string assembly = String.Empty; 216 string assembly = String.Empty;
217 217
218 lock(m_Scripts) 218 lock (m_Scripts)
219 { 219 {
220 if(!m_Assemblies.ContainsKey(i.AssetID)) 220 if (!m_Assemblies.ContainsKey(i.AssetID))
221 continue; 221 continue;
222 assembly = m_Assemblies[i.AssetID]; 222 assembly = m_Assemblies[i.AssetID];
223 } 223 }
@@ -240,10 +240,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
240 240
241 foreach (XScriptInstance inst in m_Scripts.Values) 241 foreach (XScriptInstance inst in m_Scripts.Values)
242 { 242 {
243 if(inst.EventTime() > m_EventLimit) 243 if (inst.EventTime() > m_EventLimit)
244 { 244 {
245 inst.Stop(100); 245 inst.Stop(100);
246 if(!m_KillTimedOutScripts) 246 if (!m_KillTimedOutScripts)
247 inst.Start(); 247 inst.Start();
248 } 248 }
249 } 249 }
@@ -251,7 +251,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
251 System.Threading.Thread.Sleep(sleepTime); 251 System.Threading.Thread.Sleep(sleepTime);
252 252
253 m_ThreadPool.QueueWorkItem(new WorkItemCallback( 253 m_ThreadPool.QueueWorkItem(new WorkItemCallback(
254 this.DoMaintenance), new Object[] 254 this.DoMaintenance), new Object[]
255 { sleepTime }); 255 { sleepTime });
256 256
257 return 0; 257 return 0;
@@ -281,7 +281,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
281 public void OnRezScript(uint localID, LLUUID itemID, string script) 281 public void OnRezScript(uint localID, LLUUID itemID, string script)
282 { 282 {
283 m_ThreadPool.QueueWorkItem(new WorkItemCallback( 283 m_ThreadPool.QueueWorkItem(new WorkItemCallback(
284 this.DoOnRezScript), new Object[] 284 this.DoOnRezScript), new Object[]
285 { localID, itemID, script}); 285 { localID, itemID, script});
286 } 286 }
287 287
@@ -296,25 +296,25 @@ namespace OpenSim.Region.ScriptEngine.XEngine
296 // already have it. 296 // already have it.
297 297
298 SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); 298 SceneObjectPart part = m_Scene.GetSceneObjectPart(localID);
299 if(part == null) 299 if (part == null)
300 return false; 300 return false;
301 301
302 TaskInventoryItem item = part.GetInventoryItem(itemID); 302 TaskInventoryItem item = part.GetInventoryItem(itemID);
303 if(item == null) 303 if (item == null)
304 return false; 304 return false;
305 305
306 LLUUID assetID=item.AssetID; 306 LLUUID assetID = item.AssetID;
307 307
308// m_log.DebugFormat("[XEngine] Compiling script {0} ({1})", 308// m_log.DebugFormat("[XEngine] Compiling script {0} ({1})",
309// item.Name, itemID.ToString()); 309// item.Name, itemID.ToString());
310 310
311 string assembly=""; 311 string assembly = "";
312 try 312 try
313 { 313 {
314 assembly=m_Compiler.PerformScriptCompile(script, 314 assembly = m_Compiler.PerformScriptCompile(script,
315 assetID.ToString()); 315 assetID.ToString());
316 m_log.DebugFormat("[XEngine] Loaded script {0}.{1}", 316 m_log.DebugFormat("[XEngine] Loaded script {0}.{1}",
317 part.ParentGroup.RootPart.Name, item.Name); 317 part.ParentGroup.RootPart.Name, item.Name);
318 } 318 }
319 catch (Exception e) 319 catch (Exception e)
320 { 320 {
@@ -325,9 +325,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
325 if (text.Length > 1400) 325 if (text.Length > 1400)
326 text = text.Substring(0, 1400); 326 text = text.Substring(0, 1400);
327 World.SimChat(Helpers.StringToField(text), 327 World.SimChat(Helpers.StringToField(text),
328 ChatTypeEnum.DebugChannel, 2147483647, 328 ChatTypeEnum.DebugChannel, 2147483647,
329 part.AbsolutePosition, 329 part.AbsolutePosition,
330 part.Name, part.UUID, false); 330 part.Name, part.UUID, false);
331 } 331 }
332 catch (Exception e2) // LEGIT: User Scripting 332 catch (Exception e2) // LEGIT: User Scripting
333 { 333 {
@@ -342,28 +342,28 @@ namespace OpenSim.Region.ScriptEngine.XEngine
342 return false; 342 return false;
343 } 343 }
344 344
345 lock(m_Scripts) 345 lock (m_Scripts)
346 { 346 {
347 // Create the object record 347 // Create the object record
348 348
349 if(!m_PrimObjects.ContainsKey(localID)) 349 if (!m_PrimObjects.ContainsKey(localID))
350 m_PrimObjects[localID] = new List<LLUUID>(); 350 m_PrimObjects[localID] = new List<LLUUID>();
351 351
352 if(!m_PrimObjects[localID].Contains(itemID)) 352 if (!m_PrimObjects[localID].Contains(itemID))
353 m_PrimObjects[localID].Add(itemID); 353 m_PrimObjects[localID].Add(itemID);
354 354
355 if(!m_Assemblies.ContainsKey(assetID)) 355 if (!m_Assemblies.ContainsKey(assetID))
356 m_Assemblies[assetID] = assembly; 356 m_Assemblies[assetID] = assembly;
357 357
358 if((!m_Scripts.ContainsKey(itemID)) || 358 if ((!m_Scripts.ContainsKey(itemID)) ||
359 (m_Scripts[itemID].AssetID != assetID)) 359 (m_Scripts[itemID].AssetID != assetID))
360 { 360 {
361 LLUUID appDomain=assetID; 361 LLUUID appDomain=assetID;
362 362
363 if(part.ParentGroup.RootPart.m_IsAttachment) 363 if (part.ParentGroup.RootPart.m_IsAttachment)
364 appDomain=part.ParentGroup.RootPart.UUID; 364 appDomain = part.ParentGroup.RootPart.UUID;
365 365
366 if(!m_AppDomains.ContainsKey(appDomain)) 366 if (!m_AppDomains.ContainsKey(appDomain))
367 { 367 {
368 try 368 try
369 { 369 {
@@ -373,16 +373,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine
373// m_Scene.RegionInfo.RegionID.ToString()); 373// m_Scene.RegionInfo.RegionID.ToString());
374 374
375 Evidence baseEvidence = 375 Evidence baseEvidence =
376 AppDomain.CurrentDomain.Evidence; 376 AppDomain.CurrentDomain.Evidence;
377 Evidence evidence = new Evidence(baseEvidence); 377 Evidence evidence = new Evidence(baseEvidence);
378 378
379 m_AppDomains[appDomain] = 379 m_AppDomains[appDomain] =
380 AppDomain.CreateDomain( 380 AppDomain.CreateDomain(
381 m_Scene.RegionInfo.RegionID.ToString(), 381 m_Scene.RegionInfo.RegionID.ToString(),
382 evidence, appSetup); 382 evidence, appSetup);
383 383
384 m_AppDomains[appDomain].AssemblyResolve += 384 m_AppDomains[appDomain].AssemblyResolve +=
385 new ResolveEventHandler( 385 new ResolveEventHandler(
386 AssemblyResolver.OnAssemblyResolve); 386 AssemblyResolver.OnAssemblyResolve);
387 m_DomainScripts[appDomain] = new List<LLUUID>(); 387 m_DomainScripts[appDomain] = new List<LLUUID>();
388 } 388 }
@@ -394,10 +394,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
394 } 394 }
395 m_DomainScripts[appDomain].Add(itemID); 395 m_DomainScripts[appDomain].Add(itemID);
396 396
397
398 XScriptInstance instance = new XScriptInstance(this,localID, 397 XScriptInstance instance = new XScriptInstance(this,localID,
399 part.UUID, itemID, assetID, assembly, 398 part.UUID, itemID, assetID, assembly,
400 m_AppDomains[appDomain]); 399 m_AppDomains[appDomain]);
401 400
402 instance.AppDomain = appDomain; 401 instance.AppDomain = appDomain;
403 402
@@ -409,10 +408,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
409 408
410 public void OnRemoveScript(uint localID, LLUUID itemID) 409 public void OnRemoveScript(uint localID, LLUUID itemID)
411 { 410 {
412 lock(m_Scripts) 411 lock (m_Scripts)
413 { 412 {
414 // Do we even have it? 413 // Do we even have it?
415 if(!m_Scripts.ContainsKey(itemID)) 414 if (!m_Scripts.ContainsKey(itemID))
416 return; 415 return;
417 416
418 m_ASYNCLSLCommandManager.RemoveScript(localID, itemID); 417 m_ASYNCLSLCommandManager.RemoveScript(localID, itemID);
@@ -424,27 +423,27 @@ namespace OpenSim.Region.ScriptEngine.XEngine
424 instance.Stop(0); 423 instance.Stop(0);
425 424
426 SceneObjectPart part = 425 SceneObjectPart part =
427 m_Scene.GetSceneObjectPart(localID); 426 m_Scene.GetSceneObjectPart(localID);
428 427
429 if(part != null) 428 if (part != null)
430 part.RemoveScriptEvents(itemID); 429 part.RemoveScriptEvents(itemID);
431 430
432 // Remove the script from it's prim 431 // Remove the script from it's prim
433 if(m_PrimObjects.ContainsKey(localID)) 432 if (m_PrimObjects.ContainsKey(localID))
434 { 433 {
435 // Remove inventory item record 434 // Remove inventory item record
436 if(m_PrimObjects[localID].Contains(itemID)) 435 if (m_PrimObjects[localID].Contains(itemID))
437 m_PrimObjects[localID].Remove(itemID); 436 m_PrimObjects[localID].Remove(itemID);
438 437
439 // If there are no more scripts, remove prim 438 // If there are no more scripts, remove prim
440 if(m_PrimObjects[localID].Count == 0) 439 if (m_PrimObjects[localID].Count == 0)
441 { 440 {
442 m_PrimObjects.Remove(localID); 441 m_PrimObjects.Remove(localID);
443 } 442 }
444 } 443 }
445 444
446 m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); 445 m_DomainScripts[instance.AppDomain].Remove(instance.ItemID);
447 if(m_DomainScripts[instance.AppDomain].Count == 0) 446 if (m_DomainScripts[instance.AppDomain].Count == 0)
448 { 447 {
449 m_DomainScripts.Remove(instance.AppDomain); 448 m_DomainScripts.Remove(instance.AppDomain);
450 UnloadAppDomain(instance.AppDomain); 449 UnloadAppDomain(instance.AppDomain);
@@ -467,7 +466,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
467 466
468 foreach (XScriptInstance i in m_Scripts.Values) 467 foreach (XScriptInstance i in m_Scripts.Values)
469 { 468 {
470 if(assetIDList.Contains(i.AssetID)) 469 if (assetIDList.Contains(i.AssetID))
471 assetIDList.Remove(i.AssetID); 470 assetIDList.Remove(i.AssetID);
472 } 471 }
473 472
@@ -476,11 +475,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
476// m_log.DebugFormat("[XEngine] Removing unreferenced assembly {0}", m_Assemblies[assetID]); 475// m_log.DebugFormat("[XEngine] Removing unreferenced assembly {0}", m_Assemblies[assetID]);
477 try 476 try
478 { 477 {
479 if(File.Exists(m_Assemblies[assetID])) 478 if (File.Exists(m_Assemblies[assetID]))
480 File.Delete(m_Assemblies[assetID]); 479 File.Delete(m_Assemblies[assetID]);
481 if(File.Exists(m_Assemblies[assetID]+".state")) 480
481 if (File.Exists(m_Assemblies[assetID]+".state"))
482 File.Delete(m_Assemblies[assetID]+".state"); 482 File.Delete(m_Assemblies[assetID]+".state");
483 if(File.Exists(m_Assemblies[assetID]+".mdb")) 483
484 if (File.Exists(m_Assemblies[assetID]+".mdb"))
484 File.Delete(m_Assemblies[assetID]+".mdb"); 485 File.Delete(m_Assemblies[assetID]+".mdb");
485 } 486 }
486 catch (Exception e) 487 catch (Exception e)
@@ -492,9 +493,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
492 493
493 private void UnloadAppDomain(LLUUID id) 494 private void UnloadAppDomain(LLUUID id)
494 { 495 {
495 if(m_AppDomains.ContainsKey(id)) 496 if (m_AppDomains.ContainsKey(id))
496 { 497 {
497 AppDomain domain=m_AppDomains[id]; 498 AppDomain domain = m_AppDomains[id];
498 m_AppDomains.Remove(id); 499 m_AppDomains.Remove(id);
499 500
500 AppDomain.Unload(domain); 501 AppDomain.Unload(domain);
@@ -507,10 +508,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
507 // Start processing 508 // Start processing
508 // 509 //
509 private void StartEngine(int minThreads, int maxThreads, 510 private void StartEngine(int minThreads, int maxThreads,
510 int idleTimeout, ThreadPriority threadPriority, 511 int idleTimeout, ThreadPriority threadPriority,
511 int maxScriptQueue, int stackSize) 512 int maxScriptQueue, int stackSize)
512 { 513 {
513 m_MaxScriptQueue=maxScriptQueue; 514 m_MaxScriptQueue = maxScriptQueue;
514 515
515 STPStartInfo startInfo = new STPStartInfo(); 516 STPStartInfo startInfo = new STPStartInfo();
516 startInfo.IdleTimeout = idleTimeout; 517 startInfo.IdleTimeout = idleTimeout;
@@ -519,7 +520,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
519 startInfo.ThreadPriority = threadPriority; 520 startInfo.ThreadPriority = threadPriority;
520 startInfo.StackSize = stackSize; 521 startInfo.StackSize = stackSize;
521 startInfo.StartSuspended = true; 522 startInfo.StartSuspended = true;
522 523
523 m_ThreadPool = new SmartThreadPool(startInfo); 524 m_ThreadPool = new SmartThreadPool(startInfo);
524 } 525 }
525 526
@@ -529,7 +530,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
529 public IWorkItemResult QueueEventHandler(object parms) 530 public IWorkItemResult QueueEventHandler(object parms)
530 { 531 {
531 return m_ThreadPool.QueueWorkItem(new WorkItemCallback( 532 return m_ThreadPool.QueueWorkItem(new WorkItemCallback(
532 this.ProcessEventHandler), parms); 533 this.ProcessEventHandler), parms);
533 } 534 }
534 535
535 // 536 //
@@ -537,8 +538,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
537 // 538 //
538 private object ProcessEventHandler(object parms) 539 private object ProcessEventHandler(object parms)
539 { 540 {
540 XScriptInstance instance=(XScriptInstance)parms; 541 XScriptInstance instance = (XScriptInstance) parms;
541 542
542 return instance.EventProcessor(); 543 return instance.EventProcessor();
543 } 544 }
544 545
@@ -549,15 +550,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
549 { 550 {
550 bool result = false; 551 bool result = false;
551 552
552 if(!m_PrimObjects.ContainsKey(localID)) 553 if (!m_PrimObjects.ContainsKey(localID))
553 return false; 554 return false;
554 555
555 foreach (LLUUID itemID in m_PrimObjects[localID]) 556 foreach (LLUUID itemID in m_PrimObjects[localID])
556 { 557 {
557 if(m_Scripts.ContainsKey(itemID)) 558 if (m_Scripts.ContainsKey(itemID))
558 { 559 {
559 XScriptInstance instance = m_Scripts[itemID]; 560 XScriptInstance instance = m_Scripts[itemID];
560 if(instance != null) 561 if (instance != null)
561 { 562 {
562 instance.PostEvent(p); 563 instance.PostEvent(p);
563 result = true; 564 result = true;
@@ -572,10 +573,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
572 // 573 //
573 public bool PostScriptEvent(LLUUID itemID, XEventParams p) 574 public bool PostScriptEvent(LLUUID itemID, XEventParams p)
574 { 575 {
575 if(m_Scripts.ContainsKey(itemID)) 576 if (m_Scripts.ContainsKey(itemID))
576 { 577 {
577 XScriptInstance instance = m_Scripts[itemID]; 578 XScriptInstance instance = m_Scripts[itemID];
578 if(instance != null) 579 if (instance != null)
579 instance.PostEvent(p); 580 instance.PostEvent(p);
580 return true; 581 return true;
581 } 582 }
@@ -583,25 +584,25 @@ namespace OpenSim.Region.ScriptEngine.XEngine
583 } 584 }
584 585
585 public Assembly OnAssemblyResolve(object sender, 586 public Assembly OnAssemblyResolve(object sender,
586 ResolveEventArgs args) 587 ResolveEventArgs args)
587 { 588 {
588 if(!(sender is System.AppDomain)) 589 if (!(sender is System.AppDomain))
589 return null; 590 return null;
590 591
591 string[] pathList=new string[] {"bin", "ScriptEngines", 592 string[] pathList = new string[] {"bin", "ScriptEngines",
592 Path.Combine("ScriptEngines", 593 Path.Combine("ScriptEngines",
593 m_Scene.RegionInfo.RegionID.ToString())}; 594 m_Scene.RegionInfo.RegionID.ToString())};
594 595
595 string assemblyName = args.Name; 596 string assemblyName = args.Name;
596 if(assemblyName.IndexOf(",") != -1) 597 if (assemblyName.IndexOf(",") != -1)
597 assemblyName=args.Name.Substring(0, args.Name.IndexOf(",")); 598 assemblyName = args.Name.Substring(0, args.Name.IndexOf(","));
598 599
599 foreach (string s in pathList) 600 foreach (string s in pathList)
600 { 601 {
601 string path=Path.Combine(Directory.GetCurrentDirectory(), 602 string path = Path.Combine(Directory.GetCurrentDirectory(),
602 Path.Combine(s, assemblyName))+".dll"; 603 Path.Combine(s, assemblyName))+".dll";
603 604
604 if(File.Exists(path)) 605 if (File.Exists(path))
605 return Assembly.LoadFrom(path); 606 return Assembly.LoadFrom(path);
606 } 607 }
607 608
@@ -611,9 +612,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
611 private XScriptInstance GetInstance(LLUUID itemID) 612 private XScriptInstance GetInstance(LLUUID itemID)
612 { 613 {
613 XScriptInstance instance; 614 XScriptInstance instance;
614 lock(m_Scripts) 615 lock (m_Scripts)
615 { 616 {
616 if(!m_Scripts.ContainsKey(itemID)) 617 if (!m_Scripts.ContainsKey(itemID))
617 return null; 618 return null;
618 instance = m_Scripts[itemID]; 619 instance = m_Scripts[itemID];
619 } 620 }
@@ -623,9 +624,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
623 public void SetScriptState(LLUUID itemID, bool running) 624 public void SetScriptState(LLUUID itemID, bool running)
624 { 625 {
625 XScriptInstance instance = GetInstance(itemID); 626 XScriptInstance instance = GetInstance(itemID);
626 if(instance != null) 627 if (instance != null)
627 { 628 {
628 if(running) 629 if (running)
629 instance.Start(); 630 instance.Start();
630 else 631 else
631 instance.Stop(500); 632 instance.Stop(500);
@@ -635,7 +636,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
635 public bool GetScriptState(LLUUID itemID) 636 public bool GetScriptState(LLUUID itemID)
636 { 637 {
637 XScriptInstance instance = GetInstance(itemID); 638 XScriptInstance instance = GetInstance(itemID);
638 if(instance != null) 639 if (instance != null)
639 return instance.Running; 640 return instance.Running;
640 return false; 641 return false;
641 } 642 }
@@ -643,14 +644,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine
643 public void ResetScript(LLUUID itemID) 644 public void ResetScript(LLUUID itemID)
644 { 645 {
645 XScriptInstance instance = GetInstance(itemID); 646 XScriptInstance instance = GetInstance(itemID);
646 if(instance != null) 647 if (instance != null)
647 instance.ResetScript(); 648 instance.ResetScript();
648 } 649 }
649 650
650 public XDetectParams GetDetectParams(LLUUID itemID, int idx) 651 public XDetectParams GetDetectParams(LLUUID itemID, int idx)
651 { 652 {
652 XScriptInstance instance = GetInstance(itemID); 653 XScriptInstance instance = GetInstance(itemID);
653 if(instance != null) 654 if (instance != null)
654 return instance.GetDetectParams(idx); 655 return instance.GetDetectParams(idx);
655 return new XDetectParams(); 656 return new XDetectParams();
656 } 657 }
@@ -658,7 +659,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
658 public LLUUID GetDetectID(LLUUID itemID, int idx) 659 public LLUUID GetDetectID(LLUUID itemID, int idx)
659 { 660 {
660 XScriptInstance instance = GetInstance(itemID); 661 XScriptInstance instance = GetInstance(itemID);
661 if(instance != null) 662 if (instance != null)
662 return instance.GetDetectID(idx); 663 return instance.GetDetectID(idx);
663 return LLUUID.Zero; 664 return LLUUID.Zero;
664 } 665 }
@@ -688,8 +689,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
688 { 689 {
689 private XEngine m_Engine; 690 private XEngine m_Engine;
690 private IWorkItemResult m_CurrentResult=null; 691 private IWorkItemResult m_CurrentResult=null;
691 private Queue m_EventQueue=new Queue(32); 692 private Queue m_EventQueue = new Queue(32);
692 private bool m_RunEvents=false; 693 private bool m_RunEvents = false;
693 private LLUUID m_ItemID; 694 private LLUUID m_ItemID;
694 private uint m_LocalID; 695 private uint m_LocalID;
695 private LLUUID m_ObjectID; 696 private LLUUID m_ObjectID;
@@ -765,7 +766,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
765 public XScriptInstance(XEngine engine, uint localID, LLUUID objectID, 766 public XScriptInstance(XEngine engine, uint localID, LLUUID objectID,
766 LLUUID itemID, LLUUID assetID, string assembly, AppDomain dom) 767 LLUUID itemID, LLUUID assetID, string assembly, AppDomain dom)
767 { 768 {
768 m_Engine=engine; 769 m_Engine = engine;
769 770
770 m_LocalID = localID; 771 m_LocalID = localID;
771 m_ObjectID = objectID; 772 m_ObjectID = objectID;
@@ -773,22 +774,22 @@ namespace OpenSim.Region.ScriptEngine.XEngine
773 m_AssetID = assetID; 774 m_AssetID = assetID;
774 775
775 SceneObjectPart part=engine.World.GetSceneObjectPart(localID); 776 SceneObjectPart part=engine.World.GetSceneObjectPart(localID);
776 if(part == null) 777 if (part == null)
777 { 778 {
778 engine.Log.Error("[XEngine] SceneObjectPart unavailable. Script NOT started."); 779 engine.Log.Error("[XEngine] SceneObjectPart unavailable. Script NOT started.");
779 return; 780 return;
780 } 781 }
781 782
782 m_LSLCommands = new LSL_ScriptCommands(engine, this, part, localID, 783 m_LSLCommands = new LSL_ScriptCommands(engine, this, part, localID,
783 itemID); 784 itemID);
784 m_OSSLCommands = new OSSL_ScriptCommands(engine, this, part, 785 m_OSSLCommands = new OSSL_ScriptCommands(engine, this, part,
785 localID, itemID); 786 localID, itemID);
786 787
787 try 788 try
788 { 789 {
789 m_Script = (IScript)dom.CreateInstanceAndUnwrap( 790 m_Script = (IScript)dom.CreateInstanceAndUnwrap(
790 Path.GetFileNameWithoutExtension(assembly), 791 Path.GetFileNameWithoutExtension(assembly),
791 "SecondLife.Script"); 792 "SecondLife.Script");
792 } 793 }
793 catch (Exception e) 794 catch (Exception e)
794 { 795 {
@@ -804,15 +805,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
804// m_Engine.Log.Debug("[XEngine] Script instance created"); 805// m_Engine.Log.Debug("[XEngine] Script instance created");
805 806
806 part.SetScriptEvents(m_ItemID, 807 part.SetScriptEvents(m_ItemID,
807 (int)m_Executor.GetStateEventFlags()); 808 (int)m_Executor.GetStateEventFlags());
808 } 809 }
809 catch (Exception e) 810 catch (Exception e)
810 { 811 {
811 m_Engine.Log.Error("Error loading script instance\n"+e.ToString()); 812 m_Engine.Log.Error("Error loading script instance\n"+e.ToString());
812 } 813 }
813 814
814 string savedState = assembly+".state"; 815 string savedState = assembly + ".state";
815 if(File.Exists(savedState)) 816 if (File.Exists(savedState))
816 { 817 {
817 string xml = String.Empty; 818 string xml = String.Empty;
818 819
@@ -820,44 +821,44 @@ namespace OpenSim.Region.ScriptEngine.XEngine
820 { 821 {
821 FileInfo fi = new FileInfo(savedState); 822 FileInfo fi = new FileInfo(savedState);
822 int size=(int)fi.Length; 823 int size=(int)fi.Length;
823 if(size < 130000) 824 if (size < 130000)
824 { 825 {
825 using (FileStream fs = File.Open(savedState, 826 using (FileStream fs = File.Open(savedState,
826 FileMode.Open, FileAccess.Read, FileShare.None)) 827 FileMode.Open, FileAccess.Read, FileShare.None))
827 { 828 {
828 System.Text.ASCIIEncoding enc = 829 System.Text.ASCIIEncoding enc =
829 new System.Text.ASCIIEncoding(); 830 new System.Text.ASCIIEncoding();
830 831
831 Byte[] data=new Byte[size]; 832 Byte[] data = new Byte[size];
832 fs.Read(data, 0, size); 833 fs.Read(data, 0, size);
833 834
834 xml=enc.GetString(data); 835 xml = enc.GetString(data);
835 836
836 ScriptSerializer.Deserialize(xml, this); 837 ScriptSerializer.Deserialize(xml, this);
837 838
838 m_Engine.m_ASYNCLSLCommandManager.CreateFromData( 839 m_Engine.m_ASYNCLSLCommandManager.CreateFromData(
839 m_LocalID, m_ItemID, m_ObjectID, 840 m_LocalID, m_ItemID, m_ObjectID,
840 PluginData); 841 PluginData);
841 } 842 }
842 } 843 }
843 else 844 else
844 { 845 {
845 m_Engine.Log.Error("Unable to load script state: Memory limit exceeded"); 846 m_Engine.Log.Error("Unable to load script state: Memory limit exceeded");
846 PostEvent(new XEventParams("state_entry", 847 PostEvent(new XEventParams("state_entry",
847 new Object[0], new XDetectParams[0])); 848 new Object[0], new XDetectParams[0]));
848 } 849 }
849 } 850 }
850 catch (Exception e) 851 catch (Exception e)
851 { 852 {
852 m_Engine.Log.ErrorFormat("Unable to load script state from xml: {0}\n"+e.ToString(), xml); 853 m_Engine.Log.ErrorFormat("Unable to load script state from xml: {0}\n"+e.ToString(), xml);
853 PostEvent(new XEventParams("state_entry", 854 PostEvent(new XEventParams("state_entry",
854 new Object[0], new XDetectParams[0])); 855 new Object[0], new XDetectParams[0]));
855 } 856 }
856 } 857 }
857 else 858 else
858 { 859 {
859 PostEvent(new XEventParams("state_entry", 860 PostEvent(new XEventParams("state_entry",
860 new Object[0], new XDetectParams[0])); 861 new Object[0], new XDetectParams[0]));
861 } 862 }
862 Start(); 863 Start();
863 } 864 }
@@ -868,23 +869,23 @@ namespace OpenSim.Region.ScriptEngine.XEngine
868 foreach (KeyValuePair<string, object> v in vars) 869 foreach (KeyValuePair<string, object> v in vars)
869 { 870 {
870 Console.WriteLine("Variable: {0} = '{1}'", v. Key, 871 Console.WriteLine("Variable: {0} = '{1}'", v. Key,
871 v.Value.ToString()); 872 v.Value.ToString());
872 } 873 }
873 } 874 }
874 875
875 public void Start() 876 public void Start()
876 { 877 {
877 lock(m_EventQueue) 878 lock (m_EventQueue)
878 { 879 {
879 if(Running) 880 if (Running)
880 return; 881 return;
881 882
882 m_RunEvents=true; 883 m_RunEvents = true;
883 884
884 if(m_EventQueue.Count > 0) 885 if (m_EventQueue.Count > 0)
885 { 886 {
886 if(m_CurrentResult == null) 887 if (m_CurrentResult == null)
887 m_CurrentResult=m_Engine.QueueEventHandler(this); 888 m_CurrentResult = m_Engine.QueueEventHandler(this);
888 } 889 }
889 } 890 }
890 } 891 }
@@ -893,36 +894,36 @@ namespace OpenSim.Region.ScriptEngine.XEngine
893 { 894 {
894 IWorkItemResult result; 895 IWorkItemResult result;
895 896
896 lock(m_EventQueue) 897 lock (m_EventQueue)
897 { 898 {
898 if(!Running) 899 if (!Running)
899 return true; 900 return true;
900 901
901 if(m_CurrentResult == null) 902 if (m_CurrentResult == null)
902 { 903 {
903 m_RunEvents=false; 904 m_RunEvents = false;
904 return true; 905 return true;
905 } 906 }
906 907
907 if(m_CurrentResult.Cancel()) 908 if (m_CurrentResult.Cancel())
908 { 909 {
909 m_CurrentResult=null; 910 m_CurrentResult = null;
910 m_RunEvents=false; 911 m_RunEvents = false;
911 return true; 912 return true;
912 } 913 }
913 914
914 result=m_CurrentResult; 915 result = m_CurrentResult;
915 m_RunEvents=false; 916 m_RunEvents = false;
916 } 917 }
917 918
918 if(SmartThreadPool.WaitAll(new IWorkItemResult[] {result}, new TimeSpan((long)timeout*100000), false)) 919 if (SmartThreadPool.WaitAll(new IWorkItemResult[] {result}, new TimeSpan((long)timeout * 100000), false))
919 { 920 {
920 return true; 921 return true;
921 } 922 }
922 923
923 lock(m_EventQueue) 924 lock (m_EventQueue)
924 { 925 {
925 if(m_CurrentResult != null) 926 if (m_CurrentResult != null)
926 m_CurrentResult.Abort(); 927 m_CurrentResult.Abort();
927 else 928 else
928 return true; 929 return true;
@@ -934,75 +935,75 @@ namespace OpenSim.Region.ScriptEngine.XEngine
934 public void SetState(string state) 935 public void SetState(string state)
935 { 936 {
936 PostEvent(new XEventParams("state_exit", new Object[0], 937 PostEvent(new XEventParams("state_exit", new Object[0],
937 new XDetectParams[0])); 938 new XDetectParams[0]));
938 PostEvent(new XEventParams("state", new Object[] { state }, 939 PostEvent(new XEventParams("state", new Object[] { state },
939 new XDetectParams[0])); 940 new XDetectParams[0]));
940 PostEvent(new XEventParams("state_entry", new Object[0], 941 PostEvent(new XEventParams("state_entry", new Object[0],
941 new XDetectParams[0])); 942 new XDetectParams[0]));
942 } 943 }
943 944
944 public void PostEvent(XEventParams data) 945 public void PostEvent(XEventParams data)
945 { 946 {
946 lock(m_EventQueue) 947 lock (m_EventQueue)
947 { 948 {
948 if(m_EventQueue.Count >= m_Engine.MaxScriptQueue) 949 if (m_EventQueue.Count >= m_Engine.MaxScriptQueue)
949 return; 950 return;
950 951
951 m_EventQueue.Enqueue(data); 952 m_EventQueue.Enqueue(data);
952 if(data.EventName == "timer") 953 if (data.EventName == "timer")
953 { 954 {
954 if(m_TimerQueued) 955 if (m_TimerQueued)
955 return; 956 return;
956 m_TimerQueued = true; 957 m_TimerQueued = true;
957 } 958 }
958 959
959 if(!m_RunEvents) 960 if (!m_RunEvents)
960 return; 961 return;
961 962
962 if(m_CurrentResult == null) 963 if (m_CurrentResult == null)
963 { 964 {
964 m_CurrentResult=m_Engine.QueueEventHandler(this); 965 m_CurrentResult = m_Engine.QueueEventHandler(this);
965 } 966 }
966 } 967 }
967 } 968 }
968 969
969 public object EventProcessor() 970 public object EventProcessor()
970 { 971 {
971 XEventParams data=null; 972 XEventParams data = null;
972 973
973 lock(m_EventQueue) 974 lock (m_EventQueue)
974 { 975 {
975 data=(XEventParams)m_EventQueue.Dequeue(); 976 data = (XEventParams) m_EventQueue.Dequeue();
976 if(data == null) // Shouldn't happen 977 if (data == null) // Shouldn't happen
977 { 978 {
978 m_CurrentResult=null; 979 m_CurrentResult = null;
979 return 0; 980 return 0;
980 } 981 }
981 if(data.EventName == "timer") 982 if (data.EventName == "timer")
982 m_TimerQueued = false; 983 m_TimerQueued = false;
983 } 984 }
984 985
985 m_DetectParams=data.DetectParams; 986 m_DetectParams = data.DetectParams;
986 987
987 if(data.EventName == "state") // Hardcoded state change 988 if (data.EventName == "state") // Hardcoded state change
988 { 989 {
989 m_State=data.Params[0].ToString(); 990 m_State=data.Params[0].ToString();
990 m_Engine.m_ASYNCLSLCommandManager.RemoveScript( 991 m_Engine.m_ASYNCLSLCommandManager.RemoveScript(
991 m_LocalID, m_ItemID); 992 m_LocalID, m_ItemID);
992 993
993 SceneObjectPart part=m_Engine.World.GetSceneObjectPart( 994 SceneObjectPart part = m_Engine.World.GetSceneObjectPart(
994 m_LocalID); 995 m_LocalID);
995 if(part != null) 996 if (part != null)
996 { 997 {
997 part.SetScriptEvents(m_ItemID, 998 part.SetScriptEvents(m_ItemID,
998 (int)m_Executor.GetStateEventFlags()); 999 (int)m_Executor.GetStateEventFlags());
999 } 1000 }
1000 } 1001 }
1001 else 1002 else
1002 { 1003 {
1003// m_Engine.Log.DebugFormat("[XEngine] Processed event {0}", data.EventName); 1004// m_Engine.Log.DebugFormat("[XEngine] Processed event {0}", data.EventName);
1004 SceneObjectPart part=m_Engine.World.GetSceneObjectPart( 1005 SceneObjectPart part = m_Engine.World.GetSceneObjectPart(
1005 m_LocalID); 1006 m_LocalID);
1006 try 1007 try
1007 { 1008 {
1008 m_EventStart = DateTime.Now; 1009 m_EventStart = DateTime.Now;
@@ -1013,21 +1014,21 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1013 catch (Exception e) 1014 catch (Exception e)
1014 { 1015 {
1015 m_InEvent = false; 1016 m_InEvent = false;
1016 if(e is System.Threading.ThreadAbortException) 1017 if (e is System.Threading.ThreadAbortException)
1017 { 1018 {
1018 lock(m_EventQueue) 1019 lock (m_EventQueue)
1019 { 1020 {
1020 if((m_EventQueue.Count > 0) && m_RunEvents) 1021 if ((m_EventQueue.Count > 0) && m_RunEvents)
1021 { 1022 {
1022 m_CurrentResult=m_Engine.QueueEventHandler(this); 1023 m_CurrentResult=m_Engine.QueueEventHandler(this);
1023 } 1024 }
1024 else 1025 else
1025 { 1026 {
1026 m_CurrentResult=null; 1027 m_CurrentResult = null;
1027 } 1028 }
1028 } 1029 }
1029 1030
1030 m_DetectParams=null; 1031 m_DetectParams = null;
1031 1032
1032 return 0; 1033 return 0;
1033 } 1034 }
@@ -1039,42 +1040,42 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1039 if (text.Length > 1400) 1040 if (text.Length > 1400)
1040 text = text.Substring(0, 1400); 1041 text = text.Substring(0, 1400);
1041 m_Engine.World.SimChat(Helpers.StringToField(text), 1042 m_Engine.World.SimChat(Helpers.StringToField(text),
1042 ChatTypeEnum.DebugChannel, 2147483647, 1043 ChatTypeEnum.DebugChannel, 2147483647,
1043 part.AbsolutePosition, 1044 part.AbsolutePosition,
1044 part.Name, part.UUID, false); 1045 part.Name, part.UUID, false);
1045 } 1046 }
1046 catch (Exception e2) // LEGIT: User Scripting 1047 catch (Exception e2) // LEGIT: User Scripting
1047 { 1048 {
1048 m_Engine.Log.Error("[XEngine]: "+ 1049 m_Engine.Log.Error("[XEngine]: "+
1049 "Error displaying error in-world: " + 1050 "Error displaying error in-world: " +
1050 e2.ToString()); 1051 e2.ToString());
1051 m_Engine.Log.Error("[XEngine]: " + 1052 m_Engine.Log.Error("[XEngine]: " +
1052 "Errormessage: Error compiling script:\r\n" + 1053 "Errormessage: Error compiling script:\r\n" +
1053 e.ToString()); 1054 e.ToString());
1054 } 1055 }
1055 } 1056 }
1056 } 1057 }
1057 1058
1058 lock(m_EventQueue) 1059 lock (m_EventQueue)
1059 { 1060 {
1060 if((m_EventQueue.Count > 0) && m_RunEvents) 1061 if ((m_EventQueue.Count > 0) && m_RunEvents)
1061 { 1062 {
1062 m_CurrentResult=m_Engine.QueueEventHandler(this); 1063 m_CurrentResult = m_Engine.QueueEventHandler(this);
1063 } 1064 }
1064 else 1065 else
1065 { 1066 {
1066 m_CurrentResult=null; 1067 m_CurrentResult = null;
1067 } 1068 }
1068 } 1069 }
1069 1070
1070 m_DetectParams=null; 1071 m_DetectParams = null;
1071 1072
1072 return 0; 1073 return 0;
1073 } 1074 }
1074 1075
1075 public int EventTime() 1076 public int EventTime()
1076 { 1077 {
1077 if(!m_InEvent) 1078 if (!m_InEvent)
1078 return 0; 1079 return 0;
1079 1080
1080 return (DateTime.Now - m_EventStart).Seconds; 1081 return (DateTime.Now - m_EventStart).Seconds;
@@ -1082,14 +1083,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1082 1083
1083 public void ResetScript() 1084 public void ResetScript()
1084 { 1085 {
1085 bool running=Running; 1086 bool running = Running;
1086 1087
1087 Stop(0); 1088 Stop(0);
1088 m_Engine.m_ASYNCLSLCommandManager.RemoveScript(m_LocalID, m_ItemID); 1089 m_Engine.m_ASYNCLSLCommandManager.RemoveScript(m_LocalID, m_ItemID);
1089 m_EventQueue.Clear(); 1090 m_EventQueue.Clear();
1090 m_Script.ResetVars(); 1091 m_Script.ResetVars();
1091 m_State = "default"; 1092 m_State = "default";
1092 if(running) 1093 if (running)
1093 Start(); 1094 Start();
1094 PostEvent(new XEventParams("state_entry", 1095 PostEvent(new XEventParams("state_entry",
1095 new Object[0], new XDetectParams[0])); 1096 new Object[0], new XDetectParams[0]));
@@ -1107,7 +1108,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1107 1108
1108 public XDetectParams GetDetectParams(int idx) 1109 public XDetectParams GetDetectParams(int idx)
1109 { 1110 {
1110 if(idx < 0 || idx >= m_DetectParams.Length) 1111 if (idx < 0 || idx >= m_DetectParams.Length)
1111 return new XDetectParams(); 1112 return new XDetectParams();
1112 1113
1113 return m_DetectParams[idx]; 1114 return m_DetectParams[idx];
@@ -1115,7 +1116,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1115 1116
1116 public LLUUID GetDetectID(int idx) 1117 public LLUUID GetDetectID(int idx)
1117 { 1118 {
1118 if(idx < 0 || idx >= m_DetectParams.Length) 1119 if (idx < 0 || idx >= m_DetectParams.Length)
1119 return LLUUID.Zero; 1120 return LLUUID.Zero;
1120 1121
1121 return m_DetectParams[idx].Key; 1122 return m_DetectParams[idx].Key;
@@ -1124,22 +1125,21 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1124 public void SaveState(string assembly) 1125 public void SaveState(string assembly)
1125 { 1126 {
1126 PluginData = 1127 PluginData =
1127 m_Engine.m_ASYNCLSLCommandManager.GetSerializationData( 1128 m_Engine.m_ASYNCLSLCommandManager.GetSerializationData(
1128 m_ItemID); 1129 m_ItemID);
1129 1130
1130 string xml=ScriptSerializer.Serialize(this); 1131 string xml = ScriptSerializer.Serialize(this);
1131 1132
1132 try 1133 try
1133 { 1134 {
1134 FileStream fs = File.Create(assembly+".state"); 1135 FileStream fs = File.Create(assembly + ".state");
1135 System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); 1136 System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
1136 Byte[] buf=enc.GetBytes(xml); 1137 Byte[] buf = enc.GetBytes(xml);
1137 fs.Write(buf, 0, buf.Length); 1138 fs.Write(buf, 0, buf.Length);
1138 fs.Close(); 1139 fs.Close();
1139 } 1140 }
1140 catch(Exception) 1141 catch(Exception)
1141 { 1142 {
1142 return;
1143 } 1143 }
1144 } 1144 }
1145 } 1145 }
@@ -1153,11 +1153,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1153 XmlDocument xmldoc = new XmlDocument(); 1153 XmlDocument xmldoc = new XmlDocument();
1154 1154
1155 XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, 1155 XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration,
1156 "", ""); 1156 "", "");
1157 xmldoc.AppendChild(xmlnode); 1157 xmldoc.AppendChild(xmlnode);
1158 1158
1159 XmlElement rootElement = xmldoc.CreateElement("", "ScriptState", 1159 XmlElement rootElement = xmldoc.CreateElement("", "ScriptState",
1160 ""); 1160 "");
1161 xmldoc.AppendChild(rootElement); 1161 xmldoc.AppendChild(rootElement);
1162 1162
1163 XmlElement state = xmldoc.CreateElement("", "State", ""); 1163 XmlElement state = xmldoc.CreateElement("", "State", "");
@@ -1171,15 +1171,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1171 1171
1172 foreach (KeyValuePair<string, Object> var in vars) 1172 foreach (KeyValuePair<string, Object> var in vars)
1173 WriteTypedValue(xmldoc, variables, "Variable", var.Key, 1173 WriteTypedValue(xmldoc, variables, "Variable", var.Key,
1174 var.Value); 1174 var.Value);
1175 1175
1176 rootElement.AppendChild(variables); 1176 rootElement.AppendChild(variables);
1177 1177
1178 XmlElement queue = xmldoc.CreateElement("", "Queue", ""); 1178 XmlElement queue = xmldoc.CreateElement("", "Queue", "");
1179 1179
1180 int count = instance.EventQueue.Count; 1180 int count = instance.EventQueue.Count;
1181 1181
1182 while(count > 0) 1182 while (count > 0)
1183 { 1183 {
1184 XEventParams ep = (XEventParams)instance.EventQueue.Dequeue(); 1184 XEventParams ep = (XEventParams)instance.EventQueue.Dequeue();
1185 instance.EventQueue.Enqueue(ep); 1185 instance.EventQueue.Enqueue(ep);
@@ -1187,8 +1187,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1187 1187
1188 XmlElement item = xmldoc.CreateElement("", "Item", ""); 1188 XmlElement item = xmldoc.CreateElement("", "Item", "");
1189 XmlAttribute itemEvent = xmldoc.CreateAttribute("", "event", 1189 XmlAttribute itemEvent = xmldoc.CreateAttribute("", "event",
1190 ""); 1190 "");
1191 itemEvent.Value=ep.EventName; 1191 itemEvent.Value = ep.EventName;
1192 item.Attributes.Append(itemEvent); 1192 item.Attributes.Append(itemEvent);
1193 1193
1194 XmlElement parms = xmldoc.CreateElement("", "Params", ""); 1194 XmlElement parms = xmldoc.CreateElement("", "Params", "");
@@ -1203,12 +1203,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1203 foreach (XDetectParams det in ep.DetectParams) 1203 foreach (XDetectParams det in ep.DetectParams)
1204 { 1204 {
1205 XmlElement objectElem = xmldoc.CreateElement("", "Object", 1205 XmlElement objectElem = xmldoc.CreateElement("", "Object",
1206 ""); 1206 "");
1207 XmlAttribute pos = xmldoc.CreateAttribute("", "pos", ""); 1207 XmlAttribute pos = xmldoc.CreateAttribute("", "pos", "");
1208 pos.Value=det.OffsetPos.ToString(); 1208 pos.Value = det.OffsetPos.ToString();
1209 objectElem.Attributes.Append(pos); 1209 objectElem.Attributes.Append(pos);
1210 objectElem.AppendChild( 1210 objectElem.AppendChild(
1211 xmldoc.CreateTextNode(det.Key.ToString())); 1211 xmldoc.CreateTextNode(det.Key.ToString()));
1212 1212
1213 detect.AppendChild(objectElem); 1213 detect.AppendChild(objectElem);
1214 } 1214 }
@@ -1221,9 +1221,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1221 rootElement.AppendChild(queue); 1221 rootElement.AppendChild(queue);
1222 1222
1223 XmlNode plugins = xmldoc.CreateElement("", "Plugins", ""); 1223 XmlNode plugins = xmldoc.CreateElement("", "Plugins", "");
1224 if(instance.PluginData.Length > 0) 1224 if (instance.PluginData.Length > 0)
1225 DumpList(xmldoc, plugins, 1225 DumpList(xmldoc, plugins,
1226 new LSL_Types.list(instance.PluginData)); 1226 new LSL_Types.list(instance.PluginData));
1227 1227
1228 rootElement.AppendChild(plugins); 1228 rootElement.AppendChild(plugins);
1229 1229
@@ -1241,22 +1241,22 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1241 instance.PluginData = new Object[0]; 1241 instance.PluginData = new Object[0];
1242 1242
1243 doc.LoadXml(xml); 1243 doc.LoadXml(xml);
1244 1244
1245 XmlNodeList rootL = doc.GetElementsByTagName("ScriptState"); 1245 XmlNodeList rootL = doc.GetElementsByTagName("ScriptState");
1246 if(rootL.Count != 1) 1246 if (rootL.Count != 1)
1247 { 1247 {
1248 return; 1248 return;
1249 } 1249 }
1250 XmlNode rootNode = rootL[0]; 1250 XmlNode rootNode = rootL[0];
1251 1251
1252 if(rootNode != null) 1252 if (rootNode != null)
1253 { 1253 {
1254 object varValue; 1254 object varValue;
1255 XmlNodeList partL = rootNode.ChildNodes; 1255 XmlNodeList partL = rootNode.ChildNodes;
1256 1256
1257 foreach (XmlNode part in partL) 1257 foreach (XmlNode part in partL)
1258 { 1258 {
1259 switch(part.Name) 1259 switch (part.Name)
1260 { 1260 {
1261 case "State": 1261 case "State":
1262 instance.State=part.InnerText; 1262 instance.State=part.InnerText;
@@ -1268,7 +1268,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1268 string varName; 1268 string varName;
1269 varValue=ReadTypedValue(var, out varName); 1269 varValue=ReadTypedValue(var, out varName);
1270 1270
1271 if(vars.ContainsKey(varName)) 1271 if (vars.ContainsKey(varName))
1272 vars[varName] = varValue; 1272 vars[varName] = varValue;
1273 } 1273 }
1274 instance.SetVars(vars); 1274 instance.SetVars(vars);
@@ -1286,7 +1286,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1286 XmlNodeList eventL = item.ChildNodes; 1286 XmlNodeList eventL = item.ChildNodes;
1287 foreach (XmlNode evt in eventL) 1287 foreach (XmlNode evt in eventL)
1288 { 1288 {
1289 switch(evt.Name) 1289 switch (evt.Name)
1290 { 1290 {
1291 case "Params": 1291 case "Params":
1292 XmlNodeList prms = evt.ChildNodes; 1292 XmlNodeList prms = evt.ChildNodes;
@@ -1342,7 +1342,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1342 List<Object> olist = new List<Object>(); 1342 List<Object> olist = new List<Object>();
1343 1343
1344 XmlNodeList itemL = parent.ChildNodes; 1344 XmlNodeList itemL = parent.ChildNodes;
1345 foreach(XmlNode item in itemL) 1345 foreach (XmlNode item in itemL)
1346 olist.Add(ReadTypedValue(item)); 1346 olist.Add(ReadTypedValue(item));
1347 1347
1348 return new LSL_Types.list(olist.ToArray()); 1348 return new LSL_Types.list(olist.ToArray());
@@ -1355,14 +1355,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1355 XmlAttribute typ = doc.CreateAttribute("", "type", ""); 1355 XmlAttribute typ = doc.CreateAttribute("", "type", "");
1356 XmlNode n = doc.CreateElement("", tag, ""); 1356 XmlNode n = doc.CreateElement("", tag, "");
1357 1357
1358 if(value is LSL_Types.list) 1358 if (value is LSL_Types.list)
1359 { 1359 {
1360 typ.Value = "list"; 1360 typ.Value = "list";
1361 n.Attributes.Append(typ); 1361 n.Attributes.Append(typ);
1362 1362
1363 DumpList(doc, n, (LSL_Types.list) value); 1363 DumpList(doc, n, (LSL_Types.list) value);
1364 1364
1365 if(name != String.Empty) 1365 if (name != String.Empty)
1366 { 1366 {
1367 XmlAttribute nam = doc.CreateAttribute("", "name", ""); 1367 XmlAttribute nam = doc.CreateAttribute("", "name", "");
1368 nam.Value = name; 1368 nam.Value = name;
@@ -1377,7 +1377,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1377 1377
1378 typ.Value = t.ToString(); 1378 typ.Value = t.ToString();
1379 n.Attributes.Append(typ); 1379 n.Attributes.Append(typ);
1380 if(name != String.Empty) 1380 if (name != String.Empty)
1381 { 1381 {
1382 XmlAttribute nam = doc.CreateAttribute("", "name", ""); 1382 XmlAttribute nam = doc.CreateAttribute("", "name", "");
1383 nam.Value = name; 1383 nam.Value = name;
@@ -1401,31 +1401,31 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1401 1401
1402 string itemType = tag.Attributes.GetNamedItem("type").Value; 1402 string itemType = tag.Attributes.GetNamedItem("type").Value;
1403 1403
1404 if(itemType == "list") 1404 if (itemType == "list")
1405 return ReadList(tag); 1405 return ReadList(tag);
1406 1406
1407 if(itemType == "libsecondlife.LLUUID") 1407 if (itemType == "libsecondlife.LLUUID")
1408 { 1408 {
1409 LLUUID val = new LLUUID(); 1409 LLUUID val = new LLUUID();
1410 LLUUID.TryParse(tag.InnerText, out val); 1410 LLUUID.TryParse(tag.InnerText, out val);
1411 1411
1412 return val; 1412 return val;
1413 } 1413 }
1414 1414
1415 Type itemT = Type.GetType(itemType); 1415 Type itemT = Type.GetType(itemType);
1416 if(itemT == null) 1416 if (itemT == null)
1417 { 1417 {
1418 Object[] args = 1418 Object[] args =
1419 new Object[] { tag.InnerText }; 1419 new Object[] { tag.InnerText };
1420 1420
1421 assembly = itemType+", OpenSim.Region.ScriptEngine.XEngine.Script"; 1421 assembly = itemType+", OpenSim.Region.ScriptEngine.XEngine.Script";
1422 itemT = Type.GetType(assembly); 1422 itemT = Type.GetType(assembly);
1423 if(itemT == null) 1423 if (itemT == null)
1424 return null; 1424 return null;
1425 1425
1426 varValue = Activator.CreateInstance(itemT, args); 1426 varValue = Activator.CreateInstance(itemT, args);
1427 1427
1428 if(varValue == null) 1428 if (varValue == null)
1429 return null; 1429 return null;
1430 } 1430 }
1431 else 1431 else