From d32cf2157670889c571a34f1a4473d672e29627d Mon Sep 17 00:00:00 2001
From: Melanie
Date: Sun, 1 Jul 2012 18:30:59 +0100
Subject: Add preservation of running state of scripts when drag-copying.
---
.../Region/Framework/Interfaces/IScriptModule.cs | 4 ++-
.../Framework/Scenes/SceneObjectPartInventory.cs | 36 +++++++++++++++++++++-
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 12 ++++++++
3 files changed, 50 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
index cbaf241..42dbedc 100644
--- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
@@ -69,6 +69,8 @@ namespace OpenSim.Region.Framework.Interfaces
ArrayList GetScriptErrors(UUID itemID);
+ bool HasScript(UUID itemID, out bool running);
+
///
/// Returns true if a script is running.
///
@@ -101,4 +103,4 @@ namespace OpenSim.Region.Framework.Interfaces
///
Dictionary GetObjectScriptsExecutionTimes();
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index c223474..6427014 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -89,6 +89,7 @@ namespace OpenSim.Region.Framework.Scenes
{
m_items = value;
m_inventorySerial++;
+ QueryScriptStates();
}
}
@@ -217,6 +218,36 @@ namespace OpenSim.Region.Framework.Scenes
}
}
+ private void QueryScriptStates()
+ {
+ if (m_part == null || m_part.ParentGroup == null)
+ return;
+
+ IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces();
+ if (engines == null) // No engine at all
+ return;
+
+ lock (Items)
+ {
+ foreach (TaskInventoryItem item in Items.Values)
+ {
+ if (item.InvType == (int)InventoryType.LSL)
+ {
+ foreach (IScriptModule e in engines)
+ {
+ bool running;
+
+ if (e.HasScript(item.ItemID, out running))
+ {
+ item.ScriptRunning = running;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
public int CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
{
int scriptsValidForStarting = 0;
@@ -321,6 +352,9 @@ namespace OpenSim.Region.Framework.Scenes
string script = Utils.BytesToString(asset.Data);
m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
+ if (!item.ScriptRunning)
+ m_part.ParentGroup.Scene.EventManager.TriggerStopScript(
+ m_part.LocalId, item.ItemID);
m_part.ParentGroup.AddActiveScriptCount(1);
m_part.ScheduleFullUpdate();
@@ -1251,4 +1285,4 @@ namespace OpenSim.Region.Framework.Scenes
}
}
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 35fac4e..7f3bd76 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -2081,5 +2081,17 @@ namespace OpenSim.Region.ScriptEngine.XEngine
// else
// m_log.DebugFormat("[XEngine]: Could not find script with ID {0} to resume", itemID);
}
+
+ public bool HasScript(UUID itemID, out bool running)
+ {
+ running = true;
+
+ IScriptInstance instance = GetInstance(itemID);
+ if (instance == null)
+ return false;
+
+ running = instance.Running;
+ return true;
+ }
}
}
--
cgit v1.1