diff options
7 files changed, 77 insertions, 35 deletions
diff --git a/OpenSim/Framework/TaskInventoryDictionary.cs b/OpenSim/Framework/TaskInventoryDictionary.cs index 421bd5d..8af2c41 100644 --- a/OpenSim/Framework/TaskInventoryDictionary.cs +++ b/OpenSim/Framework/TaskInventoryDictionary.cs | |||
@@ -35,10 +35,12 @@ using OpenMetaverse; | |||
35 | namespace OpenSim.Framework | 35 | namespace OpenSim.Framework |
36 | { | 36 | { |
37 | /// <summary> | 37 | /// <summary> |
38 | /// A dictionary for task inventory. | 38 | /// A dictionary containing task inventory items. Indexed by item UUID. |
39 | /// </summary> | 39 | /// </summary> |
40 | /// <remarks> | ||
40 | /// This class is not thread safe. Callers must synchronize on Dictionary methods or Clone() this object before | 41 | /// This class is not thread safe. Callers must synchronize on Dictionary methods or Clone() this object before |
41 | /// iterating over it. | 42 | /// iterating over it. |
43 | /// </remarks> | ||
42 | public class TaskInventoryDictionary : Dictionary<UUID, TaskInventoryItem>, | 44 | public class TaskInventoryDictionary : Dictionary<UUID, TaskInventoryItem>, |
43 | ICloneable, IXmlSerializable | 45 | ICloneable, IXmlSerializable |
44 | { | 46 | { |
diff --git a/OpenSim/Framework/TaskInventoryItem.cs b/OpenSim/Framework/TaskInventoryItem.cs index 3b40381..a06f8e7 100644 --- a/OpenSim/Framework/TaskInventoryItem.cs +++ b/OpenSim/Framework/TaskInventoryItem.cs | |||
@@ -73,9 +73,6 @@ namespace OpenSim.Framework | |||
73 | 73 | ||
74 | private bool _ownerChanged = false; | 74 | private bool _ownerChanged = false; |
75 | 75 | ||
76 | // This used ONLY during copy. It can't be relied on at other times! | ||
77 | private bool _scriptRunning = true; | ||
78 | |||
79 | public UUID AssetID { | 76 | public UUID AssetID { |
80 | get { | 77 | get { |
81 | return _assetID; | 78 | return _assetID; |
@@ -353,14 +350,13 @@ namespace OpenSim.Framework | |||
353 | } | 350 | } |
354 | } | 351 | } |
355 | 352 | ||
356 | public bool ScriptRunning { | 353 | /// <summary> |
357 | get { | 354 | /// This used ONLY during copy. It can't be relied on at other times! |
358 | return _scriptRunning; | 355 | /// </summary> |
359 | } | 356 | /// <remarks> |
360 | set { | 357 | /// For true script running status, use IEntityInventory.TryGetScriptInstanceRunning() for now. |
361 | _scriptRunning = value; | 358 | /// </remarks> |
362 | } | 359 | public bool ScriptRunning { get; set; } |
363 | } | ||
364 | 360 | ||
365 | // See ICloneable | 361 | // See ICloneable |
366 | 362 | ||
@@ -388,6 +384,7 @@ namespace OpenSim.Framework | |||
388 | 384 | ||
389 | public TaskInventoryItem() | 385 | public TaskInventoryItem() |
390 | { | 386 | { |
387 | ScriptRunning = true; | ||
391 | CreationDate = (uint)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; | 388 | CreationDate = (uint)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; |
392 | } | 389 | } |
393 | } | 390 | } |
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) |