aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorBlueWall2012-06-23 04:11:31 -0400
committerBlueWall2012-06-23 04:15:14 -0400
commit6d3ee8bb39d47ed7b32e8905fa0b2fc31c5a9f80 (patch)
tree355fc7f7b91c55f7de9a90f2bd12d4fa2cd91e0d /OpenSim
parentResolve various race conditions between accessing and removing external scrip... (diff)
downloadopensim-SC-6d3ee8bb39d47ed7b32e8905fa0b2fc31c5a9f80.zip
opensim-SC-6d3ee8bb39d47ed7b32e8905fa0b2fc31c5a9f80.tar.gz
opensim-SC-6d3ee8bb39d47ed7b32e8905fa0b2fc31c5a9f80.tar.bz2
opensim-SC-6d3ee8bb39d47ed7b32e8905fa0b2fc31c5a9f80.tar.xz
Fix script "Running" behavior
Unchecking "Running" box in script editor now persists. This fixes http://opensimulator.org/mantis/view.php?id=6057
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Framework/Interfaces/IScriptModule.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs14
-rw-r--r--OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs10
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs9
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptSerializer.cs11
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs7
6 files changed, 53 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
index 0d488df..cbaf241 100644
--- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
@@ -75,6 +75,8 @@ namespace OpenSim.Region.Framework.Interfaces
75 /// <param name="itemID">The item ID of the script.</param> 75 /// <param name="itemID">The item ID of the script.</param>
76 bool GetScriptState(UUID itemID); 76 bool GetScriptState(UUID itemID);
77 77
78 void SetRunEnable(UUID instanceID, bool enable);
79
78 void SaveAllState(); 80 void SaveAllState();
79 81
80 /// <summary> 82 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index e413281..9ff8467 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -2143,10 +2143,24 @@ namespace OpenSim.Region.Framework.Scenes
2143 if (part == null) 2143 if (part == null)
2144 return; 2144 return;
2145 2145
2146 IScriptModule[] engines = RequestModuleInterfaces<IScriptModule>();
2147
2146 if (running) 2148 if (running)
2149 {
2150 foreach (IScriptModule engine in engines)
2151 {
2152 engine.SetRunEnable(itemID, true);
2153 }
2147 EventManager.TriggerStartScript(part.LocalId, itemID); 2154 EventManager.TriggerStartScript(part.LocalId, itemID);
2155 }
2148 else 2156 else
2157 {
2158 foreach (IScriptModule engine in engines)
2159 {
2160 engine.SetRunEnable(itemID, false);
2161 }
2149 EventManager.TriggerStopScript(part.LocalId, itemID); 2162 EventManager.TriggerStopScript(part.LocalId, itemID);
2163 }
2150 } 2164 }
2151 2165
2152 public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) 2166 public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID)
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 5dfe58e..306090e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -120,6 +120,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
120 120
121 public bool Running { get; set; } 121 public bool Running { get; set; }
122 122
123 public bool Run { get; set; }
124
123 public bool Suspended 125 public bool Suspended
124 { 126 {
125 get { return m_Suspended; } 127 get { return m_Suspended; }
@@ -215,6 +217,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
215 m_postOnRez = postOnRez; 217 m_postOnRez = postOnRez;
216 m_AttachedAvatar = part.ParentGroup.AttachedAvatar; 218 m_AttachedAvatar = part.ParentGroup.AttachedAvatar;
217 m_RegionID = part.ParentGroup.Scene.RegionInfo.RegionID; 219 m_RegionID = part.ParentGroup.Scene.RegionInfo.RegionID;
220 Run = true;
218 221
219 if (part != null) 222 if (part != null)
220 { 223 {
@@ -359,6 +362,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
359 362
360 if (m_startedFromSavedState) 363 if (m_startedFromSavedState)
361 { 364 {
365 if (!Run)
366 return;
367
362 Start(); 368 Start();
363 if (m_postOnRez) 369 if (m_postOnRez)
364 { 370 {
@@ -391,6 +397,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
391 } 397 }
392 else 398 else
393 { 399 {
400 if (!Run)
401 return;
402
394 Start(); 403 Start();
395 PostEvent(new EventParams("state_entry", 404 PostEvent(new EventParams("state_entry",
396 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 25b27b9..06ed9d6 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -1503,6 +1503,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1503 } 1503 }
1504 } 1504 }
1505 1505
1506 public void SetRunEnable(UUID instanceID, bool enable)
1507 {
1508 IScriptInstance instance = GetInstance(instanceID);
1509 if (instance != null)
1510 instance.Run = enable;
1511 }
1512
1506 public bool GetScriptState(UUID itemID) 1513 public bool GetScriptState(UUID itemID)
1507 { 1514 {
1508 IScriptInstance instance = GetInstance(itemID); 1515 IScriptInstance instance = GetInstance(itemID);