aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs10
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs22
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs11
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs63
4 files changed, 70 insertions, 36 deletions
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
index b04f6b6..ec13b6c 100644
--- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
@@ -64,6 +64,16 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
64 bool Running { get; set; } 64 bool Running { get; set; }
65 65
66 /// <summary> 66 /// <summary>
67 /// Gets or sets a value indicating whether this
68 /// <see cref="OpenSim.Region.ScriptEngine.Interfaces.IScriptInstance"/> is run.
69 /// For viewer script editor control
70 /// </summary>
71 /// <value>
72 /// <c>true</c> if run; otherwise, <c>false</c>.
73 /// </value>
74 bool Run { get; set; }
75
76 /// <summary>
67 /// Is the script suspended? 77 /// Is the script suspended?
68 /// </summary> 78 /// </summary>
69 bool Suspended { get; set; } 79 bool Suspended { get; set; }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 1c59d45..3797683 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -121,6 +121,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
121 121
122 public bool Running { get; set; } 122 public bool Running { get; set; }
123 123
124 public bool Run { get; set; }
125
124 public bool Suspended 126 public bool Suspended
125 { 127 {
126 get { return m_Suspended; } 128 get { return m_Suspended; }
@@ -216,6 +218,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
216 m_postOnRez = postOnRez; 218 m_postOnRez = postOnRez;
217 m_AttachedAvatar = part.ParentGroup.AttachedAvatar; 219 m_AttachedAvatar = part.ParentGroup.AttachedAvatar;
218 m_RegionID = part.ParentGroup.Scene.RegionInfo.RegionID; 220 m_RegionID = part.ParentGroup.Scene.RegionInfo.RegionID;
221 Run = true;
219 222
220 if (part != null) 223 if (part != null)
221 { 224 {
@@ -330,16 +333,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
330 } 333 }
331 else 334 else
332 { 335 {
333 m_log.ErrorFormat( 336 m_log.WarnFormat(
334 "[SCRIPT INSTANCE]: Unable to load script state from assembly {0}: Memory limit exceeded", 337 "[SCRIPT INSTANCE]: Unable to load script state file {0} for script {1} {2} in {3} {4} (assembly {5}). Memory limit exceeded",
335 assembly); 338 savedState, ScriptName, ItemID, PrimName, ObjectID, assembly);
336 } 339 }
337 } 340 }
338 catch (Exception e) 341 catch (Exception e)
339 { 342 {
340 m_log.ErrorFormat( 343 m_log.ErrorFormat(
341 "[SCRIPT INSTANCE]: Unable to load script state from assembly {0}. XML is {1}. Exception {2}{3}", 344 "[SCRIPT INSTANCE]: Unable to load script state file {0} for script {1} {2} in {3} {4} (assembly {5}). XML is {6}. Exception {7}{8}",
342 assembly, xml, e.Message, e.StackTrace); 345 savedState, ScriptName, ItemID, PrimName, ObjectID, assembly, xml, e.Message, e.StackTrace);
343 } 346 }
344 } 347 }
345// else 348// else
@@ -354,10 +357,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
354 357
355 public void Init() 358 public void Init()
356 { 359 {
357 if (!m_startOnInit) return; 360 if (!m_startOnInit)
361 return;
358 362
359 if (m_startedFromSavedState) 363 if (m_startedFromSavedState)
360 { 364 {
365 if (!Run)
366 return;
367
361 Start(); 368 Start();
362 if (m_postOnRez) 369 if (m_postOnRez)
363 { 370 {
@@ -390,6 +397,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
390 } 397 }
391 else 398 else
392 { 399 {
400 if (!Run)
401 return;
402
393 Start(); 403 Start();
394 PostEvent(new EventParams("state_entry", 404 PostEvent(new EventParams("state_entry",
395 new Object[0], new DetectParams[0])); 405 new Object[0], new DetectParams[0]));
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs
index bcdc7bf..797bce3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs
@@ -55,6 +55,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
55 public static string Serialize(ScriptInstance instance) 55 public static string Serialize(ScriptInstance instance)
56 { 56 {
57 bool running = instance.Running; 57 bool running = instance.Running;
58 bool enabled = instance.Run;
58 59
59 XmlDocument xmldoc = new XmlDocument(); 60 XmlDocument xmldoc = new XmlDocument();
60 61
@@ -77,6 +78,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
77 78
78 rootElement.AppendChild(run); 79 rootElement.AppendChild(run);
79 80
81 XmlElement run_enable = xmldoc.CreateElement("", "Run", "");
82 run_enable.AppendChild(xmldoc.CreateTextNode(
83 enabled.ToString()));
84
85 rootElement.AppendChild(run_enable);
86
80 Dictionary<string, Object> vars = instance.GetVars(); 87 Dictionary<string, Object> vars = instance.GetVars();
81 88
82 XmlElement variables = xmldoc.CreateElement("", "Variables", ""); 89 XmlElement variables = xmldoc.CreateElement("", "Variables", "");
@@ -225,6 +232,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
225 { 232 {
226 object varValue; 233 object varValue;
227 XmlNodeList partL = rootNode.ChildNodes; 234 XmlNodeList partL = rootNode.ChildNodes;
235 instance.Run = true;
228 236
229 foreach (XmlNode part in partL) 237 foreach (XmlNode part in partL)
230 { 238 {
@@ -236,6 +244,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
236 case "Running": 244 case "Running":
237 instance.Running=bool.Parse(part.InnerText); 245 instance.Running=bool.Parse(part.InnerText);
238 break; 246 break;
247 case "Run":
248 instance.Run = bool.Parse(part.InnerText);
249 break;
239 case "Variables": 250 case "Variables":
240 XmlNodeList varL = part.ChildNodes; 251 XmlNodeList varL = part.ChildNodes;
241 foreach (XmlNode var in varL) 252 foreach (XmlNode var in varL)
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 01021c9..b1583b2 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -920,15 +920,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
920 { 920 {
921 if (m_InitialStartup) 921 if (m_InitialStartup)
922 { 922 {
923 m_InitialStartup = false; 923 // This delay exists to stop mono problems where script compilation and startup would stop the sim
924 // working properly for the session.
924 System.Threading.Thread.Sleep(15000); 925 System.Threading.Thread.Sleep(15000);
925
926 if (m_CompileQueue.Count == 0)
927 {
928 // No scripts on region, so won't get triggered later
929 // by the queue becoming empty so we trigger it here
930 m_Scene.EventManager.TriggerEmptyScriptCompileQueue(0, String.Empty);
931 }
932 } 926 }
933 927
934 object[] o; 928 object[] o;
@@ -941,14 +935,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine
941 { 935 {
942 scriptsStarted++; 936 scriptsStarted++;
943 937
944// if (scriptsStarted % 50 == 0) 938 if (m_InitialStartup)
945// m_log.DebugFormat( 939 if (scriptsStarted % 50 == 0)
946// "[XEngine]: Started {0} scripts in {1}", scriptsStarted, m_Scene.RegionInfo.RegionName); 940 m_log.InfoFormat(
941 "[XEngine]: Started {0} scripts in {1}", scriptsStarted, m_Scene.RegionInfo.RegionName);
947 } 942 }
948 } 943 }
949 944
950// m_log.DebugFormat( 945 if (m_InitialStartup)
951// "[XEngine]: Completed starting {0} scripts on {1}", scriptsStarted, m_Scene.RegionInfo.RegionName); 946 m_log.InfoFormat(
947 "[XEngine]: Completed starting {0} scripts on {1}", scriptsStarted, m_Scene.RegionInfo.RegionName);
952 948
953 // NOTE: Despite having a lockless queue, this lock is required 949 // NOTE: Despite having a lockless queue, this lock is required
954 // to make sure there is never no compile thread while there 950 // to make sure there is never no compile thread while there
@@ -956,12 +952,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
956 // due to a race condition 952 // due to a race condition
957 // 953 //
958 lock (m_CompileQueue) 954 lock (m_CompileQueue)
959 {
960 m_CurrentCompile = null; 955 m_CurrentCompile = null;
961 } 956
962 m_Scene.EventManager.TriggerEmptyScriptCompileQueue(m_ScriptFailCount, 957 m_Scene.EventManager.TriggerEmptyScriptCompileQueue(m_ScriptFailCount,
963 m_ScriptErrorMessage); 958 m_ScriptErrorMessage);
959
964 m_ScriptFailCount = 0; 960 m_ScriptFailCount = 0;
961 m_InitialStartup = false;
965 962
966 return null; 963 return null;
967 } 964 }
@@ -1451,25 +1448,24 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1451 return false; 1448 return false;
1452 1449
1453 uuids = m_PrimObjects[localID]; 1450 uuids = m_PrimObjects[localID];
1454
1455
1456 foreach (UUID itemID in uuids)
1457 {
1458 IScriptInstance instance = null;
1459 try
1460 {
1461 if (m_Scripts.ContainsKey(itemID))
1462 instance = m_Scripts[itemID];
1463 }
1464 catch { /* ignore race conditions */ }
1465 1451
1466 if (instance != null) 1452 foreach (UUID itemID in uuids)
1467 { 1453 {
1468 instance.PostEvent(p); 1454 IScriptInstance instance = null;
1469 result = true; 1455 try
1456 {
1457 if (m_Scripts.ContainsKey(itemID))
1458 instance = m_Scripts[itemID];
1459 }
1460 catch { /* ignore race conditions */ }
1461
1462 if (instance != null)
1463 {
1464 instance.PostEvent(p);
1465 result = true;
1466 }
1470 } 1467 }
1471 } 1468 }
1472 }
1473 1469
1474 return result; 1470 return result;
1475 } 1471 }
@@ -1594,6 +1590,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1594 } 1590 }
1595 } 1591 }
1596 1592
1593 public void SetRunEnable(UUID instanceID, bool enable)
1594 {
1595 IScriptInstance instance = GetInstance(instanceID);
1596 if (instance != null)
1597 instance.Run = enable;
1598 }
1599
1597 public bool GetScriptState(UUID itemID) 1600 public bool GetScriptState(UUID itemID)
1598 { 1601 {
1599 IScriptInstance instance = GetInstance(itemID); 1602 IScriptInstance instance = GetInstance(itemID);