aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityInventory.cs35
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs23
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEnvironmentModule.cs36
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEstateModule.cs3
-rw-r--r--OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs10
-rw-r--r--OpenSim/Region/Framework/Interfaces/IJsonStoreModule.cs48
-rw-r--r--OpenSim/Region/Framework/Interfaces/INPCModule.cs36
-rw-r--r--OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs59
-rw-r--r--OpenSim/Region/Framework/Interfaces/IScriptModule.cs16
-rw-r--r--OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs21
-rw-r--r--OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs20
-rw-r--r--OpenSim/Region/Framework/Interfaces/IUrlModule.cs1
-rw-r--r--OpenSim/Region/Framework/Interfaces/IWorldComm.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs19
-rw-r--r--OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs12
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs49
-rw-r--r--OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs9
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs14
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs26
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Permissions.cs17
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs416
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs31
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs91
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs32
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs182
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs439
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs20
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs45
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs72
-rw-r--r--OpenSim/Region/Framework/Scenes/SimStatsReporter.cs300
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs10
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs10
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs154
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs130
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs19
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs455
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs2
51 files changed, 2081 insertions, 833 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
index 32f4eea..c605fc1 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
@@ -166,6 +166,19 @@ namespace OpenSim.Region.Framework.Interfaces
166 List<TaskInventoryItem> GetInventoryItems(); 166 List<TaskInventoryItem> GetInventoryItems();
167 167
168 /// <summary> 168 /// <summary>
169 /// Gets an inventory item by name
170 /// </summary>
171 /// <remarks>
172 /// This method returns the first inventory item that matches the given name. In SL this is all you need
173 /// since each item in a prim inventory must have a unique name.
174 /// </remarks>
175 /// <param name='name'></param>
176 /// <returns>
177 /// The inventory item. Null if no such item was found.
178 /// </returns>
179 TaskInventoryItem GetInventoryItem(string name);
180
181 /// <summary>
169 /// Get inventory items by name. 182 /// Get inventory items by name.
170 /// </summary> 183 /// </summary>
171 /// <param name="name"></param> 184 /// <param name="name"></param>
@@ -174,7 +187,17 @@ namespace OpenSim.Region.Framework.Interfaces
174 /// If no inventory item has that name then an empty list is returned. 187 /// If no inventory item has that name then an empty list is returned.
175 /// </returns> 188 /// </returns>
176 List<TaskInventoryItem> GetInventoryItems(string name); 189 List<TaskInventoryItem> GetInventoryItems(string name);
177 190
191 /// <summary>
192 /// Get inventory items by type.
193 /// </summary>
194 /// <param type="name"></param>
195 /// <returns>
196 /// A list of inventory items of that type.
197 /// If no inventory items of that type then an empty list is returned.
198 /// </returns>
199 List<TaskInventoryItem> GetInventoryItems(InventoryType type);
200
178 /// <summary> 201 /// <summary>
179 /// Get the scene object referenced by an inventory item. 202 /// Get the scene object referenced by an inventory item.
180 /// </summary> 203 /// </summary>
@@ -228,6 +251,16 @@ namespace OpenSim.Region.Framework.Interfaces
228 bool ContainsScripts(); 251 bool ContainsScripts();
229 252
230 /// <summary> 253 /// <summary>
254 /// Returns the count of scripts contained
255 /// </summary></returns>
256 int ScriptCount();
257
258 /// <summary>
259 /// Returns the count of running scripts contained
260 /// </summary></returns>
261 int RunningScriptCount();
262
263 /// <summary>
231 /// Get the uuids of all items in this inventory 264 /// Get the uuids of all items in this inventory
232 /// </summary> 265 /// </summary>
233 /// <returns></returns> 266 /// <returns></returns>
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
index 76f1641..5bc8e51 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs
@@ -39,13 +39,30 @@ namespace OpenSim.Region.Framework.Interfaces
39 39
40 public interface IEntityTransferModule 40 public interface IEntityTransferModule
41 { 41 {
42 void Teleport(ScenePresence agent, ulong regionHandle, Vector3 position, 42 /// <summary>
43 Vector3 lookAt, uint teleportFlags); 43 /// Teleport an agent within the same or to a different region.
44 /// </summary>
45 /// <param name='agent'></param>
46 /// <param name='regionHandle'>
47 /// The handle of the destination region. If it's the same as the region currently
48 /// occupied by the agent then the teleport will be within that region.
49 /// </param>
50 /// <param name='position'></param>
51 /// <param name='lookAt'></param>
52 /// <param name='teleportFlags'></param>
53 void Teleport(ScenePresence agent, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags);
44 54
45 bool TeleportHome(UUID id, IClientAPI client); 55 bool TeleportHome(UUID id, IClientAPI client);
46 56
47 void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination, 57 void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination,
48 Vector3 position, Vector3 lookAt, uint teleportFlags, IEventQueue eq); 58 Vector3 position, Vector3 lookAt, uint teleportFlags);
59
60 /// <summary>
61 /// Show whether the given agent is being teleported.
62 /// </summary>
63 /// <param name='id'>The agent ID</para></param>
64 /// <returns>true if the agent is in the process of being teleported, false otherwise.</returns>
65 bool IsInTransit(UUID id);
49 66
50 bool Cross(ScenePresence agent, bool isFlying); 67 bool Cross(ScenePresence agent, bool isFlying);
51 68
diff --git a/OpenSim/Region/Framework/Interfaces/IEnvironmentModule.cs b/OpenSim/Region/Framework/Interfaces/IEnvironmentModule.cs
new file mode 100644
index 0000000..7a7b782
--- /dev/null
+++ b/OpenSim/Region/Framework/Interfaces/IEnvironmentModule.cs
@@ -0,0 +1,36 @@
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
28using OpenMetaverse;
29
30namespace OpenSim.Region.Framework.Interfaces
31{
32 public interface IEnvironmentModule
33 {
34 void ResetEnvironmentSettings(UUID regionUUID);
35 }
36}
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/IInventoryAccessModule.cs b/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs
index 1904011..3576e35 100644
--- a/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs
@@ -49,11 +49,15 @@ namespace OpenSim.Region.Framework.Interfaces
49 /// <param name="folderID"></param> 49 /// <param name="folderID"></param>
50 /// <param name="objectGroups"></param> 50 /// <param name="objectGroups"></param>
51 /// <param name="remoteClient"></param> 51 /// <param name="remoteClient"></param>
52 /// <param name="asAttachment">
53 /// Should be true if the object(s) are begin taken as attachments. False otherwise.
54 /// </param>
52 /// <returns> 55 /// <returns>
53 /// Returns the UUID of the newly created item asset (not the item itself). 56 /// A list of the items created. If there was more than one object and objects are not being coaleseced in
54 /// FIXME: This is not very useful. It would be far more useful to return a list of items instead. 57 /// inventory, then the order of items is in the same order as the input objects.
55 /// </returns> 58 /// </returns>
56 UUID CopyToInventory(DeRezAction action, UUID folderID, List<SceneObjectGroup> objectGroups, IClientAPI remoteClient); 59 List<InventoryItemBase> CopyToInventory(
60 DeRezAction action, UUID folderID, List<SceneObjectGroup> objectGroups, IClientAPI remoteClient, bool asAttachment);
57 61
58 /// <summary> 62 /// <summary>
59 /// Rez an object into the scene from the user's inventory 63 /// Rez an object into the scene from the user's inventory
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
28using System;
29using System.Reflection;
30using OpenMetaverse;
31
32namespace 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/INPCModule.cs b/OpenSim/Region/Framework/Interfaces/INPCModule.cs
index dc3ff89..860483d 100644
--- a/OpenSim/Region/Framework/Interfaces/INPCModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/INPCModule.cs
@@ -113,9 +113,11 @@ namespace OpenSim.Region.Framework.Interfaces
113 /// </param> 113 /// </param>
114 /// <param name="landAtTarget"> 114 /// <param name="landAtTarget">
115 /// If true and the avatar is flying when it reaches the target, land. 115 /// If true and the avatar is flying when it reaches the target, land.
116 /// </param> 116 /// </param> name="running">
117 /// If true, NPC moves with running speed.
117 /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns> 118 /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns>
118 bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget); 119 ///
120 bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget, bool running);
119 121
120 /// <summary> 122 /// <summary>
121 /// Stop the NPC's current movement. 123 /// Stop the NPC's current movement.
@@ -135,6 +137,36 @@ namespace OpenSim.Region.Framework.Interfaces
135 bool Say(UUID agentID, Scene scene, string text); 137 bool Say(UUID agentID, Scene scene, string text);
136 138
137 /// <summary> 139 /// <summary>
140 /// Get the NPC to say something.
141 /// </summary>
142 /// <param name="agentID">The UUID of the NPC</param>
143 /// <param name="scene"></param>
144 /// <param name="text"></param>
145 /// <param name="channel"></param>
146 /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns>
147 bool Say(UUID agentID, Scene scene, string text, int channel);
148
149 /// <summary>
150 /// Get the NPC to shout something.
151 /// </summary>
152 /// <param name="agentID">The UUID of the NPC</param>
153 /// <param name="scene"></param>
154 /// <param name="text"></param>
155 /// <param name="channel"></param>
156 /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns>
157 bool Shout(UUID agentID, Scene scene, string text, int channel);
158
159 /// <summary>
160 /// Get the NPC to whisper something.
161 /// </summary>
162 /// <param name="agentID">The UUID of the NPC</param>
163 /// <param name="scene"></param>
164 /// <param name="text"></param>
165 /// <param name="channel"></param>
166 /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns>
167 bool Whisper(UUID agentID, Scene scene, string text, int channel);
168
169 /// <summary>
138 /// Sit the NPC. 170 /// Sit the NPC.
139 /// </summary> 171 /// </summary>
140 /// <param name="agentID"></param> 172 /// <param name="agentID"></param>
diff --git a/OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs
new file mode 100644
index 0000000..e03ac5a
--- /dev/null
+++ b/OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs
@@ -0,0 +1,59 @@
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
28using System;
29using System.Collections.Generic;
30using System.Linq;
31using System.Text;
32using OpenSim.Region.Framework.Scenes;
33using System.IO;
34using OpenMetaverse;
35
36namespace OpenSim.Region.Framework.Interfaces
37{
38 public interface IRegionCombinerModule
39 {
40 /// <summary>
41 /// Does the given id belong to the root region of a megaregion?
42 /// </summary>
43 bool IsRootForMegaregion(UUID regionId);
44
45 /// <summary>
46 /// Gets the size of megaregion.
47 /// </summary>
48 /// <remarks>
49 /// Returns size in meters.
50 /// Do not rely on this method remaining the same - this area is actively under development.
51 /// </remarks>
52 /// <param name="sceneId">
53 /// The id of the root region for a megaregion.
54 /// This may change in the future to allow any region id that makes up a megaregion.
55 /// Currently, will throw an exception if this does not match a root region.
56 /// </param>
57 Vector2 GetSizeOfMegaregion(UUID regionId);
58 }
59} \ No newline at end of file
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/Interfaces/ISimulationDataService.cs b/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs
index 5295a72..0fcafcc 100644
--- a/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs
+++ b/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs
@@ -95,5 +95,26 @@ namespace OpenSim.Region.Framework.Interfaces
95 RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID); 95 RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID);
96 void StoreRegionWindlightSettings(RegionLightShareData wl); 96 void StoreRegionWindlightSettings(RegionLightShareData wl);
97 void RemoveRegionWindlightSettings(UUID regionID); 97 void RemoveRegionWindlightSettings(UUID regionID);
98
99 /// <summary>
100 /// Load Environment settings from region storage
101 /// </summary>
102 /// <param name="regionUUID">the region UUID</param>
103 /// <returns>LLSD string for viewer</returns>
104 string LoadRegionEnvironmentSettings(UUID regionUUID);
105
106 /// <summary>
107 /// Store Environment settings into region storage
108 /// </summary>
109 /// <param name="regionUUID">the region UUID</param>
110 /// <param name="settings">LLSD string from viewer</param>
111 void StoreRegionEnvironmentSettings(UUID regionUUID, string settings);
112
113 /// <summary>
114 /// Delete Environment settings from region storage
115 /// </summary>
116 /// <param name="regionUUID">the region UUID</param>
117 void RemoveRegionEnvironmentSettings(UUID regionUUID);
118
98 } 119 }
99} 120}
diff --git a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs
index 615f377..e424976 100644
--- a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs
+++ b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs
@@ -107,6 +107,26 @@ namespace OpenSim.Region.Framework.Interfaces
107 void StoreRegionWindlightSettings(RegionLightShareData wl); 107 void StoreRegionWindlightSettings(RegionLightShareData wl);
108 void RemoveRegionWindlightSettings(UUID regionID); 108 void RemoveRegionWindlightSettings(UUID regionID);
109 109
110 /// <summary>
111 /// Load Environment settings from region storage
112 /// </summary>
113 /// <param name="regionUUID">the region UUID</param>
114 /// <returns>LLSD string for viewer</returns>
115 string LoadRegionEnvironmentSettings(UUID regionUUID);
116
117 /// <summary>
118 /// Store Environment settings into region storage
119 /// </summary>
120 /// <param name="regionUUID">the region UUID</param>
121 /// <param name="settings">LLSD string from viewer</param>
122 void StoreRegionEnvironmentSettings(UUID regionUUID, string settings);
123
124 /// <summary>
125 /// Delete Environment settings from region storage
126 /// </summary>
127 /// <param name="regionUUID">the region UUID</param>
128 void RemoveRegionEnvironmentSettings(UUID regionUUID);
129
110 void Shutdown(); 130 void Shutdown();
111 } 131 }
112} 132}
diff --git a/OpenSim/Region/Framework/Interfaces/IUrlModule.cs b/OpenSim/Region/Framework/Interfaces/IUrlModule.cs
index 1b91166..457444c 100644
--- a/OpenSim/Region/Framework/Interfaces/IUrlModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IUrlModule.cs
@@ -34,6 +34,7 @@ namespace OpenSim.Region.Framework.Interfaces
34{ 34{
35 public interface IUrlModule 35 public interface IUrlModule
36 { 36 {
37 string ExternalHostNameForLSL { get; }
37 UUID RequestURL(IScriptModule engine, SceneObjectPart host, UUID itemID); 38 UUID RequestURL(IScriptModule engine, SceneObjectPart host, UUID itemID);
38 UUID RequestSecureURL(IScriptModule engine, SceneObjectPart host, UUID itemID); 39 UUID RequestSecureURL(IScriptModule engine, SceneObjectPart host, UUID itemID);
39 void ReleaseURL(string url); 40 void ReleaseURL(string url);
diff --git a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs
index e8e375e..4e74781 100644
--- a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs
+++ b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs
@@ -103,7 +103,7 @@ namespace OpenSim.Region.Framework.Interfaces
103 /// <param name='msg'> 103 /// <param name='msg'>
104 /// Message. 104 /// Message.
105 /// </param> 105 /// </param>
106 bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error); 106 void DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg);
107 107
108 /// <summary> 108 /// <summary>
109 /// Are there any listen events ready to be dispatched? 109 /// Are there any listen events ready to be dispatched?
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
index e577958..9ddac19 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
@@ -294,6 +294,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation
294 return "FALLDOWN"; 294 return "FALLDOWN";
295 } 295 }
296 296
297 // Check if the user has stopped walking just now
298 if (CurrentMovementAnimation == "WALK" && (move == Vector3.Zero))
299 return "STAND";
300
297 return CurrentMovementAnimation; 301 return CurrentMovementAnimation;
298 } 302 }
299 303
@@ -418,13 +422,16 @@ namespace OpenSim.Region.Framework.Scenes.Animation
418 /// </summary> 422 /// </summary>
419 public void UpdateMovementAnimations() 423 public void UpdateMovementAnimations()
420 { 424 {
421 CurrentMovementAnimation = DetermineMovementAnimation(); 425 lock (m_animations)
426 {
427 CurrentMovementAnimation = DetermineMovementAnimation();
422 428
423// m_log.DebugFormat( 429// m_log.DebugFormat(
424// "[SCENE PRESENCE ANIMATOR]: Determined animation {0} for {1} in UpdateMovementAnimations()", 430// "[SCENE PRESENCE ANIMATOR]: Determined animation {0} for {1} in UpdateMovementAnimations()",
425// CurrentMovementAnimation, m_scenePresence.Name); 431// CurrentMovementAnimation, m_scenePresence.Name);
426 432
427 TrySetMovementAnimation(CurrentMovementAnimation); 433 TrySetMovementAnimation(CurrentMovementAnimation);
434 }
428 } 435 }
429 436
430 public UUID[] GetAnimationArray() 437 public UUID[] GetAnimationArray()
diff --git a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
index f678d07..f555b49 100644
--- a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
+++ b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
@@ -117,7 +117,7 @@ namespace OpenSim.Region.Framework.Scenes
117 117
118 private void InventoryRunDeleteTimer(object sender, ElapsedEventArgs e) 118 private void InventoryRunDeleteTimer(object sender, ElapsedEventArgs e)
119 { 119 {
120 m_log.Debug("[ASYNC DELETER]: Starting send to inventory loop"); 120// m_log.Debug("[ASYNC DELETER]: Starting send to inventory loop");
121 121
122 // We must set appearance parameters in the en_US culture in order to avoid issues where values are saved 122 // We must set appearance parameters in the en_US culture in order to avoid issues where values are saved
123 // in a culture where decimal points are commas and then reloaded in a culture which just treats them as 123 // in a culture where decimal points are commas and then reloaded in a culture which just treats them as
@@ -147,15 +147,15 @@ namespace OpenSim.Region.Framework.Scenes
147 { 147 {
148 x = m_inventoryDeletes.Dequeue(); 148 x = m_inventoryDeletes.Dequeue();
149 149
150 m_log.DebugFormat( 150// m_log.DebugFormat(
151 "[ASYNC DELETER]: Sending object to user's inventory, action {1}, count {2}, {0} item(s) remaining.", 151// "[ASYNC DELETER]: Sending object to user's inventory, action {1}, count {2}, {0} item(s) remaining.",
152 left, x.action, x.objectGroups.Count); 152// left, x.action, x.objectGroups.Count);
153 153
154 try 154 try
155 { 155 {
156 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>(); 156 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
157 if (invAccess != null) 157 if (invAccess != null)
158 invAccess.CopyToInventory(x.action, x.folderID, x.objectGroups, x.remoteClient); 158 invAccess.CopyToInventory(x.action, x.folderID, x.objectGroups, x.remoteClient, false);
159 159
160 if (x.permissionToDelete) 160 if (x.permissionToDelete)
161 { 161 {
@@ -185,7 +185,7 @@ namespace OpenSim.Region.Framework.Scenes
185 e.StackTrace); 185 e.StackTrace);
186 } 186 }
187 187
188 m_log.Debug("[ASYNC DELETER]: No objects left in inventory send queue."); 188// m_log.Debug("[ASYNC DELETER]: No objects left in inventory send queue.");
189 189
190 return false; 190 return false;
191 } 191 }
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 2365cfe..76a952b 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -53,6 +53,10 @@ namespace OpenSim.Region.Framework.Scenes
53 53
54 public event ClientMovement OnClientMovement; 54 public event ClientMovement OnClientMovement;
55 55
56 public delegate void OnTerrainTaintedDelegate();
57
58 public event OnTerrainTaintedDelegate OnTerrainTainted;
59
56 public delegate void OnTerrainTickDelegate(); 60 public delegate void OnTerrainTickDelegate();
57 61
58 public delegate void OnTerrainUpdateDelegate(); 62 public delegate void OnTerrainUpdateDelegate();
@@ -484,6 +488,9 @@ namespace OpenSim.Region.Framework.Scenes
484 public delegate void SceneObjectPartUpdated(SceneObjectPart sop); 488 public delegate void SceneObjectPartUpdated(SceneObjectPart sop);
485 public event SceneObjectPartUpdated OnSceneObjectPartUpdated; 489 public event SceneObjectPartUpdated OnSceneObjectPartUpdated;
486 490
491 public delegate void ScenePresenceUpdated(ScenePresence sp);
492 public event ScenePresenceUpdated OnScenePresenceUpdated;
493
487 public delegate void RegionUp(GridRegion region); 494 public delegate void RegionUp(GridRegion region);
488 public event RegionUp OnRegionUp; 495 public event RegionUp OnRegionUp;
489 496
@@ -935,6 +942,27 @@ namespace OpenSim.Region.Framework.Scenes
935 } 942 }
936 } 943 }
937 944
945 public void TriggerTerrainTainted()
946 {
947 OnTerrainTaintedDelegate handlerTerrainTainted = OnTerrainTainted;
948 if (handlerTerrainTainted != null)
949 {
950 foreach (OnTerrainTaintedDelegate d in handlerTerrainTainted.GetInvocationList())
951 {
952 try
953 {
954 d();
955 }
956 catch (Exception e)
957 {
958 m_log.ErrorFormat(
959 "[EVENT MANAGER]: Delegate for TriggerTerrainTainted failed - continuing. {0} {1}",
960 e.Message, e.StackTrace);
961 }
962 }
963 }
964 }
965
938 public void TriggerParcelPrimCountAdd(SceneObjectGroup obj) 966 public void TriggerParcelPrimCountAdd(SceneObjectGroup obj)
939 { 967 {
940 OnParcelPrimCountAddDelegate handlerParcelPrimCountAdd = OnParcelPrimCountAdd; 968 OnParcelPrimCountAddDelegate handlerParcelPrimCountAdd = OnParcelPrimCountAdd;
@@ -2367,6 +2395,27 @@ namespace OpenSim.Region.Framework.Scenes
2367 } 2395 }
2368 } 2396 }
2369 2397
2398 public void TriggerScenePresenceUpdated(ScenePresence sp)
2399 {
2400 ScenePresenceUpdated handler = OnScenePresenceUpdated;
2401 if (handler != null)
2402 {
2403 foreach (ScenePresenceUpdated d in handler.GetInvocationList())
2404 {
2405 try
2406 {
2407 d(sp);
2408 }
2409 catch (Exception e)
2410 {
2411 m_log.ErrorFormat(
2412 "[EVENT MANAGER]: Delegate for TriggerScenePresenceUpdated failed - continuing. {0} {1}",
2413 e.Message, e.StackTrace);
2414 }
2415 }
2416 }
2417 }
2418
2370 public void TriggerOnParcelPropertiesUpdateRequest(LandUpdateArgs args, 2419 public void TriggerOnParcelPropertiesUpdateRequest(LandUpdateArgs args,
2371 int local_id, IClientAPI remote_client) 2420 int local_id, IClientAPI remote_client)
2372 { 2421 {
diff --git a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
index 6c5685c..1365831 100644
--- a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
+++ b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
@@ -48,16 +48,19 @@ namespace OpenSim.Region.Framework.Scenes
48{ 48{
49 public class RegionStatsHandler : IStreamedRequestHandler 49 public class RegionStatsHandler : IStreamedRequestHandler
50 { 50 {
51 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52
51 private string osRXStatsURI = String.Empty; 53 private string osRXStatsURI = String.Empty;
52 private string osXStatsURI = String.Empty; 54 private string osXStatsURI = String.Empty;
53 //private string osSecret = String.Empty; 55 //private string osSecret = String.Empty;
54 private OpenSim.Framework.RegionInfo regionInfo; 56 private OpenSim.Framework.RegionInfo regionInfo;
55 public string localZone = TimeZone.CurrentTimeZone.StandardName; 57 public string localZone = TimeZone.CurrentTimeZone.StandardName;
56 public TimeSpan utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now); 58 public TimeSpan utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now);
57
58 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
59 59
60 public RegionStatsHandler(OpenSim.Framework.RegionInfo region_info) 60 public string Name { get { return "RegionStats"; } }
61 public string Description { get { return "Region Statistics"; } }
62
63 public RegionStatsHandler(RegionInfo region_info)
61 { 64 {
62 regionInfo = region_info; 65 regionInfo = region_info;
63 osRXStatsURI = Util.SHA1Hash(regionInfo.regionSecret); 66 osRXStatsURI = Util.SHA1Hash(regionInfo.regionSecret);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 29465c0..270b01b 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -300,6 +300,10 @@ namespace OpenSim.Region.Framework.Scenes
300 AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data, remoteClient.AgentId); 300 AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data, remoteClient.AgentId);
301 AssetService.Store(asset); 301 AssetService.Store(asset);
302 302
303// m_log.DebugFormat(
304// "[PRIM INVENTORY]: Stored asset {0} when updating item {1} in prim {2} for {3}",
305// asset.ID, item.Name, part.Name, remoteClient.Name);
306
303 if (isScriptRunning) 307 if (isScriptRunning)
304 { 308 {
305 part.Inventory.RemoveScriptInstance(item.ItemID, false); 309 part.Inventory.RemoveScriptInstance(item.ItemID, false);
@@ -950,8 +954,8 @@ namespace OpenSim.Region.Framework.Scenes
950 sbyte invType, sbyte type, UUID olditemID) 954 sbyte invType, sbyte type, UUID olditemID)
951 { 955 {
952// m_log.DebugFormat( 956// m_log.DebugFormat(
953// "[AGENT INVENTORY]: Received request from {0} to create inventory item link {1} in folder {2} pointing to {3}", 957// "[AGENT INVENTORY]: Received request from {0} to create inventory item link {1} in folder {2} pointing to {3}, assetType {4}, inventoryType {5}",
954// remoteClient.Name, name, folderID, olditemID); 958// remoteClient.Name, name, folderID, olditemID, (AssetType)type, (InventoryType)invType);
955 959
956 if (!Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) 960 if (!Permissions.CanCreateUserInventory(invType, remoteClient.AgentId))
957 return; 961 return;
@@ -984,10 +988,10 @@ namespace OpenSim.Region.Framework.Scenes
984 asset.Type = type; 988 asset.Type = type;
985 asset.Name = name; 989 asset.Name = name;
986 asset.Description = description; 990 asset.Description = description;
987 991
988 CreateNewInventoryItem( 992 CreateNewInventoryItem(
989 remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, name, 0, callbackID, asset, invType, 993 remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, name, 0, callbackID, asset, invType,
990 (uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All, 994 (uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All,
991 (uint)PermissionMask.All, (uint)PermissionMask.All, Util.UnixTimeSinceEpoch()); 995 (uint)PermissionMask.All, (uint)PermissionMask.All, Util.UnixTimeSinceEpoch());
992 } 996 }
993 else 997 else
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index 3ef1e29..cf68ff4 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -38,8 +38,9 @@ namespace OpenSim.Region.Framework.Scenes
38{ 38{
39 public partial class Scene 39 public partial class Scene
40 { 40 {
41
41 protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, 42 protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
42 UUID fromID, bool fromAgent, bool broadcast) 43 UUID fromID, UUID targetID, bool fromAgent, bool broadcast)
43 { 44 {
44 OSChatMessage args = new OSChatMessage(); 45 OSChatMessage args = new OSChatMessage();
45 46
@@ -63,14 +64,20 @@ namespace OpenSim.Region.Framework.Scenes
63 } 64 }
64 65
65 args.From = fromName; 66 args.From = fromName;
66 //args. 67 args.TargetUUID = targetID;
67 68
68 if (broadcast) 69 if (broadcast)
69 EventManager.TriggerOnChatBroadcast(this, args); 70 EventManager.TriggerOnChatBroadcast(this, args);
70 else 71 else
71 EventManager.TriggerOnChatFromWorld(this, args); 72 EventManager.TriggerOnChatFromWorld(this, args);
72 } 73 }
73 74
75 protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
76 UUID fromID, bool fromAgent, bool broadcast)
77 {
78 SimChat(message, type, channel, fromPos, fromName, fromID, UUID.Zero, fromAgent, broadcast);
79 }
80
74 /// <summary> 81 /// <summary>
75 /// 82 ///
76 /// </summary> 83 /// </summary>
@@ -108,6 +115,19 @@ namespace OpenSim.Region.Framework.Scenes
108 { 115 {
109 SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true); 116 SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true);
110 } 117 }
118 /// <summary>
119 ///
120 /// </summary>
121 /// <param name="message"></param>
122 /// <param name="type"></param>
123 /// <param name="fromPos"></param>
124 /// <param name="fromName"></param>
125 /// <param name="fromAgentID"></param>
126 /// <param name="targetID"></param>
127 public void SimChatToAgent(UUID targetID, byte[] message, Vector3 fromPos, string fromName, UUID fromID, bool fromAgent)
128 {
129 SimChat(message, ChatTypeEnum.Say, 0, fromPos, fromName, fromID, targetID, fromAgent, false);
130 }
111 131
112 /// <summary> 132 /// <summary>
113 /// Invoked when the client requests a prim. 133 /// Invoked when the client requests a prim.
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
index e1fedf4..535d87a 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
@@ -67,6 +67,7 @@ namespace OpenSim.Region.Framework.Scenes
67 public delegate bool RunConsoleCommandHandler(UUID user, Scene requestFromScene); 67 public delegate bool RunConsoleCommandHandler(UUID user, Scene requestFromScene);
68 public delegate bool IssueEstateCommandHandler(UUID user, Scene requestFromScene, bool ownerCommand); 68 public delegate bool IssueEstateCommandHandler(UUID user, Scene requestFromScene, bool ownerCommand);
69 public delegate bool IsGodHandler(UUID user, Scene requestFromScene); 69 public delegate bool IsGodHandler(UUID user, Scene requestFromScene);
70 public delegate bool IsGridGodHandler(UUID user, Scene requestFromScene);
70 public delegate bool IsAdministratorHandler(UUID user); 71 public delegate bool IsAdministratorHandler(UUID user);
71 public delegate bool EditParcelHandler(UUID user, ILandObject parcel, Scene scene); 72 public delegate bool EditParcelHandler(UUID user, ILandObject parcel, Scene scene);
72 public delegate bool EditParcelPropertiesHandler(UUID user, ILandObject parcel, GroupPowers p, Scene scene); 73 public delegate bool EditParcelPropertiesHandler(UUID user, ILandObject parcel, GroupPowers p, Scene scene);
@@ -134,6 +135,7 @@ namespace OpenSim.Region.Framework.Scenes
134 public event RunConsoleCommandHandler OnRunConsoleCommand; 135 public event RunConsoleCommandHandler OnRunConsoleCommand;
135 public event IssueEstateCommandHandler OnIssueEstateCommand; 136 public event IssueEstateCommandHandler OnIssueEstateCommand;
136 public event IsGodHandler OnIsGod; 137 public event IsGodHandler OnIsGod;
138 public event IsGridGodHandler OnIsGridGod;
137 public event IsAdministratorHandler OnIsAdministrator; 139 public event IsAdministratorHandler OnIsAdministrator;
138// public event EditParcelHandler OnEditParcel; 140// public event EditParcelHandler OnEditParcel;
139 public event EditParcelPropertiesHandler OnEditParcelProperties; 141 public event EditParcelPropertiesHandler OnEditParcelProperties;
@@ -728,6 +730,21 @@ namespace OpenSim.Region.Framework.Scenes
728 return true; 730 return true;
729 } 731 }
730 732
733 public bool IsGridGod(UUID user)
734 {
735 IsGridGodHandler handler = OnIsGridGod;
736 if (handler != null)
737 {
738 Delegate[] list = handler.GetInvocationList();
739 foreach (IsGridGodHandler h in list)
740 {
741 if (h(user, m_scene) == false)
742 return false;
743 }
744 }
745 return true;
746 }
747
731 public bool IsAdministrator(UUID user) 748 public bool IsAdministrator(UUID user)
732 { 749 {
733 IsAdministratorHandler handler = OnIsAdministrator; 750 IsAdministratorHandler handler = OnIsAdministrator;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 6a120c1..9c80d3e 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -77,7 +77,12 @@ namespace OpenSim.Region.Framework.Scenes
77 public bool DebugUpdates { get; private set; } 77 public bool DebugUpdates { get; private set; }
78 78
79 public SynchronizeSceneHandler SynchronizeScene; 79 public SynchronizeSceneHandler SynchronizeScene;
80 public SimStatsReporter StatsReporter; 80
81 /// <summary>
82 /// Statistical information for this scene.
83 /// </summary>
84 public SimStatsReporter StatsReporter { get; private set; }
85
81 public List<Border> NorthBorders = new List<Border>(); 86 public List<Border> NorthBorders = new List<Border>();
82 public List<Border> EastBorders = new List<Border>(); 87 public List<Border> EastBorders = new List<Border>();
83 public List<Border> SouthBorders = new List<Border>(); 88 public List<Border> SouthBorders = new List<Border>();
@@ -103,6 +108,7 @@ namespace OpenSim.Region.Framework.Scenes
103 public bool m_trustBinaries; 108 public bool m_trustBinaries;
104 public bool m_allowScriptCrossings; 109 public bool m_allowScriptCrossings;
105 public bool m_useFlySlow; 110 public bool m_useFlySlow;
111 public bool m_useTrashOnDelete = true;
106 112
107 /// <summary> 113 /// <summary>
108 /// Temporarily setting to trigger appearance resends at 60 second intervals. 114 /// Temporarily setting to trigger appearance resends at 60 second intervals.
@@ -163,7 +169,6 @@ namespace OpenSim.Region.Framework.Scenes
163 protected IConfigSource m_config; 169 protected IConfigSource m_config;
164 protected IRegionSerialiserModule m_serialiser; 170 protected IRegionSerialiserModule m_serialiser;
165 protected IDialogModule m_dialogModule; 171 protected IDialogModule m_dialogModule;
166 protected IEntityTransferModule m_teleportModule;
167 protected ICapabilitiesModule m_capsModule; 172 protected ICapabilitiesModule m_capsModule;
168 protected IGroupsModule m_groupsModule; 173 protected IGroupsModule m_groupsModule;
169 174
@@ -217,6 +222,7 @@ namespace OpenSim.Region.Framework.Scenes
217 private int backupMS; 222 private int backupMS;
218 private int terrainMS; 223 private int terrainMS;
219 private int landMS; 224 private int landMS;
225 private int spareMS;
220 226
221 /// <summary> 227 /// <summary>
222 /// Tick at which the last frame was processed. 228 /// Tick at which the last frame was processed.
@@ -458,6 +464,7 @@ namespace OpenSim.Region.Framework.Scenes
458 { 464 {
459 if (m_simulationService == null) 465 if (m_simulationService == null)
460 m_simulationService = RequestModuleInterface<ISimulationService>(); 466 m_simulationService = RequestModuleInterface<ISimulationService>();
467
461 return m_simulationService; 468 return m_simulationService;
462 } 469 }
463 } 470 }
@@ -513,6 +520,7 @@ namespace OpenSim.Region.Framework.Scenes
513 } 520 }
514 521
515 public IAttachmentsModule AttachmentsModule { get; set; } 522 public IAttachmentsModule AttachmentsModule { get; set; }
523 public IEntityTransferModule EntityTransferModule { get; private set; }
516 524
517 public IAvatarFactoryModule AvatarFactory 525 public IAvatarFactoryModule AvatarFactory
518 { 526 {
@@ -589,6 +597,20 @@ namespace OpenSim.Region.Framework.Scenes
589 get { return m_sceneGraph.Entities; } 597 get { return m_sceneGraph.Entities; }
590 } 598 }
591 599
600
601 // used in sequence see: SpawnPoint()
602 private int m_SpawnPoint;
603 // can be closest/random/sequence
604 public string SpawnPointRouting
605 {
606 get; private set;
607 }
608 // allow landmarks to pass
609 public bool TelehubAllowLandmarks
610 {
611 get; private set;
612 }
613
592 #endregion Properties 614 #endregion Properties
593 615
594 #region Constructors 616 #region Constructors
@@ -606,7 +628,7 @@ namespace OpenSim.Region.Framework.Scenes
606 628
607 Random random = new Random(); 629 Random random = new Random();
608 630
609 m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4); 631 m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue / 2)) + (uint)(uint.MaxValue / 4);
610 m_moduleLoader = moduleLoader; 632 m_moduleLoader = moduleLoader;
611 m_authenticateHandler = authen; 633 m_authenticateHandler = authen;
612 m_sceneGridService = sceneGridService; 634 m_sceneGridService = sceneGridService;
@@ -726,6 +748,9 @@ namespace OpenSim.Region.Framework.Scenes
726 m_maxPhys = RegionInfo.PhysPrimMax; 748 m_maxPhys = RegionInfo.PhysPrimMax;
727 } 749 }
728 750
751 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest");
752 TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false);
753
729 // Here, if clamping is requested in either global or 754 // Here, if clamping is requested in either global or
730 // local config, it will be used 755 // local config, it will be used
731 // 756 //
@@ -735,6 +760,7 @@ namespace OpenSim.Region.Framework.Scenes
735 m_clampPrimSize = true; 760 m_clampPrimSize = true;
736 } 761 }
737 762
763 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete);
738 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); 764 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
739 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); 765 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
740 m_dontPersistBefore = 766 m_dontPersistBefore =
@@ -833,13 +859,11 @@ namespace OpenSim.Region.Framework.Scenes
833 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; 859 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;
834 } 860 }
835 861
836 /// <summary>
837 /// Mock constructor for scene group persistency unit tests.
838 /// SceneObjectGroup RegionId property is delegated to Scene.
839 /// </summary>
840 /// <param name="regInfo"></param>
841 public Scene(RegionInfo regInfo) 862 public Scene(RegionInfo regInfo)
842 { 863 {
864 PhysicalPrims = true;
865 CollidablePrims = true;
866
843 BordersLocked = true; 867 BordersLocked = true;
844 Border northBorder = new Border(); 868 Border northBorder = new Border();
845 northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<--- 869 northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<---
@@ -866,8 +890,6 @@ namespace OpenSim.Region.Framework.Scenes
866 m_eventManager = new EventManager(); 890 m_eventManager = new EventManager();
867 891
868 m_permissions = new ScenePermissions(this); 892 m_permissions = new ScenePermissions(this);
869
870// m_lastUpdate = Util.EnvironmentTickCount();
871 } 893 }
872 894
873 #endregion 895 #endregion
@@ -936,8 +958,8 @@ namespace OpenSim.Region.Framework.Scenes
936 List<ulong> old = new List<ulong>(); 958 List<ulong> old = new List<ulong>();
937 old.Add(otherRegion.RegionHandle); 959 old.Add(otherRegion.RegionHandle);
938 agent.DropOldNeighbours(old); 960 agent.DropOldNeighbours(old);
939 if (m_teleportModule != null && agent.PresenceType != PresenceType.Npc) 961 if (EntityTransferModule != null && agent.PresenceType != PresenceType.Npc)
940 m_teleportModule.EnableChildAgent(agent, otherRegion); 962 EntityTransferModule.EnableChildAgent(agent, otherRegion);
941 }); 963 });
942 } 964 }
943 catch (NullReferenceException) 965 catch (NullReferenceException)
@@ -1044,13 +1066,13 @@ namespace OpenSim.Region.Framework.Scenes
1044 } 1066 }
1045 } 1067 }
1046 1068
1069 m_log.Error("[REGION]: Closing");
1070 Close();
1071
1047 if (PhysicsScene != null) 1072 if (PhysicsScene != null)
1048 { 1073 {
1049 PhysicsScene.Dispose(); 1074 PhysicsScene.Dispose();
1050 } 1075 }
1051
1052 m_log.Error("[REGION]: Closing");
1053 Close();
1054 1076
1055 m_log.Error("[REGION]: Firing Region Restart Message"); 1077 m_log.Error("[REGION]: Firing Region Restart Message");
1056 1078
@@ -1074,8 +1096,8 @@ namespace OpenSim.Region.Framework.Scenes
1074 { 1096 {
1075 ForEachRootScenePresence(delegate(ScenePresence agent) 1097 ForEachRootScenePresence(delegate(ScenePresence agent)
1076 { 1098 {
1077 if (m_teleportModule != null && agent.PresenceType != PresenceType.Npc) 1099 if (EntityTransferModule != null && agent.PresenceType != PresenceType.Npc)
1078 m_teleportModule.EnableChildAgent(agent, r); 1100 EntityTransferModule.EnableChildAgent(agent, r);
1079 }); 1101 });
1080 } 1102 }
1081 catch (NullReferenceException) 1103 catch (NullReferenceException)
@@ -1265,7 +1287,7 @@ namespace OpenSim.Region.Framework.Scenes
1265 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>(); 1287 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>();
1266 m_dialogModule = RequestModuleInterface<IDialogModule>(); 1288 m_dialogModule = RequestModuleInterface<IDialogModule>();
1267 m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); 1289 m_capsModule = RequestModuleInterface<ICapabilitiesModule>();
1268 m_teleportModule = RequestModuleInterface<IEntityTransferModule>(); 1290 EntityTransferModule = RequestModuleInterface<IEntityTransferModule>();
1269 m_groupsModule = RequestModuleInterface<IGroupsModule>(); 1291 m_groupsModule = RequestModuleInterface<IGroupsModule>();
1270 } 1292 }
1271 1293
@@ -1387,37 +1409,41 @@ namespace OpenSim.Region.Framework.Scenes
1387 endFrame = Frame + frames; 1409 endFrame = Frame + frames;
1388 1410
1389 float physicsFPS = 0f; 1411 float physicsFPS = 0f;
1390 int tmpPhysicsMS, tmpPhysicsMS2, tmpAgentMS, tmpTempOnRezMS, evMS, backMS, terMS; 1412 int previousFrameTick, tmpMS;
1391 int previousFrameTick; 1413 int maintc = Util.EnvironmentTickCount();
1392 int maintc;
1393 int sleepMS;
1394 int framestart;
1395 1414
1396 while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) 1415 while (!m_shuttingDown && (endFrame == null || Frame < endFrame))
1397 { 1416 {
1398 framestart = Util.EnvironmentTickCount();
1399 ++Frame; 1417 ++Frame;
1400 1418
1401// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); 1419// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName);
1402 1420
1403 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; 1421 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0;
1404 1422
1405 try 1423 try
1406 { 1424 {
1407 tmpPhysicsMS2 = Util.EnvironmentTickCount(); 1425 // Apply taints in terrain module to terrain in physics scene
1426 if (Frame % m_update_terrain == 0)
1427 {
1428 tmpMS = Util.EnvironmentTickCount();
1429 UpdateTerrain();
1430 terrainMS = Util.EnvironmentTickCountSubtract(tmpMS);
1431 }
1432
1433 tmpMS = Util.EnvironmentTickCount();
1408 if ((Frame % m_update_physics == 0) && m_physics_enabled) 1434 if ((Frame % m_update_physics == 0) && m_physics_enabled)
1409 m_sceneGraph.UpdatePreparePhysics(); 1435 m_sceneGraph.UpdatePreparePhysics();
1410 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2); 1436 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpMS);
1411 1437
1412 // Apply any pending avatar force input to the avatar's velocity 1438 // Apply any pending avatar force input to the avatar's velocity
1413 tmpAgentMS = Util.EnvironmentTickCount(); 1439 tmpMS = Util.EnvironmentTickCount();
1414 if (Frame % m_update_entitymovement == 0) 1440 if (Frame % m_update_entitymovement == 0)
1415 m_sceneGraph.UpdateScenePresenceMovement(); 1441 m_sceneGraph.UpdateScenePresenceMovement();
1416 agentMS = Util.EnvironmentTickCountSubtract(tmpAgentMS); 1442 agentMS = Util.EnvironmentTickCountSubtract(tmpMS);
1417 1443
1418 // Perform the main physics update. This will do the actual work of moving objects and avatars according to their 1444 // Perform the main physics update. This will do the actual work of moving objects and avatars according to their
1419 // velocity 1445 // velocity
1420 tmpPhysicsMS = Util.EnvironmentTickCount(); 1446 tmpMS = Util.EnvironmentTickCount();
1421 if (Frame % m_update_physics == 0) 1447 if (Frame % m_update_physics == 0)
1422 { 1448 {
1423 if (m_physics_enabled) 1449 if (m_physics_enabled)
@@ -1426,9 +1452,9 @@ namespace OpenSim.Region.Framework.Scenes
1426 if (SynchronizeScene != null) 1452 if (SynchronizeScene != null)
1427 SynchronizeScene(this); 1453 SynchronizeScene(this);
1428 } 1454 }
1429 physicsMS = Util.EnvironmentTickCountSubtract(tmpPhysicsMS); 1455 physicsMS = Util.EnvironmentTickCountSubtract(tmpMS);
1430 1456
1431 tmpAgentMS = Util.EnvironmentTickCount(); 1457 tmpMS = Util.EnvironmentTickCount();
1432 1458
1433 // Check if any objects have reached their targets 1459 // Check if any objects have reached their targets
1434 CheckAtTargets(); 1460 CheckAtTargets();
@@ -1443,36 +1469,29 @@ namespace OpenSim.Region.Framework.Scenes
1443 if (Frame % m_update_presences == 0) 1469 if (Frame % m_update_presences == 0)
1444 m_sceneGraph.UpdatePresences(); 1470 m_sceneGraph.UpdatePresences();
1445 1471
1446 agentMS += Util.EnvironmentTickCountSubtract(tmpAgentMS); 1472 agentMS += Util.EnvironmentTickCountSubtract(tmpMS);
1447 1473
1448 // Delete temp-on-rez stuff 1474 // Delete temp-on-rez stuff
1449 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) 1475 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps)
1450 { 1476 {
1451 tmpTempOnRezMS = Util.EnvironmentTickCount(); 1477 tmpMS = Util.EnvironmentTickCount();
1452 m_cleaningTemps = true; 1478 m_cleaningTemps = true;
1453 Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; }); 1479 Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; });
1454 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS); 1480 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpMS);
1455 } 1481 }
1456 1482
1457 if (Frame % m_update_events == 0) 1483 if (Frame % m_update_events == 0)
1458 { 1484 {
1459 evMS = Util.EnvironmentTickCount(); 1485 tmpMS = Util.EnvironmentTickCount();
1460 UpdateEvents(); 1486 UpdateEvents();
1461 eventMS = Util.EnvironmentTickCountSubtract(evMS); 1487 eventMS = Util.EnvironmentTickCountSubtract(tmpMS);
1462 } 1488 }
1463 1489
1464 if (Frame % m_update_backup == 0) 1490 if (Frame % m_update_backup == 0)
1465 { 1491 {
1466 backMS = Util.EnvironmentTickCount(); 1492 tmpMS = Util.EnvironmentTickCount();
1467 UpdateStorageBackup(); 1493 UpdateStorageBackup();
1468 backupMS = Util.EnvironmentTickCountSubtract(backMS); 1494 backupMS = Util.EnvironmentTickCountSubtract(tmpMS);
1469 }
1470
1471 if (Frame % m_update_terrain == 0)
1472 {
1473 terMS = Util.EnvironmentTickCount();
1474 UpdateTerrain();
1475 terrainMS = Util.EnvironmentTickCountSubtract(terMS);
1476 } 1495 }
1477 1496
1478 //if (Frame % m_update_land == 0) 1497 //if (Frame % m_update_land == 0)
@@ -1481,29 +1500,6 @@ namespace OpenSim.Region.Framework.Scenes
1481 // UpdateLand(); 1500 // UpdateLand();
1482 // landMS = Util.EnvironmentTickCountSubtract(ldMS); 1501 // landMS = Util.EnvironmentTickCountSubtract(ldMS);
1483 //} 1502 //}
1484
1485 // frameMS = Util.EnvironmentTickCountSubtract(maintc);
1486 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1487
1488 // if (Frame%m_update_avatars == 0)
1489 // UpdateInWorldTime();
1490 StatsReporter.AddPhysicsFPS(physicsFPS);
1491 StatsReporter.AddTimeDilation(TimeDilation);
1492 StatsReporter.AddFPS(1);
1493 StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount());
1494 StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount());
1495 StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount());
1496 StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount());
1497
1498 // frameMS currently records work frame times, not total frame times (work + any required sleep to
1499 // reach min frame time.
1500 // StatsReporter.addFrameMS(frameMS);
1501
1502 StatsReporter.addAgentMS(agentMS);
1503 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1504 StatsReporter.addOtherMS(otherMS);
1505 StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount());
1506 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1507 1503
1508 if (LoginsDisabled && Frame == 20) 1504 if (LoginsDisabled && Frame == 20)
1509 { 1505 {
@@ -1554,23 +1550,36 @@ namespace OpenSim.Region.Framework.Scenes
1554 1550
1555 previousFrameTick = m_lastFrameTick; 1551 previousFrameTick = m_lastFrameTick;
1556 m_lastFrameTick = Util.EnvironmentTickCount(); 1552 m_lastFrameTick = Util.EnvironmentTickCount();
1557 maintc = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart); 1553 tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc);
1558 maintc = (int)(MinFrameTime * 1000) - maintc; 1554 tmpMS = (int)(MinFrameTime * 1000) - tmpMS;
1559 1555
1560 m_firstHeartbeat = false; 1556 m_firstHeartbeat = false;
1561 1557
1558 if (tmpMS > 0)
1559 {
1560 Thread.Sleep(tmpMS);
1561 spareMS += tmpMS;
1562 }
1562 1563
1563 sleepMS = Util.EnvironmentTickCount(); 1564 frameMS = Util.EnvironmentTickCountSubtract(maintc);
1565 maintc = Util.EnvironmentTickCount();
1564 1566
1565 if (maintc > 0) 1567 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1566 Thread.Sleep(maintc); 1568
1569 // if (Frame%m_update_avatars == 0)
1570 // UpdateInWorldTime();
1571 StatsReporter.AddPhysicsFPS(physicsFPS);
1572 StatsReporter.AddTimeDilation(TimeDilation);
1573 StatsReporter.AddFPS(1);
1567 1574
1568 sleepMS = Util.EnvironmentTickCountSubtract(sleepMS);
1569 frameMS = Util.EnvironmentTickCountSubtract(framestart);
1570 StatsReporter.addSleepMS(sleepMS);
1571 StatsReporter.addFrameMS(frameMS); 1575 StatsReporter.addFrameMS(frameMS);
1572 1576 StatsReporter.addAgentMS(agentMS);
1573 // Optionally warn if a frame takes double the amount of time that it should. 1577 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1578 StatsReporter.addOtherMS(otherMS);
1579 StatsReporter.AddSpareMS(spareMS);
1580 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1581
1582 // Optionally warn if a frame takes double the amount of time that it should.
1574 if (DebugUpdates 1583 if (DebugUpdates
1575 && Util.EnvironmentTickCountSubtract( 1584 && Util.EnvironmentTickCountSubtract(
1576 m_lastFrameTick, previousFrameTick) > (int)(MinFrameTime * 1000 * 2)) 1585 m_lastFrameTick, previousFrameTick) > (int)(MinFrameTime * 1000 * 2))
@@ -2363,8 +2372,8 @@ namespace OpenSim.Region.Framework.Scenes
2363 return; 2372 return;
2364 } 2373 }
2365 2374
2366 if (m_teleportModule != null) 2375 if (EntityTransferModule != null)
2367 m_teleportModule.Cross(grp, attemptedPosition, silent); 2376 EntityTransferModule.Cross(grp, attemptedPosition, silent);
2368 } 2377 }
2369 2378
2370 public Border GetCrossedBorder(Vector3 position, Cardinals gridline) 2379 public Border GetCrossedBorder(Vector3 position, Cardinals gridline)
@@ -2684,10 +2693,10 @@ namespace OpenSim.Region.Framework.Scenes
2684 { 2693 {
2685 SceneObjectGroup grp = sceneObject; 2694 SceneObjectGroup grp = sceneObject;
2686 2695
2687 m_log.DebugFormat( 2696// m_log.DebugFormat(
2688 "[ATTACHMENT]: Received attachment {0}, inworld asset id {1}", grp.FromItemID, grp.UUID); 2697// "[ATTACHMENT]: Received attachment {0}, inworld asset id {1}", grp.FromItemID, grp.UUID);
2689 m_log.DebugFormat( 2698// m_log.DebugFormat(
2690 "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition); 2699// "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition);
2691 2700
2692 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2701 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2693 2702
@@ -2783,7 +2792,8 @@ namespace OpenSim.Region.Framework.Scenes
2783 if (sp == null) 2792 if (sp == null)
2784 { 2793 {
2785 m_log.DebugFormat( 2794 m_log.DebugFormat(
2786 "[SCENE]: Adding new child scene presence {0} to scene {1} at pos {2}", client.Name, RegionInfo.RegionName, client.StartPos); 2795 "[SCENE]: Adding new child scene presence {0} {1} to scene {2} at pos {3}",
2796 client.Name, client.AgentId, RegionInfo.RegionName, client.StartPos);
2787 2797
2788 m_clientManager.Add(client); 2798 m_clientManager.Add(client);
2789 SubscribeToClientEvents(client); 2799 SubscribeToClientEvents(client);
@@ -3207,8 +3217,10 @@ namespace OpenSim.Region.Framework.Scenes
3207 /// <param name="client">The IClientAPI for the client</param> 3217 /// <param name="client">The IClientAPI for the client</param>
3208 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) 3218 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
3209 { 3219 {
3210 if (m_teleportModule != null) 3220 if (EntityTransferModule != null)
3211 return m_teleportModule.TeleportHome(agentId, client); 3221 {
3222 EntityTransferModule.TeleportHome(agentId, client);
3223 }
3212 else 3224 else
3213 { 3225 {
3214 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3226 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
@@ -3382,8 +3394,8 @@ namespace OpenSim.Region.Framework.Scenes
3382 try 3394 try
3383 { 3395 {
3384 m_log.DebugFormat( 3396 m_log.DebugFormat(
3385 "[SCENE]: Removing {0} agent {1} from region {2}", 3397 "[SCENE]: Removing {0} agent {1} {2} from region {3}",
3386 (isChildAgent ? "child" : "root"), agentID, RegionInfo.RegionName); 3398 (isChildAgent ? "child" : "root"), avatar.Name, agentID, RegionInfo.RegionName);
3387 3399
3388 m_sceneGraph.removeUserCount(!isChildAgent); 3400 m_sceneGraph.removeUserCount(!isChildAgent);
3389 3401
@@ -3554,7 +3566,7 @@ namespace OpenSim.Region.Framework.Scenes
3554 public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason, bool requirePresenceLookup) 3566 public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason, bool requirePresenceLookup)
3555 { 3567 {
3556 bool vialogin = ((teleportFlags & (uint)TPFlags.ViaLogin) != 0 || 3568 bool vialogin = ((teleportFlags & (uint)TPFlags.ViaLogin) != 0 ||
3557 (teleportFlags & (uint)TPFlags.ViaHGLogin) != 0); 3569 (teleportFlags & (uint)TPFlags.ViaHGLogin) != 0);
3558 bool viahome = ((teleportFlags & (uint)TPFlags.ViaHome) != 0); 3570 bool viahome = ((teleportFlags & (uint)TPFlags.ViaHome) != 0);
3559 bool godlike = ((teleportFlags & (uint)TPFlags.Godlike) != 0); 3571 bool godlike = ((teleportFlags & (uint)TPFlags.Godlike) != 0);
3560 3572
@@ -3570,8 +3582,17 @@ namespace OpenSim.Region.Framework.Scenes
3570 // Don't disable this log message - it's too helpful 3582 // Don't disable this log message - it's too helpful
3571 m_log.DebugFormat( 3583 m_log.DebugFormat(
3572 "[SCENE]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5}, IP {6}, viewer {7}, teleportflags ({8}), position {9})", 3584 "[SCENE]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5}, IP {6}, viewer {7}, teleportflags ({8}), position {9})",
3573 RegionInfo.RegionName, (agent.child ? "child" : "root"),agent.firstname, agent.lastname, 3585 RegionInfo.RegionName,
3574 agent.AgentID, agent.circuitcode, agent.IPAddress, agent.Viewer, ((TPFlags)teleportFlags).ToString(), agent.startpos); 3586 (agent.child ? "child" : "root"),
3587 agent.firstname,
3588 agent.lastname,
3589 agent.AgentID,
3590 agent.circuitcode,
3591 agent.IPAddress,
3592 agent.Viewer,
3593 ((TPFlags)teleportFlags).ToString(),
3594 agent.startpos
3595 );
3575 3596
3576 if (LoginsDisabled) 3597 if (LoginsDisabled)
3577 { 3598 {
@@ -3586,7 +3607,11 @@ namespace OpenSim.Region.Framework.Scenes
3586 // We have a zombie from a crashed session. 3607 // We have a zombie from a crashed session.
3587 // Or the same user is trying to be root twice here, won't work. 3608 // Or the same user is trying to be root twice here, won't work.
3588 // Kill it. 3609 // Kill it.
3589 m_log.DebugFormat("[SCENE]: Zombie scene presence detected for {0} in {1}", agent.AgentID, RegionInfo.RegionName); 3610 m_log.DebugFormat(
3611 "[SCENE]: Zombie scene presence detected for {0} in {1}",
3612 agent.AgentID,
3613 RegionInfo.RegionName
3614 );
3590 sp.ControllingClient.Close(); 3615 sp.ControllingClient.Close();
3591 sp = null; 3616 sp = null;
3592 } 3617 }
@@ -3613,8 +3638,7 @@ namespace OpenSim.Region.Framework.Scenes
3613 { 3638 {
3614 if (!VerifyUserPresence(agent, out reason)) 3639 if (!VerifyUserPresence(agent, out reason))
3615 return false; 3640 return false;
3616 } 3641 } catch (Exception e)
3617 catch (Exception e)
3618 { 3642 {
3619 m_log.ErrorFormat( 3643 m_log.ErrorFormat(
3620 "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace); 3644 "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace);
@@ -3649,8 +3673,7 @@ namespace OpenSim.Region.Framework.Scenes
3649 CapsModule.SetAgentCapsSeeds(agent); 3673 CapsModule.SetAgentCapsSeeds(agent);
3650 CapsModule.CreateCaps(agent.AgentID); 3674 CapsModule.CreateCaps(agent.AgentID);
3651 } 3675 }
3652 } 3676 } else
3653 else
3654 { 3677 {
3655 // Let the SP know how we got here. This has a lot of interesting 3678 // Let the SP know how we got here. This has a lot of interesting
3656 // uses down the line. 3679 // uses down the line.
@@ -3673,7 +3696,7 @@ namespace OpenSim.Region.Framework.Scenes
3673 agent.teleportFlags = teleportFlags; 3696 agent.teleportFlags = teleportFlags;
3674 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); 3697 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
3675 3698
3676 if (vialogin) 3699 if (vialogin)
3677 { 3700 {
3678// CleanDroppedAttachments(); 3701// CleanDroppedAttachments();
3679 3702
@@ -3714,8 +3737,7 @@ namespace OpenSim.Region.Framework.Scenes
3714 agent.startpos.Z = 720; 3737 agent.startpos.Z = 720;
3715 } 3738 }
3716 } 3739 }
3717 } 3740 } else
3718 else
3719 { 3741 {
3720 if (agent.startpos.X > EastBorders[0].BorderLine.Z) 3742 if (agent.startpos.X > EastBorders[0].BorderLine.Z)
3721 { 3743 {
@@ -3741,10 +3763,19 @@ namespace OpenSim.Region.Framework.Scenes
3741 SceneObjectGroup telehub = GetSceneObjectGroup(RegionInfo.RegionSettings.TelehubObject); 3763 SceneObjectGroup telehub = GetSceneObjectGroup(RegionInfo.RegionSettings.TelehubObject);
3742 // Can have multiple SpawnPoints 3764 // Can have multiple SpawnPoints
3743 List<SpawnPoint> spawnpoints = RegionInfo.RegionSettings.SpawnPoints(); 3765 List<SpawnPoint> spawnpoints = RegionInfo.RegionSettings.SpawnPoints();
3744 if ( spawnpoints.Count > 1) 3766 if (spawnpoints.Count > 1)
3745 { 3767 {
3746 // We have multiple SpawnPoints, Route the agent to a random one 3768 // We have multiple SpawnPoints, Route the agent to a random or sequential one
3747 agent.startpos = spawnpoints[Util.RandomClass.Next(spawnpoints.Count)].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); 3769 if (SpawnPointRouting == "random")
3770 agent.startpos = spawnpoints[Util.RandomClass.Next(spawnpoints.Count) - 1].GetLocation(
3771 telehub.AbsolutePosition,
3772 telehub.GroupRotation
3773 );
3774 else
3775 agent.startpos = spawnpoints[SpawnPoint()].GetLocation(
3776 telehub.AbsolutePosition,
3777 telehub.GroupRotation
3778 );
3748 } 3779 }
3749 else 3780 else
3750 { 3781 {
@@ -3981,41 +4012,41 @@ namespace OpenSim.Region.Framework.Scenes
3981 return m_authenticateHandler.TryChangeCiruitCode(oldcc, newcc); 4012 return m_authenticateHandler.TryChangeCiruitCode(oldcc, newcc);
3982 } 4013 }
3983 4014
3984 /// <summary> 4015// /// <summary>
3985 /// The Grid has requested that we log-off a user. Log them off. 4016// /// The Grid has requested that we log-off a user. Log them off.
3986 /// </summary> 4017// /// </summary>
3987 /// <param name="AvatarID">Unique ID of the avatar to log-off</param> 4018// /// <param name="AvatarID">Unique ID of the avatar to log-off</param>
3988 /// <param name="RegionSecret">SecureSessionID of the user, or the RegionSecret text when logging on to the grid</param> 4019// /// <param name="RegionSecret">SecureSessionID of the user, or the RegionSecret text when logging on to the grid</param>
3989 /// <param name="message">message to display to the user. Reason for being logged off</param> 4020// /// <param name="message">message to display to the user. Reason for being logged off</param>
3990 public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message) 4021// public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message)
3991 { 4022// {
3992 ScenePresence loggingOffUser = GetScenePresence(AvatarID); 4023// ScenePresence loggingOffUser = GetScenePresence(AvatarID);
3993 if (loggingOffUser != null) 4024// if (loggingOffUser != null)
3994 { 4025// {
3995 UUID localRegionSecret = UUID.Zero; 4026// UUID localRegionSecret = UUID.Zero;
3996 bool parsedsecret = UUID.TryParse(m_regInfo.regionSecret, out localRegionSecret); 4027// bool parsedsecret = UUID.TryParse(m_regInfo.regionSecret, out localRegionSecret);
3997 4028//
3998 // Region Secret is used here in case a new sessionid overwrites an old one on the user server. 4029// // Region Secret is used here in case a new sessionid overwrites an old one on the user server.
3999 // Will update the user server in a few revisions to use it. 4030// // Will update the user server in a few revisions to use it.
4000 4031//
4001 if (RegionSecret == loggingOffUser.ControllingClient.SecureSessionId || (parsedsecret && RegionSecret == localRegionSecret)) 4032// if (RegionSecret == loggingOffUser.ControllingClient.SecureSessionId || (parsedsecret && RegionSecret == localRegionSecret))
4002 { 4033// {
4003 m_sceneGridService.SendCloseChildAgentConnections(loggingOffUser.UUID, loggingOffUser.KnownRegionHandles); 4034// m_sceneGridService.SendCloseChildAgentConnections(loggingOffUser.UUID, loggingOffUser.KnownRegionHandles);
4004 loggingOffUser.ControllingClient.Kick(message); 4035// loggingOffUser.ControllingClient.Kick(message);
4005 // Give them a second to receive the message! 4036// // Give them a second to receive the message!
4006 Thread.Sleep(1000); 4037// Thread.Sleep(1000);
4007 loggingOffUser.ControllingClient.Close(); 4038// loggingOffUser.ControllingClient.Close();
4008 } 4039// }
4009 else 4040// else
4010 { 4041// {
4011 m_log.Info("[USERLOGOFF]: System sending the LogOff user message failed to sucessfully authenticate"); 4042// m_log.Info("[USERLOGOFF]: System sending the LogOff user message failed to sucessfully authenticate");
4012 } 4043// }
4013 } 4044// }
4014 else 4045// else
4015 { 4046// {
4016 m_log.InfoFormat("[USERLOGOFF]: Got a logoff request for {0} but the user isn't here. The user might already have been logged out", AvatarID.ToString()); 4047// m_log.InfoFormat("[USERLOGOFF]: Got a logoff request for {0} but the user isn't here. The user might already have been logged out", AvatarID.ToString());
4017 } 4048// }
4018 } 4049// }
4019 4050
4020 /// <summary> 4051 /// <summary>
4021 /// Triggered when an agent crosses into this sim. Also happens on initial login. 4052 /// Triggered when an agent crosses into this sim. Also happens on initial login.
@@ -4068,21 +4099,19 @@ namespace OpenSim.Region.Framework.Scenes
4068 return false; 4099 return false;
4069 } 4100 }
4070 4101
4102 // TODO: This check should probably be in QueryAccess().
4071 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 4103 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
4072 if (nearestParcel == null) 4104 if (nearestParcel == null)
4073 { 4105 {
4074 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: no allowed parcel", cAgentData.AgentID); 4106 m_log.DebugFormat(
4075 return false; 4107 "[SCENE]: Denying root agent entry to {0} in {1}: no allowed parcel",
4076 } 4108 cAgentData.AgentID, RegionInfo.RegionName);
4077
4078 int num = m_sceneGraph.GetNumberOfScenePresences();
4079 4109
4080 if (num >= RegionInfo.RegionSettings.AgentLimit) 4110 return false;
4081 {
4082 if (!Permissions.IsAdministrator(cAgentData.AgentID))
4083 return false;
4084 } 4111 }
4085 4112
4113 // We have to wait until the viewer contacts this region after receiving EAC.
4114 // That calls AddNewClient, which finally creates the ScenePresence
4086 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); 4115 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID);
4087 4116
4088 if (childAgentUpdate != null) 4117 if (childAgentUpdate != null)
@@ -4126,14 +4155,28 @@ namespace OpenSim.Region.Framework.Scenes
4126 return false; 4155 return false;
4127 } 4156 }
4128 4157
4158 /// <summary>
4159 /// Poll until the requested ScenePresence appears or we timeout.
4160 /// </summary>
4161 /// <returns>The scene presence is found, else null.</returns>
4162 /// <param name='agentID'></param>
4129 protected virtual ScenePresence WaitGetScenePresence(UUID agentID) 4163 protected virtual ScenePresence WaitGetScenePresence(UUID agentID)
4130 { 4164 {
4131 int ntimes = 10; 4165 int ntimes = 10;
4132 ScenePresence childAgentUpdate = null; 4166 ScenePresence sp = null;
4133 while ((childAgentUpdate = GetScenePresence(agentID)) == null && (ntimes-- > 0)) 4167 while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0))
4134 Thread.Sleep(1000); 4168 Thread.Sleep(1000);
4135 return childAgentUpdate;
4136 4169
4170 if (sp == null)
4171 m_log.WarnFormat(
4172 "[SCENE PRESENCE]: Did not find presence with id {0} in {1} before timeout",
4173 agentID, RegionInfo.RegionName);
4174// else
4175// m_log.DebugFormat(
4176// "[SCENE PRESENCE]: Found presence {0} {1} {2} in {3} after {4} waits",
4177// sp.Name, sp.UUID, sp.IsChildAgent ? "child" : "root", RegionInfo.RegionName, 10 - ntimes);
4178
4179 return sp;
4137 } 4180 }
4138 4181
4139 public virtual bool IncomingRetrieveRootAgent(UUID id, out IAgentData agent) 4182 public virtual bool IncomingRetrieveRootAgent(UUID id, out IAgentData agent)
@@ -4283,8 +4326,10 @@ namespace OpenSim.Region.Framework.Scenes
4283 position.Y -= shifty; 4326 position.Y -= shifty;
4284 } 4327 }
4285 4328
4286 if (m_teleportModule != null) 4329 if (EntityTransferModule != null)
4287 m_teleportModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags); 4330 {
4331 EntityTransferModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags);
4332 }
4288 else 4333 else
4289 { 4334 {
4290 m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active"); 4335 m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active");
@@ -4295,8 +4340,10 @@ namespace OpenSim.Region.Framework.Scenes
4295 4340
4296 public bool CrossAgentToNewRegion(ScenePresence agent, bool isFlying) 4341 public bool CrossAgentToNewRegion(ScenePresence agent, bool isFlying)
4297 { 4342 {
4298 if (m_teleportModule != null) 4343 if (EntityTransferModule != null)
4299 return m_teleportModule.Cross(agent, isFlying); 4344 {
4345 return EntityTransferModule.Cross(agent, isFlying);
4346 }
4300 else 4347 else
4301 { 4348 {
4302 m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule"); 4349 m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule");
@@ -5444,29 +5491,58 @@ Environment.Exit(1);
5444 throw new Exception(error); 5491 throw new Exception(error);
5445 } 5492 }
5446 5493
5447 // This method is called across the simulation connector to 5494 /// <summary>
5448 // determine if a given agent is allowed in this region 5495 /// This method is called across the simulation connector to
5449 // AS A ROOT AGENT. Returning false here will prevent them 5496 /// determine if a given agent is allowed in this region
5450 // from logging into the region, teleporting into the region 5497 /// AS A ROOT AGENT
5451 // or corssing the broder walking, but will NOT prevent 5498 /// </summary>
5452 // child agent creation, thereby emulating the SL behavior. 5499 /// <remarks>
5500 /// Returning false here will prevent them
5501 /// from logging into the region, teleporting into the region
5502 /// or corssing the broder walking, but will NOT prevent
5503 /// child agent creation, thereby emulating the SL behavior.
5504 /// </remarks>
5505 /// <param name='agentID'></param>
5506 /// <param name='position'></param>
5507 /// <param name='reason'></param>
5508 /// <returns></returns>
5453 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5509 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5454 { 5510 {
5455 reason = "You are banned from the region"; 5511 reason = "You are banned from the region";
5456 5512
5513 if (EntityTransferModule.IsInTransit(agentID))
5514 {
5515 reason = "Agent is still in transit from this region";
5516
5517 m_log.WarnFormat(
5518 "[SCENE]: Denying agent {0} entry into {1} since region still has them registered as in transit",
5519 agentID, RegionInfo.RegionName);
5520
5521 return false;
5522 }
5523
5457 if (Permissions.IsGod(agentID)) 5524 if (Permissions.IsGod(agentID))
5458 { 5525 {
5459 reason = String.Empty; 5526 reason = String.Empty;
5460 return true; 5527 return true;
5461 } 5528 }
5462 5529
5463 int num = m_sceneGraph.GetNumberOfScenePresences(); 5530 // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check.
5531 // However, the long term fix is to make sure root agent count is always accurate.
5532 m_sceneGraph.RecalculateStats();
5533
5534 int num = m_sceneGraph.GetRootAgentCount();
5464 5535
5465 if (num >= RegionInfo.RegionSettings.AgentLimit) 5536 if (num >= RegionInfo.RegionSettings.AgentLimit)
5466 { 5537 {
5467 if (!Permissions.IsAdministrator(agentID)) 5538 if (!Permissions.IsAdministrator(agentID))
5468 { 5539 {
5469 reason = "The region is full"; 5540 reason = "The region is full";
5541
5542 m_log.DebugFormat(
5543 "[SCENE]: Denying presence with id {0} entry into {1} since region is at agent limit of {2}",
5544 agentID, RegionInfo.RegionName, RegionInfo.RegionSettings.AgentLimit);
5545
5470 return false; 5546 return false;
5471 } 5547 }
5472 } 5548 }
@@ -5637,5 +5713,19 @@ Environment.Exit(1);
5637 } 5713 }
5638 } 5714 }
5639 } 5715 }
5716
5717 // manage and select spawn points in sequence
5718 public int SpawnPoint()
5719 {
5720 int spawnpoints = RegionInfo.RegionSettings.SpawnPoints().Count;
5721
5722 if (spawnpoints == 0)
5723 return 0;
5724
5725 m_SpawnPoint++;
5726 if (m_SpawnPoint > spawnpoints)
5727 m_SpawnPoint = 1;
5728 return m_SpawnPoint - 1;
5729 }
5640 } 5730 }
5641} 5731}
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 b7466be..a62c1ac 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -101,6 +101,13 @@ 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, delinking and duplication operations from running concurrently.
106 /// </summary>
107 /// <remarks>
108 /// These operations rely on the parts composition of the object. If allowed to run concurrently then race
109 /// conditions can occur.
110 /// </remarks>
104 private Object m_updateLock = new Object(); 111 private Object m_updateLock = new Object();
105 112
106 #endregion 113 #endregion
@@ -852,11 +859,6 @@ namespace OpenSim.Region.Framework.Scenes
852 return m_scenePresenceArray; 859 return m_scenePresenceArray;
853 } 860 }
854 861
855 public int GetNumberOfScenePresences()
856 {
857 return m_scenePresenceArray.Count;
858 }
859
860 /// <summary> 862 /// <summary>
861 /// Request a scene presence by UUID. Fast, indexed lookup. 863 /// Request a scene presence by UUID. Fast, indexed lookup.
862 /// </summary> 864 /// </summary>
@@ -2063,12 +2065,14 @@ namespace OpenSim.Region.Framework.Scenes
2063 /// <param name="AgentID"></param> 2065 /// <param name="AgentID"></param>
2064 /// <param name="GroupID"></param> 2066 /// <param name="GroupID"></param>
2065 /// <param name="rot"></param> 2067 /// <param name="rot"></param>
2068 /// <returns>null if duplication fails, otherwise the duplicated object</returns>
2069 /// <summary>
2066 public SceneObjectGroup DuplicateObject(uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot) 2070 public SceneObjectGroup DuplicateObject(uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot)
2067 { 2071 {
2068// m_log.DebugFormat( 2072// m_log.DebugFormat(
2069// "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", 2073// "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}",
2070// originalPrimID, offset, AgentID); 2074// originalPrimID, offset, AgentID);
2071 2075
2072 SceneObjectGroup original = GetGroupByPrim(originalPrimID); 2076 SceneObjectGroup original = GetGroupByPrim(originalPrimID);
2073 if (original != null) 2077 if (original != null)
2074 { 2078 {
@@ -2098,25 +2102,25 @@ namespace OpenSim.Region.Framework.Scenes
2098 2102
2099 // FIXME: This section needs to be refactored so that it just calls AddSceneObject() 2103 // FIXME: This section needs to be refactored so that it just calls AddSceneObject()
2100 Entities.Add(copy); 2104 Entities.Add(copy);
2101 2105
2102 lock (SceneObjectGroupsByFullID) 2106 lock (SceneObjectGroupsByFullID)
2103 SceneObjectGroupsByFullID[copy.UUID] = copy; 2107 SceneObjectGroupsByFullID[copy.UUID] = copy;
2104 2108
2105 SceneObjectPart[] children = copy.Parts; 2109 SceneObjectPart[] children = copy.Parts;
2106 2110
2107 lock (SceneObjectGroupsByFullPartID) 2111 lock (SceneObjectGroupsByFullPartID)
2108 { 2112 {
2109 SceneObjectGroupsByFullPartID[copy.UUID] = copy; 2113 SceneObjectGroupsByFullPartID[copy.UUID] = copy;
2110 foreach (SceneObjectPart part in children) 2114 foreach (SceneObjectPart part in children)
2111 SceneObjectGroupsByFullPartID[part.UUID] = copy; 2115 SceneObjectGroupsByFullPartID[part.UUID] = copy;
2112 } 2116 }
2113 2117
2114 lock (SceneObjectGroupsByLocalPartID) 2118 lock (SceneObjectGroupsByLocalPartID)
2115 { 2119 {
2116 SceneObjectGroupsByLocalPartID[copy.LocalId] = copy; 2120 SceneObjectGroupsByLocalPartID[copy.LocalId] = copy;
2117 foreach (SceneObjectPart part in children) 2121 foreach (SceneObjectPart part in children)
2118 SceneObjectGroupsByLocalPartID[part.LocalId] = copy; 2122 SceneObjectGroupsByLocalPartID[part.LocalId] = copy;
2119 } 2123 }
2120 // PROBABLE END OF FIXME 2124 // PROBABLE END OF FIXME
2121 2125
2122 // Since we copy from a source group that is in selected 2126 // Since we copy from a source group that is in selected
@@ -2148,11 +2152,10 @@ namespace OpenSim.Region.Framework.Scenes
2148 { 2152 {
2149 m_log.WarnFormat("[SCENE]: Attempted to duplicate nonexistant prim id {0}", GroupID); 2153 m_log.WarnFormat("[SCENE]: Attempted to duplicate nonexistant prim id {0}", GroupID);
2150 } 2154 }
2151 2155
2152 return null; 2156 return null;
2153 } 2157 }
2154 2158
2155 /// <summary>
2156 /// Calculates the distance between two Vector3s 2159 /// Calculates the distance between two Vector3s
2157 /// </summary> 2160 /// </summary>
2158 /// <param name="v1"></param> 2161 /// <param name="v1"></param>
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 7568888..46a7e3d 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -2670,6 +2670,10 @@ namespace OpenSim.Region.Framework.Scenes
2670 /// <summary> 2670 /// <summary>
2671 /// Link the prims in a given group to this group 2671 /// Link the prims in a given group to this group
2672 /// </summary> 2672 /// </summary>
2673 /// <remarks>
2674 /// Do not call this method directly - use Scene.LinkObjects() instead to avoid races between threads.
2675 /// FIXME: There are places where scripts call these methods directly without locking. This is a potential race condition.
2676 /// </remarks>
2673 /// <param name="objectGroup">The group of prims which should be linked to this group</param> 2677 /// <param name="objectGroup">The group of prims which should be linked to this group</param>
2674 public void LinkToGroup(SceneObjectGroup objectGroup) 2678 public void LinkToGroup(SceneObjectGroup objectGroup)
2675 { 2679 {
@@ -2751,6 +2755,7 @@ namespace OpenSim.Region.Framework.Scenes
2751 } 2755 }
2752 2756
2753 linkPart.LinkNum = linkNum++; 2757 linkPart.LinkNum = linkNum++;
2758 linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false);
2754 2759
2755 SceneObjectPart[] ogParts = objectGroup.Parts; 2760 SceneObjectPart[] ogParts = objectGroup.Parts;
2756 Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) 2761 Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b)
@@ -2802,6 +2807,11 @@ namespace OpenSim.Region.Framework.Scenes
2802 /// Delink the given prim from this group. The delinked prim is established as 2807 /// Delink the given prim from this group. The delinked prim is established as
2803 /// an independent SceneObjectGroup. 2808 /// an independent SceneObjectGroup.
2804 /// </summary> 2809 /// </summary>
2810 /// <remarks>
2811 /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race
2812 /// condition. But currently there is no
2813 /// alternative method that does take a lonk to delink a single prim.
2814 /// </remarks>
2805 /// <param name="partID"></param> 2815 /// <param name="partID"></param>
2806 /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> 2816 /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns>
2807 public SceneObjectGroup DelinkFromGroup(uint partID) 2817 public SceneObjectGroup DelinkFromGroup(uint partID)
@@ -2813,6 +2823,11 @@ namespace OpenSim.Region.Framework.Scenes
2813 /// Delink the given prim from this group. The delinked prim is established as 2823 /// Delink the given prim from this group. The delinked prim is established as
2814 /// an independent SceneObjectGroup. 2824 /// an independent SceneObjectGroup.
2815 /// </summary> 2825 /// </summary>
2826 /// <remarks>
2827 /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race
2828 /// condition. But currently there is no
2829 /// alternative method that does take a lonk to delink a single prim.
2830 /// </remarks>
2816 /// <param name="partID"></param> 2831 /// <param name="partID"></param>
2817 /// <param name="sendEvents"></param> 2832 /// <param name="sendEvents"></param>
2818 /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> 2833 /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns>
@@ -2838,6 +2853,11 @@ namespace OpenSim.Region.Framework.Scenes
2838 /// Delink the given prim from this group. The delinked prim is established as 2853 /// Delink the given prim from this group. The delinked prim is established as
2839 /// an independent SceneObjectGroup. 2854 /// an independent SceneObjectGroup.
2840 /// </summary> 2855 /// </summary>
2856 /// <remarks>
2857 /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race
2858 /// condition. But currently there is no
2859 /// alternative method that does take a lonk to delink a single prim.
2860 /// </remarks>
2841 /// <param name="partID"></param> 2861 /// <param name="partID"></param>
2842 /// <param name="sendEvents"></param> 2862 /// <param name="sendEvents"></param>
2843 /// <returns>The object group of the newly delinked prim.</returns> 2863 /// <returns>The object group of the newly delinked prim.</returns>
@@ -2971,6 +2991,8 @@ namespace OpenSim.Region.Framework.Scenes
2971 oldRot = part.RotationOffset; 2991 oldRot = part.RotationOffset;
2972 Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot; 2992 Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot;
2973 part.RotationOffset = newRot; 2993 part.RotationOffset = newRot;
2994
2995 part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false);
2974 } 2996 }
2975 2997
2976 /// <summary> 2998 /// <summary>
@@ -3482,7 +3504,7 @@ namespace OpenSim.Region.Framework.Scenes
3482 3504
3483 //we need to do a terse update even if the move wasn't allowed 3505 //we need to do a terse update even if the move wasn't allowed
3484 // so that the position is reset in the client (the object snaps back) 3506 // so that the position is reset in the client (the object snaps back)
3485 ScheduleGroupForTerseUpdate(); 3507 RootPart.ScheduleTerseUpdate();
3486 } 3508 }
3487 3509
3488 /// <summary> 3510 /// <summary>
@@ -4182,7 +4204,72 @@ namespace OpenSim.Region.Framework.Scenes
4182 for (int i = 0; i < parts.Length; i++) 4204 for (int i = 0; i < parts.Length; i++)
4183 parts[i].TriggerScriptChangedEvent(val); 4205 parts[i].TriggerScriptChangedEvent(val);
4184 } 4206 }
4185 4207
4208 /// <summary>
4209 /// Returns a count of the number of scripts in this groups parts.
4210 /// </summary>
4211 public int ScriptCount()
4212 {
4213 int count = 0;
4214 SceneObjectPart[] parts = m_parts.GetArray();
4215 for (int i = 0; i < parts.Length; i++)
4216 count += parts[i].Inventory.ScriptCount();
4217
4218 return count;
4219 }
4220
4221 /// <summary>
4222 /// A float the value is a representative execution time in milliseconds of all scripts in the link set.
4223 /// </summary>
4224 public float ScriptExecutionTime()
4225 {
4226 IScriptModule[] engines = Scene.RequestModuleInterfaces<IScriptModule>();
4227
4228 if (engines.Length == 0) // No engine at all
4229 return 0.0f;
4230
4231 float time = 0.0f;
4232
4233 // get all the scripts in all parts
4234 SceneObjectPart[] parts = m_parts.GetArray();
4235 List<TaskInventoryItem> scripts = new List<TaskInventoryItem>();
4236 for (int i = 0; i < parts.Length; i++)
4237 {
4238 scripts.AddRange(parts[i].Inventory.GetInventoryItems(InventoryType.LSL));
4239 }
4240 // extract the UUIDs
4241 List<UUID> ids = new List<UUID>(scripts.Count);
4242 foreach (TaskInventoryItem script in scripts)
4243 {
4244 if (!ids.Contains(script.ItemID))
4245 {
4246 ids.Add(script.ItemID);
4247 }
4248 }
4249 // Offer the list of script UUIDs to each engine found and accumulate the time
4250 foreach (IScriptModule e in engines)
4251 {
4252 if (e != null)
4253 {
4254 time += e.GetScriptExecutionTime(ids);
4255 }
4256 }
4257 return time;
4258 }
4259
4260 /// <summary>
4261 /// Returns a count of the number of running scripts in this groups parts.
4262 /// </summary>
4263 public int RunningScriptCount()
4264 {
4265 int count = 0;
4266 SceneObjectPart[] parts = m_parts.GetArray();
4267 for (int i = 0; i < parts.Length; i++)
4268 count += parts[i].Inventory.RunningScriptCount();
4269
4270 return count;
4271 }
4272
4186 public override string ToString() 4273 public override string ToString()
4187 { 4274 {
4188 return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); 4275 return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition);
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 8e74dc8..61ef827 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -1016,7 +1016,18 @@ namespace OpenSim.Region.Framework.Scenes
1016 public int LinkNum 1016 public int LinkNum
1017 { 1017 {
1018 get { return m_linkNum; } 1018 get { return m_linkNum; }
1019 set { m_linkNum = value; } 1019 set
1020 {
1021// if (ParentGroup != null)
1022// {
1023// m_log.DebugFormat(
1024// "[SCENE OBJECT PART]: Setting linknum of {0}@{1} to {2} from {3}",
1025// Name, AbsolutePosition, value, m_linkNum);
1026// Util.PrintCallStack();
1027// }
1028
1029 m_linkNum = value;
1030 }
1020 } 1031 }
1021 1032
1022 public byte ClickAction 1033 public byte ClickAction
@@ -2153,6 +2164,9 @@ namespace OpenSim.Region.Framework.Scenes
2153 /// <param name="isNew"></param> 2164 /// <param name="isNew"></param>
2154 public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew) 2165 public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew)
2155 { 2166 {
2167 if (ParentGroup.Scene == null)
2168 return;
2169
2156 if (!ParentGroup.Scene.PhysicalPrims && UsePhysics) 2170 if (!ParentGroup.Scene.PhysicalPrims && UsePhysics)
2157 return; 2171 return;
2158 2172
@@ -3631,7 +3645,6 @@ namespace OpenSim.Region.Framework.Scenes
3631 hasProfileCut = hasDimple; // is it the same thing? 3645 hasProfileCut = hasDimple; // is it the same thing?
3632 } 3646 }
3633 3647
3634
3635 public void SetGroup(UUID groupID, IClientAPI client) 3648 public void SetGroup(UUID groupID, IClientAPI client)
3636 { 3649 {
3637 // Scene.AddNewPrims() calls with client == null so can't use this. 3650 // Scene.AddNewPrims() calls with client == null so can't use this.
@@ -3661,10 +3674,12 @@ namespace OpenSim.Region.Framework.Scenes
3661 3674
3662 public void SetPhysicsAxisRotation() 3675 public void SetPhysicsAxisRotation()
3663 { 3676 {
3664 if (PhysActor != null) 3677 PhysicsActor pa = PhysActor;
3678
3679 if (pa != null)
3665 { 3680 {
3666 PhysActor.LockAngularMotion(RotationAxis); 3681 pa.LockAngularMotion(RotationAxis);
3667 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); 3682 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa);
3668 } 3683 }
3669 } 3684 }
3670 3685
@@ -4381,7 +4396,7 @@ namespace OpenSim.Region.Framework.Scenes
4381 // For now, we use the NINJA naming scheme for identifying joints. 4396 // For now, we use the NINJA naming scheme for identifying joints.
4382 // In the future, we can support other joint specification schemes such as a 4397 // In the future, we can support other joint specification schemes such as a
4383 // custom checkbox in the viewer GUI. 4398 // custom checkbox in the viewer GUI.
4384 if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) 4399 if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
4385 { 4400 {
4386 string hingeString = "hingejoint"; 4401 string hingeString = "hingejoint";
4387 return (Name.Length >= hingeString.Length && Name.Substring(0, hingeString.Length) == hingeString); 4402 return (Name.Length >= hingeString.Length && Name.Substring(0, hingeString.Length) == hingeString);
@@ -4397,7 +4412,7 @@ namespace OpenSim.Region.Framework.Scenes
4397 // For now, we use the NINJA naming scheme for identifying joints. 4412 // For now, we use the NINJA naming scheme for identifying joints.
4398 // In the future, we can support other joint specification schemes such as a 4413 // In the future, we can support other joint specification schemes such as a
4399 // custom checkbox in the viewer GUI. 4414 // custom checkbox in the viewer GUI.
4400 if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) 4415 if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
4401 { 4416 {
4402 string ballString = "balljoint"; 4417 string ballString = "balljoint";
4403 return (Name.Length >= ballString.Length && Name.Substring(0, ballString.Length) == ballString); 4418 return (Name.Length >= ballString.Length && Name.Substring(0, ballString.Length) == ballString);
@@ -4413,7 +4428,7 @@ namespace OpenSim.Region.Framework.Scenes
4413 // For now, we use the NINJA naming scheme for identifying joints. 4428 // For now, we use the NINJA naming scheme for identifying joints.
4414 // In the future, we can support other joint specification schemes such as a 4429 // In the future, we can support other joint specification schemes such as a
4415 // custom checkbox in the viewer GUI. 4430 // custom checkbox in the viewer GUI.
4416 if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) 4431 if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
4417 { 4432 {
4418 return IsHingeJoint() || IsBallJoint(); 4433 return IsHingeJoint() || IsBallJoint();
4419 } 4434 }
@@ -4534,7 +4549,6 @@ namespace OpenSim.Region.Framework.Scenes
4534 } 4549 }
4535 */ 4550 */
4536 } 4551 }
4537
4538 else // it already has a physical representation 4552 else // it already has a physical representation
4539 { 4553 {
4540 DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. 4554 DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status.
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 959046a..f5b9825 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
@@ -770,14 +759,22 @@ namespace OpenSim.Region.Framework.Scenes
770 return item; 759 return item;
771 } 760 }
772 761
773 /// <summary> 762 public TaskInventoryItem GetInventoryItem(string name)
774 /// Get inventory items by name. 763 {
775 /// </summary> 764 m_items.LockItemsForRead(true);
776 /// <param name="name"></param> 765 foreach (TaskInventoryItem item in m_items.Values)
777 /// <returns> 766 {
778 /// A list of inventory items with that name. 767 if (item.Name == name)
779 /// If no inventory item has that name then an empty list is returned. 768 {
780 /// </returns> 769 return item;
770 m_items.LockItemsForRead(false);
771 }
772 }
773 m_items.LockItemsForRead(false);
774
775 return null;
776 }
777
781 public List<TaskInventoryItem> GetInventoryItems(string name) 778 public List<TaskInventoryItem> GetInventoryItems(string name)
782 { 779 {
783 List<TaskInventoryItem> items = new List<TaskInventoryItem>(); 780 List<TaskInventoryItem> items = new List<TaskInventoryItem>();
@@ -1247,10 +1244,10 @@ namespace OpenSim.Region.Framework.Scenes
1247 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) 1244 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
1248 item.CurrentPermissions &= ~(uint)PermissionMask.Modify; 1245 item.CurrentPermissions &= ~(uint)PermissionMask.Modify;
1249 } 1246 }
1250 item.OwnerChanged = true;
1251 item.CurrentPermissions &= item.NextPermissions; 1247 item.CurrentPermissions &= item.NextPermissions;
1252 item.BasePermissions &= item.NextPermissions; 1248 item.BasePermissions &= item.NextPermissions;
1253 item.EveryonePermissions &= item.NextPermissions; 1249 item.EveryonePermissions &= item.NextPermissions;
1250 item.OwnerChanged = true;
1254 item.PermsMask = 0; 1251 item.PermsMask = 0;
1255 item.PermsGranter = UUID.Zero; 1252 item.PermsGranter = UUID.Zero;
1256 } 1253 }
@@ -1281,9 +1278,57 @@ namespace OpenSim.Region.Framework.Scenes
1281 return true; 1278 return true;
1282 } 1279 }
1283 } 1280 }
1281
1284 return false; 1282 return false;
1285 } 1283 }
1286 1284
1285 /// <summary>
1286 /// Returns the count of scripts in this parts inventory.
1287 /// </summary>
1288 /// <returns></returns>
1289 public int ScriptCount()
1290 {
1291 int count = 0;
1292 Items.LockItemsForRead(true);
1293 foreach (TaskInventoryItem item in m_items.Values)
1294 {
1295 if (item.InvType == (int)InventoryType.LSL)
1296 {
1297 count++;
1298 }
1299 }
1300 Items.LockItemsForRead(false);
1301 return count;
1302 }
1303 /// <summary>
1304 /// Returns the count of running scripts in this parts inventory.
1305 /// </summary>
1306 /// <returns></returns>
1307 public int RunningScriptCount()
1308 {
1309 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
1310 if (engines.Length == 0)
1311 return 0;
1312
1313 int count = 0;
1314 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
1315
1316 foreach (TaskInventoryItem item in scripts)
1317 {
1318 foreach (IScriptModule engine in engines)
1319 {
1320 if (engine != null)
1321 {
1322 if (engine.GetScriptState(item.ItemID))
1323 {
1324 count++;
1325 }
1326 }
1327 }
1328 }
1329 return count;
1330 }
1331
1287 public List<UUID> GetInventoryList() 1332 public List<UUID> GetInventoryList()
1288 { 1333 {
1289 List<UUID> ret = new List<UUID>(); 1334 List<UUID> ret = new List<UUID>();
@@ -1298,22 +1343,24 @@ namespace OpenSim.Region.Framework.Scenes
1298 { 1343 {
1299 List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); 1344 List<TaskInventoryItem> ret = new List<TaskInventoryItem>();
1300 1345
1301 lock (m_items) 1346 Items.LockItemsForRead(true);
1302 ret = new List<TaskInventoryItem>(m_items.Values); 1347 ret = new List<TaskInventoryItem>(m_items.Values);
1348 Items.LockItemsForRead(false);
1303 1349
1304 return ret; 1350 return ret;
1305 } 1351 }
1306 1352
1307 public List<TaskInventoryItem> GetInventoryScripts() 1353 public List<TaskInventoryItem> GetInventoryItems(InventoryType type)
1308 { 1354 {
1309 List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); 1355 List<TaskInventoryItem> ret = new List<TaskInventoryItem>();
1310 1356
1311 lock (m_items) 1357 Items.LockItemsForRead(true);
1312 { 1358
1313 foreach (TaskInventoryItem item in m_items.Values) 1359 foreach (TaskInventoryItem item in m_items.Values)
1314 if (item.InvType == (int)InventoryType.LSL) 1360 if (item.InvType == (int)type)
1315 ret.Add(item); 1361 ret.Add(item);
1316 } 1362
1363 Items.LockItemsForRead(false);
1317 1364
1318 return ret; 1365 return ret;
1319 } 1366 }
@@ -1335,35 +1382,32 @@ namespace OpenSim.Region.Framework.Scenes
1335 if (engines.Length == 0) // No engine at all 1382 if (engines.Length == 0) // No engine at all
1336 return ret; 1383 return ret;
1337 1384
1338 Items.LockItemsForRead(true); 1385 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
1339 foreach (TaskInventoryItem item in m_items.Values) 1386
1387 foreach (TaskInventoryItem item in scripts)
1340 { 1388 {
1341 if (item.InvType == (int)InventoryType.LSL) 1389 foreach (IScriptModule e in engines)
1342 { 1390 {
1343 foreach (IScriptModule e in engines) 1391 if (e != null)
1344 { 1392 {
1345 if (e != null) 1393 string n = e.GetXMLState(item.ItemID);
1394 if (n != String.Empty)
1346 { 1395 {
1347 string n = e.GetXMLState(item.ItemID); 1396 if (oldIDs)
1348 if (n != String.Empty) 1397 {
1398 if (!ret.ContainsKey(item.OldItemID))
1399 ret[item.OldItemID] = n;
1400 }
1401 else
1349 { 1402 {
1350 if (oldIDs) 1403 if (!ret.ContainsKey(item.ItemID))
1351 { 1404 ret[item.ItemID] = n;
1352 if (!ret.ContainsKey(item.OldItemID))
1353 ret[item.OldItemID] = n;
1354 }
1355 else
1356 {
1357 if (!ret.ContainsKey(item.ItemID))
1358 ret[item.ItemID] = n;
1359 }
1360 break;
1361 } 1405 }
1406 break;
1362 } 1407 }
1363 } 1408 }
1364 } 1409 }
1365 } 1410 }
1366 Items.LockItemsForRead(false);
1367 return ret; 1411 return ret;
1368 } 1412 }
1369 1413
@@ -1373,27 +1417,27 @@ namespace OpenSim.Region.Framework.Scenes
1373 if (engines.Length == 0) 1417 if (engines.Length == 0)
1374 return; 1418 return;
1375 1419
1420 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
1376 1421
1377 Items.LockItemsForRead(true); 1422 foreach (TaskInventoryItem item in scripts)
1378
1379 foreach (TaskInventoryItem item in m_items.Values)
1380 { 1423 {
1381 if (item.InvType == (int)InventoryType.LSL) 1424 foreach (IScriptModule engine in engines)
1382 { 1425 {
1383 foreach (IScriptModule engine in engines) 1426 if (engine != null)
1384 { 1427 {
1385 if (engine != null) 1428// m_log.DebugFormat(
1386 { 1429// "[PRIM INVENTORY]: Resuming script {0} {1} for {2}, OwnerChanged {3}",
1387 if (item.OwnerChanged) 1430// item.Name, item.ItemID, item.OwnerID, item.OwnerChanged);
1388 engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER }); 1431
1389 item.OwnerChanged = false; 1432 engine.ResumeScript(item.ItemID);
1390 engine.ResumeScript(item.ItemID); 1433
1391 } 1434 if (item.OwnerChanged)
1435 engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER });
1436
1437 item.OwnerChanged = false;
1392 } 1438 }
1393 } 1439 }
1394 } 1440 }
1395
1396 Items.LockItemsForRead(false);
1397 } 1441 }
1398 } 1442 }
1399} 1443}
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 2b1fb3d..33a17db 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
@@ -45,6 +45,7 @@ using TeleportFlags = OpenSim.Framework.Constants.TeleportFlags;
45 45
46namespace OpenSim.Region.Framework.Scenes 46namespace OpenSim.Region.Framework.Scenes
47{ 47{
48 [Flags]
48 enum ScriptControlled : uint 49 enum ScriptControlled : uint
49 { 50 {
50 CONTROL_ZERO = 0, 51 CONTROL_ZERO = 0,
@@ -76,6 +77,11 @@ namespace OpenSim.Region.Framework.Scenes
76// { 77// {
77// m_log.Debug("[SCENE PRESENCE] Destructor called"); 78// m_log.Debug("[SCENE PRESENCE] Destructor called");
78// } 79// }
80 private void TriggerScenePresenceUpdated()
81 {
82 if (m_scene != null)
83 m_scene.EventManager.TriggerScenePresenceUpdated(this);
84 }
79 85
80 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 86 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
81 87
@@ -497,6 +503,7 @@ namespace OpenSim.Region.Framework.Scenes
497 //m_log.DebugFormat( 503 //m_log.DebugFormat(
498 // "[ENTITY BASE]: In {0} set AbsolutePosition of {1} to {2}", 504 // "[ENTITY BASE]: In {0} set AbsolutePosition of {1} to {2}",
499 // Scene.RegionInfo.RegionName, Name, m_pos); 505 // Scene.RegionInfo.RegionName, Name, m_pos);
506 TriggerScenePresenceUpdated();
500 } 507 }
501 } 508 }
502 509
@@ -516,6 +523,7 @@ namespace OpenSim.Region.Framework.Scenes
516 return; 523 return;
517 524
518 m_pos = value; 525 m_pos = value;
526 TriggerScenePresenceUpdated();
519 } 527 }
520 } 528 }
521 529
@@ -1085,23 +1093,13 @@ namespace OpenSim.Region.Framework.Scenes
1085 /// <param name="pos"></param> 1093 /// <param name="pos"></param>
1086 public void Teleport(Vector3 pos) 1094 public void Teleport(Vector3 pos)
1087 { 1095 {
1088 bool isFlying = Flying; 1096 TeleportWithMomentum(pos, Vector3.Zero);
1089 RemoveFromPhysicalScene();
1090 Velocity = Vector3.Zero;
1091 CheckLandingPoint(ref pos);
1092 AbsolutePosition = pos;
1093 AddToPhysicalScene(isFlying);
1094
1095 SendTerseUpdateToAllClients();
1096 }
1097
1098 public void TeleportWithMomentum(Vector3 pos)
1099 {
1100 TeleportWithMomentum(pos, null);
1101 } 1097 }
1102 1098
1103 public void TeleportWithMomentum(Vector3 pos, Vector3? v) 1099 public void TeleportWithMomentum(Vector3 pos, Vector3? v)
1104 { 1100 {
1101 if (ParentID != (uint)0)
1102 StandUp();
1105 bool isFlying = Flying; 1103 bool isFlying = Flying;
1106 Vector3 vel = Velocity; 1104 Vector3 vel = Velocity;
1107 RemoveFromPhysicalScene(); 1105 RemoveFromPhysicalScene();
@@ -1281,17 +1279,33 @@ namespace OpenSim.Region.Framework.Scenes
1281 1279
1282 bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); 1280 bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
1283 MakeRootAgent(AbsolutePosition, flying); 1281 MakeRootAgent(AbsolutePosition, flying);
1282 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
1283
1284// m_log.DebugFormat("[SCENE PRESENCE] Completed movement");
1284 1285
1285 if ((m_callbackURI != null) && !m_callbackURI.Equals("")) 1286 if ((m_callbackURI != null) && !m_callbackURI.Equals(""))
1286 { 1287 {
1287 m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); 1288 // We cannot sleep here since this would hold up the inbound packet processing thread, as
1289 // CompleteMovement() is executed synchronously. However, it might be better to delay the release
1290 // here until we know for sure that the agent is active in this region. Sending AgentMovementComplete
1291 // is not enough for Imprudence clients - there appears to be a small delay (<200ms, <500ms) until they regard this
1292 // region as the current region, meaning that a close sent before then will fail the teleport.
1293// System.Threading.Thread.Sleep(2000);
1294
1295 m_log.DebugFormat(
1296 "[SCENE PRESENCE]: Releasing {0} {1} with callback to {2}",
1297 client.Name, client.AgentId, m_callbackURI);
1298
1288 Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI); 1299 Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI);
1289 m_callbackURI = null; 1300 m_callbackURI = null;
1290 } 1301 }
1302// else
1303// {
1304// m_log.DebugFormat(
1305// "[SCENE PRESENCE]: No callback provided on CompleteMovement of {0} {1} to {2}",
1306// client.Name, client.AgentId, m_scene.RegionInfo.RegionName);
1307// }
1291 1308
1292// m_log.DebugFormat("[SCENE PRESENCE] Completed movement");
1293
1294 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
1295 ValidateAndSendAppearanceAndAgentData(); 1309 ValidateAndSendAppearanceAndAgentData();
1296 1310
1297 // Create child agents in neighbouring regions 1311 // Create child agents in neighbouring regions
@@ -1306,7 +1320,6 @@ namespace OpenSim.Region.Framework.Scenes
1306 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); 1320 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient);
1307 } 1321 }
1308 1322
1309
1310// m_log.DebugFormat( 1323// m_log.DebugFormat(
1311// "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms", 1324// "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms",
1312// client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds); 1325// client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds);
@@ -1359,7 +1372,7 @@ namespace OpenSim.Region.Framework.Scenes
1359 { 1372 {
1360// m_log.DebugFormat( 1373// m_log.DebugFormat(
1361// "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}", 1374// "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}",
1362// Scene.RegionInfo.RegionName, remoteClient.Name, agentData.ControlFlags); 1375// Scene.RegionInfo.RegionName, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags);
1363 1376
1364 if (IsChildAgent) 1377 if (IsChildAgent)
1365 { 1378 {
@@ -1469,14 +1482,8 @@ namespace OpenSim.Region.Framework.Scenes
1469 } 1482 }
1470 } 1483 }
1471 1484
1472 lock (scriptedcontrols) 1485 uint flagsForScripts = (uint)flags;
1473 { 1486 flags = RemoveIgnoredControls(flags, IgnoredControls);
1474 if (scriptedcontrols.Count > 0)
1475 {
1476 SendControlToScripts((uint)flags);
1477 flags = RemoveIgnoredControls(flags, IgnoredControls);
1478 }
1479 }
1480 1487
1481 if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) 1488 if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0)
1482 HandleAgentSitOnGround(); 1489 HandleAgentSitOnGround();
@@ -1490,6 +1497,7 @@ namespace OpenSim.Region.Framework.Scenes
1490 PhysicsActor actor = PhysicsActor; 1497 PhysicsActor actor = PhysicsActor;
1491 if (actor == null) 1498 if (actor == null)
1492 { 1499 {
1500 SendControlsToScripts(flagsForScripts);
1493 return; 1501 return;
1494 } 1502 }
1495 1503
@@ -1569,7 +1577,7 @@ namespace OpenSim.Region.Framework.Scenes
1569 MovementFlag |= (byte)nudgehack; 1577 MovementFlag |= (byte)nudgehack;
1570 } 1578 }
1571 1579
1572// m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF); 1580 //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF);
1573 MovementFlag += (byte)(uint)DCF; 1581 MovementFlag += (byte)(uint)DCF;
1574 update_movementflag = true; 1582 update_movementflag = true;
1575 } 1583 }
@@ -1582,7 +1590,7 @@ namespace OpenSim.Region.Framework.Scenes
1582 && ((MovementFlag & (byte)nudgehack) == nudgehack)) 1590 && ((MovementFlag & (byte)nudgehack) == nudgehack))
1583 ) // This or is for Nudge forward 1591 ) // This or is for Nudge forward
1584 { 1592 {
1585// m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF); 1593 //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF);
1586 MovementFlag -= ((byte)(uint)DCF); 1594 MovementFlag -= ((byte)(uint)DCF);
1587 update_movementflag = true; 1595 update_movementflag = true;
1588 1596
@@ -1663,11 +1671,14 @@ namespace OpenSim.Region.Framework.Scenes
1663// } 1671// }
1664// } 1672// }
1665 1673
1666// if (update_movementflag && ParentID == 0) 1674 if (update_movementflag && ParentID == 0)
1667// Animator.UpdateMovementAnimations(); 1675 Animator.UpdateMovementAnimations();
1676
1677 SendControlsToScripts(flagsForScripts);
1668 } 1678 }
1669 1679
1670 m_scene.EventManager.TriggerOnClientMovement(this); 1680 m_scene.EventManager.TriggerOnClientMovement(this);
1681 TriggerScenePresenceUpdated();
1671 } 1682 }
1672 1683
1673 /// <summary> 1684 /// <summary>
@@ -2607,6 +2618,7 @@ namespace OpenSim.Region.Framework.Scenes
2607 2618
2608 m_scene.ForEachClient(SendTerseUpdateToClient); 2619 m_scene.ForEachClient(SendTerseUpdateToClient);
2609 } 2620 }
2621 TriggerScenePresenceUpdated();
2610 } 2622 }
2611 2623
2612 public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs) 2624 public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs)
@@ -2685,7 +2697,7 @@ namespace OpenSim.Region.Framework.Scenes
2685 // If we are using the the cached appearance then send it out to everyone 2697 // If we are using the the cached appearance then send it out to everyone
2686 if (cachedappearance) 2698 if (cachedappearance)
2687 { 2699 {
2688 m_log.DebugFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name); 2700 m_log.DebugFormat("[SCENE PRESENCE]: baked textures are in the cache for {0}", Name);
2689 2701
2690 // If the avatars baked textures are all in the cache, then we have a 2702 // If the avatars baked textures are all in the cache, then we have a
2691 // complete appearance... send it out, if not, then we'll send it when 2703 // complete appearance... send it out, if not, then we'll send it when
@@ -3089,8 +3101,8 @@ namespace OpenSim.Region.Framework.Scenes
3089 x = x / Constants.RegionSize; 3101 x = x / Constants.RegionSize;
3090 y = y / Constants.RegionSize; 3102 y = y / Constants.RegionSize;
3091 3103
3092 //m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); 3104// m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX)));
3093 //m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); 3105// m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY)));
3094 if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY)) 3106 if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY))
3095 { 3107 {
3096 byebyeRegions.Add(handle); 3108 byebyeRegions.Add(handle);
@@ -3147,7 +3159,7 @@ namespace OpenSim.Region.Framework.Scenes
3147 3159
3148 public void ChildAgentDataUpdate(AgentData cAgentData) 3160 public void ChildAgentDataUpdate(AgentData cAgentData)
3149 { 3161 {
3150 //m_log.Debug(" >>> ChildAgentDataUpdate <<< " + Scene.RegionInfo.RegionName); 3162// m_log.Debug(" >>> ChildAgentDataUpdate <<< " + Scene.RegionInfo.RegionName);
3151 if (!IsChildAgent) 3163 if (!IsChildAgent)
3152 return; 3164 return;
3153 3165
@@ -3291,6 +3303,9 @@ namespace OpenSim.Region.Framework.Scenes
3291 m_originRegionID = cAgent.RegionID; 3303 m_originRegionID = cAgent.RegionID;
3292 3304
3293 m_callbackURI = cAgent.CallbackURI; 3305 m_callbackURI = cAgent.CallbackURI;
3306// m_log.DebugFormat(
3307// "[SCENE PRESENCE]: Set callback for {0} in {1} to {2} in CopyFrom()",
3308// Name, m_scene.RegionInfo.RegionName, m_callbackURI);
3294 3309
3295 m_pos = cAgent.Position; 3310 m_pos = cAgent.Position;
3296 m_velocity = cAgent.Velocity; 3311 m_velocity = cAgent.Velocity;
@@ -3392,6 +3407,7 @@ namespace OpenSim.Region.Framework.Scenes
3392 Velocity = force; 3407 Velocity = force;
3393 3408
3394 m_forceToApply = null; 3409 m_forceToApply = null;
3410 TriggerScenePresenceUpdated();
3395 } 3411 }
3396 } 3412 }
3397 3413
@@ -3499,23 +3515,53 @@ namespace OpenSim.Region.Framework.Scenes
3499 3515
3500 RaiseCollisionScriptEvents(coldata); 3516 RaiseCollisionScriptEvents(coldata);
3501 3517
3502 if (Invulnerable || GodLevel >= 200) 3518 // Gods do not take damage and Invulnerable is set depending on parcel/region flags
3519 if (Invulnerable || GodLevel > 0)
3503 return; 3520 return;
3504 3521
3522 // The following may be better in the ICombatModule
3523 // probably tweaking of the values for ground and normal prim collisions will be needed
3505 float starthealth = Health; 3524 float starthealth = Health;
3506 uint killerObj = 0; 3525 uint killerObj = 0;
3526 SceneObjectPart part = null;
3507 foreach (uint localid in coldata.Keys) 3527 foreach (uint localid in coldata.Keys)
3508 { 3528 {
3509 SceneObjectPart part = Scene.GetSceneObjectPart(localid); 3529 if (localid == 0)
3510 3530 {
3511 if (part != null && part.ParentGroup.Damage != -1.0f) 3531 part = null;
3512 Health -= part.ParentGroup.Damage; 3532 }
3533 else
3534 {
3535 part = Scene.GetSceneObjectPart(localid);
3536 }
3537 if (part != null)
3538 {
3539 // Ignore if it has been deleted or volume detect
3540 if (!part.ParentGroup.IsDeleted && !part.ParentGroup.IsVolumeDetect)
3541 {
3542 if (part.ParentGroup.Damage > 0.0f)
3543 {
3544 // Something with damage...
3545 Health -= part.ParentGroup.Damage;
3546 part.ParentGroup.Scene.DeleteSceneObject(part.ParentGroup, false);
3547 }
3548 else
3549 {
3550 // An ordinary prim
3551 if (coldata[localid].PenetrationDepth >= 0.10f)
3552 Health -= coldata[localid].PenetrationDepth * 5.0f;
3553 }
3554 }
3555 }
3513 else 3556 else
3514 { 3557 {
3515 if (coldata[localid].PenetrationDepth >= 0.10f) 3558 // 0 is the ground
3559 // what about collisions with other avatars?
3560 if (localid == 0 && coldata[localid].PenetrationDepth >= 0.10f)
3516 Health -= coldata[localid].PenetrationDepth * 5.0f; 3561 Health -= coldata[localid].PenetrationDepth * 5.0f;
3517 } 3562 }
3518 3563
3564
3519 if (Health <= 0.0f) 3565 if (Health <= 0.0f)
3520 { 3566 {
3521 if (localid != 0) 3567 if (localid != 0)
@@ -3531,7 +3577,16 @@ namespace OpenSim.Region.Framework.Scenes
3531 ControllingClient.SendHealth(Health); 3577 ControllingClient.SendHealth(Health);
3532 } 3578 }
3533 if (Health <= 0) 3579 if (Health <= 0)
3580 {
3534 m_scene.EventManager.TriggerAvatarKill(killerObj, this); 3581 m_scene.EventManager.TriggerAvatarKill(killerObj, this);
3582 }
3583 if (starthealth == Health && Health < 100.0f)
3584 {
3585 Health += 0.03f;
3586 if (Health > 100.0f)
3587 Health = 100.0f;
3588 ControllingClient.SendHealth(Health);
3589 }
3535 } 3590 }
3536 } 3591 }
3537 3592
@@ -3613,6 +3668,63 @@ namespace OpenSim.Region.Framework.Scenes
3613 return m_attachments.Count > 0; 3668 return m_attachments.Count > 0;
3614 } 3669 }
3615 3670
3671 /// <summary>
3672 /// Returns the total count of scripts in all parts inventories.
3673 /// </summary>
3674 public int ScriptCount()
3675 {
3676 int count = 0;
3677 lock (m_attachments)
3678 {
3679 foreach (SceneObjectGroup gobj in m_attachments)
3680 {
3681 if (gobj != null)
3682 {
3683 count += gobj.ScriptCount();
3684 }
3685 }
3686 }
3687 return count;
3688 }
3689
3690 /// <summary>
3691 /// A float the value is a representative execution time in milliseconds of all scripts in all attachments.
3692 /// </summary>
3693 public float ScriptExecutionTime()
3694 {
3695 float time = 0.0f;
3696 lock (m_attachments)
3697 {
3698 foreach (SceneObjectGroup gobj in m_attachments)
3699 {
3700 if (gobj != null)
3701 {
3702 time += gobj.ScriptExecutionTime();
3703 }
3704 }
3705 }
3706 return time;
3707 }
3708
3709 /// <summary>
3710 /// Returns the total count of running scripts in all parts.
3711 /// </summary>
3712 public int RunningScriptCount()
3713 {
3714 int count = 0;
3715 lock (m_attachments)
3716 {
3717 foreach (SceneObjectGroup gobj in m_attachments)
3718 {
3719 if (gobj != null)
3720 {
3721 count += gobj.RunningScriptCount();
3722 }
3723 }
3724 }
3725 return count;
3726 }
3727
3616 public bool HasScriptedAttachments() 3728 public bool HasScriptedAttachments()
3617 { 3729 {
3618 lock (m_attachments) 3730 lock (m_attachments)
@@ -3830,77 +3942,92 @@ namespace OpenSim.Region.Framework.Scenes
3830 } 3942 }
3831 } 3943 }
3832 3944
3833 internal void SendControlToScripts(uint flags) 3945 private void SendControlsToScripts(uint flags)
3834 { 3946 {
3835 ScriptControlled allflags = ScriptControlled.CONTROL_ZERO; 3947 // Notify the scripts only after calling UpdateMovementAnimations(), so that if a script
3836 3948 // (e.g., a walking script) checks which animation is active it will be the correct animation.
3837 if (MouseDown) 3949 lock (scriptedcontrols)
3838 { 3950 {
3839 allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON); 3951 if (scriptedcontrols.Count <= 0)
3840 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0) 3952 return;
3953
3954 ScriptControlled allflags = ScriptControlled.CONTROL_ZERO;
3955
3956 if (MouseDown)
3957 {
3958 allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON);
3959 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0)
3960 {
3961 allflags = ScriptControlled.CONTROL_ZERO;
3962 MouseDown = true;
3963 }
3964 }
3965
3966 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0)
3841 { 3967 {
3842 allflags = ScriptControlled.CONTROL_ZERO; 3968 allflags |= ScriptControlled.CONTROL_ML_LBUTTON;
3843 MouseDown = true; 3969 MouseDown = true;
3844 } 3970 }
3845 } 3971
3972 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0)
3973 {
3974 allflags |= ScriptControlled.CONTROL_LBUTTON;
3975 MouseDown = true;
3976 }
3977
3978 // find all activated controls, whether the scripts are interested in them or not
3979 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0)
3980 {
3981 allflags |= ScriptControlled.CONTROL_FWD;
3982 }
3983
3984 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0)
3985 {
3986 allflags |= ScriptControlled.CONTROL_BACK;
3987 }
3988
3989 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0)
3990 {
3991 allflags |= ScriptControlled.CONTROL_UP;
3992 }
3993
3994 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)
3995 {
3996 allflags |= ScriptControlled.CONTROL_DOWN;
3997 }
3846 3998
3847 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0) 3999 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0)
3848 { 4000 {
3849 allflags |= ScriptControlled.CONTROL_ML_LBUTTON; 4001 allflags |= ScriptControlled.CONTROL_LEFT;
3850 MouseDown = true; 4002 }
3851 } 4003
3852 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0) 4004 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0)
3853 { 4005 {
3854 allflags |= ScriptControlled.CONTROL_LBUTTON; 4006 allflags |= ScriptControlled.CONTROL_RIGHT;
3855 MouseDown = true; 4007 }
3856 } 4008
4009 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
4010 {
4011 allflags |= ScriptControlled.CONTROL_ROT_RIGHT;
4012 }
4013
4014 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)
4015 {
4016 allflags |= ScriptControlled.CONTROL_ROT_LEFT;
4017 }
3857 4018
3858 // find all activated controls, whether the scripts are interested in them or not 4019 // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that
3859 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0) 4020 if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands)
3860 {
3861 allflags |= ScriptControlled.CONTROL_FWD;
3862 }
3863 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0)
3864 {
3865 allflags |= ScriptControlled.CONTROL_BACK;
3866 }
3867 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0)
3868 {
3869 allflags |= ScriptControlled.CONTROL_UP;
3870 }
3871 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)
3872 {
3873 allflags |= ScriptControlled.CONTROL_DOWN;
3874 }
3875 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0)
3876 {
3877 allflags |= ScriptControlled.CONTROL_LEFT;
3878 }
3879 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0)
3880 {
3881 allflags |= ScriptControlled.CONTROL_RIGHT;
3882 }
3883 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
3884 {
3885 allflags |= ScriptControlled.CONTROL_ROT_RIGHT;
3886 }
3887 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)
3888 {
3889 allflags |= ScriptControlled.CONTROL_ROT_LEFT;
3890 }
3891 // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that
3892 if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands)
3893 {
3894 lock (scriptedcontrols)
3895 { 4021 {
3896 foreach (KeyValuePair<UUID, ScriptControllers> kvp in scriptedcontrols) 4022 foreach (KeyValuePair<UUID, ScriptControllers> kvp in scriptedcontrols)
3897 { 4023 {
3898 UUID scriptUUID = kvp.Key; 4024 UUID scriptUUID = kvp.Key;
3899 ScriptControllers scriptControlData = kvp.Value; 4025 ScriptControllers scriptControlData = kvp.Value;
3900 4026
3901 ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us 4027 ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us
3902 ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle 4028 ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle
3903 ScriptControlled localChange = localHeld ^ localLast; // the changed bits 4029 ScriptControlled localChange = localHeld ^ localLast; // the changed bits
4030
3904 if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO) 4031 if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO)
3905 { 4032 {
3906 // only send if still pressed or just changed 4033 // only send if still pressed or just changed
@@ -3908,9 +4035,9 @@ namespace OpenSim.Region.Framework.Scenes
3908 } 4035 }
3909 } 4036 }
3910 } 4037 }
4038
4039 LastCommands = allflags;
3911 } 4040 }
3912
3913 LastCommands = allflags;
3914 } 4041 }
3915 4042
3916 internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored) 4043 internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored)
@@ -3990,7 +4117,7 @@ namespace OpenSim.Region.Framework.Scenes
3990 land.LandData.UserLocation != Vector3.Zero && 4117 land.LandData.UserLocation != Vector3.Zero &&
3991 land.LandData.OwnerID != m_uuid && 4118 land.LandData.OwnerID != m_uuid &&
3992 (!m_scene.Permissions.IsGod(m_uuid)) && 4119 (!m_scene.Permissions.IsGod(m_uuid)) &&
3993 (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) 4120 (!m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)))
3994 { 4121 {
3995 float curr = Vector3.Distance(AbsolutePosition, pos); 4122 float curr = Vector3.Distance(AbsolutePosition, pos);
3996 if (Vector3.Distance(land.LandData.UserLocation, pos) < curr) 4123 if (Vector3.Distance(land.LandData.UserLocation, pos) < curr)
@@ -4004,13 +4131,13 @@ namespace OpenSim.Region.Framework.Scenes
4004 { 4131 {
4005 if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) == 4132 if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) ==
4006 (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) || 4133 (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) ||
4007 (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 || 4134 (m_scene.TelehubAllowLandmarks == true ? false : ((m_teleportFlags & TeleportFlags.ViaLandmark) != 0 )) ||
4008 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || 4135 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
4009 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0) 4136 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)
4010 { 4137 {
4011 if (GodLevel < 200 && 4138 if (GodLevel < 200 &&
4012 ((!m_scene.Permissions.IsGod(m_uuid) && 4139 ((!m_scene.Permissions.IsGod(m_uuid) &&
4013 !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) || 4140 !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) ||
4014 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || 4141 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
4015 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) 4142 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0))
4016 { 4143 {
@@ -4018,28 +4145,92 @@ namespace OpenSim.Region.Framework.Scenes
4018 if (spawnPoints.Length == 0) 4145 if (spawnPoints.Length == 0)
4019 return; 4146 return;
4020 4147
4021 float distance = 9999; 4148 int index;
4022 int closest = -1; 4149 bool selected = false;
4023 4150
4024 for (int i = 0 ; i < spawnPoints.Length ; i++) 4151 switch (m_scene.SpawnPointRouting)
4025 { 4152 {
4026 Vector3 spawnPosition = spawnPoints[i].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); 4153 case "random":
4027 Vector3 offset = spawnPosition - pos;
4028 float d = Vector3.Mag(offset);
4029 if (d >= distance)
4030 continue;
4031 ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y);
4032 if (land == null)
4033 continue;
4034 if (land.IsEitherBannedOrRestricted(UUID))
4035 continue;
4036 distance = d;
4037 closest = i;
4038 }
4039 if (closest == -1)
4040 return;
4041 4154
4042 pos = spawnPoints[closest].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); 4155 do
4156 {
4157 index = Util.RandomClass.Next(spawnPoints.Length - 1);
4158
4159 Vector3 spawnPosition = spawnPoints[index].GetLocation(
4160 telehub.AbsolutePosition,
4161 telehub.GroupRotation
4162 );
4163 // SpawnPoint sp = spawnPoints[index];
4164
4165 ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y);
4166 if (land == null || land.IsEitherBannedOrRestricted(UUID))
4167 selected = false;
4168 else
4169 selected = true;
4170
4171 } while ( selected == false);
4172
4173 pos = spawnPoints[index].GetLocation(
4174 telehub.AbsolutePosition,
4175 telehub.GroupRotation
4176 );
4177 return;
4178
4179 case "sequence":
4180
4181 do
4182 {
4183 index = m_scene.SpawnPoint();
4184
4185 Vector3 spawnPosition = spawnPoints[index].GetLocation(
4186 telehub.AbsolutePosition,
4187 telehub.GroupRotation
4188 );
4189 // SpawnPoint sp = spawnPoints[index];
4190
4191 ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y);
4192 if (land == null || land.IsEitherBannedOrRestricted(UUID))
4193 selected = false;
4194 else
4195 selected = true;
4196
4197 } while (selected == false);
4198
4199 pos = spawnPoints[index].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation);
4200 ;
4201 return;
4202
4203 default:
4204 case "closest":
4205
4206 float distance = 9999;
4207 int closest = -1;
4208
4209 for (int i = 0; i < spawnPoints.Length; i++)
4210 {
4211 Vector3 spawnPosition = spawnPoints[i].GetLocation(
4212 telehub.AbsolutePosition,
4213 telehub.GroupRotation
4214 );
4215 Vector3 offset = spawnPosition - pos;
4216 float d = Vector3.Mag(offset);
4217 if (d >= distance)
4218 continue;
4219 ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y);
4220 if (land == null)
4221 continue;
4222 if (land.IsEitherBannedOrRestricted(UUID))
4223 continue;
4224 distance = d;
4225 closest = i;
4226 }
4227 if (closest == -1)
4228 return;
4229
4230 pos = spawnPoints[closest].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation);
4231 return;
4232
4233 }
4043 } 4234 }
4044 } 4235 }
4045 } 4236 }
@@ -4084,7 +4275,7 @@ namespace OpenSim.Region.Framework.Scenes
4084 GodLevel < 200 && 4275 GodLevel < 200 &&
4085 ((land.LandData.OwnerID != m_uuid && 4276 ((land.LandData.OwnerID != m_uuid &&
4086 !m_scene.Permissions.IsGod(m_uuid) && 4277 !m_scene.Permissions.IsGod(m_uuid) &&
4087 !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) || 4278 !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) ||
4088 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || 4279 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
4089 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) 4280 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0))
4090 { 4281 {
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs
index 55455cc..a4f730d 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs
@@ -47,14 +47,30 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
47 /// </remarks> 47 /// </remarks>
48 public class CoalescedSceneObjectsSerializer 48 public class CoalescedSceneObjectsSerializer
49 { 49 {
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 51
52 /// <summary> 52 /// <summary>
53 /// Serialize coalesced objects to Xml 53 /// Serialize coalesced objects to Xml
54 /// </summary> 54 /// </summary>
55 /// <param name="coa"></param> 55 /// <param name="coa"></param>
56 /// <param name="doScriptStates">
57 /// If true then serialize script states. This will halt any running scripts
58 /// </param>
56 /// <returns></returns> 59 /// <returns></returns>
57 public static string ToXml(CoalescedSceneObjects coa) 60 public static string ToXml(CoalescedSceneObjects coa)
61 {
62 return ToXml(coa, true);
63 }
64
65 /// <summary>
66 /// Serialize coalesced objects to Xml
67 /// </summary>
68 /// <param name="coa"></param>
69 /// <param name="doScriptStates">
70 /// If true then serialize script states. This will halt any running scripts
71 /// </param>
72 /// <returns></returns>
73 public static string ToXml(CoalescedSceneObjects coa, bool doScriptStates)
58 { 74 {
59 using (StringWriter sw = new StringWriter()) 75 using (StringWriter sw = new StringWriter())
60 { 76 {
@@ -91,7 +107,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
91 writer.WriteAttributeString("offsety", offsets[i].Y.ToString()); 107 writer.WriteAttributeString("offsety", offsets[i].Y.ToString());
92 writer.WriteAttributeString("offsetz", offsets[i].Z.ToString()); 108 writer.WriteAttributeString("offsetz", offsets[i].Z.ToString());
93 109
94 SceneObjectSerializer.ToOriginalXmlFormat(obj, writer, true); 110 SceneObjectSerializer.ToOriginalXmlFormat(obj, writer, doScriptStates);
95 111
96 writer.WriteEndElement(); // SceneObjectGroup 112 writer.WriteEndElement(); // SceneObjectGroup
97 } 113 }
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index 151eba2..e223f47 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -1538,51 +1538,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1538 } 1538 }
1539 } 1539 }
1540 1540
1541 //////// Read /////////
1542 public static bool Xml2ToSOG(XmlTextReader reader, SceneObjectGroup sog)
1543 {
1544 reader.Read();
1545 reader.ReadStartElement("SceneObjectGroup");
1546 SceneObjectPart root = Xml2ToSOP(reader);
1547 if (root != null)
1548 sog.SetRootPart(root);
1549 else
1550 {
1551 return false;
1552 }
1553
1554 if (sog.UUID == UUID.Zero)
1555 sog.UUID = sog.RootPart.UUID;
1556
1557 reader.Read(); // OtherParts
1558
1559 while (!reader.EOF)
1560 {
1561 switch (reader.NodeType)
1562 {
1563 case XmlNodeType.Element:
1564 if (reader.Name == "SceneObjectPart")
1565 {
1566 SceneObjectPart child = Xml2ToSOP(reader);
1567 if (child != null)
1568 sog.AddPart(child);
1569 }
1570 else
1571 {
1572 //Logger.Log("Found unexpected prim XML element " + reader.Name, Helpers.LogLevel.Debug);
1573 reader.Read();
1574 }
1575 break;
1576 case XmlNodeType.EndElement:
1577 default:
1578 reader.Read();
1579 break;
1580 }
1581
1582 }
1583 return true;
1584 }
1585
1586 public static SceneObjectPart Xml2ToSOP(XmlTextReader reader) 1541 public static SceneObjectPart Xml2ToSOP(XmlTextReader reader)
1587 { 1542 {
1588 SceneObjectPart obj = new SceneObjectPart(); 1543 SceneObjectPart obj = new SceneObjectPart();
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs
index d214eba..a3485d2 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs
@@ -223,50 +223,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
223 223
224 public static SceneObjectGroup DeserializeGroupFromXml2(string xmlString) 224 public static SceneObjectGroup DeserializeGroupFromXml2(string xmlString)
225 { 225 {
226 XmlDocument doc = new XmlDocument(); 226 return SceneObjectSerializer.FromXml2Format(xmlString);
227 XmlNode rootNode;
228
229 XmlTextReader reader = new XmlTextReader(new StringReader(xmlString));
230 reader.WhitespaceHandling = WhitespaceHandling.None;
231 doc.Load(reader);
232 reader.Close();
233 rootNode = doc.FirstChild;
234
235 // This is to deal with neighbouring regions that are still surrounding the group xml with the <scene>
236 // tag. It should be possible to remove the first part of this if statement once we go past 0.5.9 (or
237 // when some other changes forces all regions to upgrade).
238 // This might seem rather pointless since prim crossing from this revision to an earlier revision remains
239 // broken. But it isn't much work to accomodate the old format here.
240 if (rootNode.LocalName.Equals("scene"))
241 {
242 foreach (XmlNode aPrimNode in rootNode.ChildNodes)
243 {
244 // There is only ever one prim. This oddity should be removeable post 0.5.9
245 //return SceneObjectSerializer.FromXml2Format(aPrimNode.OuterXml);
246 using (reader = new XmlTextReader(new StringReader(aPrimNode.OuterXml)))
247 {
248 SceneObjectGroup obj = new SceneObjectGroup();
249 if (SceneObjectSerializer.Xml2ToSOG(reader, obj))
250 return obj;
251
252 return null;
253 }
254 }
255
256 return null;
257 }
258 else
259 {
260 //return SceneObjectSerializer.FromXml2Format(rootNode.OuterXml);
261 using (reader = new XmlTextReader(new StringReader(rootNode.OuterXml)))
262 {
263 SceneObjectGroup obj = new SceneObjectGroup();
264 if (SceneObjectSerializer.Xml2ToSOG(reader, obj))
265 return obj;
266
267 return null;
268 }
269 }
270 } 227 }
271 228
272 /// <summary> 229 /// <summary>
@@ -307,8 +264,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
307 ICollection<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>(); 264 ICollection<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
308 foreach (XmlNode aPrimNode in rootNode.ChildNodes) 265 foreach (XmlNode aPrimNode in rootNode.ChildNodes)
309 { 266 {
310 SceneObjectGroup obj = CreatePrimFromXml2(scene, aPrimNode.OuterXml); 267 SceneObjectGroup obj = DeserializeGroupFromXml2(aPrimNode.OuterXml);
311 if (obj != null && startScripts) 268 if (startScripts)
312 sceneObjects.Add(obj); 269 sceneObjects.Add(obj);
313 } 270 }
314 271
@@ -319,27 +276,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
319 } 276 }
320 } 277 }
321 278
322 /// <summary>
323 /// Create a prim from the xml2 representation.
324 /// </summary>
325 /// <param name="scene"></param>
326 /// <param name="xmlData"></param>
327 /// <returns>The scene object created. null if the scene object already existed</returns>
328 protected static SceneObjectGroup CreatePrimFromXml2(Scene scene, string xmlData)
329 {
330 //SceneObjectGroup obj = SceneObjectSerializer.FromXml2Format(xmlData);
331 using (XmlTextReader reader = new XmlTextReader(new StringReader(xmlData)))
332 {
333 SceneObjectGroup obj = new SceneObjectGroup();
334 SceneObjectSerializer.Xml2ToSOG(reader, obj);
335
336 if (scene.AddRestoredSceneObject(obj, true, false))
337 return obj;
338 else
339 return null;
340 }
341 }
342
343 #endregion 279 #endregion
344 } 280 }
345} 281} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
index a4afd47..18e6ece 100644
--- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
+++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
@@ -26,7 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29//using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Timers; 30using System.Timers;
31using OpenMetaverse.Packets; 31using OpenMetaverse.Packets;
32using OpenSim.Framework; 32using OpenSim.Framework;
@@ -35,10 +35,18 @@ using OpenSim.Region.Framework.Interfaces;
35 35
36namespace OpenSim.Region.Framework.Scenes 36namespace OpenSim.Region.Framework.Scenes
37{ 37{
38 /// <summary>
39 /// Collect statistics from the scene to send to the client and for access by other monitoring tools.
40 /// </summary>
41 /// <remarks>
42 /// FIXME: This should be a monitoring region module
43 /// </remarks>
38 public class SimStatsReporter 44 public class SimStatsReporter
39 { 45 {
40// private static readonly log4net.ILog m_log 46 private static readonly log4net.ILog m_log
41// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 47 = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
48
49 public const string LastReportedObjectUpdateStatName = "LastReportedObjectUpdates";
42 50
43 public delegate void SendStatResult(SimStats stats); 51 public delegate void SendStatResult(SimStats stats);
44 52
@@ -48,10 +56,17 @@ namespace OpenSim.Region.Framework.Scenes
48 56
49 public event YourStatsAreWrong OnStatsIncorrect; 57 public event YourStatsAreWrong OnStatsIncorrect;
50 58
51 private SendStatResult handlerSendStatResult = null; 59 private SendStatResult handlerSendStatResult;
52 60
53 private YourStatsAreWrong handlerStatsIncorrect = null; 61 private YourStatsAreWrong handlerStatsIncorrect;
54 62
63 /// <summary>
64 /// These are the IDs of stats sent in the StatsPacket to the viewer.
65 /// </summary>
66 /// <remarks>
67 /// Some of these are not relevant to OpenSimulator since it is architected differently to other simulators
68 /// (e.g. script instructions aren't executed as part of the frame loop so 'script time' is tricky).
69 /// </remarks>
55 public enum Stats : uint 70 public enum Stats : uint
56 { 71 {
57 TimeDilation = 0, 72 TimeDilation = 0,
@@ -75,20 +90,20 @@ namespace OpenSim.Region.Framework.Scenes
75 OutPacketsPerSecond = 18, 90 OutPacketsPerSecond = 18,
76 PendingDownloads = 19, 91 PendingDownloads = 19,
77 PendingUploads = 20, 92 PendingUploads = 20,
78 VirtualSizeKB = 21, 93 VirtualSizeKb = 21,
79 ResidentSizeKB = 22, 94 ResidentSizeKb = 22,
80 PendingLocalUploads = 23, 95 PendingLocalUploads = 23,
81 UnAckedBytes = 24, 96 UnAckedBytes = 24,
82 PhysicsPinnedTasks = 25, 97 PhysicsPinnedTasks = 25,
83 PhysicsLODTasks = 26, 98 PhysicsLodTasks = 26,
84 PhysicsStepMS = 27, 99 SimPhysicsStepMs = 27,
85 PhysicsShapeMS = 28, 100 SimPhysicsShapeMs = 28,
86 PhysicsOtherMS = 29, 101 SimPhysicsOtherMs = 29,
87 PhysicsMemory = 30, 102 SimPhysicsMemory = 30,
88 ScriptEPS = 31, 103 ScriptEps = 31,
89 SimSpareTime = 32, 104 SimSpareMs = 32,
90 SimSleepTime = 33, 105 SimSleepMs = 33,
91 IOPumpTime = 34 106 SimIoPumpTime = 34
92 } 107 }
93 108
94 /// <summary> 109 /// <summary>
@@ -113,11 +128,24 @@ namespace OpenSim.Region.Framework.Scenes
113 get { return lastReportedSimStats; } 128 get { return lastReportedSimStats; }
114 } 129 }
115 130
131 /// <summary>
132 /// Extra sim statistics that are used by monitors but not sent to the client.
133 /// </summary>
134 /// <value>
135 /// The keys are the stat names.
136 /// </value>
137 private Dictionary<string, float> m_lastReportedExtraSimStats = new Dictionary<string, float>();
138
116 // Sending a stats update every 3 seconds- 139 // Sending a stats update every 3 seconds-
117 private int statsUpdatesEveryMS = 3000; 140 private int m_statsUpdatesEveryMS = 3000;
118 private float statsUpdateFactor = 0; 141 private float m_statsUpdateFactor;
119 private float m_timeDilation = 0; 142 private float m_timeDilation;
120 private int m_fps = 0; 143 private int m_fps;
144
145 /// <summary>
146 /// Number of the last frame on which we processed a stats udpate.
147 /// </summary>
148 private uint m_lastUpdateFrame;
121 149
122 /// <summary> 150 /// <summary>
123 /// Our nominal fps target, as expected in fps stats when a sim is running normally. 151 /// Our nominal fps target, as expected in fps stats when a sim is running normally.
@@ -135,43 +163,42 @@ namespace OpenSim.Region.Framework.Scenes
135 private float m_reportedFpsCorrectionFactor = 5; 163 private float m_reportedFpsCorrectionFactor = 5;
136 164
137 // saved last reported value so there is something available for llGetRegionFPS 165 // saved last reported value so there is something available for llGetRegionFPS
138 private float lastReportedSimFPS = 0; 166 private float lastReportedSimFPS;
139 private float[] lastReportedSimStats = new float[23]; 167 private float[] lastReportedSimStats = new float[22];
140 private float m_pfps = 0; 168 private float m_pfps;
141 169
142 /// <summary> 170 /// <summary>
143 /// Number of agent updates requested in this stats cycle 171 /// Number of agent updates requested in this stats cycle
144 /// </summary> 172 /// </summary>
145 private int m_agentUpdates = 0; 173 private int m_agentUpdates;
146 174
147 /// <summary> 175 /// <summary>
148 /// Number of object updates requested in this stats cycle 176 /// Number of object updates requested in this stats cycle
149 /// </summary> 177 /// </summary>
150 private int m_objectUpdates; 178 private int m_objectUpdates;
151 179
152 private int m_frameMS = 0; 180 private int m_frameMS;
153 private int m_netMS = 0; 181 private int m_spareMS;
154 private int m_agentMS = 0; 182 private int m_netMS;
155 private int m_physicsMS = 0; 183 private int m_agentMS;
156 private int m_imageMS = 0; 184 private int m_physicsMS;
157 private int m_otherMS = 0; 185 private int m_imageMS;
158 private int m_sleeptimeMS = 0; 186 private int m_otherMS;
159
160 187
161//Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed. 188//Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed.
162//Ckrinke private int m_scriptMS = 0; 189//Ckrinke private int m_scriptMS = 0;
163 190
164 private int m_rootAgents = 0; 191 private int m_rootAgents;
165 private int m_childAgents = 0; 192 private int m_childAgents;
166 private int m_numPrim = 0; 193 private int m_numPrim;
167 private int m_inPacketsPerSecond = 0; 194 private int m_inPacketsPerSecond;
168 private int m_outPacketsPerSecond = 0; 195 private int m_outPacketsPerSecond;
169 private int m_activePrim = 0; 196 private int m_activePrim;
170 private int m_unAckedBytes = 0; 197 private int m_unAckedBytes;
171 private int m_pendingDownloads = 0; 198 private int m_pendingDownloads;
172 private int m_pendingUploads = 0; 199 private int m_pendingUploads = 0; // FIXME: Not currently filled in
173 private int m_activeScripts = 0; 200 private int m_activeScripts;
174 private int m_scriptLinesPerSecond = 0; 201 private int m_scriptLinesPerSecond;
175 202
176 private int m_objectCapacity = 45000; 203 private int m_objectCapacity = 45000;
177 204
@@ -187,13 +214,13 @@ namespace OpenSim.Region.Framework.Scenes
187 { 214 {
188 m_scene = scene; 215 m_scene = scene;
189 m_reportedFpsCorrectionFactor = scene.MinFrameTime * m_nominalReportedFps; 216 m_reportedFpsCorrectionFactor = scene.MinFrameTime * m_nominalReportedFps;
190 statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000); 217 m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000);
191 ReportingRegion = scene.RegionInfo; 218 ReportingRegion = scene.RegionInfo;
192 219
193 m_objectCapacity = scene.RegionInfo.ObjectCapacity; 220 m_objectCapacity = scene.RegionInfo.ObjectCapacity;
194 m_report.AutoReset = true; 221 m_report.AutoReset = true;
195 m_report.Interval = statsUpdatesEveryMS; 222 m_report.Interval = m_statsUpdatesEveryMS;
196 m_report.Elapsed += statsHeartBeat; 223 m_report.Elapsed += TriggerStatsHeartbeat;
197 m_report.Enabled = true; 224 m_report.Enabled = true;
198 225
199 if (StatsManager.SimExtraStats != null) 226 if (StatsManager.SimExtraStats != null)
@@ -202,20 +229,38 @@ namespace OpenSim.Region.Framework.Scenes
202 229
203 public void Close() 230 public void Close()
204 { 231 {
205 m_report.Elapsed -= statsHeartBeat; 232 m_report.Elapsed -= TriggerStatsHeartbeat;
206 m_report.Close(); 233 m_report.Close();
207 } 234 }
208 235
236 /// <summary>
237 /// Sets the number of milliseconds between stat updates.
238 /// </summary>
239 /// <param name='ms'></param>
209 public void SetUpdateMS(int ms) 240 public void SetUpdateMS(int ms)
210 { 241 {
211 statsUpdatesEveryMS = ms; 242 m_statsUpdatesEveryMS = ms;
212 statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000); 243 m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000);
213 m_report.Interval = statsUpdatesEveryMS; 244 m_report.Interval = m_statsUpdatesEveryMS;
245 }
246
247 private void TriggerStatsHeartbeat(object sender, EventArgs args)
248 {
249 try
250 {
251 statsHeartBeat(sender, args);
252 }
253 catch (Exception e)
254 {
255 m_log.Warn(string.Format(
256 "[SIM STATS REPORTER] Update for {0} failed with exception ",
257 m_scene.RegionInfo.RegionName), e);
258 }
214 } 259 }
215 260
216 private void statsHeartBeat(object sender, EventArgs e) 261 private void statsHeartBeat(object sender, EventArgs e)
217 { 262 {
218 SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[23]; 263 SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[22];
219 SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); 264 SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
220 265
221 // Know what's not thread safe in Mono... modifying timers. 266 // Know what's not thread safe in Mono... modifying timers.
@@ -242,7 +287,7 @@ namespace OpenSim.Region.Framework.Scenes
242 int reportedFPS = (int)(m_fps * m_reportedFpsCorrectionFactor); 287 int reportedFPS = (int)(m_fps * m_reportedFpsCorrectionFactor);
243 288
244 // save the reported value so there is something available for llGetRegionFPS 289 // save the reported value so there is something available for llGetRegionFPS
245 lastReportedSimFPS = reportedFPS / statsUpdateFactor; 290 lastReportedSimFPS = reportedFPS / m_statsUpdateFactor;
246 291
247 float physfps = ((m_pfps / 1000)); 292 float physfps = ((m_pfps / 1000));
248 293
@@ -253,7 +298,6 @@ namespace OpenSim.Region.Framework.Scenes
253 physfps = 0; 298 physfps = 0;
254 299
255#endregion 300#endregion
256 float factor = 1 / statsUpdateFactor;
257 if (reportedFPS <= 0) 301 if (reportedFPS <= 0)
258 reportedFPS = 1; 302 reportedFPS = 1;
259 303
@@ -264,32 +308,38 @@ namespace OpenSim.Region.Framework.Scenes
264 float targetframetime = 1100.0f / (float)m_nominalReportedFps; 308 float targetframetime = 1100.0f / (float)m_nominalReportedFps;
265 309
266 float sparetime; 310 float sparetime;
267 float sleeptime;
268 if (TotalFrameTime > targetframetime) 311 if (TotalFrameTime > targetframetime)
269 { 312 {
270 sparetime = 0; 313 sparetime = 0;
271 sleeptime = 0;
272 }
273 else
274 {
275 sparetime = m_frameMS - m_physicsMS - m_agentMS;
276 sparetime *= perframe;
277 if (sparetime < 0)
278 sparetime = 0;
279 else if (sparetime > TotalFrameTime)
280 sparetime = TotalFrameTime;
281 sleeptime = m_sleeptimeMS * perframe;
282 } 314 }
315
316 m_rootAgents = m_scene.SceneGraph.GetRootAgentCount();
317 m_childAgents = m_scene.SceneGraph.GetChildAgentCount();
318 m_numPrim = m_scene.SceneGraph.GetTotalObjectsCount();
319 m_activePrim = m_scene.SceneGraph.GetActiveObjectsCount();
320 m_activeScripts = m_scene.SceneGraph.GetActiveScriptsCount();
321
322 // FIXME: Checking for stat sanity is a complex approach. What we really need to do is fix the code
323 // so that stat numbers are always consistent.
324 CheckStatSanity();
283 325
284 // other MS is actually simulation time 326 // other MS is actually simulation time
285 // m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS; 327 // m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS;
286 // m_imageMS m_netMS are not included in m_frameMS 328 // m_imageMS m_netMS are not included in m_frameMS
287 329
288 m_otherMS = m_frameMS - m_physicsMS - m_agentMS - m_sleeptimeMS; 330 m_otherMS = m_frameMS - m_physicsMS - m_agentMS;
289 if (m_otherMS < 0) 331 if (m_otherMS < 0)
290 m_otherMS = 0; 332 m_otherMS = 0;
291 333
292 for (int i = 0; i < 23; i++) 334 uint thisFrame = m_scene.Frame;
335 float framesUpdated = (float)(thisFrame - m_lastUpdateFrame) * m_reportedFpsCorrectionFactor;
336 m_lastUpdateFrame = thisFrame;
337
338 // Avoid div-by-zero if somehow we've not updated any frames.
339 if (framesUpdated == 0)
340 framesUpdated = 1;
341
342 for (int i = 0; i < 22; i++)
293 { 343 {
294 sb[i] = new SimStatsPacket.StatBlock(); 344 sb[i] = new SimStatsPacket.StatBlock();
295 } 345 }
@@ -298,13 +348,13 @@ namespace OpenSim.Region.Framework.Scenes
298 sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor)); 348 sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor));
299 349
300 sb[1].StatID = (uint) Stats.SimFPS; 350 sb[1].StatID = (uint) Stats.SimFPS;
301 sb[1].StatValue = reportedFPS / statsUpdateFactor; 351 sb[1].StatValue = reportedFPS / m_statsUpdateFactor;
302 352
303 sb[2].StatID = (uint) Stats.PhysicsFPS; 353 sb[2].StatID = (uint) Stats.PhysicsFPS;
304 sb[2].StatValue = physfps / statsUpdateFactor; 354 sb[2].StatValue = physfps / m_statsUpdateFactor;
305 355
306 sb[3].StatID = (uint) Stats.AgentUpdates; 356 sb[3].StatID = (uint) Stats.AgentUpdates;
307 sb[3].StatValue = (m_agentUpdates / statsUpdateFactor); 357 sb[3].StatValue = (m_agentUpdates / m_statsUpdateFactor);
308 358
309 sb[4].StatID = (uint) Stats.Agents; 359 sb[4].StatID = (uint) Stats.Agents;
310 sb[4].StatValue = m_rootAgents; 360 sb[4].StatValue = m_rootAgents;
@@ -319,38 +369,31 @@ namespace OpenSim.Region.Framework.Scenes
319 sb[7].StatValue = m_activePrim; 369 sb[7].StatValue = m_activePrim;
320 370
321 sb[8].StatID = (uint)Stats.FrameMS; 371 sb[8].StatID = (uint)Stats.FrameMS;
322 // sb[8].StatValue = m_frameMS / statsUpdateFactor; 372 sb[8].StatValue = m_frameMS / framesUpdated;
323 sb[8].StatValue = TotalFrameTime;
324 373
325 sb[9].StatID = (uint)Stats.NetMS; 374 sb[9].StatID = (uint)Stats.NetMS;
326 // sb[9].StatValue = m_netMS / statsUpdateFactor; 375 sb[9].StatValue = m_netMS / framesUpdated;
327 sb[9].StatValue = m_netMS * perframe;
328 376
329 sb[10].StatID = (uint)Stats.PhysicsMS; 377 sb[10].StatID = (uint)Stats.PhysicsMS;
330 // sb[10].StatValue = m_physicsMS / statsUpdateFactor; 378 sb[10].StatValue = m_physicsMS / framesUpdated;
331 sb[10].StatValue = m_physicsMS * perframe;
332 379
333 sb[11].StatID = (uint)Stats.ImageMS ; 380 sb[11].StatID = (uint)Stats.ImageMS ;
334 // sb[11].StatValue = m_imageMS / statsUpdateFactor; 381 sb[11].StatValue = m_imageMS / framesUpdated;
335 sb[11].StatValue = m_imageMS * perframe;
336 382
337 sb[12].StatID = (uint)Stats.OtherMS; 383 sb[12].StatID = (uint)Stats.OtherMS;
338 // sb[12].StatValue = m_otherMS / statsUpdateFactor; 384 sb[12].StatValue = m_otherMS / framesUpdated;
339 sb[12].StatValue = m_otherMS * perframe;
340
341 385
342 sb[13].StatID = (uint)Stats.InPacketsPerSecond; 386 sb[13].StatID = (uint)Stats.InPacketsPerSecond;
343 sb[13].StatValue = (m_inPacketsPerSecond / statsUpdateFactor); 387 sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor);
344 388
345 sb[14].StatID = (uint)Stats.OutPacketsPerSecond; 389 sb[14].StatID = (uint)Stats.OutPacketsPerSecond;
346 sb[14].StatValue = (m_outPacketsPerSecond / statsUpdateFactor); 390 sb[14].StatValue = (m_outPacketsPerSecond / m_statsUpdateFactor);
347 391
348 sb[15].StatID = (uint)Stats.UnAckedBytes; 392 sb[15].StatID = (uint)Stats.UnAckedBytes;
349 sb[15].StatValue = m_unAckedBytes; 393 sb[15].StatValue = m_unAckedBytes;
350 394
351 sb[16].StatID = (uint)Stats.AgentMS; 395 sb[16].StatID = (uint)Stats.AgentMS;
352// sb[16].StatValue = m_agentMS / statsUpdateFactor; 396 sb[16].StatValue = m_agentMS / framesUpdated;
353 sb[16].StatValue = m_agentMS * perframe;
354 397
355 sb[17].StatID = (uint)Stats.PendingDownloads; 398 sb[17].StatID = (uint)Stats.PendingDownloads;
356 sb[17].StatValue = m_pendingDownloads; 399 sb[17].StatValue = m_pendingDownloads;
@@ -362,15 +405,12 @@ namespace OpenSim.Region.Framework.Scenes
362 sb[19].StatValue = m_activeScripts; 405 sb[19].StatValue = m_activeScripts;
363 406
364 sb[20].StatID = (uint)Stats.ScriptLinesPerSecond; 407 sb[20].StatID = (uint)Stats.ScriptLinesPerSecond;
365 sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor; 408 sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor;
366 409
367 sb[21].StatID = (uint)Stats.SimSpareTime; 410 sb[21].StatID = (uint)Stats.SimSpareMs;
368 sb[21].StatValue = sparetime; 411 sb[21].StatValue = m_spareMS / framesUpdated;
369 412
370 sb[22].StatID = (uint)Stats.SimSleepTime; 413 for (int i = 0; i < 22; i++)
371 sb[22].StatValue = sleeptime;
372
373 for (int i = 0; i < 23; i++)
374 { 414 {
375 lastReportedSimStats[i] = sb[i].StatValue; 415 lastReportedSimStats[i] = sb[i].StatValue;
376 } 416 }
@@ -387,13 +427,32 @@ namespace OpenSim.Region.Framework.Scenes
387 } 427 }
388 428
389 // Extra statistics that aren't currently sent to clients 429 // Extra statistics that aren't currently sent to clients
390 LastReportedObjectUpdates = m_objectUpdates / statsUpdateFactor; 430 lock (m_lastReportedExtraSimStats)
431 {
432 m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor;
433
434 Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats();
435
436 if (physicsStats != null)
437 {
438 foreach (KeyValuePair<string, float> tuple in physicsStats)
439 {
440 // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second
441 // Need to change things so that stats source can indicate whether they are per second or
442 // per frame.
443 if (tuple.Key.EndsWith("MS"))
444 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / framesUpdated;
445 else
446 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor;
447 }
448 }
449 }
391 450
392 resetvalues(); 451 ResetValues();
393 } 452 }
394 } 453 }
395 454
396 private void resetvalues() 455 private void ResetValues()
397 { 456 {
398 m_timeDilation = 0; 457 m_timeDilation = 0;
399 m_fps = 0; 458 m_fps = 0;
@@ -411,7 +470,7 @@ namespace OpenSim.Region.Framework.Scenes
411 m_physicsMS = 0; 470 m_physicsMS = 0;
412 m_imageMS = 0; 471 m_imageMS = 0;
413 m_otherMS = 0; 472 m_otherMS = 0;
414 m_sleeptimeMS = 0; 473 m_spareMS = 0;
415 474
416//Ckrinke This variable is not used, so comment to remove compiler warning until it is used. 475//Ckrinke This variable is not used, so comment to remove compiler warning until it is used.
417//Ckrinke m_scriptMS = 0; 476//Ckrinke m_scriptMS = 0;
@@ -433,13 +492,6 @@ namespace OpenSim.Region.Framework.Scenes
433 m_timeDilation = td; 492 m_timeDilation = td;
434 } 493 }
435 494
436 public void SetRootAgents(int rootAgents)
437 {
438 m_rootAgents = rootAgents;
439 CheckStatSanity();
440
441 }
442
443 internal void CheckStatSanity() 495 internal void CheckStatSanity()
444 { 496 {
445 if (m_rootAgents < 0 || m_childAgents < 0) 497 if (m_rootAgents < 0 || m_childAgents < 0)
@@ -456,22 +508,6 @@ namespace OpenSim.Region.Framework.Scenes
456 } 508 }
457 } 509 }
458 510
459 public void SetChildAgents(int childAgents)
460 {
461 m_childAgents = childAgents;
462 CheckStatSanity();
463 }
464
465 public void SetObjects(int objects)
466 {
467 m_numPrim = objects;
468 }
469
470 public void SetActiveObjects(int objects)
471 {
472 m_activePrim = objects;
473 }
474
475 public void AddFPS(int frames) 511 public void AddFPS(int frames)
476 { 512 {
477 m_fps += frames; 513 m_fps += frames;
@@ -513,6 +549,11 @@ namespace OpenSim.Region.Framework.Scenes
513 m_frameMS += ms; 549 m_frameMS += ms;
514 } 550 }
515 551
552 public void AddSpareMS(int ms)
553 {
554 m_spareMS += ms;
555 }
556
516 public void addNetMS(int ms) 557 public void addNetMS(int ms)
517 { 558 {
518 m_netMS += ms; 559 m_netMS += ms;
@@ -538,15 +579,13 @@ namespace OpenSim.Region.Framework.Scenes
538 m_otherMS += ms; 579 m_otherMS += ms;
539 } 580 }
540 581
541 public void addSleepMS(int ms)
542 {
543 m_sleeptimeMS += ms;
544 }
545
546 public void AddPendingDownloads(int count) 582 public void AddPendingDownloads(int count)
547 { 583 {
548 m_pendingDownloads += count; 584 m_pendingDownloads += count;
549 if (m_pendingDownloads < 0) m_pendingDownloads = 0; 585
586 if (m_pendingDownloads < 0)
587 m_pendingDownloads = 0;
588
550 //m_log.InfoFormat("[stats]: Adding {0} to pending downloads to make {1}", count, m_pendingDownloads); 589 //m_log.InfoFormat("[stats]: Adding {0} to pending downloads to make {1}", count, m_pendingDownloads);
551 } 590 }
552 591
@@ -555,11 +594,6 @@ namespace OpenSim.Region.Framework.Scenes
555 m_scriptLinesPerSecond += count; 594 m_scriptLinesPerSecond += count;
556 } 595 }
557 596
558 public void SetActiveScripts(int count)
559 {
560 m_activeScripts = count;
561 }
562
563 public void AddPacketsStats(int inPackets, int outPackets, int unAckedBytes) 597 public void AddPacketsStats(int inPackets, int outPackets, int unAckedBytes)
564 { 598 {
565 AddInPackets(inPackets); 599 AddInPackets(inPackets);
@@ -568,5 +602,11 @@ namespace OpenSim.Region.Framework.Scenes
568 } 602 }
569 603
570 #endregion 604 #endregion
605
606 public Dictionary<string, float> GetExtraSimStats()
607 {
608 lock (m_lastReportedExtraSimStats)
609 return new Dictionary<string, float>(m_lastReportedExtraSimStats);
610 }
571 } 611 }
572} 612}
diff --git a/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs b/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs
index ab6311b..4a21dc9 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO;
30using System.Text; 31using System.Text;
31using NUnit.Framework; 32using NUnit.Framework;
32using OpenMetaverse; 33using OpenMetaverse;
@@ -68,11 +69,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
68 Vector3 position = new Vector3(200,200,21); 69 Vector3 position = new Vector3(200,200,21);
69 70
70 foreach (Border b in testborders) 71 foreach (Border b in testborders)
71 {
72 Assert.That(!b.TestCross(position)); 72 Assert.That(!b.TestCross(position));
73 73
74 }
75
76 position = new Vector3(200,280,21); 74 position = new Vector3(200,280,21);
77 Assert.That(NorthBorder.TestCross(position)); 75 Assert.That(NorthBorder.TestCross(position));
78 76
diff --git a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
index a5d2b23..ea9fc93 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs
@@ -45,7 +45,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
45 { 45 {
46 static public Random random; 46 static public Random random;
47 SceneObjectGroup found; 47 SceneObjectGroup found;
48 Scene scene = SceneHelpers.SetupScene(); 48 Scene scene = new SceneHelpers().SetupScene();
49 49
50 [Test] 50 [Test]
51 public void T010_AddObjects() 51 public void T010_AddObjects()
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
index 9a60e50..d23c965 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
@@ -26,7 +26,9 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.IO;
29using System.Reflection; 30using System.Reflection;
31using System.Text;
30using NUnit.Framework; 32using NUnit.Framework;
31using OpenMetaverse; 33using OpenMetaverse;
32using OpenSim.Framework; 34using OpenSim.Framework;
@@ -44,7 +46,9 @@ namespace OpenSim.Region.Framework.Scenes.Tests
44 public void TestDuplicateObject() 46 public void TestDuplicateObject()
45 { 47 {
46 TestHelpers.InMethod(); 48 TestHelpers.InMethod();
47 Scene scene = SceneHelpers.SetupScene(); 49// TestHelpers.EnableLogging();
50
51 Scene scene = new SceneHelpers().SetupScene();
48 52
49 UUID ownerId = new UUID("00000000-0000-0000-0000-000000000010"); 53 UUID ownerId = new UUID("00000000-0000-0000-0000-000000000010");
50 string part1Name = "part1"; 54 string part1Name = "part1";
@@ -82,6 +86,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
82 Assert.That(dupePart1.PhysActor, Is.Not.Null); 86 Assert.That(dupePart1.PhysActor, Is.Not.Null);
83 Assert.That(dupePart2.PhysActor, Is.Not.Null); 87 Assert.That(dupePart2.PhysActor, Is.Not.Null);
84 */ 88 */
89
90// TestHelpers.DisableLogging();
85 } 91 }
86 } 92 }
87} \ No newline at end of file 93} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
index 7737d8e..453e077 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
@@ -88,7 +88,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
88 { 88 {
89 TestHelpers.InMethod(); 89 TestHelpers.InMethod();
90 90
91 Scene scene = SceneHelpers.SetupScene(); 91 Scene scene = new SceneHelpers().SetupScene();
92 int partsToTestCount = 3; 92 int partsToTestCount = 3;
93 93
94 SceneObjectGroup so 94 SceneObjectGroup so
@@ -118,7 +118,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
118 { 118 {
119 TestHelpers.InMethod(); 119 TestHelpers.InMethod();
120 120
121 Scene scene = SceneHelpers.SetupScene(); 121 Scene scene = new SceneHelpers().SetupScene();
122 122
123 string obj1Name = "Alfred"; 123 string obj1Name = "Alfred";
124 string obj2Name = "Betty"; 124 string obj2Name = "Betty";
@@ -152,7 +152,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
152 { 152 {
153 TestHelpers.InMethod(); 153 TestHelpers.InMethod();
154 154
155 Scene scene = SceneHelpers.SetupScene(); 155 Scene scene = new SceneHelpers().SetupScene();
156 int partsToTestCount = 3; 156 int partsToTestCount = 3;
157 157
158 SceneObjectGroup so 158 SceneObjectGroup so
@@ -185,7 +185,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
185 { 185 {
186 TestHelpers.InMethod(); 186 TestHelpers.InMethod();
187 187
188 TestScene scene = SceneHelpers.SetupScene(); 188 TestScene scene = new SceneHelpers().SetupScene();
189 SceneObjectPart part = SceneHelpers.AddSceneObject(scene); 189 SceneObjectPart part = SceneHelpers.AddSceneObject(scene);
190 scene.DeleteSceneObject(part.ParentGroup, false); 190 scene.DeleteSceneObject(part.ParentGroup, false);
191 191
@@ -204,7 +204,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
204 204
205 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); 205 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001");
206 206
207 TestScene scene = SceneHelpers.SetupScene(); 207 TestScene scene = new SceneHelpers().SetupScene();
208 208
209 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. 209 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
210 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; 210 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
index 654b1a2..0076f41 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs
@@ -61,7 +61,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
61 61
62 UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); 62 UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001");
63 63
64 TestScene scene = SceneHelpers.SetupScene(); 64 TestScene scene = new SceneHelpers().SetupScene();
65 IConfigSource configSource = new IniConfigSource(); 65 IConfigSource configSource = new IniConfigSource();
66 IConfig config = configSource.AddConfig("Startup"); 66 IConfig config = configSource.AddConfig("Startup");
67 config.Set("serverside_object_permissions", true); 67 config.Set("serverside_object_permissions", true);
@@ -100,7 +100,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
100 UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); 100 UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001");
101 UUID objectOwnerId = UUID.Parse("20000000-0000-0000-0000-000000000001"); 101 UUID objectOwnerId = UUID.Parse("20000000-0000-0000-0000-000000000001");
102 102
103 TestScene scene = SceneHelpers.SetupScene(); 103 TestScene scene = new SceneHelpers().SetupScene();
104 IConfigSource configSource = new IniConfigSource(); 104 IConfigSource configSource = new IniConfigSource();
105 IConfig config = configSource.AddConfig("Startup"); 105 IConfig config = configSource.AddConfig("Startup");
106 config.Set("serverside_object_permissions", true); 106 config.Set("serverside_object_permissions", true);
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
index be5b4a8..1add3dd 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
@@ -55,7 +55,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
55 UUID ownerId = TestHelpers.ParseTail(0x1); 55 UUID ownerId = TestHelpers.ParseTail(0x1);
56 int nParts = 3; 56 int nParts = 3;
57 57
58 TestScene scene = SceneHelpers.SetupScene(); 58 TestScene scene = new SceneHelpers().SetupScene();
59 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(nParts, ownerId, "TestLinkToSelf_", 0x10); 59 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(nParts, ownerId, "TestLinkToSelf_", 0x10);
60 scene.AddSceneObject(sog1); 60 scene.AddSceneObject(sog1);
61 scene.LinkObjects(ownerId, sog1.LocalId, new List<uint>() { sog1.Parts[1].LocalId }); 61 scene.LinkObjects(ownerId, sog1.LocalId, new List<uint>() { sog1.Parts[1].LocalId });
@@ -71,7 +71,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
71 71
72 bool debugtest = false; 72 bool debugtest = false;
73 73
74 Scene scene = SceneHelpers.SetupScene(); 74 Scene scene = new SceneHelpers().SetupScene();
75 SceneObjectPart part1 = SceneHelpers.AddSceneObject(scene); 75 SceneObjectPart part1 = SceneHelpers.AddSceneObject(scene);
76 SceneObjectGroup grp1 = part1.ParentGroup; 76 SceneObjectGroup grp1 = part1.ParentGroup;
77 SceneObjectPart part2 = SceneHelpers.AddSceneObject(scene); 77 SceneObjectPart part2 = SceneHelpers.AddSceneObject(scene);
@@ -153,7 +153,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
153 153
154 bool debugtest = false; 154 bool debugtest = false;
155 155
156 Scene scene = SceneHelpers.SetupScene(); 156 Scene scene = new SceneHelpers().SetupScene();
157 SceneObjectPart part1 = SceneHelpers.AddSceneObject(scene); 157 SceneObjectPart part1 = SceneHelpers.AddSceneObject(scene);
158 SceneObjectGroup grp1 = part1.ParentGroup; 158 SceneObjectGroup grp1 = part1.ParentGroup;
159 SceneObjectPart part2 = SceneHelpers.AddSceneObject(scene); 159 SceneObjectPart part2 = SceneHelpers.AddSceneObject(scene);
@@ -286,7 +286,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
286 TestHelpers.InMethod(); 286 TestHelpers.InMethod();
287 //log4net.Config.XmlConfigurator.Configure(); 287 //log4net.Config.XmlConfigurator.Configure();
288 288
289 TestScene scene = SceneHelpers.SetupScene(); 289 TestScene scene = new SceneHelpers().SetupScene();
290 290
291 string rootPartName = "rootpart"; 291 string rootPartName = "rootpart";
292 UUID rootPartUuid = new UUID("00000000-0000-0000-0000-000000000001"); 292 UUID rootPartUuid = new UUID("00000000-0000-0000-0000-000000000001");
@@ -325,7 +325,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
325 TestHelpers.InMethod(); 325 TestHelpers.InMethod();
326 //log4net.Config.XmlConfigurator.Configure(); 326 //log4net.Config.XmlConfigurator.Configure();
327 327
328 TestScene scene = SceneHelpers.SetupScene(); 328 TestScene scene = new SceneHelpers().SetupScene();
329 329
330 string rootPartName = "rootpart"; 330 string rootPartName = "rootpart";
331 UUID rootPartUuid = new UUID("00000000-0000-0000-0000-000000000001"); 331 UUID rootPartUuid = new UUID("00000000-0000-0000-0000-000000000001");
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
index b49c6e7..0a94c19 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
@@ -52,7 +52,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
52 TestHelpers.InMethod(); 52 TestHelpers.InMethod();
53// log4net.Config.XmlConfigurator.Configure(); 53// log4net.Config.XmlConfigurator.Configure();
54 54
55 Scene scene = SceneHelpers.SetupScene(); 55 Scene scene = new SceneHelpers().SetupScene();
56 SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene).ParentGroup; 56 SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene).ParentGroup;
57 57
58 g1.GroupResize(new Vector3(2, 3, 4)); 58 g1.GroupResize(new Vector3(2, 3, 4));
@@ -75,7 +75,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
75 TestHelpers.InMethod(); 75 TestHelpers.InMethod();
76 //log4net.Config.XmlConfigurator.Configure(); 76 //log4net.Config.XmlConfigurator.Configure();
77 77
78 Scene scene = SceneHelpers.SetupScene(); 78 Scene scene = new SceneHelpers().SetupScene();
79 79
80 SceneObjectGroup g1 = SceneHelpers.CreateSceneObject(2, UUID.Zero); 80 SceneObjectGroup g1 = SceneHelpers.CreateSceneObject(2, UUID.Zero);
81 g1.RootPart.Scale = new Vector3(2, 3, 4); 81 g1.RootPart.Scale = new Vector3(2, 3, 4);
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs
index c582cf6..d2361f8 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs
@@ -52,7 +52,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
52// UUID itemId = TestHelpers.ParseTail(0x2); 52// UUID itemId = TestHelpers.ParseTail(0x2);
53 string itemName = "Test Script Item"; 53 string itemName = "Test Script Item";
54 54
55 Scene scene = SceneHelpers.SetupScene(); 55 Scene scene = new SceneHelpers().SetupScene();
56 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId); 56 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId);
57 scene.AddNewSceneObject(so, true); 57 scene.AddNewSceneObject(so, true);
58 58
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs
new file mode 100644
index 0000000..6d255aa
--- /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
28using System;
29using System.Reflection;
30using System.Threading;
31using NUnit.Framework;
32using OpenMetaverse;
33using OpenSim.Framework;
34using OpenSim.Framework.Communications;
35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Tests.Common;
37using OpenSim.Tests.Common.Mock;
38
39namespace 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 = new 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
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs
index 2a342d5..742c769 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using System.Reflection; 30using System.Reflection;
30using NUnit.Framework; 31using NUnit.Framework;
31using OpenMetaverse; 32using OpenMetaverse;
@@ -43,24 +44,141 @@ namespace OpenSim.Region.Framework.Scenes.Tests
43 [TestFixture] 44 [TestFixture]
44 public class SceneObjectStatusTests 45 public class SceneObjectStatusTests
45 { 46 {
47 private TestScene m_scene;
48 private UUID m_ownerId = TestHelpers.ParseTail(0x1);
49 private SceneObjectGroup m_so1;
50 private SceneObjectGroup m_so2;
51
52 [SetUp]
53 public void Init()
54 {
55 m_scene = new SceneHelpers().SetupScene();
56 m_so1 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so1", 0x10);
57 m_so2 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so2", 0x20);
58 }
59
46 [Test] 60 [Test]
47 public void TestSetPhantom() 61 public void TestSetPhantomSinglePrim()
48 { 62 {
49 TestHelpers.InMethod(); 63 TestHelpers.InMethod();
50 64
51// Scene scene = SceneSetupHelpers.SetupScene(); 65 m_scene.AddSceneObject(m_so1);
52 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, UUID.Zero); 66
53 SceneObjectPart rootPart = so.RootPart; 67 SceneObjectPart rootPart = m_so1.RootPart;
54 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); 68 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
55 69
56 so.ScriptSetPhantomStatus(true); 70 m_so1.ScriptSetPhantomStatus(true);
57 71
58// Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags); 72// Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags);
59 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom)); 73 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom));
60 74
61 so.ScriptSetPhantomStatus(false); 75 m_so1.ScriptSetPhantomStatus(false);
62 76
63 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); 77 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
64 } 78 }
79
80 [Test]
81 public void TestSetPhysicsSinglePrim()
82 {
83 TestHelpers.InMethod();
84
85 m_scene.AddSceneObject(m_so1);
86
87 SceneObjectPart rootPart = m_so1.RootPart;
88 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
89
90 m_so1.ScriptSetPhysicsStatus(true);
91
92// Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags);
93 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics));
94
95 m_so1.ScriptSetPhysicsStatus(false);
96
97 Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
98 }
99
100 [Test]
101 public void TestSetPhysicsLinkset()
102 {
103 TestHelpers.InMethod();
104
105 m_scene.AddSceneObject(m_so1);
106 m_scene.AddSceneObject(m_so2);
107
108 m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
109
110 m_so1.ScriptSetPhysicsStatus(true);
111
112 Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
113 Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
114
115 m_so1.ScriptSetPhysicsStatus(false);
116
117 Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None));
118 Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None));
119
120 m_so1.ScriptSetPhysicsStatus(true);
121
122 Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
123 Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
124 }
125
126 /// <summary>
127 /// Test that linking results in the correct physical status for all linkees.
128 /// </summary>
129 [Test]
130 public void TestLinkPhysicsBothPhysical()
131 {
132 TestHelpers.InMethod();
133
134 m_scene.AddSceneObject(m_so1);
135 m_scene.AddSceneObject(m_so2);
136
137 m_so1.ScriptSetPhysicsStatus(true);
138 m_so2.ScriptSetPhysicsStatus(true);
139
140 m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
141
142 Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
143 Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
144 }
145
146 /// <summary>
147 /// Test that linking results in the correct physical status for all linkees.
148 /// </summary>
149 [Test]
150 public void TestLinkPhysicsRootPhysicalOnly()
151 {
152 TestHelpers.InMethod();
153
154 m_scene.AddSceneObject(m_so1);
155 m_scene.AddSceneObject(m_so2);
156
157 m_so1.ScriptSetPhysicsStatus(true);
158
159 m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
160
161 Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
162 Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
163 }
164
165 /// <summary>
166 /// Test that linking results in the correct physical status for all linkees.
167 /// </summary>
168 [Test]
169 public void TestLinkPhysicsChildPhysicalOnly()
170 {
171 TestHelpers.InMethod();
172
173 m_scene.AddSceneObject(m_so1);
174 m_scene.AddSceneObject(m_so2);
175
176 m_so2.ScriptSetPhysicsStatus(true);
177
178 m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
179
180 Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None));
181 Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None));
182 }
65 } 183 }
66} \ No newline at end of file 184} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs
index c13d82e..c7eaff9 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
58 58
59 UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); 59 UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001");
60 60
61 TestScene scene = SceneHelpers.SetupScene(); 61 TestScene scene = new SceneHelpers().SetupScene();
62 IConfigSource configSource = new IniConfigSource(); 62 IConfigSource configSource = new IniConfigSource();
63 63
64 IConfig startupConfig = configSource.AddConfig("Startup"); 64 IConfig startupConfig = configSource.AddConfig("Startup");
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
index ed9b179..1aa48d7 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
@@ -67,10 +67,12 @@ namespace OpenSim.Region.Framework.Scenes.Tests
67 public void Init() 67 public void Init()
68 { 68 {
69 TestHelpers.InMethod(); 69 TestHelpers.InMethod();
70 70
71 scene = SceneHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); 71 SceneHelpers sh = new SceneHelpers();
72 scene2 = SceneHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000); 72
73 scene3 = SceneHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000); 73 scene = sh.SetupScene("Neighbour x", UUID.Random(), 1000, 1000);
74 scene2 = sh.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000);
75 scene3 = sh.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000);
74 76
75 ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); 77 ISharedRegionModule interregionComms = new LocalSimulationConnectorModule();
76 interregionComms.Initialise(new IniConfigSource()); 78 interregionComms.Initialise(new IniConfigSource());
@@ -101,7 +103,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
101 TestHelpers.InMethod(); 103 TestHelpers.InMethod();
102// log4net.Config.XmlConfigurator.Configure(); 104// log4net.Config.XmlConfigurator.Configure();
103 105
104 TestScene scene = SceneHelpers.SetupScene(); 106 TestScene scene = new SceneHelpers().SetupScene();
105 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); 107 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
106 108
107 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Not.Null); 109 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Not.Null);
@@ -126,7 +128,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
126 IConfig config = configSource.AddConfig("Modules"); 128 IConfig config = configSource.AddConfig("Modules");
127 config.Set("SimulationServices", "LocalSimulationConnectorModule"); 129 config.Set("SimulationServices", "LocalSimulationConnectorModule");
128 130
129 TestScene scene = SceneHelpers.SetupScene(); 131 SceneHelpers sceneHelpers = new SceneHelpers();
132 TestScene scene = sceneHelpers.SetupScene();
130 SceneHelpers.SetupSceneModules(scene, configSource, lsc); 133 SceneHelpers.SetupSceneModules(scene, configSource, lsc);
131 134
132 UUID agentId = TestHelpers.ParseTail(0x01); 135 UUID agentId = TestHelpers.ParseTail(0x01);
@@ -176,8 +179,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
176 179
177// UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001"); 180// UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001");
178 181
179 TestScene myScene1 = SceneHelpers.SetupScene("Neighbour y", UUID.Random(), 1000, 1000); 182 TestScene myScene1 = new SceneHelpers().SetupScene("Neighbour y", UUID.Random(), 1000, 1000);
180 TestScene myScene2 = SceneHelpers.SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000); 183 TestScene myScene2 = new SceneHelpers().SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000);
181 184
182 IConfigSource configSource = new IniConfigSource(); 185 IConfigSource configSource = new IniConfigSource();
183 IConfig config = configSource.AddConfig("Startup"); 186 IConfig config = configSource.AddConfig("Startup");
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs
index 89f8007..646e5fa 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs
@@ -59,7 +59,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
59 TestHelpers.InMethod(); 59 TestHelpers.InMethod();
60// log4net.Config.XmlConfigurator.Configure(); 60// log4net.Config.XmlConfigurator.Configure();
61 61
62 TestScene scene = SceneHelpers.SetupScene(); 62 TestScene scene = new SceneHelpers().SetupScene();
63 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); 63 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
64 sp.Flying = true; 64 sp.Flying = true;
65 sp.PhysicsCollisionUpdate(new CollisionEventUpdate()); 65 sp.PhysicsCollisionUpdate(new CollisionEventUpdate());
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs
index cfea10d..1d1ff88 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs
@@ -64,7 +64,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
64 [SetUp] 64 [SetUp]
65 public void Init() 65 public void Init()
66 { 66 {
67 m_scene = SceneHelpers.SetupScene(); 67 m_scene = new SceneHelpers().SetupScene();
68 } 68 }
69 69
70 [Test] 70 [Test]
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs
index b7b8db4..313e350 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs
@@ -50,7 +50,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
50 [SetUp] 50 [SetUp]
51 public void Init() 51 public void Init()
52 { 52 {
53 m_scene = SceneHelpers.SetupScene(); 53 m_scene = new SceneHelpers().SetupScene();
54 m_sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); 54 m_sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1));
55 } 55 }
56 56
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
index bebc10c..ccfe4ff 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs
@@ -34,10 +34,14 @@ using OpenSim.Framework;
34using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Servers; 35using OpenSim.Framework.Servers;
36using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.CoreModules.Framework;
38using OpenSim.Region.CoreModules.Framework.EntityTransfer;
37using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; 39using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
40using OpenSim.Region.CoreModules.World.Permissions;
38using OpenSim.Tests.Common; 41using OpenSim.Tests.Common;
39using OpenSim.Tests.Common.Mock; 42using OpenSim.Tests.Common.Mock;
40using System.Threading; 43using System.IO;
44using System.Text;
41 45
42namespace OpenSim.Region.Framework.Scenes.Tests 46namespace OpenSim.Region.Framework.Scenes.Tests
43{ 47{
@@ -47,145 +51,344 @@ namespace OpenSim.Region.Framework.Scenes.Tests
47 [TestFixture] 51 [TestFixture]
48 public class ScenePresenceTeleportTests 52 public class ScenePresenceTeleportTests
49 { 53 {
50 /// <summary> 54 [TestFixtureSetUp]
51 /// Test a teleport between two regions that are not neighbours and do not share any neighbours in common. 55 public void FixtureInit()
52 /// </summary> 56 {
53 /// Does not yet do what is says on the tin. 57 // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
54 /// Commenting for now 58 Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest;
55 //[Test, LongRunning] 59 }
56 public void TestSimpleNotNeighboursTeleport() 60
61 [TestFixtureTearDown]
62 public void TearDown()
63 {
64 // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
65 // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression
66 // tests really shouldn't).
67 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
68 }
69
70 [Test]
71 public void TestSameRegionTeleport()
57 { 72 {
58 TestHelpers.InMethod(); 73 TestHelpers.InMethod();
59 ThreadRunResults results = new ThreadRunResults(); 74// log4net.Config.XmlConfigurator.Configure();
60 results.Result = false; 75
61 results.Message = "Test did not run"; 76 EntityTransferModule etm = new EntityTransferModule();
62 TestRunning testClass = new TestRunning(results); 77
78 IConfigSource config = new IniConfigSource();
79 config.AddConfig("Modules");
80 // Not strictly necessary since FriendsModule assumes it is the default (!)
81 config.Configs["Modules"].Set("EntityTransferModule", etm.Name);
82
83 TestScene scene = new SceneHelpers().SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
84 SceneHelpers.SetupSceneModules(scene, config, etm);
85
86 Vector3 teleportPosition = new Vector3(10, 11, 12);
87 Vector3 teleportLookAt = new Vector3(20, 21, 22);
63 88
64 Thread testThread = new Thread(testClass.run); 89 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
90 sp.AbsolutePosition = new Vector3(30, 31, 32);
91 scene.RequestTeleportLocation(
92 sp.ControllingClient,
93 scene.RegionInfo.RegionHandle,
94 teleportPosition,
95 teleportLookAt,
96 (uint)TeleportFlags.ViaLocation);
65 97
66 // Seems kind of redundant to start a thread and then join it, however.. We need to protect against 98 Assert.That(sp.AbsolutePosition, Is.EqualTo(teleportPosition));
67 // A thread abort exception in the simulator code.
68 testThread.Start();
69 testThread.Join();
70 99
71 Assert.That(testClass.results.Result, Is.EqualTo(true), testClass.results.Message); 100 // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
72 // Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod()); 101 // position instead).
102// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
73 } 103 }
74 104
75 [TearDown] 105 [Test]
76 public void TearDown() 106 public void TestSameSimulatorSeparatedRegionsTeleport()
77 { 107 {
78 try 108 TestHelpers.InMethod();
79 { 109// log4net.Config.XmlConfigurator.Configure();
80 if (MainServer.Instance != null) MainServer.Instance.Stop(); 110
81 } 111 UUID userId = TestHelpers.ParseTail(0x1);
82 catch (NullReferenceException) 112
83 { } 113 EntityTransferModule etmA = new EntityTransferModule();
114 EntityTransferModule etmB = new EntityTransferModule();
115 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
116
117 IConfigSource config = new IniConfigSource();
118 IConfig modulesConfig = config.AddConfig("Modules");
119 modulesConfig.Set("EntityTransferModule", etmA.Name);
120 modulesConfig.Set("SimulationServices", lscm.Name);
121 IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
122
123 // In order to run a single threaded regression test we do not want the entity transfer module waiting
124 // for a callback from the destination scene before removing its avatar data.
125 entityTransferConfig.Set("wait_for_callback", false);
126
127 SceneHelpers sh = new SceneHelpers();
128 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
129 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000);
130
131 SceneHelpers.SetupSceneModules(sceneA, config, etmA);
132 SceneHelpers.SetupSceneModules(sceneB, config, etmB);
133 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
134
135 Vector3 teleportPosition = new Vector3(10, 11, 12);
136 Vector3 teleportLookAt = new Vector3(20, 21, 22);
137
138 ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager);
139 sp.AbsolutePosition = new Vector3(30, 31, 32);
140
141 // XXX: A very nasty hack to tell the client about the destination scene without having to crank the whole
142 // UDP stack (?)
143// ((TestClient)sp.ControllingClient).TeleportTargetScene = sceneB;
144
145 sceneA.RequestTeleportLocation(
146 sp.ControllingClient,
147 sceneB.RegionInfo.RegionHandle,
148 teleportPosition,
149 teleportLookAt,
150 (uint)TeleportFlags.ViaLocation);
151
152 ((TestClient)sp.ControllingClient).CompleteTeleportClientSide();
153
154 Assert.That(sceneA.GetScenePresence(userId), Is.Null);
155
156 ScenePresence sceneBSp = sceneB.GetScenePresence(userId);
157 Assert.That(sceneBSp, Is.Not.Null);
158 Assert.That(sceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
159 Assert.That(sceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));
160
161 // TODO: Add assertions to check correct circuit details in both scenes.
162
163 // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
164 // position instead).
165// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
84 } 166 }
85 167
86 } 168 /// <summary>
169 /// Test teleport procedures when the target simulator returns false when queried about access.
170 /// </summary>
171 [Test]
172 public void TestSameSimulatorSeparatedRegionsQueryAccessFails()
173 {
174 TestHelpers.InMethod();
175// TestHelpers.EnableLogging();
87 176
88 public class ThreadRunResults 177 UUID userId = TestHelpers.ParseTail(0x1);
89 { 178 Vector3 preTeleportPosition = new Vector3(30, 31, 32);
90 public bool Result = false;
91 public string Message = string.Empty;
92 }
93 179
94 public class TestRunning 180 EntityTransferModule etmA = new EntityTransferModule();
95 { 181 EntityTransferModule etmB = new EntityTransferModule();
96 public ThreadRunResults results; 182
97 public TestRunning(ThreadRunResults t) 183 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
184
185 IConfigSource config = new IniConfigSource();
186 config.AddConfig("Modules");
187 config.Configs["Modules"].Set("EntityTransferModule", etmA.Name);
188 config.Configs["Modules"].Set("SimulationServices", lscm.Name);
189
190 config.AddConfig("EntityTransfer");
191
192 // In order to run a single threaded regression test we do not want the entity transfer module waiting
193 // for a callback from the destination scene before removing its avatar data.
194 config.Configs["EntityTransfer"].Set("wait_for_callback", false);
195
196 config.AddConfig("Startup");
197 config.Configs["Startup"].Set("serverside_object_permissions", true);
198
199 SceneHelpers sh = new SceneHelpers();
200 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
201 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000);
202
203 SceneHelpers.SetupSceneModules(sceneA, config, etmA );
204
205 // We need to set up the permisions module on scene B so that our later use of agent limit to deny
206 // QueryAccess won't succeed anyway because administrators are always allowed in and the default
207 // IsAdministrator if no permissions module is present is true.
208 SceneHelpers.SetupSceneModules(sceneB, config, new object[] { new PermissionsModule(), etmB });
209
210 // Shared scene modules
211 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
212
213 Vector3 teleportPosition = new Vector3(10, 11, 12);
214 Vector3 teleportLookAt = new Vector3(20, 21, 22);
215
216 ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager);
217 sp.AbsolutePosition = preTeleportPosition;
218
219 // Make sceneB return false on query access
220 sceneB.RegionInfo.RegionSettings.AgentLimit = 0;
221
222 sceneA.RequestTeleportLocation(
223 sp.ControllingClient,
224 sceneB.RegionInfo.RegionHandle,
225 teleportPosition,
226 teleportLookAt,
227 (uint)TeleportFlags.ViaLocation);
228
229// ((TestClient)sp.ControllingClient).CompleteTeleportClientSide();
230
231 Assert.That(sceneB.GetScenePresence(userId), Is.Null);
232
233 ScenePresence sceneASp = sceneA.GetScenePresence(userId);
234 Assert.That(sceneASp, Is.Not.Null);
235 Assert.That(sceneASp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneA.RegionInfo.RegionName));
236 Assert.That(sceneASp.AbsolutePosition, Is.EqualTo(preTeleportPosition));
237
238 // TODO: Add assertions to check correct circuit details in both scenes.
239
240 // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
241 // position instead).
242// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
243
244// TestHelpers.DisableLogging();
245 }
246
247 /// <summary>
248 /// Test teleport procedures when the target simulator create agent step is refused.
249 /// </summary>
250 [Test]
251 public void TestSameSimulatorSeparatedRegionsCreateAgentFails()
98 { 252 {
99 results = t; 253 TestHelpers.InMethod();
254// TestHelpers.EnableLogging();
255
256 UUID userId = TestHelpers.ParseTail(0x1);
257 Vector3 preTeleportPosition = new Vector3(30, 31, 32);
258
259 EntityTransferModule etmA = new EntityTransferModule();
260 EntityTransferModule etmB = new EntityTransferModule();
261 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
262
263 IConfigSource config = new IniConfigSource();
264 config.AddConfig("Modules");
265 config.Configs["Modules"].Set("EntityTransferModule", etmA.Name);
266 config.Configs["Modules"].Set("SimulationServices", lscm.Name);
267
268 config.AddConfig("EntityTransfer");
269
270 // In order to run a single threaded regression test we do not want the entity transfer module waiting
271 // for a callback from the destination scene before removing its avatar data.
272 config.Configs["EntityTransfer"].Set("wait_for_callback", false);
273
274 SceneHelpers sh = new SceneHelpers();
275 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
276 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000);
277
278 SceneHelpers.SetupSceneModules(sceneA, config, etmA);
279 SceneHelpers.SetupSceneModules(sceneB, config, etmB);
280
281 // Shared scene modules
282 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
283
284 Vector3 teleportPosition = new Vector3(10, 11, 12);
285 Vector3 teleportLookAt = new Vector3(20, 21, 22);
286
287 ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager);
288 sp.AbsolutePosition = preTeleportPosition;
289
290 // Make sceneB refuse CreateAgent
291 sceneB.LoginsDisabled = true;
292
293 sceneA.RequestTeleportLocation(
294 sp.ControllingClient,
295 sceneB.RegionInfo.RegionHandle,
296 teleportPosition,
297 teleportLookAt,
298 (uint)TeleportFlags.ViaLocation);
299
300// ((TestClient)sp.ControllingClient).CompleteTeleportClientSide();
301
302 Assert.That(sceneB.GetScenePresence(userId), Is.Null);
303
304 ScenePresence sceneASp = sceneA.GetScenePresence(userId);
305 Assert.That(sceneASp, Is.Not.Null);
306 Assert.That(sceneASp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneA.RegionInfo.RegionName));
307 Assert.That(sceneASp.AbsolutePosition, Is.EqualTo(preTeleportPosition));
308
309 // TODO: Add assertions to check correct circuit details in both scenes.
310
311 // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
312 // position instead).
313// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
314
315// TestHelpers.DisableLogging();
100 } 316 }
101 public void run(object o) 317
318 [Test]
319 public void TestSameSimulatorNeighbouringRegionsTeleport()
102 { 320 {
103 321 TestHelpers.InMethod();
104 //results.Result = true; 322// TestHelpers.EnableLogging();
105 log4net.Config.XmlConfigurator.Configure(); 323
106 324 UUID userId = TestHelpers.ParseTail(0x1);
107 UUID sceneAId = UUID.Parse("00000000-0000-0000-0000-000000000100"); 325
108 UUID sceneBId = UUID.Parse("00000000-0000-0000-0000-000000000200"); 326 EntityTransferModule etmA = new EntityTransferModule();
109 327 EntityTransferModule etmB = new EntityTransferModule();
110 // shared module 328 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
111 ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); 329
112 330 IConfigSource config = new IniConfigSource();
113 331 IConfig modulesConfig = config.AddConfig("Modules");
114 Scene sceneB = SceneHelpers.SetupScene("sceneB", sceneBId, 1010, 1010); 332 modulesConfig.Set("EntityTransferModule", etmA.Name);
115 SceneHelpers.SetupSceneModules(sceneB, new IniConfigSource(), interregionComms); 333 modulesConfig.Set("SimulationServices", lscm.Name);
116 sceneB.RegisterRegionWithGrid(); 334 IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
117 335
118 Scene sceneA = SceneHelpers.SetupScene("sceneA", sceneAId, 1000, 1000); 336 // In order to run a single threaded regression test we do not want the entity transfer module waiting
119 SceneHelpers.SetupSceneModules(sceneA, new IniConfigSource(), interregionComms); 337 // for a callback from the destination scene before removing its avatar data.
120 sceneA.RegisterRegionWithGrid(); 338 entityTransferConfig.Set("wait_for_callback", false);
121 339
122 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000041"); 340 SceneHelpers sh = new SceneHelpers();
123 TestClient client = (TestClient)SceneHelpers.AddScenePresence(sceneA, agentId).ControllingClient; 341 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
124 342 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000);
125 ICapabilitiesModule sceneACapsModule = sceneA.RequestModuleInterface<ICapabilitiesModule>(); 343
126 344 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
127 results.Result = (sceneACapsModule.GetCapsPath(agentId) == client.CapsSeedUrl); 345 SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
128 346 SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);
129 if (!results.Result) 347
130 { 348 Vector3 teleportPosition = new Vector3(10, 11, 12);
131 results.Message = "Incorrect caps object path set up in sceneA"; 349 Vector3 teleportLookAt = new Vector3(20, 21, 22);
132 return; 350
133 } 351 ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager);
134 352 originalSp.AbsolutePosition = new Vector3(30, 31, 32);
135 /* 353
136 Assert.That( 354 ScenePresence beforeSceneASp = sceneA.GetScenePresence(userId);
137 sceneACapsModule.GetCapsPath(agentId), 355 Assert.That(beforeSceneASp, Is.Not.Null);
138 Is.EqualTo(client.CapsSeedUrl), 356 Assert.That(beforeSceneASp.IsChildAgent, Is.False);
139 "Incorrect caps object path set up in sceneA"); 357
140 */ 358 ScenePresence beforeSceneBSp = sceneB.GetScenePresence(userId);
141 // FIXME: This is a hack to get the test working - really the normal OpenSim mechanisms should be used. 359 Assert.That(beforeSceneBSp, Is.Not.Null);
142 360 Assert.That(beforeSceneBSp.IsChildAgent, Is.True);
143 361
144 client.TeleportTargetScene = sceneB; 362 // XXX: A very nasty hack to tell the client about the destination scene without having to crank the whole
145 client.Teleport(sceneB.RegionInfo.RegionHandle, new Vector3(100, 100, 100), new Vector3(40, 40, 40)); 363 // UDP stack (?)
146 364// ((TestClient)beforeSceneASp.ControllingClient).TeleportTargetScene = sceneB;
147 results.Result = (sceneB.GetScenePresence(agentId) != null); 365
148 if (!results.Result) 366 sceneA.RequestTeleportLocation(
149 { 367 beforeSceneASp.ControllingClient,
150 results.Message = "Client does not have an agent in sceneB"; 368 sceneB.RegionInfo.RegionHandle,
151 return; 369 teleportPosition,
152 } 370 teleportLookAt,
153 371 (uint)TeleportFlags.ViaLocation);
154 //Assert.That(sceneB.GetScenePresence(agentId), Is.Not.Null, "Client does not have an agent in sceneB"); 372
155 373 ((TestClient)beforeSceneASp.ControllingClient).CompleteTeleportClientSide();
156 //Assert.That(sceneA.GetScenePresence(agentId), Is.Null, "Client still had an agent in sceneA"); 374
157 375 ScenePresence afterSceneASp = sceneA.GetScenePresence(userId);
158 results.Result = (sceneA.GetScenePresence(agentId) == null); 376 Assert.That(afterSceneASp, Is.Not.Null);
159 if (!results.Result) 377 Assert.That(afterSceneASp.IsChildAgent, Is.True);
160 { 378
161 results.Message = "Client still had an agent in sceneA"; 379 ScenePresence afterSceneBSp = sceneB.GetScenePresence(userId);
162 return; 380 Assert.That(afterSceneBSp, Is.Not.Null);
163 } 381 Assert.That(afterSceneBSp.IsChildAgent, Is.False);
164 382 Assert.That(afterSceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
165 ICapabilitiesModule sceneBCapsModule = sceneB.RequestModuleInterface<ICapabilitiesModule>(); 383 Assert.That(afterSceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));
166 384
167 385 // TODO: Add assertions to check correct circuit details in both scenes.
168 results.Result = ("http://" + sceneB.RegionInfo.ExternalHostName + ":" + sceneB.RegionInfo.HttpPort + 386
169 "/CAPS/" + sceneBCapsModule.GetCapsPath(agentId) + "0000/" == client.CapsSeedUrl); 387 // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
170 if (!results.Result) 388 // position instead).
171 { 389// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
172 results.Message = "Incorrect caps object path set up in sceneB"; 390
173 return; 391// TestHelpers.DisableLogging();
174 }
175
176 // Temporary assertion - caps url construction should at least be doable through a method.
177 /*
178 Assert.That(
179 "http://" + sceneB.RegionInfo.ExternalHostName + ":" + sceneB.RegionInfo.HttpPort + "/CAPS/" + sceneBCapsModule.GetCapsPath(agentId) + "0000/",
180 Is.EqualTo(client.CapsSeedUrl),
181 "Incorrect caps object path set up in sceneB");
182 */
183 // This assertion will currently fail since we don't remove the caps paths when no longer needed
184 //Assert.That(sceneACapsModule.GetCapsPath(agentId), Is.Null, "sceneA still had a caps object path");
185
186 // TODO: Check that more of everything is as it should be
187
188 // TODO: test what happens if we try to teleport to a region that doesn't exist
189 } 392 }
190 } 393 }
191} 394} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
index 5c9a77d..d722a09 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
@@ -60,7 +60,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
60 { 60 {
61 TestHelpers.InMethod(); 61 TestHelpers.InMethod();
62 62
63 Scene scene = SceneHelpers.SetupScene(); 63 Scene scene = new SceneHelpers().SetupScene();
64 scene.Update(1); 64 scene.Update(1);
65 65
66 Assert.That(scene.Frame, Is.EqualTo(1)); 66 Assert.That(scene.Frame, Is.EqualTo(1));
diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
index 55c80f5..d15141b 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Region.Framework.Tests
58 TestHelpers.InMethod(); 58 TestHelpers.InMethod();
59// log4net.Config.XmlConfigurator.Configure(); 59// log4net.Config.XmlConfigurator.Configure();
60 60
61 Scene scene = SceneHelpers.SetupScene(); 61 Scene scene = new SceneHelpers().SetupScene();
62 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); 62 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene);
63 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); 63 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID);
64 SceneObjectPart sop1 = sog1.RootPart; 64 SceneObjectPart sop1 = sog1.RootPart;
@@ -81,7 +81,7 @@ namespace OpenSim.Region.Framework.Tests
81 TestHelpers.InMethod(); 81 TestHelpers.InMethod();
82// log4net.Config.XmlConfigurator.Configure(); 82// log4net.Config.XmlConfigurator.Configure();
83 83
84 Scene scene = SceneHelpers.SetupScene(); 84 Scene scene = new SceneHelpers().SetupScene();
85 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); 85 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene);
86 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); 86 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID);
87 SceneObjectPart sop1 = sog1.RootPart; 87 SceneObjectPart sop1 = sog1.RootPart;
@@ -124,7 +124,7 @@ namespace OpenSim.Region.Framework.Tests
124 TestHelpers.InMethod(); 124 TestHelpers.InMethod();
125// log4net.Config.XmlConfigurator.Configure(); 125// log4net.Config.XmlConfigurator.Configure();
126 126
127 Scene scene = SceneHelpers.SetupScene(); 127 Scene scene = new SceneHelpers().SetupScene();
128 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); 128 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene);
129 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); 129 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID);
130 SceneObjectPart sop1 = sog1.RootPart; 130 SceneObjectPart sop1 = sog1.RootPart;
@@ -153,7 +153,7 @@ namespace OpenSim.Region.Framework.Tests
153 TestHelpers.InMethod(); 153 TestHelpers.InMethod();
154// log4net.Config.XmlConfigurator.Configure(); 154// log4net.Config.XmlConfigurator.Configure();
155 155
156 Scene scene = SceneHelpers.SetupScene(); 156 Scene scene = new SceneHelpers().SetupScene();
157 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); 157 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene);
158 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); 158 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID);
159 SceneObjectPart sop1 = sog1.RootPart; 159 SceneObjectPart sop1 = sog1.RootPart;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs
index 55fc1e7..44d2d45 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Region.Framework.Tests
58 TestHelpers.InMethod(); 58 TestHelpers.InMethod();
59// log4net.Config.XmlConfigurator.Configure(); 59// log4net.Config.XmlConfigurator.Configure();
60 60
61 Scene scene = SceneHelpers.SetupScene(); 61 Scene scene = new SceneHelpers().SetupScene();
62 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001)); 62 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001));
63 UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002)); 63 UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002));
64 InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "item1", user1.PrincipalID); 64 InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "item1", user1.PrincipalID);
@@ -85,7 +85,7 @@ namespace OpenSim.Region.Framework.Tests
85 TestHelpers.InMethod(); 85 TestHelpers.InMethod();
86// log4net.Config.XmlConfigurator.Configure(); 86// log4net.Config.XmlConfigurator.Configure();
87 87
88 Scene scene = SceneHelpers.SetupScene(); 88 Scene scene = new SceneHelpers().SetupScene();
89 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001)); 89 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1001));
90 UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002)); 90 UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(1002));
91 InventoryFolderBase folder1 91 InventoryFolderBase folder1
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
index d9fe87c..198e487 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
@@ -47,7 +47,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
47 public void Init() 47 public void Init()
48 { 48 {
49 // FIXME: We don't need a full scene here - it would be enough to set up the asset service. 49 // FIXME: We don't need a full scene here - it would be enough to set up the asset service.
50 Scene scene = SceneHelpers.SetupScene(); 50 Scene scene = new SceneHelpers().SetupScene();
51 m_assetService = scene.AssetService; 51 m_assetService = scene.AssetService;
52 m_uuidGatherer = new UuidGatherer(m_assetService); 52 m_uuidGatherer = new UuidGatherer(m_assetService);
53 } 53 }