From 78c0028179923710949fea349baad2e6bebc49bd Mon Sep 17 00:00:00 2001 From: Talun Date: Mon, 9 Apr 2012 19:58:07 +0100 Subject: Mantis5502 implementation of some of the new constants Signed-off-by: Melanie --- .../Framework/Interfaces/IEntityInventory.cs | 10 +++++ .../Region/Framework/Interfaces/IScriptModule.cs | 6 +++ .../Region/Framework/Scenes/SceneObjectGroup.cs | 28 +++++++++++- .../Framework/Scenes/SceneObjectPartInventory.cs | 51 +++++++++++++++++++++- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 38 ++++++++++++++++ 5 files changed, 131 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs index 1334905..f5dda34 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs @@ -226,6 +226,16 @@ namespace OpenSim.Region.Framework.Interfaces bool ContainsScripts(); /// + /// Returns the count of scripts contained + /// + int ScriptCount(); + + /// + /// Returns the count of running scripts contained + /// + int RunningScriptCount(); + + /// /// Get the uuids of all items in this inventory /// /// diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs index 9cab2e1..c0616ed 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs @@ -69,6 +69,12 @@ namespace OpenSim.Region.Framework.Interfaces ArrayList GetScriptErrors(UUID itemID); + /// + /// Returns true if a script is running. + /// + /// The item ID of the script. + bool GetScriptState(UUID itemID); + void SaveAllState(); /// diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 17f3be7..7d14814 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3255,7 +3255,33 @@ namespace OpenSim.Region.Framework.Scenes for (int i = 0; i < parts.Length; i++) parts[i].TriggerScriptChangedEvent(val); } - + + /// + /// Returns a count of the number of scripts in this groups parts. + /// + public int ScriptCount() + { + int count = 0; + SceneObjectPart[] parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + count += parts[i].Inventory.ScriptCount(); + + return count; + } + + /// + /// Returns a count of the number of running scripts in this groups parts. + /// + public int RunningScriptCount() + { + int count = 0; + SceneObjectPart[] parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + count += parts[i].Inventory.RunningScriptCount(); + + return count; + } + public override string ToString() { return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index f7e123b..9a04c65 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -1081,10 +1081,59 @@ namespace OpenSim.Region.Framework.Scenes } } } - + return false; } + /// + /// Returns the count of scripts in this parts inventory. + /// + /// + public int ScriptCount() + { + int count = 0; + lock (m_items) + { + foreach (TaskInventoryItem item in m_items.Values) + { + if (item.InvType == (int)InventoryType.LSL) + { + count++; + } + } + } + + return count; + } + /// + /// Returns the count of running scripts in this parts inventory. + /// + /// + public int RunningScriptCount() + { + IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces(); + if (engines.Length == 0) + return 0; + + int count = 0; + List scripts = GetInventoryScripts(); + + foreach (TaskInventoryItem item in scripts) + { + foreach (IScriptModule engine in engines) + { + if (engine != null) + { + if (engine.GetScriptState(item.ItemID)) + { + count++; + } + } + } + } + return count; + } + public List GetInventoryList() { List ret = new List(); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a21c66f..8863df1 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3418,6 +3418,44 @@ namespace OpenSim.Region.Framework.Scenes return m_attachments.Count > 0; } + /// + /// Returns the total count of scripts in all parts inventories. + /// + public int ScriptCount() + { + int count = 0; + lock (m_attachments) + { + foreach (SceneObjectGroup gobj in m_attachments) + { + if (gobj != null) + { + count += gobj.ScriptCount(); + } + } + } + return count; + } + + /// + /// Returns the total count of running scripts in all parts. + /// + public int RunningScriptCount() + { + int count = 0; + lock (m_attachments) + { + foreach (SceneObjectGroup gobj in m_attachments) + { + if (gobj != null) + { + count += gobj.RunningScriptCount(); + } + } + } + return count; + } + public bool HasScriptedAttachments() { lock (m_attachments) -- cgit v1.1