aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs86
1 files changed, 85 insertions, 1 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 47020af..cb0a57a 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -2590,6 +2590,10 @@ namespace OpenSim.Region.Framework.Scenes
2590 /// <summary> 2590 /// <summary>
2591 /// Link the prims in a given group to this group 2591 /// Link the prims in a given group to this group
2592 /// </summary> 2592 /// </summary>
2593 /// <remarks>
2594 /// Do not call this method directly - use Scene.LinkObjects() instead to avoid races between threads.
2595 /// FIXME: There are places where scripts call these methods directly without locking. This is a potential race condition.
2596 /// </remarks>
2593 /// <param name="objectGroup">The group of prims which should be linked to this group</param> 2597 /// <param name="objectGroup">The group of prims which should be linked to this group</param>
2594 public void LinkToGroup(SceneObjectGroup objectGroup) 2598 public void LinkToGroup(SceneObjectGroup objectGroup)
2595 { 2599 {
@@ -2720,6 +2724,11 @@ namespace OpenSim.Region.Framework.Scenes
2720 /// Delink the given prim from this group. The delinked prim is established as 2724 /// Delink the given prim from this group. The delinked prim is established as
2721 /// an independent SceneObjectGroup. 2725 /// an independent SceneObjectGroup.
2722 /// </summary> 2726 /// </summary>
2727 /// <remarks>
2728 /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race
2729 /// condition. But currently there is no
2730 /// alternative method that does take a lonk to delink a single prim.
2731 /// </remarks>
2723 /// <param name="partID"></param> 2732 /// <param name="partID"></param>
2724 /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> 2733 /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns>
2725 public SceneObjectGroup DelinkFromGroup(uint partID) 2734 public SceneObjectGroup DelinkFromGroup(uint partID)
@@ -2731,6 +2740,11 @@ namespace OpenSim.Region.Framework.Scenes
2731 /// Delink the given prim from this group. The delinked prim is established as 2740 /// Delink the given prim from this group. The delinked prim is established as
2732 /// an independent SceneObjectGroup. 2741 /// an independent SceneObjectGroup.
2733 /// </summary> 2742 /// </summary>
2743 /// <remarks>
2744 /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race
2745 /// condition. But currently there is no
2746 /// alternative method that does take a lonk to delink a single prim.
2747 /// </remarks>
2734 /// <param name="partID"></param> 2748 /// <param name="partID"></param>
2735 /// <param name="sendEvents"></param> 2749 /// <param name="sendEvents"></param>
2736 /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> 2750 /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns>
@@ -2756,6 +2770,11 @@ namespace OpenSim.Region.Framework.Scenes
2756 /// Delink the given prim from this group. The delinked prim is established as 2770 /// Delink the given prim from this group. The delinked prim is established as
2757 /// an independent SceneObjectGroup. 2771 /// an independent SceneObjectGroup.
2758 /// </summary> 2772 /// </summary>
2773 /// <remarks>
2774 /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race
2775 /// condition. But currently there is no
2776 /// alternative method that does take a lonk to delink a single prim.
2777 /// </remarks>
2759 /// <param name="partID"></param> 2778 /// <param name="partID"></param>
2760 /// <param name="sendEvents"></param> 2779 /// <param name="sendEvents"></param>
2761 /// <returns>The object group of the newly delinked prim.</returns> 2780 /// <returns>The object group of the newly delinked prim.</returns>
@@ -4051,7 +4070,72 @@ namespace OpenSim.Region.Framework.Scenes
4051 for (int i = 0; i < parts.Length; i++) 4070 for (int i = 0; i < parts.Length; i++)
4052 parts[i].TriggerScriptChangedEvent(val); 4071 parts[i].TriggerScriptChangedEvent(val);
4053 } 4072 }
4054 4073
4074 /// <summary>
4075 /// Returns a count of the number of scripts in this groups parts.
4076 /// </summary>
4077 public int ScriptCount()
4078 {
4079 int count = 0;
4080 SceneObjectPart[] parts = m_parts.GetArray();
4081 for (int i = 0; i < parts.Length; i++)
4082 count += parts[i].Inventory.ScriptCount();
4083
4084 return count;
4085 }
4086
4087 /// <summary>
4088 /// A float the value is a representative execution time in milliseconds of all scripts in the link set.
4089 /// </summary>
4090 public float ScriptExecutionTime()
4091 {
4092 IScriptModule[] engines = Scene.RequestModuleInterfaces<IScriptModule>();
4093
4094 if (engines.Length == 0) // No engine at all
4095 return 0.0f;
4096
4097 float time = 0.0f;
4098
4099 // get all the scripts in all parts
4100 SceneObjectPart[] parts = m_parts.GetArray();
4101 List<TaskInventoryItem> scripts = new List<TaskInventoryItem>();
4102 for (int i = 0; i < parts.Length; i++)
4103 {
4104 scripts.AddRange(parts[i].Inventory.GetInventoryItems(InventoryType.LSL));
4105 }
4106 // extract the UUIDs
4107 List<UUID> ids = new List<UUID>(scripts.Count);
4108 foreach (TaskInventoryItem script in scripts)
4109 {
4110 if (!ids.Contains(script.ItemID))
4111 {
4112 ids.Add(script.ItemID);
4113 }
4114 }
4115 // Offer the list of script UUIDs to each engine found and accumulate the time
4116 foreach (IScriptModule e in engines)
4117 {
4118 if (e != null)
4119 {
4120 time += e.GetScriptExecutionTime(ids);
4121 }
4122 }
4123 return time;
4124 }
4125
4126 /// <summary>
4127 /// Returns a count of the number of running scripts in this groups parts.
4128 /// </summary>
4129 public int RunningScriptCount()
4130 {
4131 int count = 0;
4132 SceneObjectPart[] parts = m_parts.GetArray();
4133 for (int i = 0; i < parts.Length; i++)
4134 count += parts[i].Inventory.RunningScriptCount();
4135
4136 return count;
4137 }
4138
4055 public override string ToString() 4139 public override string ToString()
4056 { 4140 {
4057 return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); 4141 return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition);