aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/Executor.cs80
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs25
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs1
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs55
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs145
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs18
9 files changed, 259 insertions, 77 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/Executor.cs b/OpenSim/Region/ScriptEngine/Common/Executor.cs
index cadd55c..363d81e 100644
--- a/OpenSim/Region/ScriptEngine/Common/Executor.cs
+++ b/OpenSim/Region/ScriptEngine/Common/Executor.cs
@@ -23,7 +23,7 @@ namespace OpenSim.Region.ScriptEngine.Common
23 // Object never expires 23 // Object never expires
24 public override Object InitializeLifetimeService() 24 public override Object InitializeLifetimeService()
25 { 25 {
26 Console.WriteLine("Executor: InitializeLifetimeService()"); 26 //Console.WriteLine("Executor: InitializeLifetimeService()");
27 // return null; 27 // return null;
28 ILease lease = (ILease)base.InitializeLifetimeService(); 28 ILease lease = (ILease)base.InitializeLifetimeService();
29 29
@@ -45,54 +45,60 @@ namespace OpenSim.Region.ScriptEngine.Common
45 { 45 {
46 // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. 46 // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory.
47 // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead! 47 // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead!
48 48 try
49 if (m_Running == false)
50 { 49 {
51 // Script is inactive, do not execute! 50 if (m_Running == false)
52 return; 51 {
53 } 52 // Script is inactive, do not execute!
53 return;
54 }
54 55
55 string EventName = m_Script.State() + "_event_" + FunctionName; 56 string EventName = m_Script.State() + "_event_" + FunctionName;
56 57
57 //type.InvokeMember(EventName, BindingFlags.InvokeMethod, null, m_Script, args); 58 //type.InvokeMember(EventName, BindingFlags.InvokeMethod, null, m_Script, args);
58 59
59 Console.WriteLine("ScriptEngine Executor.ExecuteEvent: \"" + EventName + "\""); 60 Console.WriteLine("ScriptEngine Executor.ExecuteEvent: \"" + EventName + "\"");
60 61
61 if (Events.ContainsKey(EventName) == false) 62 if (Events.ContainsKey(EventName) == false)
62 {
63 // Not found, create
64 Type type = m_Script.GetType();
65 try
66 {
67 MethodInfo mi = type.GetMethod(EventName);
68 Events.Add(EventName, mi);
69 }
70 catch (Exception e)
71 { 63 {
72 // Event name not found, cache it as not found 64 // Not found, create
73 Events.Add(EventName, null); 65 Type type = m_Script.GetType();
66 try
67 {
68 MethodInfo mi = type.GetMethod(EventName);
69 Events.Add(EventName, mi);
70 }
71 catch (Exception e)
72 {
73 // Event name not found, cache it as not found
74 Events.Add(EventName, null);
75 }
74 } 76 }
75 }
76 77
77 // Get event 78 // Get event
78 MethodInfo ev = null; 79 MethodInfo ev = null;
79 Events.TryGetValue(EventName, out ev); 80 Events.TryGetValue(EventName, out ev);
80 81
81 if (ev == null) // No event by that name! 82 if (ev == null) // No event by that name!
82 return; 83 {
84 Console.WriteLine("ScriptEngine Can not find any event named: \"" + EventName + "\"");
85 return;
86 }
83 87
84 // Found 88 // Found
85 try 89 try
86 { 90 {
87 // Invoke it 91 // Invoke it
88 ev.Invoke(m_Script, args); 92 ev.Invoke(m_Script, args);
89 93
94 }
95 catch (Exception e)
96 {
97 // TODO: Send to correct place
98 Console.WriteLine("ScriptEngine Exception attempting to executing script function: " + e.ToString());
99 }
90 } 100 }
91 catch (Exception e) 101 catch { }
92 {
93 // TODO: Send to correct place
94 Console.WriteLine("ScriptEngine Exception attempting to executing script function: " + e.ToString());
95 }
96 } 102 }
97 103
98 104
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs
index b58e996..f24eb63 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs
@@ -51,6 +51,14 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
51 // Output assembly name 51 // Output assembly name
52 ScriptCompileCounter++; 52 ScriptCompileCounter++;
53 string OutFile = Path.Combine("ScriptEngines", "Script_" + ScriptCompileCounter + ".dll"); 53 string OutFile = Path.Combine("ScriptEngines", "Script_" + ScriptCompileCounter + ".dll");
54 try
55 {
56 System.IO.File.Delete(OutFile);
57 }
58 catch (Exception e)
59 {
60 Console.WriteLine("Exception attempting to delete old compiled script: " + e.ToString());
61 }
54 //string OutFile = Path.Combine("ScriptEngines", "SecondLife.Script.dll"); 62 //string OutFile = Path.Combine("ScriptEngines", "SecondLife.Script.dll");
55 63
56 // DEBUG - write source to disk 64 // DEBUG - write source to disk
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs
index cb0f9ba..9af9c82 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs
@@ -15,7 +15,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
15 // Object never expires 15 // Object never expires
16 public override Object InitializeLifetimeService() 16 public override Object InitializeLifetimeService()
17 { 17 {
18 Console.WriteLine("LSL_BaseClass: InitializeLifetimeService()"); 18 //Console.WriteLine("LSL_BaseClass: InitializeLifetimeService()");
19 // return null; 19 // return null;
20 ILease lease = (ILease)base.InitializeLifetimeService(); 20 ILease lease = (ILease)base.InitializeLifetimeService();
21 21
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs
index 187ac59..bfee3e5 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs
@@ -19,15 +19,20 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
19 { 19 {
20 20
21 private System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); 21 private System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
22 private ScriptManager m_manager; 22 private ScriptEngine m_ScriptEngine;
23 private IScriptHost m_host; 23 private IScriptHost m_host;
24 private uint m_localID;
25 private LLUUID m_itemID;
24 26
25 public LSL_BuiltIn_Commands(ScriptManager manager, IScriptHost host) 27 public LSL_BuiltIn_Commands(ScriptEngine ScriptEngine, IScriptHost host, uint localID, LLUUID itemID)
26 { 28 {
27 m_manager = manager; 29 m_ScriptEngine = ScriptEngine;
28 m_host = host; 30 m_host = host;
31 m_localID = localID;
32 m_itemID = itemID;
33
29 34
30 MainLog.Instance.Notice("ScriptEngine", "LSL_BaseClass.Start() called. Hosted by [" + m_host.Name + ":" + m_host.UUID + "@" + m_host.AbsolutePosition + "]"); 35 //MainLog.Instance.Notice("ScriptEngine", "LSL_BaseClass.Start() called. Hosted by [" + m_host.Name + ":" + m_host.UUID + "@" + m_host.AbsolutePosition + "]");
31 } 36 }
32 37
33 38
@@ -39,7 +44,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
39 // Object never expires 44 // Object never expires
40 public override Object InitializeLifetimeService() 45 public override Object InitializeLifetimeService()
41 { 46 {
42 Console.WriteLine("LSL_BuiltIn_Commands: InitializeLifetimeService()"); 47 //Console.WriteLine("LSL_BuiltIn_Commands: InitializeLifetimeService()");
43 // return null; 48 // return null;
44 ILease lease = (ILease)base.InitializeLifetimeService(); 49 ILease lease = (ILease)base.InitializeLifetimeService();
45 50
@@ -55,7 +60,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
55 60
56 public Scene World 61 public Scene World
57 { 62 {
58 get { return m_manager.World; } 63 get { return m_ScriptEngine.World; }
59 } 64 }
60 65
61 //These are the implementations of the various ll-functions used by the LSL scripts. 66 //These are the implementations of the various ll-functions used by the LSL scripts.
@@ -258,7 +263,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
258 public void llRezObject(string inventory, LSL_Types.Vector3 pos, LSL_Types.Quaternion rot, int param) { } 263 public void llRezObject(string inventory, LSL_Types.Vector3 pos, LSL_Types.Quaternion rot, int param) { }
259 public void llLookAt(LSL_Types.Vector3 target, double strength, double damping) { } 264 public void llLookAt(LSL_Types.Vector3 target, double strength, double damping) { }
260 public void llStopLookAt() { } 265 public void llStopLookAt() { }
261 public void llSetTimerEvent(double sec) { } 266 public void llSetTimerEvent(double sec)
267 {
268 // Setting timer repeat
269 m_ScriptEngine.myLSLLongCmdHandler.SetTimerEvent(m_localID, m_itemID, sec);
270 }
262 public void llSleep(double sec) { System.Threading.Thread.Sleep((int)(sec * 1000)); } 271 public void llSleep(double sec) { System.Threading.Thread.Sleep((int)(sec * 1000)); }
263 public double llGetMass() { return 0; } 272 public double llGetMass() { return 0; }
264 public void llCollisionFilter(string name, string id, int accept) { } 273 public void llCollisionFilter(string name, string id, int accept) { }
@@ -416,7 +425,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
416 public LSL_Types.Vector3 llGroundContour(LSL_Types.Vector3 offset) { return new LSL_Types.Vector3(); } 425 public LSL_Types.Vector3 llGroundContour(LSL_Types.Vector3 offset) { return new LSL_Types.Vector3(); }
417 public int llGetAttached() { return 0; } 426 public int llGetAttached() { return 0; }
418 public int llGetFreeMemory() { return 0; } 427 public int llGetFreeMemory() { return 0; }
419 public string llGetRegionName() { return m_manager.RegionName; } 428 public string llGetRegionName() { return World.RegionInfo.RegionName; }
420 public double llGetRegionTimeDilation() { return 1.0f; } 429 public double llGetRegionTimeDilation() { return 1.0f; }
421 public double llGetRegionFPS() { return 10.0f; } 430 public double llGetRegionFPS() { return 10.0f; }
422 public void llParticleSystem(List<Object> rules) { } 431 public void llParticleSystem(List<Object> rules) { }
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs
index 986d333..9c8c29a 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs
@@ -77,7 +77,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
77 //); 77 //);
78 Console.WriteLine("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " + script.Length); 78 Console.WriteLine("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " + script.Length);
79 myScriptEngine.myScriptManager.StartScript(localID, itemID, script); 79 myScriptEngine.myScriptManager.StartScript(localID, itemID, script);
80 myScriptEngine.myEventQueueManager.AddToObjectQueue(localID, "state_entry", new object[] { });
81 } 80 }
82 public void OnRemoveScript(uint localID, LLUUID itemID) 81 public void OnRemoveScript(uint localID, LLUUID itemID)
83 { 82 {
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs
index 1cab01e..c62e862 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs
@@ -226,6 +226,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
226 } 226 }
227 } 227 }
228 228
229
229 /// <summary> 230 /// <summary>
230 /// Add event to event execution queue 231 /// Add event to event execution queue
231 /// </summary> 232 /// </summary>
@@ -237,34 +238,44 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
237 // Determine all scripts in Object and add to their queue 238 // Determine all scripts in Object and add to their queue
238 //myScriptEngine.m_logger.Verbose("ScriptEngine", "EventQueueManager Adding localID: " + localID + ", FunctionName: " + FunctionName); 239 //myScriptEngine.m_logger.Verbose("ScriptEngine", "EventQueueManager Adding localID: " + localID + ", FunctionName: " + FunctionName);
239 240
240 lock (QueueLock)
241 {
242 241
243 // Do we have any scripts in this object at all? If not, return 242 // Do we have any scripts in this object at all? If not, return
244 if (myScriptEngine.myScriptManager.Scripts.ContainsKey(localID) == false) 243 if (myScriptEngine.myScriptManager.Scripts.ContainsKey(localID) == false)
245 { 244 {
246 //Console.WriteLine("Event \"" + FunctionName + "\" for localID: " + localID + ". No scripts found on this localID."); 245 //Console.WriteLine("Event \"" + FunctionName + "\" for localID: " + localID + ". No scripts found on this localID.");
247 return; 246 return;
248 } 247 }
249 248
250 foreach (LLUUID itemID in myScriptEngine.myScriptManager.GetScriptKeys(localID)) 249 foreach (LLUUID itemID in new System.Collections.ArrayList(myScriptEngine.myScriptManager.GetScriptKeys(localID)))
251 { 250 {
252 // Add to each script in that object 251 // Add to each script in that object
253 // TODO: Some scripts may not subscribe to this event. Should we NOT add it? Does it matter? 252 // TODO: Some scripts may not subscribe to this event. Should we NOT add it? Does it matter?
253 AddToScriptQueue(localID, itemID, FunctionName, param);
254 }
254 255
255 // Create a structure and add data 256 }
256 QueueItemStruct QIS = new QueueItemStruct();
257 QIS.localID = localID;
258 QIS.itemID = itemID;
259 QIS.FunctionName = FunctionName;
260 QIS.param = param;
261 257
262 // Add it to queue 258 /// <summary>
263 EventQueue.Enqueue(QIS); 259 /// Add event to event execution queue
260 /// </summary>
261 /// <param name="localID"></param>
262 /// <param name="itemID"></param>
263 /// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param>
264 /// <param name="param">Array of parameters to match event mask</param>
265 public void AddToScriptQueue(uint localID, LLUUID itemID, string FunctionName, object[] param)
266 {
267 lock (QueueLock)
268 {
269 // Create a structure and add data
270 QueueItemStruct QIS = new QueueItemStruct();
271 QIS.localID = localID;
272 QIS.itemID = itemID;
273 QIS.FunctionName = FunctionName;
274 QIS.param = param;
264 275
265 } 276 // Add it to queue
277 EventQueue.Enqueue(QIS);
266 } 278 }
267
268 } 279 }
269 280
270 } 281 }
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs
new file mode 100644
index 0000000..e2c039c
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs
@@ -0,0 +1,145 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Threading;
5using libsecondlife;
6
7namespace OpenSim.Region.ScriptEngine.DotNetEngine
8{
9 /// <summary>
10 /// Handles LSL commands that takes long time and returns an event, for example timers, HTTP requests, etc.
11 /// </summary>
12 class LSLLongCmdHandler
13 {
14 private Thread CmdHandlerThread;
15 private int CmdHandlerThreadCycleSleepms = 100;
16
17 private ScriptEngine myScriptEngine;
18 public LSLLongCmdHandler(ScriptEngine _ScriptEngine)
19 {
20 myScriptEngine = _ScriptEngine;
21
22 // Start the thread that will be doing the work
23 CmdHandlerThread = new Thread(CmdHandlerThreadLoop);
24 CmdHandlerThread.Name = "CmdHandlerThread";
25 CmdHandlerThread.Priority = ThreadPriority.BelowNormal;
26 CmdHandlerThread.IsBackground = true;
27 CmdHandlerThread.Start();
28 }
29 ~LSLLongCmdHandler()
30 {
31 // Shut down thread
32 try
33 {
34 if (CmdHandlerThread != null)
35 {
36 if (CmdHandlerThread.IsAlive == true)
37 {
38 CmdHandlerThread.Abort();
39 CmdHandlerThread.Join();
40 }
41 }
42 }
43 catch { }
44 }
45
46 private void CmdHandlerThreadLoop()
47 {
48 while (true)
49 {
50 // Check timers
51 CheckTimerEvents();
52
53 // Sleep before next cycle
54 Thread.Sleep(CmdHandlerThreadCycleSleepms);
55 }
56 }
57
58 /// <summary>
59 /// Remove a specific script (and all its pending commands)
60 /// </summary>
61 /// <param name="m_localID"></param>
62 /// <param name="m_itemID"></param>
63 public void RemoveScript(uint m_localID, LLUUID m_itemID)
64 {
65 // Remove a specific script
66
67 // Remove from: Timers
68 UnSetTimerEvents(m_localID, m_itemID);
69 }
70
71
72 //
73 // TIMER
74 //
75 private class TimerClass
76 {
77 public uint localID;
78 public LLUUID itemID;
79 public double interval;
80 public DateTime next;
81 }
82 private List<TimerClass> Timers = new List<TimerClass>();
83 private object ListLock = new object();
84 public void SetTimerEvent(uint m_localID, LLUUID m_itemID, double sec)
85 {
86 Console.WriteLine("SetTimerEvent");
87
88 // Always remove first, in case this is a re-set
89 UnSetTimerEvents(m_localID, m_itemID);
90 if (sec == 0) // Disabling timer
91 return;
92
93 // Add to timer
94 TimerClass ts = new TimerClass();
95 ts.localID = m_localID;
96 ts.itemID = m_itemID;
97 ts.interval = sec;
98 ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
99 lock (ListLock)
100 {
101 Timers.Add(ts);
102 }
103 }
104 public void UnSetTimerEvents(uint m_localID, LLUUID m_itemID)
105 {
106 // Remove from timer
107 lock (ListLock)
108 {
109 List<TimerClass> NewTimers = new List<TimerClass>();
110 foreach (TimerClass ts in Timers)
111 {
112 if (ts.localID != m_localID && ts.itemID != m_itemID)
113 {
114 NewTimers.Add(ts);
115 }
116 }
117 Timers.Clear();
118 Timers = NewTimers;
119 }
120 }
121 public void CheckTimerEvents()
122 {
123 // Nothing to do here?
124 if (Timers.Count == 0)
125 return;
126
127 // Go through all timers
128 foreach (TimerClass ts in Timers)
129 {
130 // Time has passed?
131 if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime())
132 {
133 // Add it to queue
134 //Console.WriteLine("Enqueue timer event: " + ts.next.ToUniversalTime().ToString("HH:mm:ss") + " > " + DateTime.Now.ToUniversalTime().ToString("HH:mm:ss"));
135 myScriptEngine.myEventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer", new object[] { });
136 // set next interval
137
138
139 ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
140 }
141 }
142 }
143
144 }
145}
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
index 77bd409..d0823d0 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
@@ -48,6 +48,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
48 internal EventQueueManager myEventQueueManager; // Executes events 48 internal EventQueueManager myEventQueueManager; // Executes events
49 internal ScriptManager myScriptManager; // Load, unload and execute scripts 49 internal ScriptManager myScriptManager; // Load, unload and execute scripts
50 internal AppDomainManager myAppDomainManager; 50 internal AppDomainManager myAppDomainManager;
51 internal LSLLongCmdHandler myLSLLongCmdHandler;
51 52
52 private OpenSim.Framework.Console.LogBase m_log; 53 private OpenSim.Framework.Console.LogBase m_log;
53 54
@@ -77,6 +78,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
77 myEventManager = new EventManager(this); 78 myEventManager = new EventManager(this);
78 myScriptManager = new ScriptManager(this); 79 myScriptManager = new ScriptManager(this);
79 myAppDomainManager = new AppDomainManager(); 80 myAppDomainManager = new AppDomainManager();
81 myLSLLongCmdHandler = new LSLLongCmdHandler(this);
80 82
81 // Should we iterate the region for scripts that needs starting? 83 // Should we iterate the region for scripts that needs starting?
82 // Or can we assume we are loaded before anything else so we can use proper events? 84 // Or can we assume we are loaded before anything else so we can use proper events?
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
index 9621e56..29171a1 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
@@ -249,6 +249,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
249 { 249 {
250 250
251 251
252
253
252 // Create a new instance of the compiler (currently we don't want reuse) 254 // Create a new instance of the compiler (currently we don't want reuse)
253 OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.Compiler LSLCompiler = new OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.Compiler(); 255 OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.Compiler LSLCompiler = new OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.Compiler();
254 // Compile (We assume LSL) 256 // Compile (We assume LSL)
@@ -272,11 +274,15 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
272 274
273 // We need to give (untrusted) assembly a private instance of BuiltIns 275 // We need to give (untrusted) assembly a private instance of BuiltIns
274 // this private copy will contain Read-Only FullitemID so that it can bring that on to the server whenever needed. 276 // this private copy will contain Read-Only FullitemID so that it can bring that on to the server whenever needed.
275 LSL_BuiltIn_Commands LSLB = new LSL_BuiltIn_Commands(this, World.GetSceneObjectPart(localID)); 277 LSL_BuiltIn_Commands LSLB = new LSL_BuiltIn_Commands(m_scriptEngine, World.GetSceneObjectPart(localID), localID, itemID);
276 278
277 // Start the script - giving it BuiltIns 279 // Start the script - giving it BuiltIns
278 CompiledScript.Start(LSLB); 280 CompiledScript.Start(LSLB);
279 281
282 // Fire the first start-event
283 m_scriptEngine.myEventQueueManager.AddToObjectQueue(localID, "state_entry", new object[] { });
284
285
280 } 286 }
281 catch (Exception e) 287 catch (Exception e)
282 { 288 {
@@ -291,6 +297,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
291 // Stop script 297 // Stop script
292 Console.WriteLine("Stop script localID: " + localID + " LLUID: " + itemID.ToString()); 298 Console.WriteLine("Stop script localID: " + localID + " LLUID: " + itemID.ToString());
293 299
300 // Stop long command on script
301 m_scriptEngine.myLSLLongCmdHandler.RemoveScript(localID, itemID);
302
294 // Get AppDomain 303 // Get AppDomain
295 AppDomain ad = GetScript(localID, itemID).Exec.GetAppDomain(); 304 AppDomain ad = GetScript(localID, itemID).Exec.GetAppDomain();
296 // Tell script not to accept new requests 305 // Tell script not to accept new requests
@@ -328,12 +337,5 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
328 337
329 } 338 }
330 339
331 public string RegionName
332 {
333 get
334 {
335 return World.RegionInfo.RegionName;
336 }
337 }
338 } 340 }
339} 341}