Merge branch 'master' into careminster
Conflicts: OpenSim/Framework/TaskInventoryItem.cs OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.csavinationmerge
commit
a2c6094324
|
@ -39,10 +39,12 @@ using OpenMetaverse;
|
||||||
namespace OpenSim.Framework
|
namespace OpenSim.Framework
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A dictionary for task inventory.
|
/// A dictionary containing task inventory items. Indexed by item UUID.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
/// This class is not thread safe. Callers must synchronize on Dictionary methods or Clone() this object before
|
/// This class is not thread safe. Callers must synchronize on Dictionary methods or Clone() this object before
|
||||||
/// iterating over it.
|
/// iterating over it.
|
||||||
|
/// </remarks>
|
||||||
public class TaskInventoryDictionary : Dictionary<UUID, TaskInventoryItem>,
|
public class TaskInventoryDictionary : Dictionary<UUID, TaskInventoryItem>,
|
||||||
ICloneable, IXmlSerializable
|
ICloneable, IXmlSerializable
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,9 +73,6 @@ namespace OpenSim.Framework
|
||||||
|
|
||||||
private bool _ownerChanged = false;
|
private bool _ownerChanged = false;
|
||||||
|
|
||||||
// This used ONLY during copy. It can't be relied on at other times!
|
|
||||||
private bool _scriptRunning = true;
|
|
||||||
|
|
||||||
public UUID AssetID {
|
public UUID AssetID {
|
||||||
get {
|
get {
|
||||||
return _assetID;
|
return _assetID;
|
||||||
|
@ -353,14 +350,13 @@ namespace OpenSim.Framework
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ScriptRunning {
|
/// <summary>
|
||||||
get {
|
/// This used ONLY during copy. It can't be relied on at other times!
|
||||||
return _scriptRunning;
|
/// </summary>
|
||||||
}
|
/// <remarks>
|
||||||
set {
|
/// For true script running status, use IEntityInventory.TryGetScriptInstanceRunning() for now.
|
||||||
_scriptRunning = value;
|
/// </remarks>
|
||||||
}
|
public bool ScriptRunning { get; set; }
|
||||||
}
|
|
||||||
|
|
||||||
// See ICloneable
|
// See ICloneable
|
||||||
|
|
||||||
|
@ -388,6 +384,7 @@ namespace OpenSim.Framework
|
||||||
|
|
||||||
public TaskInventoryItem()
|
public TaskInventoryItem()
|
||||||
{
|
{
|
||||||
|
ScriptRunning = true;
|
||||||
CreationDate = (uint)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
|
CreationDate = (uint)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5314,8 +5314,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
AddLocalPacketHandler(PacketType.MultipleObjectUpdate, HandleMultipleObjUpdate, false);
|
AddLocalPacketHandler(PacketType.MultipleObjectUpdate, HandleMultipleObjUpdate, false);
|
||||||
AddLocalPacketHandler(PacketType.MoneyTransferRequest, HandleMoneyTransferRequest, false);
|
AddLocalPacketHandler(PacketType.MoneyTransferRequest, HandleMoneyTransferRequest, false);
|
||||||
AddLocalPacketHandler(PacketType.ParcelBuy, HandleParcelBuyRequest, false);
|
AddLocalPacketHandler(PacketType.ParcelBuy, HandleParcelBuyRequest, false);
|
||||||
AddLocalPacketHandler(PacketType.UUIDGroupNameRequest, HandleUUIDGroupNameRequest, false);
|
AddLocalPacketHandler(PacketType.UUIDGroupNameRequest, HandleUUIDGroupNameRequest);
|
||||||
AddLocalPacketHandler(PacketType.ObjectGroup, HandleObjectGroupRequest, false);
|
AddLocalPacketHandler(PacketType.ObjectGroup, HandleObjectGroupRequest);
|
||||||
AddLocalPacketHandler(PacketType.GenericMessage, HandleGenericMessage);
|
AddLocalPacketHandler(PacketType.GenericMessage, HandleGenericMessage);
|
||||||
AddLocalPacketHandler(PacketType.AvatarPropertiesRequest, HandleAvatarPropertiesRequest);
|
AddLocalPacketHandler(PacketType.AvatarPropertiesRequest, HandleAvatarPropertiesRequest);
|
||||||
AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer);
|
AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer);
|
||||||
|
|
|
@ -639,9 +639,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
|
|
||||||
if (grp.HasGroupChanged)
|
if (grp.HasGroupChanged)
|
||||||
{
|
{
|
||||||
// m_log.DebugFormat(
|
m_log.DebugFormat(
|
||||||
// "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}",
|
"[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}",
|
||||||
// grp.UUID, grp.AttachmentPoint);
|
grp.UUID, grp.AttachmentPoint);
|
||||||
|
|
||||||
string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, scriptedState);
|
string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, scriptedState);
|
||||||
|
|
||||||
|
|
|
@ -606,12 +606,18 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
|
||||||
cdt.AddColumn("Asset UUID", 36);
|
cdt.AddColumn("Asset UUID", 36);
|
||||||
|
|
||||||
foreach (TaskInventoryItem item in inv.GetInventoryItems())
|
foreach (TaskInventoryItem item in inv.GetInventoryItems())
|
||||||
|
{
|
||||||
|
bool foundScriptInstance, scriptRunning;
|
||||||
|
foundScriptInstance
|
||||||
|
= SceneObjectPartInventory.TryGetScriptInstanceRunning(m_scene, item, out scriptRunning);
|
||||||
|
|
||||||
cdt.AddRow(
|
cdt.AddRow(
|
||||||
item.Name,
|
item.Name,
|
||||||
((InventoryType)item.InvType).ToString(),
|
((InventoryType)item.InvType).ToString(),
|
||||||
(InventoryType)item.InvType == InventoryType.LSL ? item.ScriptRunning.ToString() : "n/a",
|
foundScriptInstance ? scriptRunning.ToString() : "n/a",
|
||||||
item.ItemID.ToString(),
|
item.ItemID.ToString(),
|
||||||
item.AssetID.ToString());
|
item.AssetID.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
return sb.Append(cdt.ToString());
|
return sb.Append(cdt.ToString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,6 +151,19 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
/// <param name="itemId"></param>
|
/// <param name="itemId"></param>
|
||||||
void StopScriptInstance(UUID itemId);
|
void StopScriptInstance(UUID itemId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Try to get the script running status.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// Returns true if a script for the item was found in one of the simulator's script engines. In this case,
|
||||||
|
/// the running parameter will reflect the running status.
|
||||||
|
/// Returns false if the item could not be found, if the item is not a script or if a script instance for the
|
||||||
|
/// item was not found in any of the script engines. In this case, running status is irrelevant.
|
||||||
|
/// </returns>
|
||||||
|
/// <param name='itemId'></param>
|
||||||
|
/// <param name='running'></param>
|
||||||
|
bool TryGetScriptInstanceRunning(UUID itemId, out bool running);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add an item to this entity's inventory. If an item with the same name already exists, then an alternative
|
/// Add an item to this entity's inventory. If an item with the same name already exists, then an alternative
|
||||||
/// name is chosen.
|
/// name is chosen.
|
||||||
|
|
|
@ -244,31 +244,52 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
if (m_part == null || m_part.ParentGroup == null || m_part.ParentGroup.Scene == null)
|
if (m_part == null || m_part.ParentGroup == null || m_part.ParentGroup.Scene == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
|
|
||||||
if (engines == null) // No engine at all
|
|
||||||
return;
|
|
||||||
|
|
||||||
Items.LockItemsForRead(true);
|
Items.LockItemsForRead(true);
|
||||||
foreach (TaskInventoryItem item in Items.Values)
|
foreach (TaskInventoryItem item in Items.Values)
|
||||||
{
|
{
|
||||||
if (item.InvType == (int)InventoryType.LSL)
|
if (item.InvType == (int)InventoryType.LSL)
|
||||||
{
|
{
|
||||||
foreach (IScriptModule e in engines)
|
bool running;
|
||||||
{
|
if (TryGetScriptInstanceRunning(m_part.ParentGroup.Scene, item, out running))
|
||||||
bool running;
|
item.ScriptRunning = running;
|
||||||
|
|
||||||
if (e.HasScript(item.ItemID, out running))
|
|
||||||
{
|
|
||||||
item.ScriptRunning = running;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Items.LockItemsForRead(false);
|
Items.LockItemsForRead(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool TryGetScriptInstanceRunning(UUID itemId, out bool running)
|
||||||
|
{
|
||||||
|
running = false;
|
||||||
|
|
||||||
|
TaskInventoryItem item = GetInventoryItem(itemId);
|
||||||
|
|
||||||
|
if (item == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return TryGetScriptInstanceRunning(m_part.ParentGroup.Scene, item, out running);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool TryGetScriptInstanceRunning(Scene scene, TaskInventoryItem item, out bool running)
|
||||||
|
{
|
||||||
|
running = false;
|
||||||
|
|
||||||
|
if (item.InvType != (int)InventoryType.LSL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
IScriptModule[] engines = scene.RequestModuleInterfaces<IScriptModule>();
|
||||||
|
if (engines == null) // No engine at all
|
||||||
|
return false;
|
||||||
|
|
||||||
|
foreach (IScriptModule e in engines)
|
||||||
|
{
|
||||||
|
if (e.HasScript(item.ItemID, out running))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public int CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
|
public int CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
|
||||||
{
|
{
|
||||||
int scriptsValidForStarting = 0;
|
int scriptsValidForStarting = 0;
|
||||||
|
|
|
@ -26,9 +26,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace OpenSim.Region.ScriptEngine.Shared
|
namespace OpenSim.Region.ScriptEngine.Shared
|
||||||
{
|
{
|
||||||
|
[Serializable]
|
||||||
public class ScriptException : Exception
|
public class ScriptException : Exception
|
||||||
{
|
{
|
||||||
public ScriptException() : base() {}
|
public ScriptException() : base() {}
|
||||||
|
@ -36,5 +38,7 @@ namespace OpenSim.Region.ScriptEngine.Shared
|
||||||
public ScriptException(string message) : base(message) {}
|
public ScriptException(string message) : base(message) {}
|
||||||
|
|
||||||
public ScriptException(string message, Exception innerException) : base(message, innerException) {}
|
public ScriptException(string message, Exception innerException) : base(message, innerException) {}
|
||||||
|
|
||||||
|
public ScriptException(SerializationInfo info, StreamingContext context) :base(info, context) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -90,7 +90,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Tests
|
||||||
// log4net.Config.XmlConfigurator.Configure();
|
// log4net.Config.XmlConfigurator.Configure();
|
||||||
|
|
||||||
UUID userId = TestHelpers.ParseTail(0x1);
|
UUID userId = TestHelpers.ParseTail(0x1);
|
||||||
// UUID objectId = TestHelpers.ParseTail(0x2);
|
// UUID objectId = TestHelpers.ParseTail(0x100);
|
||||||
// UUID itemId = TestHelpers.ParseTail(0x3);
|
// UUID itemId = TestHelpers.ParseTail(0x3);
|
||||||
string itemName = "TestStartScript() Item";
|
string itemName = "TestStartScript() Item";
|
||||||
|
|
||||||
|
@ -105,12 +105,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Tests
|
||||||
|
|
||||||
m_scene.EventManager.OnChatFromWorld += OnChatFromWorld;
|
m_scene.EventManager.OnChatFromWorld += OnChatFromWorld;
|
||||||
|
|
||||||
m_scene.RezNewScript(userId, itemTemplate);
|
SceneObjectPart partWhereRezzed = m_scene.RezNewScript(userId, itemTemplate);
|
||||||
|
|
||||||
m_chatEvent.WaitOne(60000);
|
m_chatEvent.WaitOne(60000);
|
||||||
|
|
||||||
Assert.That(m_osChatMessageReceived, Is.Not.Null, "No chat message received in TestStartScript()");
|
Assert.That(m_osChatMessageReceived, Is.Not.Null, "No chat message received in TestStartScript()");
|
||||||
Assert.That(m_osChatMessageReceived.Message, Is.EqualTo("Script running"));
|
Assert.That(m_osChatMessageReceived.Message, Is.EqualTo("Script running"));
|
||||||
|
|
||||||
|
bool running;
|
||||||
|
TaskInventoryItem scriptItem = partWhereRezzed.Inventory.GetInventoryItem(itemName);
|
||||||
|
Assert.That(
|
||||||
|
SceneObjectPartInventory.TryGetScriptInstanceRunning(m_scene, scriptItem, out running), Is.True);
|
||||||
|
Assert.That(running, Is.True);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnChatFromWorld(object sender, OSChatMessage oscm)
|
private void OnChatFromWorld(object sender, OSChatMessage oscm)
|
||||||
|
|
Loading…
Reference in New Issue