diff options
Diffstat (limited to 'OpenSim/Region/Framework')
10 files changed, 482 insertions, 67 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs index 32f4eea..8732ec0 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs | |||
@@ -174,7 +174,17 @@ namespace OpenSim.Region.Framework.Interfaces | |||
174 | /// If no inventory item has that name then an empty list is returned. | 174 | /// If no inventory item has that name then an empty list is returned. |
175 | /// </returns> | 175 | /// </returns> |
176 | List<TaskInventoryItem> GetInventoryItems(string name); | 176 | List<TaskInventoryItem> GetInventoryItems(string name); |
177 | 177 | ||
178 | /// <summary> | ||
179 | /// Get inventory items by type. | ||
180 | /// </summary> | ||
181 | /// <param type="name"></param> | ||
182 | /// <returns> | ||
183 | /// A list of inventory items of that type. | ||
184 | /// If no inventory items of that type then an empty list is returned. | ||
185 | /// </returns> | ||
186 | List<TaskInventoryItem> GetInventoryItems(InventoryType type); | ||
187 | |||
178 | /// <summary> | 188 | /// <summary> |
179 | /// Get the scene object referenced by an inventory item. | 189 | /// Get the scene object referenced by an inventory item. |
180 | /// </summary> | 190 | /// </summary> |
@@ -228,6 +238,16 @@ namespace OpenSim.Region.Framework.Interfaces | |||
228 | bool ContainsScripts(); | 238 | bool ContainsScripts(); |
229 | 239 | ||
230 | /// <summary> | 240 | /// <summary> |
241 | /// Returns the count of scripts contained | ||
242 | /// </summary></returns> | ||
243 | int ScriptCount(); | ||
244 | |||
245 | /// <summary> | ||
246 | /// Returns the count of running scripts contained | ||
247 | /// </summary></returns> | ||
248 | int RunningScriptCount(); | ||
249 | |||
250 | /// <summary> | ||
231 | /// Get the uuids of all items in this inventory | 251 | /// Get the uuids of all items in this inventory |
232 | /// </summary> | 252 | /// </summary> |
233 | /// <returns></returns> | 253 | /// <returns></returns> |
diff --git a/OpenSim/Region/Framework/Interfaces/IEstateModule.cs b/OpenSim/Region/Framework/Interfaces/IEstateModule.cs index 72e79ed..ca2ad94 100644 --- a/OpenSim/Region/Framework/Interfaces/IEstateModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IEstateModule.cs | |||
@@ -47,5 +47,8 @@ namespace OpenSim.Region.Framework.Interfaces | |||
47 | void sendRegionHandshakeToAll(); | 47 | void sendRegionHandshakeToAll(); |
48 | void TriggerEstateInfoChange(); | 48 | void TriggerEstateInfoChange(); |
49 | void TriggerRegionInfoChange(); | 49 | void TriggerRegionInfoChange(); |
50 | |||
51 | void setEstateTerrainBaseTexture(int level, UUID texture); | ||
52 | void setEstateTerrainTextureHeights(int corner, float lowValue, float highValue); | ||
50 | } | 53 | } |
51 | } | 54 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs b/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs new file mode 100644 index 0000000..baac6e8 --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using OpenMetaverse; | ||
31 | |||
32 | namespace OpenSim.Region.Framework.Interfaces | ||
33 | { | ||
34 | public delegate void TakeValueCallback(string s); | ||
35 | |||
36 | public interface IJsonStoreModule | ||
37 | { | ||
38 | bool CreateStore(string value, out UUID result); | ||
39 | bool DestroyStore(UUID storeID); | ||
40 | bool TestPath(UUID storeID, string path, bool useJson); | ||
41 | bool SetValue(UUID storeID, string path, string value, bool useJson); | ||
42 | bool RemoveValue(UUID storeID, string path); | ||
43 | bool GetValue(UUID storeID, string path, bool useJson, out string value); | ||
44 | |||
45 | void TakeValue(UUID storeID, string path, bool useJson, TakeValueCallback cback); | ||
46 | void ReadValue(UUID storeID, string path, bool useJson, TakeValueCallback cback); | ||
47 | } | ||
48 | } | ||
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs index ce66100..143af48 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs | |||
@@ -71,6 +71,12 @@ namespace OpenSim.Region.Framework.Interfaces | |||
71 | 71 | ||
72 | bool HasScript(UUID itemID, out bool running); | 72 | bool HasScript(UUID itemID, out bool running); |
73 | 73 | ||
74 | /// <summary> | ||
75 | /// Returns true if a script is running. | ||
76 | /// </summary> | ||
77 | /// <param name="itemID">The item ID of the script.</param> | ||
78 | bool GetScriptState(UUID itemID); | ||
79 | |||
74 | void SaveAllState(); | 80 | void SaveAllState(); |
75 | 81 | ||
76 | /// <summary> | 82 | /// <summary> |
@@ -79,6 +85,14 @@ namespace OpenSim.Region.Framework.Interfaces | |||
79 | void StartProcessing(); | 85 | void StartProcessing(); |
80 | 86 | ||
81 | /// <summary> | 87 | /// <summary> |
88 | /// Get the execution times of all scripts in the given array if they are currently running. | ||
89 | /// </summary> | ||
90 | /// <returns> | ||
91 | /// A float the value is a representative execution time in milliseconds of all scripts in that Array. | ||
92 | /// </returns> | ||
93 | float GetScriptExecutionTime(List<UUID> itemIDs); | ||
94 | |||
95 | /// <summary> | ||
82 | /// Get the execution times of all scripts in each object. | 96 | /// Get the execution times of all scripts in each object. |
83 | /// </summary> | 97 | /// </summary> |
84 | /// <returns> | 98 | /// <returns> |
@@ -87,4 +101,4 @@ namespace OpenSim.Region.Framework.Interfaces | |||
87 | /// </returns> | 101 | /// </returns> |
88 | Dictionary<uint, float> GetObjectScriptsExecutionTimes(); | 102 | Dictionary<uint, float> GetObjectScriptsExecutionTimes(); |
89 | } | 103 | } |
90 | } \ No newline at end of file | 104 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index b806d91..77e808e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs | |||
@@ -156,7 +156,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
156 | // that the region position is cached or performance will degrade | 156 | // that the region position is cached or performance will degrade |
157 | Utils.LongToUInts(regionHandle, out x, out y); | 157 | Utils.LongToUInts(regionHandle, out x, out y); |
158 | GridRegion dest = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); | 158 | GridRegion dest = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); |
159 | // bool v = true; | 159 | if (dest == null) |
160 | continue; | ||
161 | |||
160 | if (!simulatorList.Contains(dest.ServerURI)) | 162 | if (!simulatorList.Contains(dest.ServerURI)) |
161 | { | 163 | { |
162 | // we havent seen this simulator before, add it to the list | 164 | // we havent seen this simulator before, add it to the list |
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index b7dc335..f6f6a1a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -101,6 +101,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
101 | /// </summary> | 101 | /// </summary> |
102 | protected internal Dictionary<uint, SceneObjectGroup> SceneObjectGroupsByLocalPartID = new Dictionary<uint, SceneObjectGroup>(); | 102 | protected internal Dictionary<uint, SceneObjectGroup> SceneObjectGroupsByLocalPartID = new Dictionary<uint, SceneObjectGroup>(); |
103 | 103 | ||
104 | /// <summary> | ||
105 | /// Lock to prevent object group update, linking and delinking operations from running concurrently. | ||
106 | /// </summary> | ||
104 | private Object m_updateLock = new Object(); | 107 | private Object m_updateLock = new Object(); |
105 | 108 | ||
106 | #endregion | 109 | #endregion |
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); |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index a2649ee..36cb09a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -267,14 +267,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
267 | /// </summary> | 267 | /// </summary> |
268 | public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) | 268 | public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) |
269 | { | 269 | { |
270 | Items.LockItemsForRead(true); | 270 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); |
271 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 271 | foreach (TaskInventoryItem item in scripts) |
272 | Items.LockItemsForRead(false); | 272 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); |
273 | foreach (TaskInventoryItem item in items) | ||
274 | { | ||
275 | if ((int)InventoryType.LSL == item.InvType) | ||
276 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); | ||
277 | } | ||
278 | } | 273 | } |
279 | 274 | ||
280 | public ArrayList GetScriptErrors(UUID itemID) | 275 | public ArrayList GetScriptErrors(UUID itemID) |
@@ -305,17 +300,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
305 | /// </param> | 300 | /// </param> |
306 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) | 301 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) |
307 | { | 302 | { |
308 | Items.LockItemsForRead(true); | 303 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); |
309 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 304 | foreach (TaskInventoryItem item in scripts) |
310 | Items.LockItemsForRead(false); | ||
311 | |||
312 | foreach (TaskInventoryItem item in items) | ||
313 | { | 305 | { |
314 | if ((int)InventoryType.LSL == item.InvType) | 306 | RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); |
315 | { | 307 | m_part.RemoveScriptEvents(item.ItemID); |
316 | RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); | ||
317 | m_part.RemoveScriptEvents(item.ItemID); | ||
318 | } | ||
319 | } | 308 | } |
320 | } | 309 | } |
321 | 310 | ||
@@ -1280,9 +1269,57 @@ namespace OpenSim.Region.Framework.Scenes | |||
1280 | return true; | 1269 | return true; |
1281 | } | 1270 | } |
1282 | } | 1271 | } |
1272 | |||
1283 | return false; | 1273 | return false; |
1284 | } | 1274 | } |
1285 | 1275 | ||
1276 | /// <summary> | ||
1277 | /// Returns the count of scripts in this parts inventory. | ||
1278 | /// </summary> | ||
1279 | /// <returns></returns> | ||
1280 | public int ScriptCount() | ||
1281 | { | ||
1282 | int count = 0; | ||
1283 | Items.LockItemsForRead(true); | ||
1284 | foreach (TaskInventoryItem item in m_items.Values) | ||
1285 | { | ||
1286 | if (item.InvType == (int)InventoryType.LSL) | ||
1287 | { | ||
1288 | count++; | ||
1289 | } | ||
1290 | } | ||
1291 | Items.LockItemsForRead(false); | ||
1292 | return count; | ||
1293 | } | ||
1294 | /// <summary> | ||
1295 | /// Returns the count of running scripts in this parts inventory. | ||
1296 | /// </summary> | ||
1297 | /// <returns></returns> | ||
1298 | public int RunningScriptCount() | ||
1299 | { | ||
1300 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | ||
1301 | if (engines.Length == 0) | ||
1302 | return 0; | ||
1303 | |||
1304 | int count = 0; | ||
1305 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); | ||
1306 | |||
1307 | foreach (TaskInventoryItem item in scripts) | ||
1308 | { | ||
1309 | foreach (IScriptModule engine in engines) | ||
1310 | { | ||
1311 | if (engine != null) | ||
1312 | { | ||
1313 | if (engine.GetScriptState(item.ItemID)) | ||
1314 | { | ||
1315 | count++; | ||
1316 | } | ||
1317 | } | ||
1318 | } | ||
1319 | } | ||
1320 | return count; | ||
1321 | } | ||
1322 | |||
1286 | public List<UUID> GetInventoryList() | 1323 | public List<UUID> GetInventoryList() |
1287 | { | 1324 | { |
1288 | List<UUID> ret = new List<UUID>(); | 1325 | List<UUID> ret = new List<UUID>(); |
@@ -1297,22 +1334,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1297 | { | 1334 | { |
1298 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); | 1335 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); |
1299 | 1336 | ||
1300 | lock (m_items) | 1337 | Items.LockItemsForRead(true); |
1301 | ret = new List<TaskInventoryItem>(m_items.Values); | 1338 | ret = new List<TaskInventoryItem>(m_items.Values); |
1339 | Items.LockItemsForRead(false); | ||
1302 | 1340 | ||
1303 | return ret; | 1341 | return ret; |
1304 | } | 1342 | } |
1305 | 1343 | ||
1306 | public List<TaskInventoryItem> GetInventoryScripts() | 1344 | public List<TaskInventoryItem> GetInventoryItems(InventoryType type) |
1307 | { | 1345 | { |
1308 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); | 1346 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); |
1309 | 1347 | ||
1310 | lock (m_items) | 1348 | Items.LockItemsForRead(true); |
1311 | { | 1349 | |
1312 | foreach (TaskInventoryItem item in m_items.Values) | 1350 | foreach (TaskInventoryItem item in m_items.Values) |
1313 | if (item.InvType == (int)InventoryType.LSL) | 1351 | if (item.InvType == (int)type) |
1314 | ret.Add(item); | 1352 | ret.Add(item); |
1315 | } | 1353 | |
1354 | Items.LockItemsForRead(false); | ||
1316 | 1355 | ||
1317 | return ret; | 1356 | return ret; |
1318 | } | 1357 | } |
@@ -1334,35 +1373,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
1334 | if (engines.Length == 0) // No engine at all | 1373 | if (engines.Length == 0) // No engine at all |
1335 | return ret; | 1374 | return ret; |
1336 | 1375 | ||
1337 | Items.LockItemsForRead(true); | 1376 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); |
1338 | foreach (TaskInventoryItem item in m_items.Values) | 1377 | |
1378 | foreach (TaskInventoryItem item in scripts) | ||
1339 | { | 1379 | { |
1340 | if (item.InvType == (int)InventoryType.LSL) | 1380 | foreach (IScriptModule e in engines) |
1341 | { | 1381 | { |
1342 | foreach (IScriptModule e in engines) | 1382 | if (e != null) |
1343 | { | 1383 | { |
1344 | if (e != null) | 1384 | string n = e.GetXMLState(item.ItemID); |
1385 | if (n != String.Empty) | ||
1345 | { | 1386 | { |
1346 | string n = e.GetXMLState(item.ItemID); | 1387 | if (oldIDs) |
1347 | if (n != String.Empty) | 1388 | { |
1389 | if (!ret.ContainsKey(item.OldItemID)) | ||
1390 | ret[item.OldItemID] = n; | ||
1391 | } | ||
1392 | else | ||
1348 | { | 1393 | { |
1349 | if (oldIDs) | 1394 | if (!ret.ContainsKey(item.ItemID)) |
1350 | { | 1395 | ret[item.ItemID] = n; |
1351 | if (!ret.ContainsKey(item.OldItemID)) | ||
1352 | ret[item.OldItemID] = n; | ||
1353 | } | ||
1354 | else | ||
1355 | { | ||
1356 | if (!ret.ContainsKey(item.ItemID)) | ||
1357 | ret[item.ItemID] = n; | ||
1358 | } | ||
1359 | break; | ||
1360 | } | 1396 | } |
1397 | break; | ||
1361 | } | 1398 | } |
1362 | } | 1399 | } |
1363 | } | 1400 | } |
1364 | } | 1401 | } |
1365 | Items.LockItemsForRead(false); | ||
1366 | return ret; | 1402 | return ret; |
1367 | } | 1403 | } |
1368 | 1404 | ||
@@ -1372,27 +1408,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1372 | if (engines.Length == 0) | 1408 | if (engines.Length == 0) |
1373 | return; | 1409 | return; |
1374 | 1410 | ||
1411 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); | ||
1375 | 1412 | ||
1376 | Items.LockItemsForRead(true); | 1413 | foreach (TaskInventoryItem item in scripts) |
1377 | |||
1378 | foreach (TaskInventoryItem item in m_items.Values) | ||
1379 | { | 1414 | { |
1380 | if (item.InvType == (int)InventoryType.LSL) | 1415 | foreach (IScriptModule engine in engines) |
1381 | { | 1416 | { |
1382 | foreach (IScriptModule engine in engines) | 1417 | if (engine != null) |
1383 | { | 1418 | { |
1384 | if (engine != null) | 1419 | if (item.OwnerChanged) |
1385 | { | 1420 | engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER }); |
1386 | if (item.OwnerChanged) | 1421 | item.OwnerChanged = false; |
1387 | engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER }); | 1422 | engine.ResumeScript(item.ItemID); |
1388 | item.OwnerChanged = false; | ||
1389 | engine.ResumeScript(item.ItemID); | ||
1390 | } | ||
1391 | } | 1423 | } |
1392 | } | 1424 | } |
1393 | } | 1425 | } |
1394 | |||
1395 | Items.LockItemsForRead(false); | ||
1396 | } | 1426 | } |
1397 | } | 1427 | } |
1398 | } | 1428 | } |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 1211792..ac791ae 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -3542,6 +3542,63 @@ namespace OpenSim.Region.Framework.Scenes | |||
3542 | return m_attachments.Count > 0; | 3542 | return m_attachments.Count > 0; |
3543 | } | 3543 | } |
3544 | 3544 | ||
3545 | /// <summary> | ||
3546 | /// Returns the total count of scripts in all parts inventories. | ||
3547 | /// </summary> | ||
3548 | public int ScriptCount() | ||
3549 | { | ||
3550 | int count = 0; | ||
3551 | lock (m_attachments) | ||
3552 | { | ||
3553 | foreach (SceneObjectGroup gobj in m_attachments) | ||
3554 | { | ||
3555 | if (gobj != null) | ||
3556 | { | ||
3557 | count += gobj.ScriptCount(); | ||
3558 | } | ||
3559 | } | ||
3560 | } | ||
3561 | return count; | ||
3562 | } | ||
3563 | |||
3564 | /// <summary> | ||
3565 | /// A float the value is a representative execution time in milliseconds of all scripts in all attachments. | ||
3566 | /// </summary> | ||
3567 | public float ScriptExecutionTime() | ||
3568 | { | ||
3569 | float time = 0.0f; | ||
3570 | lock (m_attachments) | ||
3571 | { | ||
3572 | foreach (SceneObjectGroup gobj in m_attachments) | ||
3573 | { | ||
3574 | if (gobj != null) | ||
3575 | { | ||
3576 | time += gobj.ScriptExecutionTime(); | ||
3577 | } | ||
3578 | } | ||
3579 | } | ||
3580 | return time; | ||
3581 | } | ||
3582 | |||
3583 | /// <summary> | ||
3584 | /// Returns the total count of running scripts in all parts. | ||
3585 | /// </summary> | ||
3586 | public int RunningScriptCount() | ||
3587 | { | ||
3588 | int count = 0; | ||
3589 | lock (m_attachments) | ||
3590 | { | ||
3591 | foreach (SceneObjectGroup gobj in m_attachments) | ||
3592 | { | ||
3593 | if (gobj != null) | ||
3594 | { | ||
3595 | count += gobj.RunningScriptCount(); | ||
3596 | } | ||
3597 | } | ||
3598 | } | ||
3599 | return count; | ||
3600 | } | ||
3601 | |||
3545 | public bool HasScriptedAttachments() | 3602 | public bool HasScriptedAttachments() |
3546 | { | 3603 | { |
3547 | lock (m_attachments) | 3604 | lock (m_attachments) |
@@ -3899,7 +3956,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3899 | land.LandData.UserLocation != Vector3.Zero && | 3956 | land.LandData.UserLocation != Vector3.Zero && |
3900 | land.LandData.OwnerID != m_uuid && | 3957 | land.LandData.OwnerID != m_uuid && |
3901 | (!m_scene.Permissions.IsGod(m_uuid)) && | 3958 | (!m_scene.Permissions.IsGod(m_uuid)) && |
3902 | (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) | 3959 | (!m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid))) |
3903 | { | 3960 | { |
3904 | float curr = Vector3.Distance(AbsolutePosition, pos); | 3961 | float curr = Vector3.Distance(AbsolutePosition, pos); |
3905 | if (Vector3.Distance(land.LandData.UserLocation, pos) < curr) | 3962 | if (Vector3.Distance(land.LandData.UserLocation, pos) < curr) |
@@ -3919,7 +3976,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3919 | { | 3976 | { |
3920 | if (GodLevel < 200 && | 3977 | if (GodLevel < 200 && |
3921 | ((!m_scene.Permissions.IsGod(m_uuid) && | 3978 | ((!m_scene.Permissions.IsGod(m_uuid) && |
3922 | !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) || | 3979 | !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) || |
3923 | (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || | 3980 | (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || |
3924 | (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) | 3981 | (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) |
3925 | { | 3982 | { |
@@ -3993,7 +4050,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3993 | GodLevel < 200 && | 4050 | GodLevel < 200 && |
3994 | ((land.LandData.OwnerID != m_uuid && | 4051 | ((land.LandData.OwnerID != m_uuid && |
3995 | !m_scene.Permissions.IsGod(m_uuid) && | 4052 | !m_scene.Permissions.IsGod(m_uuid) && |
3996 | !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) || | 4053 | !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) || |
3997 | (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || | 4054 | (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || |
3998 | (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) | 4055 | (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) |
3999 | { | 4056 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs new file mode 100644 index 0000000..9fea3c6 --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs | |||
@@ -0,0 +1,154 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using System.Threading; | ||
31 | using NUnit.Framework; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Communications; | ||
35 | using OpenSim.Region.Framework.Scenes; | ||
36 | using OpenSim.Tests.Common; | ||
37 | using OpenSim.Tests.Common.Mock; | ||
38 | |||
39 | namespace OpenSim.Region.Framework.Scenes.Tests | ||
40 | { | ||
41 | /// <summary> | ||
42 | /// Spatial scene object tests (will eventually cover root and child part position, rotation properties, etc.) | ||
43 | /// </summary> | ||
44 | [TestFixture] | ||
45 | public class SceneObjectSpatialTests | ||
46 | { | ||
47 | TestScene m_scene; | ||
48 | UUID m_ownerId = TestHelpers.ParseTail(0x1); | ||
49 | |||
50 | [SetUp] | ||
51 | public void SetUp() | ||
52 | { | ||
53 | m_scene = SceneHelpers.SetupScene(); | ||
54 | } | ||
55 | |||
56 | [Test] | ||
57 | public void TestGetSceneObjectGroupPosition() | ||
58 | { | ||
59 | TestHelpers.InMethod(); | ||
60 | |||
61 | Vector3 position = new Vector3(10, 20, 30); | ||
62 | |||
63 | SceneObjectGroup so | ||
64 | = SceneHelpers.CreateSceneObject(1, m_ownerId, "obj1", 0x10); | ||
65 | so.AbsolutePosition = position; | ||
66 | m_scene.AddNewSceneObject(so, false); | ||
67 | |||
68 | Assert.That(so.AbsolutePosition, Is.EqualTo(position)); | ||
69 | } | ||
70 | |||
71 | [Test] | ||
72 | public void TestGetRootPartPosition() | ||
73 | { | ||
74 | TestHelpers.InMethod(); | ||
75 | |||
76 | Vector3 partPosition = new Vector3(10, 20, 30); | ||
77 | |||
78 | SceneObjectGroup so | ||
79 | = SceneHelpers.CreateSceneObject(1, m_ownerId, "obj1", 0x10); | ||
80 | so.AbsolutePosition = partPosition; | ||
81 | m_scene.AddNewSceneObject(so, false); | ||
82 | |||
83 | Assert.That(so.RootPart.AbsolutePosition, Is.EqualTo(partPosition)); | ||
84 | Assert.That(so.RootPart.GroupPosition, Is.EqualTo(partPosition)); | ||
85 | Assert.That(so.RootPart.GetWorldPosition(), Is.EqualTo(partPosition)); | ||
86 | Assert.That(so.RootPart.RelativePosition, Is.EqualTo(partPosition)); | ||
87 | Assert.That(so.RootPart.OffsetPosition, Is.EqualTo(Vector3.Zero)); | ||
88 | } | ||
89 | |||
90 | [Test] | ||
91 | public void TestGetChildPartPosition() | ||
92 | { | ||
93 | TestHelpers.InMethod(); | ||
94 | |||
95 | Vector3 rootPartPosition = new Vector3(10, 20, 30); | ||
96 | Vector3 childOffsetPosition = new Vector3(2, 3, 4); | ||
97 | |||
98 | SceneObjectGroup so | ||
99 | = SceneHelpers.CreateSceneObject(2, m_ownerId, "obj1", 0x10); | ||
100 | so.AbsolutePosition = rootPartPosition; | ||
101 | so.Parts[1].OffsetPosition = childOffsetPosition; | ||
102 | |||
103 | m_scene.AddNewSceneObject(so, false); | ||
104 | |||
105 | // Calculate child absolute position. | ||
106 | Vector3 childPosition = new Vector3(rootPartPosition + childOffsetPosition); | ||
107 | |||
108 | SceneObjectPart childPart = so.Parts[1]; | ||
109 | Assert.That(childPart.AbsolutePosition, Is.EqualTo(childPosition)); | ||
110 | Assert.That(childPart.GroupPosition, Is.EqualTo(rootPartPosition)); | ||
111 | Assert.That(childPart.GetWorldPosition(), Is.EqualTo(childPosition)); | ||
112 | Assert.That(childPart.RelativePosition, Is.EqualTo(childOffsetPosition)); | ||
113 | Assert.That(childPart.OffsetPosition, Is.EqualTo(childOffsetPosition)); | ||
114 | } | ||
115 | |||
116 | [Test] | ||
117 | public void TestGetChildPartPositionAfterObjectRotation() | ||
118 | { | ||
119 | TestHelpers.InMethod(); | ||
120 | |||
121 | Vector3 rootPartPosition = new Vector3(10, 20, 30); | ||
122 | Vector3 childOffsetPosition = new Vector3(2, 3, 4); | ||
123 | |||
124 | SceneObjectGroup so | ||
125 | = SceneHelpers.CreateSceneObject(2, m_ownerId, "obj1", 0x10); | ||
126 | so.AbsolutePosition = rootPartPosition; | ||
127 | so.Parts[1].OffsetPosition = childOffsetPosition; | ||
128 | |||
129 | m_scene.AddNewSceneObject(so, false); | ||
130 | |||
131 | so.UpdateGroupRotationR(Quaternion.CreateFromEulers(0, 0, -90 * Utils.DEG_TO_RAD)); | ||
132 | |||
133 | // Calculate child absolute position. | ||
134 | Vector3 rotatedChildOffsetPosition | ||
135 | = new Vector3(childOffsetPosition.Y, -childOffsetPosition.X, childOffsetPosition.Z); | ||
136 | |||
137 | Vector3 childPosition = new Vector3(rootPartPosition + rotatedChildOffsetPosition); | ||
138 | |||
139 | SceneObjectPart childPart = so.Parts[1]; | ||
140 | |||
141 | // FIXME: Should be childPosition after rotation? | ||
142 | Assert.That(childPart.AbsolutePosition, Is.EqualTo(rootPartPosition + childOffsetPosition)); | ||
143 | |||
144 | Assert.That(childPart.GroupPosition, Is.EqualTo(rootPartPosition)); | ||
145 | Assert.That(childPart.GetWorldPosition(), Is.EqualTo(childPosition)); | ||
146 | |||
147 | // Relative to root part as (0, 0, 0) | ||
148 | Assert.That(childPart.RelativePosition, Is.EqualTo(childOffsetPosition)); | ||
149 | |||
150 | // Relative to root part as (0, 0, 0) | ||
151 | Assert.That(childPart.OffsetPosition, Is.EqualTo(childOffsetPosition)); | ||
152 | } | ||
153 | } | ||
154 | } \ No newline at end of file | ||