aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-10-31 00:31:18 +0000
committerJustin Clark-Casey (justincc)2012-10-31 00:31:18 +0000
commit6235d16c3148bb6f9f881b0dc286deccfdf9148a (patch)
tree1d8d9e0b5bdf5872dbf6ff19f87c99593d3e2505 /OpenSim/Region
parentMerge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff)
downloadopensim-SC_OLD-6235d16c3148bb6f9f881b0dc286deccfdf9148a.zip
opensim-SC_OLD-6235d16c3148bb6f9f881b0dc286deccfdf9148a.tar.gz
opensim-SC_OLD-6235d16c3148bb6f9f881b0dc286deccfdf9148a.tar.bz2
opensim-SC_OLD-6235d16c3148bb6f9f881b0dc286deccfdf9148a.tar.xz
Make "show object part" command correctly display script status.
Uses new IEntityInventory.TryGetScriptInstanceRunning() Makes it clearer that TaskInventoryItem.ScriptRunning cannot be used as it is temporary and not updated.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs6
-rw-r--r--OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs8
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityInventory.cs13
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs52
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs10
5 files changed, 66 insertions, 23 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 2a513e9..24170fc 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -571,9 +571,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
571 571
572 if (grp.HasGroupChanged) 572 if (grp.HasGroupChanged)
573 { 573 {
574// m_log.DebugFormat( 574 m_log.DebugFormat(
575// "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}", 575 "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}",
576// grp.UUID, grp.AttachmentPoint); 576 grp.UUID, grp.AttachmentPoint);
577 577
578 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, scriptedState); 578 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, scriptedState);
579 579
diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
index b2c9bce..ab8f143 100644
--- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs
@@ -606,12 +606,18 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
606 cdt.AddColumn("Asset UUID", 36); 606 cdt.AddColumn("Asset UUID", 36);
607 607
608 foreach (TaskInventoryItem item in inv.GetInventoryItems()) 608 foreach (TaskInventoryItem item in inv.GetInventoryItems())
609 {
610 bool foundScriptInstance, scriptRunning;
611 foundScriptInstance
612 = SceneObjectPartInventory.TryGetScriptInstanceRunning(m_scene, item, out scriptRunning);
613
609 cdt.AddRow( 614 cdt.AddRow(
610 item.Name, 615 item.Name,
611 ((InventoryType)item.InvType).ToString(), 616 ((InventoryType)item.InvType).ToString(),
612 (InventoryType)item.InvType == InventoryType.LSL ? item.ScriptRunning.ToString() : "n/a", 617 foundScriptInstance ? scriptRunning.ToString() : "n/a",
613 item.ItemID.ToString(), 618 item.ItemID.ToString(),
614 item.AssetID.ToString()); 619 item.AssetID.ToString());
620 }
615 621
616 return sb.Append(cdt.ToString()); 622 return sb.Append(cdt.ToString());
617 } 623 }
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
index c457b2f..150193d 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
@@ -150,6 +150,19 @@ namespace OpenSim.Region.Framework.Interfaces
150 void StopScriptInstance(UUID itemId); 150 void StopScriptInstance(UUID itemId);
151 151
152 /// <summary> 152 /// <summary>
153 /// Try to get the script running status.
154 /// </summary>
155 /// <returns>
156 /// Returns true if a script for the item was found in one of the simulator's script engines. In this case,
157 /// the running parameter will reflect the running status.
158 /// Returns false if the item could not be found, if the item is not a script or if a script instance for the
159 /// item was not found in any of the script engines. In this case, running status is irrelevant.
160 /// </returns>
161 /// <param name='itemId'></param>
162 /// <param name='running'></param>
163 bool TryGetScriptInstanceRunning(UUID itemId, out bool running);
164
165 /// <summary>
153 /// Add an item to this entity's inventory. If an item with the same name already exists, then an alternative 166 /// Add an item to this entity's inventory. If an item with the same name already exists, then an alternative
154 /// name is chosen. 167 /// name is chosen.
155 /// </summary> 168 /// </summary>
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index bdb0446..db723fa 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -232,31 +232,49 @@ namespace OpenSim.Region.Framework.Scenes
232 if (m_part == null || m_part.ParentGroup == null || m_part.ParentGroup.Scene == null) 232 if (m_part == null || m_part.ParentGroup == null || m_part.ParentGroup.Scene == null)
233 return; 233 return;
234 234
235 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
236 if (engines == null) // No engine at all
237 return;
238
239 lock (Items) 235 lock (Items)
240 { 236 {
241 foreach (TaskInventoryItem item in Items.Values) 237 foreach (TaskInventoryItem item in Items.Values)
242 { 238 {
243 if (item.InvType == (int)InventoryType.LSL) 239 bool running;
244 { 240 if (TryGetScriptInstanceRunning(m_part.ParentGroup.Scene, item, out running))
245 foreach (IScriptModule e in engines) 241 item.ScriptRunning = running;
246 {
247 bool running;
248
249 if (e.HasScript(item.ItemID, out running))
250 {
251 item.ScriptRunning = running;
252 break;
253 }
254 }
255 }
256 } 242 }
257 } 243 }
258 } 244 }
259 245
246 public bool TryGetScriptInstanceRunning(UUID itemId, out bool running)
247 {
248 running = false;
249
250 TaskInventoryItem item = GetInventoryItem(itemId);
251
252 if (item == null)
253 return false;
254
255 return TryGetScriptInstanceRunning(m_part.ParentGroup.Scene, item, out running);
256 }
257
258 public static bool TryGetScriptInstanceRunning(Scene scene, TaskInventoryItem item, out bool running)
259 {
260 running = false;
261
262 if (item.InvType != (int)InventoryType.LSL)
263 return false;
264
265 IScriptModule[] engines = scene.RequestModuleInterfaces<IScriptModule>();
266 if (engines == null) // No engine at all
267 return false;
268
269 foreach (IScriptModule e in engines)
270 {
271 if (e.HasScript(item.ItemID, out running))
272 return true;
273 }
274
275 return false;
276 }
277
260 public int CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) 278 public int CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
261 { 279 {
262 int scriptsValidForStarting = 0; 280 int scriptsValidForStarting = 0;
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs
index f247a0b..f331658 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs
@@ -90,7 +90,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Tests
90// log4net.Config.XmlConfigurator.Configure(); 90// log4net.Config.XmlConfigurator.Configure();
91 91
92 UUID userId = TestHelpers.ParseTail(0x1); 92 UUID userId = TestHelpers.ParseTail(0x1);
93// UUID objectId = TestHelpers.ParseTail(0x2); 93// UUID objectId = TestHelpers.ParseTail(0x100);
94// UUID itemId = TestHelpers.ParseTail(0x3); 94// UUID itemId = TestHelpers.ParseTail(0x3);
95 string itemName = "TestStartScript() Item"; 95 string itemName = "TestStartScript() Item";
96 96
@@ -105,12 +105,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Tests
105 105
106 m_scene.EventManager.OnChatFromWorld += OnChatFromWorld; 106 m_scene.EventManager.OnChatFromWorld += OnChatFromWorld;
107 107
108 m_scene.RezNewScript(userId, itemTemplate); 108 SceneObjectPart partWhereRezzed = m_scene.RezNewScript(userId, itemTemplate);
109 109
110 m_chatEvent.WaitOne(60000); 110 m_chatEvent.WaitOne(60000);
111 111
112 Assert.That(m_osChatMessageReceived, Is.Not.Null, "No chat message received in TestStartScript()"); 112 Assert.That(m_osChatMessageReceived, Is.Not.Null, "No chat message received in TestStartScript()");
113 Assert.That(m_osChatMessageReceived.Message, Is.EqualTo("Script running")); 113 Assert.That(m_osChatMessageReceived.Message, Is.EqualTo("Script running"));
114
115 bool running;
116 TaskInventoryItem scriptItem = partWhereRezzed.Inventory.GetInventoryItem(itemName);
117 Assert.That(
118 SceneObjectPartInventory.TryGetScriptInstanceRunning(m_scene, scriptItem, out running), Is.True);
119 Assert.That(running, Is.True);
114 } 120 }
115 121
116 private void OnChatFromWorld(object sender, OSChatMessage oscm) 122 private void OnChatFromWorld(object sender, OSChatMessage oscm)