aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs15
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueThreadClass.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api_Base.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs126
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs26
6 files changed, 106 insertions, 71 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
index c8c9cd8..0308169 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
@@ -215,6 +215,12 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
215 215
216 public void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine) 216 public void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine)
217 { 217 {
218 List<IScriptModule> engines = new List<IScriptModule>(myScriptEngine.World.RequestModuleInterfaces<IScriptModule>());
219
220 List<string> names = new List<string>();
221 foreach (IScriptModule m in engines)
222 names.Add(m.ScriptEngineName);
223
218 int lineEnd = script.IndexOf('\n'); 224 int lineEnd = script.IndexOf('\n');
219 225
220 if (lineEnd != 1) 226 if (lineEnd != 1)
@@ -224,8 +230,13 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
224 int colon = firstline.IndexOf(':'); 230 int colon = firstline.IndexOf(':');
225 if (firstline.Length > 2 && firstline.Substring(0, 2) == "//" && colon != -1) 231 if (firstline.Length > 2 && firstline.Substring(0, 2) == "//" && colon != -1)
226 { 232 {
227 engine = firstline.Substring(2, colon-2); 233 string engineName = firstline.Substring(2, colon-2);
228 script = "//" + script.Substring(script.IndexOf(':')+1); 234
235 if (names.Contains(engineName))
236 {
237 engine = engineName;
238 script = "//" + script.Substring(script.IndexOf(':')+1);
239 }
229 } 240 }
230 } 241 }
231 242
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueThreadClass.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueThreadClass.cs
index 1e71ae5..7f52793 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueThreadClass.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventQueueThreadClass.cs
@@ -282,7 +282,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
282 // QIS.functionName); 282 // QIS.functionName);
283#endif 283#endif
284 // Only pipe event if land supports it. 284 // Only pipe event if land supports it.
285 if (m_ScriptEngine.World.pipeEventsForScript(QIS.localID)) 285 if (m_ScriptEngine.World.PipeEventsForScript(QIS.localID))
286 { 286 {
287 LastExecutionStarted = DateTime.Now.Ticks; 287 LastExecutionStarted = DateTime.Now.Ticks;
288 KillCurrentScript = false; 288 KillCurrentScript = false;
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs
index d423311..2bcd949 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptEngine.cs
@@ -30,6 +30,7 @@ using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using log4net; 31using log4net;
32using Nini.Config; 32using Nini.Config;
33using OpenSim.Region.Interfaces;
33using OpenSim.Region.Environment.Interfaces; 34using OpenSim.Region.Environment.Interfaces;
34using OpenSim.Region.Environment.Scenes; 35using OpenSim.Region.Environment.Scenes;
35using OpenSim.Region.ScriptEngine.Interfaces; 36using OpenSim.Region.ScriptEngine.Interfaces;
@@ -43,7 +44,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
43 /// </summary> 44 /// </summary>
44 /// 45 ///
45 [Serializable] 46 [Serializable]
46 public abstract class ScriptEngine : IRegionModule, ScriptServerInterfaces.ScriptEngine, iScriptEngineFunctionModule, IEventReceiver 47 public abstract class ScriptEngine : IRegionModule, IScriptModule, ScriptServerInterfaces.ScriptEngine, iScriptEngineFunctionModule, IEventReceiver
47 { 48 {
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49 50
@@ -126,8 +127,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
126 m_log.Info("[" + ScriptEngineName + "]: Reading configuration from config section \"" + ScriptEngineName + "\""); 127 m_log.Info("[" + ScriptEngineName + "]: Reading configuration from config section \"" + ScriptEngineName + "\"");
127 ReadConfig(); 128 ReadConfig();
128 129
129 // Should we iterate the region for scripts that needs starting? 130 m_Scene.StackModuleInterface<IScriptModule>(this);
130 // Or can we assume we are loaded before anything else so we can use proper events?
131 } 131 }
132 132
133 public void PostInitialise() 133 public void PostInitialise()
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api_Base.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api_Base.cs
index 320e878..396d924 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api_Base.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api_Base.cs
@@ -5114,7 +5114,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5114 public LSL_Integer llScriptDanger(LSL_Vector pos) 5114 public LSL_Integer llScriptDanger(LSL_Vector pos)
5115 { 5115 {
5116 m_host.AddScriptLPS(1); 5116 m_host.AddScriptLPS(1);
5117 bool result = World.scriptDanger(m_host.LocalId, new Vector3((float)pos.x, (float)pos.y, (float)pos.z)); 5117 bool result = World.ScriptDanger(m_host.LocalId, new Vector3((float)pos.x, (float)pos.y, (float)pos.z));
5118 if (result) 5118 if (result)
5119 { 5119 {
5120 return 1; 5120 return 1;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 28a3b11..6e6d169 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -567,86 +567,90 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
567 } 567 }
568 else 568 else
569 { 569 {
570 SceneObjectPart part = m_Engine.World.GetSceneObjectPart( 570 if (m_Engine.World.PipeEventsForScript(m_LocalID) ||
571 m_LocalID); 571 data.EventName == "control") // Don't freeze avies!
572 // m_Engine.Log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}",
573 // m_PrimName, m_ScriptName, data.EventName, m_State);
574
575 try
576 { 572 {
577 m_CurrentEvent = data.EventName; 573 SceneObjectPart part = m_Engine.World.GetSceneObjectPart(
578 m_EventStart = DateTime.Now; 574 m_LocalID);
579 m_InEvent = true; 575 // m_Engine.Log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}",
576 // m_PrimName, m_ScriptName, data.EventName, m_State);
580 577
581 m_Script.ExecuteEvent(State, data.EventName, data.Params); 578 try
579 {
580 m_CurrentEvent = data.EventName;
581 m_EventStart = DateTime.Now;
582 m_InEvent = true;
582 583
583 m_InEvent = false; 584 m_Script.ExecuteEvent(State, data.EventName, data.Params);
584 m_CurrentEvent = String.Empty;
585 585
586 if (m_SaveState) 586 m_InEvent = false;
587 { 587 m_CurrentEvent = String.Empty;
588 // This will be the very first event we deliver
589 // (state_entry) in defualt state
590 //
591 588
592 SaveState(m_Assembly); 589 if (m_SaveState)
590 {
591 // This will be the very first event we deliver
592 // (state_entry) in defualt state
593 //
593 594
594 m_SaveState = false; 595 SaveState(m_Assembly);
595 }
596 }
597 catch (Exception e)
598 {
599 m_InEvent = false;
600 m_CurrentEvent = String.Empty;
601 596
602 if (!(e is TargetInvocationException) || (!(e.InnerException is EventAbortException) && (!(e.InnerException is SelfDeleteException)))) 597 m_SaveState = false;
598 }
599 }
600 catch (Exception e)
603 { 601 {
604 if (e is System.Threading.ThreadAbortException) 602 m_InEvent = false;
603 m_CurrentEvent = String.Empty;
604
605 if (!(e is TargetInvocationException) || (!(e.InnerException is EventAbortException) && (!(e.InnerException is SelfDeleteException))))
605 { 606 {
606 lock (m_EventQueue) 607 if (e is System.Threading.ThreadAbortException)
607 { 608 {
608 if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) 609 lock (m_EventQueue)
609 { 610 {
610 m_CurrentResult=m_Engine.QueueEventHandler(this); 611 if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown))
612 {
613 m_CurrentResult=m_Engine.QueueEventHandler(this);
614 }
615 else
616 {
617 m_CurrentResult = null;
618 }
611 } 619 }
612 else
613 {
614 m_CurrentResult = null;
615 }
616 }
617 620
618 m_DetectParams = null; 621 m_DetectParams = null;
619 622
620 return 0; 623 return 0;
621 } 624 }
622 625
623 try 626 try
624 { 627 {
625 // DISPLAY ERROR INWORLD 628 // DISPLAY ERROR INWORLD
626 string text = "Runtime error:\n" + e.InnerException.ToString(); 629 string text = "Runtime error:\n" + e.InnerException.ToString();
627 if (text.Length > 1000) 630 if (text.Length > 1000)
628 text = text.Substring(0, 1000); 631 text = text.Substring(0, 1000);
629 m_Engine.World.SimChat(Utils.StringToBytes(text), 632 m_Engine.World.SimChat(Utils.StringToBytes(text),
630 ChatTypeEnum.DebugChannel, 2147483647, 633 ChatTypeEnum.DebugChannel, 2147483647,
631 part.AbsolutePosition, 634 part.AbsolutePosition,
632 part.Name, part.UUID, false); 635 part.Name, part.UUID, false);
636 }
637 catch (Exception e2) // LEGIT: User Scripting
638 {
639 m_Engine.Log.Error("[Script]: "+
640 "Error displaying error in-world: " +
641 e2.ToString());
642 m_Engine.Log.Error("[Script]: " +
643 "Errormessage: Error compiling script:\r\n" +
644 e.ToString());
645 }
633 } 646 }
634 catch (Exception e2) // LEGIT: User Scripting 647 else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException))
635 { 648 {
636 m_Engine.Log.Error("[Script]: "+ 649 m_InSelfDelete = true;
637 "Error displaying error in-world: " + 650 if (part != null && part.ParentGroup != null)
638 e2.ToString()); 651 m_Engine.World.DeleteSceneObject(part.ParentGroup);
639 m_Engine.Log.Error("[Script]: " +
640 "Errormessage: Error compiling script:\r\n" +
641 e.ToString());
642 } 652 }
643 } 653 }
644 else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException))
645 {
646 m_InSelfDelete = true;
647 if (part != null && part.ParentGroup != null)
648 m_Engine.World.DeleteSceneObject(part.ParentGroup);
649 }
650 } 654 }
651 } 655 }
652 656
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 701ad60..f11ccc4 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -39,6 +39,7 @@ using log4net;
39using Nini.Config; 39using Nini.Config;
40using Amib.Threading; 40using Amib.Threading;
41using OpenSim.Framework; 41using OpenSim.Framework;
42using OpenSim.Region.Interfaces;
42using OpenSim.Region.Environment; 43using OpenSim.Region.Environment;
43using OpenSim.Region.Environment.Scenes; 44using OpenSim.Region.Environment.Scenes;
44using OpenSim.Region.Environment.Interfaces; 45using OpenSim.Region.Environment.Interfaces;
@@ -50,7 +51,7 @@ using OpenSim.Region.ScriptEngine.Interfaces;
50 51
51namespace OpenSim.Region.ScriptEngine.XEngine 52namespace OpenSim.Region.ScriptEngine.XEngine
52{ 53{
53 public class XEngine : IRegionModule, IScriptEngine 54 public class XEngine : IRegionModule, IScriptModule, IScriptEngine
54 { 55 {
55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 56 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
56 57
@@ -213,6 +214,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
213 // 214 //
214 SetupEngine(m_MinThreads, m_MaxThreads, m_IdleTimeout, m_Prio, 215 SetupEngine(m_MinThreads, m_MaxThreads, m_IdleTimeout, m_Prio,
215 m_MaxScriptQueue, m_StackSize); 216 m_MaxScriptQueue, m_StackSize);
217
218 m_Scene.StackModuleInterface<IScriptModule>(this);
216 } 219 }
217 220
218 public void PostInitialise() 221 public void PostInitialise()
@@ -331,6 +334,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
331 334
332 public void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine) 335 public void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine)
333 { 336 {
337 List<IScriptModule> engines = new List<IScriptModule>(m_Scene.RequestModuleInterfaces<IScriptModule>());
338
339 List<string> names = new List<string>();
340 foreach (IScriptModule m in engines)
341 names.Add(m.ScriptEngineName);
342
334 int lineEnd = script.IndexOf('\n'); 343 int lineEnd = script.IndexOf('\n');
335 344
336 if (lineEnd != 1) 345 if (lineEnd != 1)
@@ -340,8 +349,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
340 int colon = firstline.IndexOf(':'); 349 int colon = firstline.IndexOf(':');
341 if (firstline.Length > 2 && firstline.Substring(0, 2) == "//" && colon != -1) 350 if (firstline.Length > 2 && firstline.Substring(0, 2) == "//" && colon != -1)
342 { 351 {
343 engine = firstline.Substring(2, colon-2); 352 string engineName = firstline.Substring(2, colon-2);
344 script = "//" + script.Substring(script.IndexOf(':')+1); 353
354 if (names.Contains(engineName))
355 {
356 engine = engineName;
357 script = "//" + script.Substring(script.IndexOf(':')+1);
358 }
345 } 359 }
346 } 360 }
347 361
@@ -454,14 +468,20 @@ namespace OpenSim.Region.ScriptEngine.XEngine
454// m_log.DebugFormat("[XEngine] Compiling script {0} ({1})", 468// m_log.DebugFormat("[XEngine] Compiling script {0} ({1})",
455// item.Name, itemID.ToString()); 469// item.Name, itemID.ToString());
456 470
471 ScenePresence presence = m_Scene.GetScenePresence(item.OwnerID);
472
457 string assembly = ""; 473 string assembly = "";
458 try 474 try
459 { 475 {
460 assembly = m_Compiler.PerformScriptCompile(script, 476 assembly = m_Compiler.PerformScriptCompile(script,
461 assetID.ToString()); 477 assetID.ToString());
478 if (presence != null)
479 presence.ControllingClient.SendAgentAlertMessage("Compile successful", false);
462 } 480 }
463 catch (Exception e) 481 catch (Exception e)
464 { 482 {
483 if (presence != null)
484 presence.ControllingClient.SendAgentAlertMessage("Script saved with errors, check debug window!", false);
465 try 485 try
466 { 486 {
467 // DISPLAY ERROR INWORLD 487 // DISPLAY ERROR INWORLD