aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs25
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityInventory.cs54
-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/IScenePresence.cs6
-rw-r--r--OpenSim/Region/Framework/Interfaces/IScriptModule.cs18
-rw-r--r--OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs20
-rw-r--r--OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs20
-rw-r--r--OpenSim/Region/Framework/Interfaces/IUrlModule.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs19
-rw-r--r--OpenSim/Region/Framework/Scenes/AsyncInventorySender.cs2
-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.cs78
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Permissions.cs17
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs606
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs12
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs37
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs18
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs117
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs44
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs302
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs495
-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.cs19
-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.cs23
-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.cs478
-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
53 files changed, 2393 insertions, 1082 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
index 0516cb1..7446530 100644
--- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
@@ -37,6 +37,20 @@ namespace OpenSim.Region.Framework.Interfaces
37 public interface IAttachmentsModule 37 public interface IAttachmentsModule
38 { 38 {
39 /// <summary> 39 /// <summary>
40 /// Copy attachment data from a ScenePresence into the AgentData structure for transmission to another simulator
41 /// </summary>
42 /// <param name='sp'></param>
43 /// <param name='ad'></param>
44 void CopyAttachments(IScenePresence sp, AgentData ad);
45
46 /// <summary>
47 /// Copy attachment data from an AgentData structure into a ScenePresence.
48 /// </summary>
49 /// <param name='ad'></param>
50 /// <param name='sp'></param>
51 void CopyAttachments(AgentData ad, IScenePresence sp);
52
53 /// <summary>
40 /// RezAttachments. This should only be called upon login on the first region. 54 /// RezAttachments. This should only be called upon login on the first region.
41 /// Attachment rezzings on crossings and TPs are done in a different way. 55 /// Attachment rezzings on crossings and TPs are done in a different way.
42 /// </summary> 56 /// </summary>
@@ -44,10 +58,15 @@ namespace OpenSim.Region.Framework.Interfaces
44 void RezAttachments(IScenePresence sp); 58 void RezAttachments(IScenePresence sp);
45 59
46 /// <summary> 60 /// <summary>
47 /// Save the attachments that have change on this presence. 61 /// Derez the attachements for a scene presence that is closing.
48 /// </summary> 62 /// </summary>
49 /// <param name="sp"></param> 63 /// <remarks>
50 void SaveChangedAttachments(IScenePresence sp, bool saveAllScripted); 64 /// Attachment changes are saved.
65 /// </remarks>
66 /// <param name="sp">The presence closing</param>
67 /// <param name="saveChanged">Save changed attachments.</param>
68 /// <param name="saveAllScripted">Save attachments with scripts even if they haven't changed.</para>
69 void DeRezAttachments(IScenePresence sp, bool saveChanged, bool saveAllScripted);
51 70
52 /// <summary> 71 /// <summary>
53 /// Delete all the presence's attachments from the scene 72 /// Delete all the presence's attachments from the scene
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
index 32f4eea..4f0e100 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
@@ -81,7 +81,12 @@ namespace OpenSim.Region.Framework.Interfaces
81 /// <summary> 81 /// <summary>
82 /// Start all the scripts contained in this entity's inventory 82 /// Start all the scripts contained in this entity's inventory
83 /// </summary> 83 /// </summary>
84 void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource); 84 /// <param name="startParam"></param>
85 /// <param name="postOnRez"></param>
86 /// <param name="engine"></param>
87 /// <param name="stateSource"></param>
88 /// <returns>Number of scripts started.</returns>
89 int CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource);
85 90
86 ArrayList GetScriptErrors(UUID itemID); 91 ArrayList GetScriptErrors(UUID itemID);
87 void ResumeScripts(); 92 void ResumeScripts();
@@ -102,7 +107,11 @@ namespace OpenSim.Region.Framework.Interfaces
102 /// <param name="postOnRez"></param> 107 /// <param name="postOnRez"></param>
103 /// <param name="engine"></param> 108 /// <param name="engine"></param>
104 /// <param name="stateSource"></param> 109 /// <param name="stateSource"></param>
105 void CreateScriptInstance( 110 /// <returns>
111 /// true if the script instance was valid for starting, false otherwise. This does not guarantee
112 /// that the script was actually started, just that the script was valid (i.e. its asset data could be found, etc.)
113 /// </returns>
114 bool CreateScriptInstance(
106 TaskInventoryItem item, int startParam, bool postOnRez, string engine, int stateSource); 115 TaskInventoryItem item, int startParam, bool postOnRez, string engine, int stateSource);
107 116
108 /// <summary> 117 /// <summary>
@@ -113,7 +122,11 @@ namespace OpenSim.Region.Framework.Interfaces
113 /// <param name="postOnRez"></param> 122 /// <param name="postOnRez"></param>
114 /// <param name="engine"></param> 123 /// <param name="engine"></param>
115 /// <param name="stateSource"></param> 124 /// <param name="stateSource"></param>
116 void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource); 125 /// <returns>
126 /// true if the script instance was valid for starting, false otherwise. This does not guarantee
127 /// that the script was actually started, just that the script was valid (i.e. its asset data could be found, etc.)
128 /// </returns>
129 bool CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource);
117 130
118 ArrayList CreateScriptInstanceEr(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource); 131 ArrayList CreateScriptInstanceEr(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource);
119 132
@@ -166,6 +179,19 @@ namespace OpenSim.Region.Framework.Interfaces
166 List<TaskInventoryItem> GetInventoryItems(); 179 List<TaskInventoryItem> GetInventoryItems();
167 180
168 /// <summary> 181 /// <summary>
182 /// Gets an inventory item by name
183 /// </summary>
184 /// <remarks>
185 /// This method returns the first inventory item that matches the given name. In SL this is all you need
186 /// since each item in a prim inventory must have a unique name.
187 /// </remarks>
188 /// <param name='name'></param>
189 /// <returns>
190 /// The inventory item. Null if no such item was found.
191 /// </returns>
192 TaskInventoryItem GetInventoryItem(string name);
193
194 /// <summary>
169 /// Get inventory items by name. 195 /// Get inventory items by name.
170 /// </summary> 196 /// </summary>
171 /// <param name="name"></param> 197 /// <param name="name"></param>
@@ -174,7 +200,17 @@ namespace OpenSim.Region.Framework.Interfaces
174 /// If no inventory item has that name then an empty list is returned. 200 /// If no inventory item has that name then an empty list is returned.
175 /// </returns> 201 /// </returns>
176 List<TaskInventoryItem> GetInventoryItems(string name); 202 List<TaskInventoryItem> GetInventoryItems(string name);
177 203
204 /// <summary>
205 /// Get inventory items by type.
206 /// </summary>
207 /// <param type="name"></param>
208 /// <returns>
209 /// A list of inventory items of that type.
210 /// If no inventory items of that type then an empty list is returned.
211 /// </returns>
212 List<TaskInventoryItem> GetInventoryItems(InventoryType type);
213
178 /// <summary> 214 /// <summary>
179 /// Get the scene object referenced by an inventory item. 215 /// Get the scene object referenced by an inventory item.
180 /// </summary> 216 /// </summary>
@@ -228,6 +264,16 @@ namespace OpenSim.Region.Framework.Interfaces
228 bool ContainsScripts(); 264 bool ContainsScripts();
229 265
230 /// <summary> 266 /// <summary>
267 /// Returns the count of scripts contained
268 /// </summary></returns>
269 int ScriptCount();
270
271 /// <summary>
272 /// Returns the count of running scripts contained
273 /// </summary></returns>
274 int RunningScriptCount();
275
276 /// <summary>
231 /// Get the uuids of all items in this inventory 277 /// Get the uuids of all items in this inventory
232 /// </summary> 278 /// </summary>
233 /// <returns></returns> 279 /// <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/IScenePresence.cs b/OpenSim/Region/Framework/Interfaces/IScenePresence.cs
index 5e43843..19a8236 100644
--- a/OpenSim/Region/Framework/Interfaces/IScenePresence.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScenePresence.cs
@@ -41,6 +41,12 @@ namespace OpenSim.Region.Framework.Interfaces
41 public interface IScenePresence : ISceneAgent 41 public interface IScenePresence : ISceneAgent
42 { 42 {
43 /// <summary> 43 /// <summary>
44 /// Copy of the script states while the agent is in transit. This state may
45 /// need to be placed back in case of transfer fail.
46 /// </summary>
47 List<string> InTransitScriptStates { get; }
48
49 /// <summary>
44 /// The AttachmentsModule synchronizes on this to avoid race conditions between commands to add and remove attachments. 50 /// The AttachmentsModule synchronizes on this to avoid race conditions between commands to add and remove attachments.
45 /// </summary> 51 /// </summary>
46 /// <remarks> 52 /// <remarks>
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
index ce66100..42dbedc 100644
--- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
@@ -71,6 +71,14 @@ 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
80 void SetRunEnable(UUID instanceID, bool enable);
81
74 void SaveAllState(); 82 void SaveAllState();
75 83
76 /// <summary> 84 /// <summary>
@@ -79,6 +87,14 @@ namespace OpenSim.Region.Framework.Interfaces
79 void StartProcessing(); 87 void StartProcessing();
80 88
81 /// <summary> 89 /// <summary>
90 /// Get the execution times of all scripts in the given array if they are currently running.
91 /// </summary>
92 /// <returns>
93 /// A float the value is a representative execution time in milliseconds of all scripts in that Array.
94 /// </returns>
95 float GetScriptExecutionTime(List<UUID> itemIDs);
96
97 /// <summary>
82 /// Get the execution times of all scripts in each object. 98 /// Get the execution times of all scripts in each object.
83 /// </summary> 99 /// </summary>
84 /// <returns> 100 /// <returns>
@@ -87,4 +103,4 @@ namespace OpenSim.Region.Framework.Interfaces
87 /// </returns> 103 /// </returns>
88 Dictionary<uint, float> GetObjectScriptsExecutionTimes(); 104 Dictionary<uint, float> GetObjectScriptsExecutionTimes();
89 } 105 }
90} \ No newline at end of file 106}
diff --git a/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs b/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs
index 5b69616..ccb583d 100644
--- a/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs
+++ b/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs
@@ -96,6 +96,26 @@ namespace OpenSim.Region.Framework.Interfaces
96 void StoreRegionWindlightSettings(RegionLightShareData wl); 96 void StoreRegionWindlightSettings(RegionLightShareData wl);
97 void RemoveRegionWindlightSettings(UUID regionID); 97 void RemoveRegionWindlightSettings(UUID regionID);
98 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
99 UUID[] GetObjectIDs(UUID regionID); 119 UUID[] GetObjectIDs(UUID regionID);
100 } 120 }
101} 121}
diff --git a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs
index b7d9cfa..d7c80f7 100644
--- a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs
+++ b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs
@@ -108,6 +108,26 @@ namespace OpenSim.Region.Framework.Interfaces
108 void RemoveRegionWindlightSettings(UUID regionID); 108 void RemoveRegionWindlightSettings(UUID regionID);
109 UUID[] GetObjectIDs(UUID regionID); 109 UUID[] GetObjectIDs(UUID regionID);
110 110
111 /// <summary>
112 /// Load Environment settings from region storage
113 /// </summary>
114 /// <param name="regionUUID">the region UUID</param>
115 /// <returns>LLSD string for viewer</returns>
116 string LoadRegionEnvironmentSettings(UUID regionUUID);
117
118 /// <summary>
119 /// Store Environment settings into region storage
120 /// </summary>
121 /// <param name="regionUUID">the region UUID</param>
122 /// <param name="settings">LLSD string from viewer</param>
123 void StoreRegionEnvironmentSettings(UUID regionUUID, string settings);
124
125 /// <summary>
126 /// Delete Environment settings from region storage
127 /// </summary>
128 /// <param name="regionUUID">the region UUID</param>
129 void RemoveRegionEnvironmentSettings(UUID regionUUID);
130
111 void Shutdown(); 131 void Shutdown();
112 } 132 }
113} 133}
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/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/AsyncInventorySender.cs b/OpenSim/Region/Framework/Scenes/AsyncInventorySender.cs
index 9cb5674..d9d2e64 100644
--- a/OpenSim/Region/Framework/Scenes/AsyncInventorySender.cs
+++ b/OpenSim/Region/Framework/Scenes/AsyncInventorySender.cs
@@ -137,7 +137,7 @@ namespace OpenSim.Region.Framework.Scenes
137 } 137 }
138 } 138 }
139 139
140 if (fh.Client.IsLoggingOut) 140 if (!fh.Client.IsActive)
141 continue; 141 continue;
142 142
143// m_log.DebugFormat( 143// m_log.DebugFormat(
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..9776a82 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -60,19 +60,32 @@ namespace OpenSim.Region.Framework.Scenes
60 /// <summary> 60 /// <summary>
61 /// Creates all the scripts in the scene which should be started. 61 /// Creates all the scripts in the scene which should be started.
62 /// </summary> 62 /// </summary>
63 public void CreateScriptInstances() 63 /// <returns>
64 /// Number of scripts that were valid for starting. This does not guarantee that all these scripts
65 /// were actually started, but just that the start could be attempt (e.g. the asset data for the script could be found)
66 /// </returns>
67 public int CreateScriptInstances()
64 { 68 {
65 m_log.Info("[PRIM INVENTORY]: Creating scripts in scene"); 69 m_log.InfoFormat("[SCENE]: Initializing script instances in {0}", RegionInfo.RegionName);
70
71 int scriptsValidForStarting = 0;
66 72
67 EntityBase[] entities = Entities.GetEntities(); 73 EntityBase[] entities = Entities.GetEntities();
68 foreach (EntityBase group in entities) 74 foreach (EntityBase group in entities)
69 { 75 {
70 if (group is SceneObjectGroup) 76 if (group is SceneObjectGroup)
71 { 77 {
72 ((SceneObjectGroup) group).CreateScriptInstances(0, false, DefaultScriptEngine, 0); 78 scriptsValidForStarting
79 += ((SceneObjectGroup) group).CreateScriptInstances(0, false, DefaultScriptEngine, 0);
73 ((SceneObjectGroup) group).ResumeScripts(); 80 ((SceneObjectGroup) group).ResumeScripts();
74 } 81 }
75 } 82 }
83
84 m_log.InfoFormat(
85 "[SCENE]: Initialized {0} script instances in {1}",
86 scriptsValidForStarting, RegionInfo.RegionName);
87
88 return scriptsValidForStarting;
76 } 89 }
77 90
78 /// <summary> 91 /// <summary>
@@ -80,7 +93,7 @@ namespace OpenSim.Region.Framework.Scenes
80 /// </summary> 93 /// </summary>
81 public void StartScripts() 94 public void StartScripts()
82 { 95 {
83 m_log.Info("[PRIM INVENTORY]: Starting scripts in scene"); 96 m_log.InfoFormat("[SCENE]: Starting scripts in {0}, please wait.", RegionInfo.RegionName);
84 97
85 IScriptModule[] engines = RequestModuleInterfaces<IScriptModule>(); 98 IScriptModule[] engines = RequestModuleInterfaces<IScriptModule>();
86 99
@@ -300,6 +313,10 @@ namespace OpenSim.Region.Framework.Scenes
300 AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data, remoteClient.AgentId); 313 AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data, remoteClient.AgentId);
301 AssetService.Store(asset); 314 AssetService.Store(asset);
302 315
316// m_log.DebugFormat(
317// "[PRIM INVENTORY]: Stored asset {0} when updating item {1} in prim {2} for {3}",
318// asset.ID, item.Name, part.Name, remoteClient.Name);
319
303 if (isScriptRunning) 320 if (isScriptRunning)
304 { 321 {
305 part.Inventory.RemoveScriptInstance(item.ItemID, false); 322 part.Inventory.RemoveScriptInstance(item.ItemID, false);
@@ -431,10 +448,9 @@ namespace OpenSim.Region.Framework.Scenes
431 } 448 }
432 else 449 else
433 { 450 {
434 IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>(); 451 if (AgentTransactionsModule != null)
435 if (agentTransactions != null)
436 { 452 {
437 agentTransactions.HandleItemUpdateFromTransaction(remoteClient, transactionID, item); 453 AgentTransactionsModule.HandleItemUpdateFromTransaction(remoteClient, transactionID, item);
438 } 454 }
439 } 455 }
440 } 456 }
@@ -950,8 +966,8 @@ namespace OpenSim.Region.Framework.Scenes
950 sbyte invType, sbyte type, UUID olditemID) 966 sbyte invType, sbyte type, UUID olditemID)
951 { 967 {
952// m_log.DebugFormat( 968// m_log.DebugFormat(
953// "[AGENT INVENTORY]: Received request from {0} to create inventory item link {1} in folder {2} pointing to {3}", 969// "[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); 970// remoteClient.Name, name, folderID, olditemID, (AssetType)type, (InventoryType)invType);
955 971
956 if (!Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) 972 if (!Permissions.CanCreateUserInventory(invType, remoteClient.AgentId))
957 return; 973 return;
@@ -984,10 +1000,10 @@ namespace OpenSim.Region.Framework.Scenes
984 asset.Type = type; 1000 asset.Type = type;
985 asset.Name = name; 1001 asset.Name = name;
986 asset.Description = description; 1002 asset.Description = description;
987 1003
988 CreateNewInventoryItem( 1004 CreateNewInventoryItem(
989 remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, name, 0, callbackID, asset, invType, 1005 remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, name, 0, callbackID, asset, invType,
990 (uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All, 1006 (uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All,
991 (uint)PermissionMask.All, (uint)PermissionMask.All, Util.UnixTimeSinceEpoch()); 1007 (uint)PermissionMask.All, (uint)PermissionMask.All, Util.UnixTimeSinceEpoch());
992 } 1008 }
993 else 1009 else
@@ -1562,21 +1578,17 @@ namespace OpenSim.Region.Framework.Scenes
1562 // Only look for an uploaded updated asset if we are passed a transaction ID. This is only the 1578 // Only look for an uploaded updated asset if we are passed a transaction ID. This is only the
1563 // case for updates uploded through UDP. Updates uploaded via a capability (e.g. a script update) 1579 // case for updates uploded through UDP. Updates uploaded via a capability (e.g. a script update)
1564 // will not pass in a transaction ID in the update message. 1580 // will not pass in a transaction ID in the update message.
1565 if (transactionID != UUID.Zero) 1581 if (transactionID != UUID.Zero && AgentTransactionsModule != null)
1566 { 1582 {
1567 IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>(); 1583 AgentTransactionsModule.HandleTaskItemUpdateFromTransaction(
1568 if (agentTransactions != null) 1584 remoteClient, part, transactionID, currentItem);
1569 { 1585
1570 agentTransactions.HandleTaskItemUpdateFromTransaction( 1586// if ((InventoryType)itemInfo.InvType == InventoryType.Notecard)
1571 remoteClient, part, transactionID, currentItem); 1587// remoteClient.SendAgentAlertMessage("Notecard saved", false);
1572 1588// else if ((InventoryType)itemInfo.InvType == InventoryType.LSL)
1573// if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) 1589// remoteClient.SendAgentAlertMessage("Script saved", false);
1574// remoteClient.SendAgentAlertMessage("Notecard saved", false); 1590// else
1575// else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) 1591// remoteClient.SendAgentAlertMessage("Item saved", false);
1576// remoteClient.SendAgentAlertMessage("Script saved", false);
1577// else
1578// remoteClient.SendAgentAlertMessage("Item saved", false);
1579 }
1580 } 1592 }
1581 1593
1582 // Base ALWAYS has move 1594 // Base ALWAYS has move
@@ -2286,10 +2298,24 @@ namespace OpenSim.Region.Framework.Scenes
2286 if (part == null) 2298 if (part == null)
2287 return; 2299 return;
2288 2300
2301 IScriptModule[] engines = RequestModuleInterfaces<IScriptModule>();
2302
2289 if (running) 2303 if (running)
2304 {
2305 foreach (IScriptModule engine in engines)
2306 {
2307 engine.SetRunEnable(itemID, true);
2308 }
2290 EventManager.TriggerStartScript(part.LocalId, itemID); 2309 EventManager.TriggerStartScript(part.LocalId, itemID);
2310 }
2291 else 2311 else
2312 {
2313 foreach (IScriptModule engine in engines)
2314 {
2315 engine.SetRunEnable(itemID, false);
2316 }
2292 EventManager.TriggerStopScript(part.LocalId, itemID); 2317 EventManager.TriggerStopScript(part.LocalId, itemID);
2318 }
2293 } 2319 }
2294 2320
2295 public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) 2321 public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID)
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..8591b09 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,9 @@ 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; }
524 public IAgentAssetTransactions AgentTransactionsModule { get; private set; }
525 public IUserManagement UserManagementModule { get; private set; }
516 526
517 public IAvatarFactoryModule AvatarFactory 527 public IAvatarFactoryModule AvatarFactory
518 { 528 {
@@ -589,6 +599,20 @@ namespace OpenSim.Region.Framework.Scenes
589 get { return m_sceneGraph.Entities; } 599 get { return m_sceneGraph.Entities; }
590 } 600 }
591 601
602
603 // used in sequence see: SpawnPoint()
604 private int m_SpawnPoint;
605 // can be closest/random/sequence
606 public string SpawnPointRouting
607 {
608 get; private set;
609 }
610 // allow landmarks to pass
611 public bool TelehubAllowLandmarks
612 {
613 get; private set;
614 }
615
592 #endregion Properties 616 #endregion Properties
593 617
594 #region Constructors 618 #region Constructors
@@ -606,7 +630,7 @@ namespace OpenSim.Region.Framework.Scenes
606 630
607 Random random = new Random(); 631 Random random = new Random();
608 632
609 m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4); 633 m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue / 2)) + (uint)(uint.MaxValue / 4);
610 m_moduleLoader = moduleLoader; 634 m_moduleLoader = moduleLoader;
611 m_authenticateHandler = authen; 635 m_authenticateHandler = authen;
612 m_sceneGridService = sceneGridService; 636 m_sceneGridService = sceneGridService;
@@ -726,6 +750,9 @@ namespace OpenSim.Region.Framework.Scenes
726 m_maxPhys = RegionInfo.PhysPrimMax; 750 m_maxPhys = RegionInfo.PhysPrimMax;
727 } 751 }
728 752
753 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest");
754 TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false);
755
729 // Here, if clamping is requested in either global or 756 // Here, if clamping is requested in either global or
730 // local config, it will be used 757 // local config, it will be used
731 // 758 //
@@ -735,6 +762,7 @@ namespace OpenSim.Region.Framework.Scenes
735 m_clampPrimSize = true; 762 m_clampPrimSize = true;
736 } 763 }
737 764
765 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete);
738 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); 766 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
739 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); 767 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
740 m_dontPersistBefore = 768 m_dontPersistBefore =
@@ -833,13 +861,11 @@ namespace OpenSim.Region.Framework.Scenes
833 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; 861 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;
834 } 862 }
835 863
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) 864 public Scene(RegionInfo regInfo)
842 { 865 {
866 PhysicalPrims = true;
867 CollidablePrims = true;
868
843 BordersLocked = true; 869 BordersLocked = true;
844 Border northBorder = new Border(); 870 Border northBorder = new Border();
845 northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<--- 871 northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<---
@@ -866,8 +892,6 @@ namespace OpenSim.Region.Framework.Scenes
866 m_eventManager = new EventManager(); 892 m_eventManager = new EventManager();
867 893
868 m_permissions = new ScenePermissions(this); 894 m_permissions = new ScenePermissions(this);
869
870// m_lastUpdate = Util.EnvironmentTickCount();
871 } 895 }
872 896
873 #endregion 897 #endregion
@@ -936,8 +960,8 @@ namespace OpenSim.Region.Framework.Scenes
936 List<ulong> old = new List<ulong>(); 960 List<ulong> old = new List<ulong>();
937 old.Add(otherRegion.RegionHandle); 961 old.Add(otherRegion.RegionHandle);
938 agent.DropOldNeighbours(old); 962 agent.DropOldNeighbours(old);
939 if (m_teleportModule != null && agent.PresenceType != PresenceType.Npc) 963 if (EntityTransferModule != null && agent.PresenceType != PresenceType.Npc)
940 m_teleportModule.EnableChildAgent(agent, otherRegion); 964 EntityTransferModule.EnableChildAgent(agent, otherRegion);
941 }); 965 });
942 } 966 }
943 catch (NullReferenceException) 967 catch (NullReferenceException)
@@ -950,7 +974,7 @@ namespace OpenSim.Region.Framework.Scenes
950 else 974 else
951 { 975 {
952 m_log.InfoFormat( 976 m_log.InfoFormat(
953 "[INTERGRID]: Got notice about far away Region: {0} at ({1}, {2})", 977 "[SCENE]: Got notice about far away Region: {0} at ({1}, {2})",
954 otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY); 978 otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY);
955 } 979 }
956 } 980 }
@@ -1044,13 +1068,13 @@ namespace OpenSim.Region.Framework.Scenes
1044 } 1068 }
1045 } 1069 }
1046 1070
1071 m_log.Error("[REGION]: Closing");
1072 Close();
1073
1047 if (PhysicsScene != null) 1074 if (PhysicsScene != null)
1048 { 1075 {
1049 PhysicsScene.Dispose(); 1076 PhysicsScene.Dispose();
1050 } 1077 }
1051
1052 m_log.Error("[REGION]: Closing");
1053 Close();
1054 1078
1055 m_log.Error("[REGION]: Firing Region Restart Message"); 1079 m_log.Error("[REGION]: Firing Region Restart Message");
1056 1080
@@ -1074,8 +1098,8 @@ namespace OpenSim.Region.Framework.Scenes
1074 { 1098 {
1075 ForEachRootScenePresence(delegate(ScenePresence agent) 1099 ForEachRootScenePresence(delegate(ScenePresence agent)
1076 { 1100 {
1077 if (m_teleportModule != null && agent.PresenceType != PresenceType.Npc) 1101 if (EntityTransferModule != null && agent.PresenceType != PresenceType.Npc)
1078 m_teleportModule.EnableChildAgent(agent, r); 1102 EntityTransferModule.EnableChildAgent(agent, r);
1079 }); 1103 });
1080 } 1104 }
1081 catch (NullReferenceException) 1105 catch (NullReferenceException)
@@ -1265,8 +1289,10 @@ namespace OpenSim.Region.Framework.Scenes
1265 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>(); 1289 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>();
1266 m_dialogModule = RequestModuleInterface<IDialogModule>(); 1290 m_dialogModule = RequestModuleInterface<IDialogModule>();
1267 m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); 1291 m_capsModule = RequestModuleInterface<ICapabilitiesModule>();
1268 m_teleportModule = RequestModuleInterface<IEntityTransferModule>(); 1292 EntityTransferModule = RequestModuleInterface<IEntityTransferModule>();
1269 m_groupsModule = RequestModuleInterface<IGroupsModule>(); 1293 m_groupsModule = RequestModuleInterface<IGroupsModule>();
1294 AgentTransactionsModule = RequestModuleInterface<IAgentAssetTransactions>();
1295 UserManagementModule = RequestModuleInterface<IUserManagement>();
1270 } 1296 }
1271 1297
1272 #endregion 1298 #endregion
@@ -1387,37 +1413,41 @@ namespace OpenSim.Region.Framework.Scenes
1387 endFrame = Frame + frames; 1413 endFrame = Frame + frames;
1388 1414
1389 float physicsFPS = 0f; 1415 float physicsFPS = 0f;
1390 int tmpPhysicsMS, tmpPhysicsMS2, tmpAgentMS, tmpTempOnRezMS, evMS, backMS, terMS; 1416 int previousFrameTick, tmpMS;
1391 int previousFrameTick; 1417 int maintc = Util.EnvironmentTickCount();
1392 int maintc;
1393 int sleepMS;
1394 int framestart;
1395 1418
1396 while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) 1419 while (!m_shuttingDown && (endFrame == null || Frame < endFrame))
1397 { 1420 {
1398 framestart = Util.EnvironmentTickCount();
1399 ++Frame; 1421 ++Frame;
1400 1422
1401// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); 1423// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName);
1402 1424
1403 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; 1425 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0;
1404 1426
1405 try 1427 try
1406 { 1428 {
1407 tmpPhysicsMS2 = Util.EnvironmentTickCount(); 1429 // Apply taints in terrain module to terrain in physics scene
1430 if (Frame % m_update_terrain == 0)
1431 {
1432 tmpMS = Util.EnvironmentTickCount();
1433 UpdateTerrain();
1434 terrainMS = Util.EnvironmentTickCountSubtract(tmpMS);
1435 }
1436
1437 tmpMS = Util.EnvironmentTickCount();
1408 if ((Frame % m_update_physics == 0) && m_physics_enabled) 1438 if ((Frame % m_update_physics == 0) && m_physics_enabled)
1409 m_sceneGraph.UpdatePreparePhysics(); 1439 m_sceneGraph.UpdatePreparePhysics();
1410 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2); 1440 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpMS);
1411 1441
1412 // Apply any pending avatar force input to the avatar's velocity 1442 // Apply any pending avatar force input to the avatar's velocity
1413 tmpAgentMS = Util.EnvironmentTickCount(); 1443 tmpMS = Util.EnvironmentTickCount();
1414 if (Frame % m_update_entitymovement == 0) 1444 if (Frame % m_update_entitymovement == 0)
1415 m_sceneGraph.UpdateScenePresenceMovement(); 1445 m_sceneGraph.UpdateScenePresenceMovement();
1416 agentMS = Util.EnvironmentTickCountSubtract(tmpAgentMS); 1446 agentMS = Util.EnvironmentTickCountSubtract(tmpMS);
1417 1447
1418 // Perform the main physics update. This will do the actual work of moving objects and avatars according to their 1448 // Perform the main physics update. This will do the actual work of moving objects and avatars according to their
1419 // velocity 1449 // velocity
1420 tmpPhysicsMS = Util.EnvironmentTickCount(); 1450 tmpMS = Util.EnvironmentTickCount();
1421 if (Frame % m_update_physics == 0) 1451 if (Frame % m_update_physics == 0)
1422 { 1452 {
1423 if (m_physics_enabled) 1453 if (m_physics_enabled)
@@ -1426,9 +1456,9 @@ namespace OpenSim.Region.Framework.Scenes
1426 if (SynchronizeScene != null) 1456 if (SynchronizeScene != null)
1427 SynchronizeScene(this); 1457 SynchronizeScene(this);
1428 } 1458 }
1429 physicsMS = Util.EnvironmentTickCountSubtract(tmpPhysicsMS); 1459 physicsMS = Util.EnvironmentTickCountSubtract(tmpMS);
1430 1460
1431 tmpAgentMS = Util.EnvironmentTickCount(); 1461 tmpMS = Util.EnvironmentTickCount();
1432 1462
1433 // Check if any objects have reached their targets 1463 // Check if any objects have reached their targets
1434 CheckAtTargets(); 1464 CheckAtTargets();
@@ -1443,36 +1473,29 @@ namespace OpenSim.Region.Framework.Scenes
1443 if (Frame % m_update_presences == 0) 1473 if (Frame % m_update_presences == 0)
1444 m_sceneGraph.UpdatePresences(); 1474 m_sceneGraph.UpdatePresences();
1445 1475
1446 agentMS += Util.EnvironmentTickCountSubtract(tmpAgentMS); 1476 agentMS += Util.EnvironmentTickCountSubtract(tmpMS);
1447 1477
1448 // Delete temp-on-rez stuff 1478 // Delete temp-on-rez stuff
1449 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) 1479 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps)
1450 { 1480 {
1451 tmpTempOnRezMS = Util.EnvironmentTickCount(); 1481 tmpMS = Util.EnvironmentTickCount();
1452 m_cleaningTemps = true; 1482 m_cleaningTemps = true;
1453 Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; }); 1483 Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; });
1454 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS); 1484 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpMS);
1455 } 1485 }
1456 1486
1457 if (Frame % m_update_events == 0) 1487 if (Frame % m_update_events == 0)
1458 { 1488 {
1459 evMS = Util.EnvironmentTickCount(); 1489 tmpMS = Util.EnvironmentTickCount();
1460 UpdateEvents(); 1490 UpdateEvents();
1461 eventMS = Util.EnvironmentTickCountSubtract(evMS); 1491 eventMS = Util.EnvironmentTickCountSubtract(tmpMS);
1462 } 1492 }
1463 1493
1464 if (Frame % m_update_backup == 0) 1494 if (Frame % m_update_backup == 0)
1465 { 1495 {
1466 backMS = Util.EnvironmentTickCount(); 1496 tmpMS = Util.EnvironmentTickCount();
1467 UpdateStorageBackup(); 1497 UpdateStorageBackup();
1468 backupMS = Util.EnvironmentTickCountSubtract(backMS); 1498 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 } 1499 }
1477 1500
1478 //if (Frame % m_update_land == 0) 1501 //if (Frame % m_update_land == 0)
@@ -1481,29 +1504,6 @@ namespace OpenSim.Region.Framework.Scenes
1481 // UpdateLand(); 1504 // UpdateLand();
1482 // landMS = Util.EnvironmentTickCountSubtract(ldMS); 1505 // landMS = Util.EnvironmentTickCountSubtract(ldMS);
1483 //} 1506 //}
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 1507
1508 if (LoginsDisabled && Frame == 20) 1508 if (LoginsDisabled && Frame == 20)
1509 { 1509 {
@@ -1524,11 +1524,11 @@ namespace OpenSim.Region.Framework.Scenes
1524 LoginLock = false; 1524 LoginLock = false;
1525 EventManager.TriggerLoginsEnabled(RegionInfo.RegionName); 1525 EventManager.TriggerLoginsEnabled(RegionInfo.RegionName);
1526 } 1526 }
1527 m_log.DebugFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName);
1528 1527
1529 // For RegionReady lockouts 1528 // For RegionReady lockouts
1530 if(LoginLock == false) 1529 if (!LoginLock)
1531 { 1530 {
1531 m_log.InfoFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName);
1532 LoginsDisabled = false; 1532 LoginsDisabled = false;
1533 } 1533 }
1534 1534
@@ -1554,23 +1554,36 @@ namespace OpenSim.Region.Framework.Scenes
1554 1554
1555 previousFrameTick = m_lastFrameTick; 1555 previousFrameTick = m_lastFrameTick;
1556 m_lastFrameTick = Util.EnvironmentTickCount(); 1556 m_lastFrameTick = Util.EnvironmentTickCount();
1557 maintc = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart); 1557 tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc);
1558 maintc = (int)(MinFrameTime * 1000) - maintc; 1558 tmpMS = (int)(MinFrameTime * 1000) - tmpMS;
1559 1559
1560 m_firstHeartbeat = false; 1560 m_firstHeartbeat = false;
1561 1561
1562 if (tmpMS > 0)
1563 {
1564 Thread.Sleep(tmpMS);
1565 spareMS += tmpMS;
1566 }
1567
1568 frameMS = Util.EnvironmentTickCountSubtract(maintc);
1569 maintc = Util.EnvironmentTickCount();
1562 1570
1563 sleepMS = Util.EnvironmentTickCount(); 1571 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1564 1572
1565 if (maintc > 0) 1573 // if (Frame%m_update_avatars == 0)
1566 Thread.Sleep(maintc); 1574 // UpdateInWorldTime();
1575 StatsReporter.AddPhysicsFPS(physicsFPS);
1576 StatsReporter.AddTimeDilation(TimeDilation);
1577 StatsReporter.AddFPS(1);
1567 1578
1568 sleepMS = Util.EnvironmentTickCountSubtract(sleepMS);
1569 frameMS = Util.EnvironmentTickCountSubtract(framestart);
1570 StatsReporter.addSleepMS(sleepMS);
1571 StatsReporter.addFrameMS(frameMS); 1579 StatsReporter.addFrameMS(frameMS);
1572 1580 StatsReporter.addAgentMS(agentMS);
1573 // Optionally warn if a frame takes double the amount of time that it should. 1581 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1582 StatsReporter.addOtherMS(otherMS);
1583 StatsReporter.AddSpareMS(spareMS);
1584 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1585
1586 // Optionally warn if a frame takes double the amount of time that it should.
1574 if (DebugUpdates 1587 if (DebugUpdates
1575 && Util.EnvironmentTickCountSubtract( 1588 && Util.EnvironmentTickCountSubtract(
1576 m_lastFrameTick, previousFrameTick) > (int)(MinFrameTime * 1000 * 2)) 1589 m_lastFrameTick, previousFrameTick) > (int)(MinFrameTime * 1000 * 2))
@@ -2083,9 +2096,8 @@ namespace OpenSim.Region.Framework.Scenes
2083 sceneObject.SetGroup(groupID, null); 2096 sceneObject.SetGroup(groupID, null);
2084 } 2097 }
2085 2098
2086 IUserManagement uman = RequestModuleInterface<IUserManagement>(); 2099 if (UserManagementModule != null)
2087 if (uman != null) 2100 sceneObject.RootPart.CreatorIdentification = UserManagementModule.GetUserUUI(ownerID);
2088 sceneObject.RootPart.CreatorIdentification = uman.GetUserUUI(ownerID);
2089 2101
2090 sceneObject.ScheduleGroupForFullUpdate(); 2102 sceneObject.ScheduleGroupForFullUpdate();
2091 2103
@@ -2363,8 +2375,8 @@ namespace OpenSim.Region.Framework.Scenes
2363 return; 2375 return;
2364 } 2376 }
2365 2377
2366 if (m_teleportModule != null) 2378 if (EntityTransferModule != null)
2367 m_teleportModule.Cross(grp, attemptedPosition, silent); 2379 EntityTransferModule.Cross(grp, attemptedPosition, silent);
2368 } 2380 }
2369 2381
2370 public Border GetCrossedBorder(Vector3 position, Cardinals gridline) 2382 public Border GetCrossedBorder(Vector3 position, Cardinals gridline)
@@ -2684,10 +2696,10 @@ namespace OpenSim.Region.Framework.Scenes
2684 { 2696 {
2685 SceneObjectGroup grp = sceneObject; 2697 SceneObjectGroup grp = sceneObject;
2686 2698
2687 m_log.DebugFormat( 2699// m_log.DebugFormat(
2688 "[ATTACHMENT]: Received attachment {0}, inworld asset id {1}", grp.FromItemID, grp.UUID); 2700// "[ATTACHMENT]: Received attachment {0}, inworld asset id {1}", grp.FromItemID, grp.UUID);
2689 m_log.DebugFormat( 2701// m_log.DebugFormat(
2690 "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition); 2702// "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition);
2691 2703
2692 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2704 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2693 2705
@@ -2783,7 +2795,8 @@ namespace OpenSim.Region.Framework.Scenes
2783 if (sp == null) 2795 if (sp == null)
2784 { 2796 {
2785 m_log.DebugFormat( 2797 m_log.DebugFormat(
2786 "[SCENE]: Adding new child scene presence {0} to scene {1} at pos {2}", client.Name, RegionInfo.RegionName, client.StartPos); 2798 "[SCENE]: Adding new child scene presence {0} {1} to scene {2} at pos {3}",
2799 client.Name, client.AgentId, RegionInfo.RegionName, client.StartPos);
2787 2800
2788 m_clientManager.Add(client); 2801 m_clientManager.Add(client);
2789 SubscribeToClientEvents(client); 2802 SubscribeToClientEvents(client);
@@ -2843,14 +2856,13 @@ namespace OpenSim.Region.Framework.Scenes
2843 /// <param name="aCircuit"></param> 2856 /// <param name="aCircuit"></param>
2844 private void CacheUserName(ScenePresence sp, AgentCircuitData aCircuit) 2857 private void CacheUserName(ScenePresence sp, AgentCircuitData aCircuit)
2845 { 2858 {
2846 IUserManagement uMan = RequestModuleInterface<IUserManagement>(); 2859 if (UserManagementModule != null)
2847 if (uMan != null)
2848 { 2860 {
2849 string first = aCircuit.firstname, last = aCircuit.lastname; 2861 string first = aCircuit.firstname, last = aCircuit.lastname;
2850 2862
2851 if (sp.PresenceType == PresenceType.Npc) 2863 if (sp.PresenceType == PresenceType.Npc)
2852 { 2864 {
2853 uMan.AddUser(aCircuit.AgentID, first, last); 2865 UserManagementModule.AddUser(aCircuit.AgentID, first, last);
2854 } 2866 }
2855 else 2867 else
2856 { 2868 {
@@ -2869,7 +2881,7 @@ namespace OpenSim.Region.Framework.Scenes
2869 } 2881 }
2870 } 2882 }
2871 2883
2872 uMan.AddUser(aCircuit.AgentID, first, last, homeURL); 2884 UserManagementModule.AddUser(aCircuit.AgentID, first, last, homeURL);
2873 } 2885 }
2874 } 2886 }
2875 } 2887 }
@@ -3207,8 +3219,10 @@ namespace OpenSim.Region.Framework.Scenes
3207 /// <param name="client">The IClientAPI for the client</param> 3219 /// <param name="client">The IClientAPI for the client</param>
3208 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) 3220 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
3209 { 3221 {
3210 if (m_teleportModule != null) 3222 if (EntityTransferModule != null)
3211 return m_teleportModule.TeleportHome(agentId, client); 3223 {
3224 EntityTransferModule.TeleportHome(agentId, client);
3225 }
3212 else 3226 else
3213 { 3227 {
3214 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3228 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
@@ -3370,65 +3384,82 @@ namespace OpenSim.Region.Framework.Scenes
3370// CheckHeartbeat(); 3384// CheckHeartbeat();
3371 bool isChildAgent = false; 3385 bool isChildAgent = false;
3372 ScenePresence avatar = GetScenePresence(agentID); 3386 ScenePresence avatar = GetScenePresence(agentID);
3373 if (avatar != null) 3387
3388 if (avatar == null)
3389 {
3390 m_log.WarnFormat(
3391 "[SCENE]: Called RemoveClient() with agent ID {0} but no such presence is in the scene.", agentID);
3392
3393 return;
3394 }
3395
3396 try
3374 { 3397 {
3375 isChildAgent = avatar.IsChildAgent; 3398 isChildAgent = avatar.IsChildAgent;
3376 3399
3377 if (avatar.ParentID != 0) 3400 m_log.DebugFormat(
3401 "[SCENE]: Removing {0} agent {1} {2} from {3}",
3402 (isChildAgent ? "child" : "root"), avatar.Name, agentID, RegionInfo.RegionName);
3403
3404 // Don't do this to root agents, it's not nice for the viewer
3405 if (closeChildAgents && isChildAgent)
3378 { 3406 {
3379 avatar.StandUp(); 3407 // Tell a single agent to disconnect from the region.
3408 IEventQueue eq = RequestModuleInterface<IEventQueue>();
3409 if (eq != null)
3410 {
3411 eq.DisableSimulator(RegionInfo.RegionHandle, avatar.UUID);
3412 }
3413 else
3414 {
3415 avatar.ControllingClient.SendShutdownConnectionNotice();
3416 }
3380 } 3417 }
3381 3418
3382 try 3419 // Only applies to root agents.
3420 if (avatar.ParentID != 0)
3383 { 3421 {
3384 m_log.DebugFormat( 3422 avatar.StandUp();
3385 "[SCENE]: Removing {0} agent {1} from region {2}", 3423 }
3386 (isChildAgent ? "child" : "root"), agentID, RegionInfo.RegionName);
3387 3424
3388 m_sceneGraph.removeUserCount(!isChildAgent); 3425 m_sceneGraph.removeUserCount(!isChildAgent);
3389 3426
3390 // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop 3427 // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop
3391 // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI 3428 // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI
3392 if (closeChildAgents && CapsModule != null) 3429 if (closeChildAgents && CapsModule != null)
3393 CapsModule.RemoveCaps(agentID); 3430 CapsModule.RemoveCaps(agentID);
3394 3431
3395 // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever 3432 // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever
3396 // this method is doing is HORRIBLE!!! 3433 // this method is doing is HORRIBLE!!!
3397 avatar.Scene.NeedSceneCacheClear(avatar.UUID); 3434 avatar.Scene.NeedSceneCacheClear(avatar.UUID);
3398 3435
3399 if (closeChildAgents && !avatar.IsChildAgent) 3436 if (closeChildAgents && !isChildAgent)
3400 {
3401 List<ulong> regions = avatar.KnownRegionHandles;
3402 regions.Remove(RegionInfo.RegionHandle);
3403 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3404 }
3405 m_log.Debug("[Scene] Beginning ClientClosed");
3406 m_eventManager.TriggerClientClosed(agentID, this);
3407 m_log.Debug("[Scene] Finished ClientClosed");
3408 }
3409 catch (NullReferenceException)
3410 { 3437 {
3411 // We don't know which count to remove it from 3438 List<ulong> regions = avatar.KnownRegionHandles;
3412 // Avatar is already disposed :/ 3439 regions.Remove(RegionInfo.RegionHandle);
3440 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3413 } 3441 }
3414 3442
3415 try 3443 m_eventManager.TriggerClientClosed(agentID, this);
3444 m_eventManager.TriggerOnRemovePresence(agentID);
3445
3446 if (!isChildAgent)
3416 { 3447 {
3417 m_eventManager.TriggerOnRemovePresence(agentID); 3448 if (AttachmentsModule != null)
3418
3419 if (AttachmentsModule != null && !isChildAgent && avatar.PresenceType != PresenceType.Npc)
3420 { 3449 {
3421 IUserManagement uMan = RequestModuleInterface<IUserManagement>();
3422 // Don't save attachments for HG visitors, it 3450 // Don't save attachments for HG visitors, it
3423 // messes up their inventory. When a HG visitor logs 3451 // messes up their inventory. When a HG visitor logs
3424 // out on a foreign grid, their attachments will be 3452 // out on a foreign grid, their attachments will be
3425 // reloaded in the state they were in when they left 3453 // reloaded in the state they were in when they left
3426 // the home grid. This is best anyway as the visited 3454 // the home grid. This is best anyway as the visited
3427 // grid may use an incompatible script engine. 3455 // grid may use an incompatible script engine.
3428 if (uMan == null || uMan.IsLocalGridUser(avatar.UUID)) 3456 bool saveChanged
3429 AttachmentsModule.SaveChangedAttachments(avatar, false); 3457 = avatar.PresenceType != PresenceType.Npc
3458 && (UserManagementModule == null || UserManagementModule.IsLocalGridUser(avatar.UUID));
3459
3460 AttachmentsModule.DeRezAttachments(avatar, saveChanged, false);
3430 } 3461 }
3431 3462
3432 ForEachClient( 3463 ForEachClient(
3433 delegate(IClientAPI client) 3464 delegate(IClientAPI client)
3434 { 3465 {
@@ -3436,43 +3467,35 @@ namespace OpenSim.Region.Framework.Scenes
3436 try { client.SendKillObject(avatar.RegionHandle, new List<uint> { avatar.LocalId }); } 3467 try { client.SendKillObject(avatar.RegionHandle, new List<uint> { avatar.LocalId }); }
3437 catch (NullReferenceException) { } 3468 catch (NullReferenceException) { }
3438 }); 3469 });
3439
3440 IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>();
3441 if (agentTransactions != null)
3442 {
3443 agentTransactions.RemoveAgentAssetTransactions(agentID);
3444 }
3445 }
3446 finally
3447 {
3448 // Always clean these structures up so that any failure above doesn't cause them to remain in the
3449 // scene with possibly bad effects (e.g. continually timing out on unacked packets and triggering
3450 // the same cleanup exception continually.
3451 // TODO: This should probably extend to the whole method, but we don't want to also catch the NRE
3452 // since this would hide the underlying failure and other associated problems.
3453 m_sceneGraph.RemoveScenePresence(agentID);
3454 m_clientManager.Remove(agentID);
3455 } 3470 }
3456 3471
3457 try 3472 // It's possible for child agents to have transactions if changes are being made cross-border.
3458 { 3473 if (AgentTransactionsModule != null)
3459 avatar.Close(); 3474 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID);
3460 } 3475
3461 catch (NullReferenceException) 3476 avatar.Close();
3462 { 3477
3463 //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway.
3464 }
3465 catch (Exception e)
3466 {
3467 m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace);
3468 }
3469 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3470 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3478 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3471// CleanDroppedAttachments();
3472 m_log.Debug("[Scene] The avatar has left the building"); 3479 m_log.Debug("[Scene] The avatar has left the building");
3473 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3474 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3475 } 3480 }
3481 catch (Exception e)
3482 {
3483 m_log.Error(
3484 string.Format("[SCENE]: Exception removing {0} from {1}, ", avatar.Name, RegionInfo.RegionName), e);
3485 }
3486 finally
3487 {
3488 // Always clean these structures up so that any failure above doesn't cause them to remain in the
3489 // scene with possibly bad effects (e.g. continually timing out on unacked packets and triggering
3490 // the same cleanup exception continually.
3491 // TODO: This should probably extend to the whole method, but we don't want to also catch the NRE
3492 // since this would hide the underlying failure and other associated problems.
3493 m_sceneGraph.RemoveScenePresence(agentID);
3494 m_clientManager.Remove(agentID);
3495 }
3496
3497 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3498 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3476 } 3499 }
3477 3500
3478 /// <summary> 3501 /// <summary>
@@ -3554,7 +3577,7 @@ namespace OpenSim.Region.Framework.Scenes
3554 public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason, bool requirePresenceLookup) 3577 public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason, bool requirePresenceLookup)
3555 { 3578 {
3556 bool vialogin = ((teleportFlags & (uint)TPFlags.ViaLogin) != 0 || 3579 bool vialogin = ((teleportFlags & (uint)TPFlags.ViaLogin) != 0 ||
3557 (teleportFlags & (uint)TPFlags.ViaHGLogin) != 0); 3580 (teleportFlags & (uint)TPFlags.ViaHGLogin) != 0);
3558 bool viahome = ((teleportFlags & (uint)TPFlags.ViaHome) != 0); 3581 bool viahome = ((teleportFlags & (uint)TPFlags.ViaHome) != 0);
3559 bool godlike = ((teleportFlags & (uint)TPFlags.Godlike) != 0); 3582 bool godlike = ((teleportFlags & (uint)TPFlags.Godlike) != 0);
3560 3583
@@ -3570,8 +3593,17 @@ namespace OpenSim.Region.Framework.Scenes
3570 // Don't disable this log message - it's too helpful 3593 // Don't disable this log message - it's too helpful
3571 m_log.DebugFormat( 3594 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})", 3595 "[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, 3596 RegionInfo.RegionName,
3574 agent.AgentID, agent.circuitcode, agent.IPAddress, agent.Viewer, ((TPFlags)teleportFlags).ToString(), agent.startpos); 3597 (agent.child ? "child" : "root"),
3598 agent.firstname,
3599 agent.lastname,
3600 agent.AgentID,
3601 agent.circuitcode,
3602 agent.IPAddress,
3603 agent.Viewer,
3604 ((TPFlags)teleportFlags).ToString(),
3605 agent.startpos
3606 );
3575 3607
3576 if (LoginsDisabled) 3608 if (LoginsDisabled)
3577 { 3609 {
@@ -3586,7 +3618,10 @@ namespace OpenSim.Region.Framework.Scenes
3586 // We have a zombie from a crashed session. 3618 // We have a zombie from a crashed session.
3587 // Or the same user is trying to be root twice here, won't work. 3619 // Or the same user is trying to be root twice here, won't work.
3588 // Kill it. 3620 // Kill it.
3589 m_log.DebugFormat("[SCENE]: Zombie scene presence detected for {0} in {1}", agent.AgentID, RegionInfo.RegionName); 3621 m_log.DebugFormat(
3622 "[SCENE]: Zombie scene presence detected for {0} {1} in {2}",
3623 sp.Name, sp.UUID, RegionInfo.RegionName);
3624
3590 sp.ControllingClient.Close(); 3625 sp.ControllingClient.Close();
3591 sp = null; 3626 sp = null;
3592 } 3627 }
@@ -3613,8 +3648,7 @@ namespace OpenSim.Region.Framework.Scenes
3613 { 3648 {
3614 if (!VerifyUserPresence(agent, out reason)) 3649 if (!VerifyUserPresence(agent, out reason))
3615 return false; 3650 return false;
3616 } 3651 } catch (Exception e)
3617 catch (Exception e)
3618 { 3652 {
3619 m_log.ErrorFormat( 3653 m_log.ErrorFormat(
3620 "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace); 3654 "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace);
@@ -3649,8 +3683,7 @@ namespace OpenSim.Region.Framework.Scenes
3649 CapsModule.SetAgentCapsSeeds(agent); 3683 CapsModule.SetAgentCapsSeeds(agent);
3650 CapsModule.CreateCaps(agent.AgentID); 3684 CapsModule.CreateCaps(agent.AgentID);
3651 } 3685 }
3652 } 3686 } else
3653 else
3654 { 3687 {
3655 // Let the SP know how we got here. This has a lot of interesting 3688 // Let the SP know how we got here. This has a lot of interesting
3656 // uses down the line. 3689 // uses down the line.
@@ -3673,7 +3706,7 @@ namespace OpenSim.Region.Framework.Scenes
3673 agent.teleportFlags = teleportFlags; 3706 agent.teleportFlags = teleportFlags;
3674 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); 3707 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
3675 3708
3676 if (vialogin) 3709 if (vialogin)
3677 { 3710 {
3678// CleanDroppedAttachments(); 3711// CleanDroppedAttachments();
3679 3712
@@ -3714,8 +3747,7 @@ namespace OpenSim.Region.Framework.Scenes
3714 agent.startpos.Z = 720; 3747 agent.startpos.Z = 720;
3715 } 3748 }
3716 } 3749 }
3717 } 3750 } else
3718 else
3719 { 3751 {
3720 if (agent.startpos.X > EastBorders[0].BorderLine.Z) 3752 if (agent.startpos.X > EastBorders[0].BorderLine.Z)
3721 { 3753 {
@@ -3741,10 +3773,19 @@ namespace OpenSim.Region.Framework.Scenes
3741 SceneObjectGroup telehub = GetSceneObjectGroup(RegionInfo.RegionSettings.TelehubObject); 3773 SceneObjectGroup telehub = GetSceneObjectGroup(RegionInfo.RegionSettings.TelehubObject);
3742 // Can have multiple SpawnPoints 3774 // Can have multiple SpawnPoints
3743 List<SpawnPoint> spawnpoints = RegionInfo.RegionSettings.SpawnPoints(); 3775 List<SpawnPoint> spawnpoints = RegionInfo.RegionSettings.SpawnPoints();
3744 if ( spawnpoints.Count > 1) 3776 if (spawnpoints.Count > 1)
3745 { 3777 {
3746 // We have multiple SpawnPoints, Route the agent to a random one 3778 // 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); 3779 if (SpawnPointRouting == "random")
3780 agent.startpos = spawnpoints[Util.RandomClass.Next(spawnpoints.Count) - 1].GetLocation(
3781 telehub.AbsolutePosition,
3782 telehub.GroupRotation
3783 );
3784 else
3785 agent.startpos = spawnpoints[SpawnPoint()].GetLocation(
3786 telehub.AbsolutePosition,
3787 telehub.GroupRotation
3788 );
3748 } 3789 }
3749 else 3790 else
3750 { 3791 {
@@ -3981,41 +4022,41 @@ namespace OpenSim.Region.Framework.Scenes
3981 return m_authenticateHandler.TryChangeCiruitCode(oldcc, newcc); 4022 return m_authenticateHandler.TryChangeCiruitCode(oldcc, newcc);
3982 } 4023 }
3983 4024
3984 /// <summary> 4025// /// <summary>
3985 /// The Grid has requested that we log-off a user. Log them off. 4026// /// The Grid has requested that we log-off a user. Log them off.
3986 /// </summary> 4027// /// </summary>
3987 /// <param name="AvatarID">Unique ID of the avatar to log-off</param> 4028// /// <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> 4029// /// <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> 4030// /// <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) 4031// public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message)
3991 { 4032// {
3992 ScenePresence loggingOffUser = GetScenePresence(AvatarID); 4033// ScenePresence loggingOffUser = GetScenePresence(AvatarID);
3993 if (loggingOffUser != null) 4034// if (loggingOffUser != null)
3994 { 4035// {
3995 UUID localRegionSecret = UUID.Zero; 4036// UUID localRegionSecret = UUID.Zero;
3996 bool parsedsecret = UUID.TryParse(m_regInfo.regionSecret, out localRegionSecret); 4037// bool parsedsecret = UUID.TryParse(m_regInfo.regionSecret, out localRegionSecret);
3997 4038//
3998 // Region Secret is used here in case a new sessionid overwrites an old one on the user server. 4039// // 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. 4040// // Will update the user server in a few revisions to use it.
4000 4041//
4001 if (RegionSecret == loggingOffUser.ControllingClient.SecureSessionId || (parsedsecret && RegionSecret == localRegionSecret)) 4042// if (RegionSecret == loggingOffUser.ControllingClient.SecureSessionId || (parsedsecret && RegionSecret == localRegionSecret))
4002 { 4043// {
4003 m_sceneGridService.SendCloseChildAgentConnections(loggingOffUser.UUID, loggingOffUser.KnownRegionHandles); 4044// m_sceneGridService.SendCloseChildAgentConnections(loggingOffUser.UUID, loggingOffUser.KnownRegionHandles);
4004 loggingOffUser.ControllingClient.Kick(message); 4045// loggingOffUser.ControllingClient.Kick(message);
4005 // Give them a second to receive the message! 4046// // Give them a second to receive the message!
4006 Thread.Sleep(1000); 4047// Thread.Sleep(1000);
4007 loggingOffUser.ControllingClient.Close(); 4048// loggingOffUser.ControllingClient.Close();
4008 } 4049// }
4009 else 4050// else
4010 { 4051// {
4011 m_log.Info("[USERLOGOFF]: System sending the LogOff user message failed to sucessfully authenticate"); 4052// m_log.Info("[USERLOGOFF]: System sending the LogOff user message failed to sucessfully authenticate");
4012 } 4053// }
4013 } 4054// }
4014 else 4055// else
4015 { 4056// {
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()); 4057// 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 } 4058// }
4018 } 4059// }
4019 4060
4020 /// <summary> 4061 /// <summary>
4021 /// Triggered when an agent crosses into this sim. Also happens on initial login. 4062 /// Triggered when an agent crosses into this sim. Also happens on initial login.
@@ -4068,21 +4109,19 @@ namespace OpenSim.Region.Framework.Scenes
4068 return false; 4109 return false;
4069 } 4110 }
4070 4111
4112 // TODO: This check should probably be in QueryAccess().
4071 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 4113 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
4072 if (nearestParcel == null) 4114 if (nearestParcel == null)
4073 { 4115 {
4074 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: no allowed parcel", cAgentData.AgentID); 4116 m_log.DebugFormat(
4075 return false; 4117 "[SCENE]: Denying root agent entry to {0} in {1}: no allowed parcel",
4076 } 4118 cAgentData.AgentID, RegionInfo.RegionName);
4077
4078 int num = m_sceneGraph.GetNumberOfScenePresences();
4079 4119
4080 if (num >= RegionInfo.RegionSettings.AgentLimit) 4120 return false;
4081 {
4082 if (!Permissions.IsAdministrator(cAgentData.AgentID))
4083 return false;
4084 } 4121 }
4085 4122
4123 // We have to wait until the viewer contacts this region after receiving EAC.
4124 // That calls AddNewClient, which finally creates the ScenePresence
4086 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); 4125 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID);
4087 4126
4088 if (childAgentUpdate != null) 4127 if (childAgentUpdate != null)
@@ -4126,14 +4165,28 @@ namespace OpenSim.Region.Framework.Scenes
4126 return false; 4165 return false;
4127 } 4166 }
4128 4167
4168 /// <summary>
4169 /// Poll until the requested ScenePresence appears or we timeout.
4170 /// </summary>
4171 /// <returns>The scene presence is found, else null.</returns>
4172 /// <param name='agentID'></param>
4129 protected virtual ScenePresence WaitGetScenePresence(UUID agentID) 4173 protected virtual ScenePresence WaitGetScenePresence(UUID agentID)
4130 { 4174 {
4131 int ntimes = 10; 4175 int ntimes = 10;
4132 ScenePresence childAgentUpdate = null; 4176 ScenePresence sp = null;
4133 while ((childAgentUpdate = GetScenePresence(agentID)) == null && (ntimes-- > 0)) 4177 while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0))
4134 Thread.Sleep(1000); 4178 Thread.Sleep(1000);
4135 return childAgentUpdate;
4136 4179
4180 if (sp == null)
4181 m_log.WarnFormat(
4182 "[SCENE PRESENCE]: Did not find presence with id {0} in {1} before timeout",
4183 agentID, RegionInfo.RegionName);
4184// else
4185// m_log.DebugFormat(
4186// "[SCENE PRESENCE]: Found presence {0} {1} {2} in {3} after {4} waits",
4187// sp.Name, sp.UUID, sp.IsChildAgent ? "child" : "root", RegionInfo.RegionName, 10 - ntimes);
4188
4189 return sp;
4137 } 4190 }
4138 4191
4139 public virtual bool IncomingRetrieveRootAgent(UUID id, out IAgentData agent) 4192 public virtual bool IncomingRetrieveRootAgent(UUID id, out IAgentData agent)
@@ -4171,33 +4224,7 @@ namespace OpenSim.Region.Framework.Scenes
4171 ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); 4224 ScenePresence presence = m_sceneGraph.GetScenePresence(agentID);
4172 if (presence != null) 4225 if (presence != null)
4173 { 4226 {
4174 // Nothing is removed here, so down count it as such 4227 presence.ControllingClient.Close();
4175 if (presence.IsChildAgent)
4176 {
4177 m_sceneGraph.removeUserCount(false);
4178 }
4179 else if (!childOnly)
4180 {
4181 m_sceneGraph.removeUserCount(true);
4182 }
4183
4184 // Don't do this to root agents on logout, it's not nice for the viewer
4185 if (presence.IsChildAgent)
4186 {
4187 // Tell a single agent to disconnect from the region.
4188 IEventQueue eq = RequestModuleInterface<IEventQueue>();
4189 if (eq != null)
4190 {
4191 eq.DisableSimulator(RegionInfo.RegionHandle, agentID);
4192 }
4193 else
4194 presence.ControllingClient.SendShutdownConnectionNotice();
4195 presence.ControllingClient.Close(false);
4196 }
4197 else if (!childOnly)
4198 {
4199 presence.ControllingClient.Close(true);
4200 }
4201 return true; 4228 return true;
4202 } 4229 }
4203 4230
@@ -4283,8 +4310,10 @@ namespace OpenSim.Region.Framework.Scenes
4283 position.Y -= shifty; 4310 position.Y -= shifty;
4284 } 4311 }
4285 4312
4286 if (m_teleportModule != null) 4313 if (EntityTransferModule != null)
4287 m_teleportModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags); 4314 {
4315 EntityTransferModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags);
4316 }
4288 else 4317 else
4289 { 4318 {
4290 m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active"); 4319 m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active");
@@ -4295,8 +4324,10 @@ namespace OpenSim.Region.Framework.Scenes
4295 4324
4296 public bool CrossAgentToNewRegion(ScenePresence agent, bool isFlying) 4325 public bool CrossAgentToNewRegion(ScenePresence agent, bool isFlying)
4297 { 4326 {
4298 if (m_teleportModule != null) 4327 if (EntityTransferModule != null)
4299 return m_teleportModule.Cross(agent, isFlying); 4328 {
4329 return EntityTransferModule.Cross(agent, isFlying);
4330 }
4300 else 4331 else
4301 { 4332 {
4302 m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule"); 4333 m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule");
@@ -5444,29 +5475,58 @@ Environment.Exit(1);
5444 throw new Exception(error); 5475 throw new Exception(error);
5445 } 5476 }
5446 5477
5447 // This method is called across the simulation connector to 5478 /// <summary>
5448 // determine if a given agent is allowed in this region 5479 /// This method is called across the simulation connector to
5449 // AS A ROOT AGENT. Returning false here will prevent them 5480 /// determine if a given agent is allowed in this region
5450 // from logging into the region, teleporting into the region 5481 /// AS A ROOT AGENT
5451 // or corssing the broder walking, but will NOT prevent 5482 /// </summary>
5452 // child agent creation, thereby emulating the SL behavior. 5483 /// <remarks>
5484 /// Returning false here will prevent them
5485 /// from logging into the region, teleporting into the region
5486 /// or corssing the broder walking, but will NOT prevent
5487 /// child agent creation, thereby emulating the SL behavior.
5488 /// </remarks>
5489 /// <param name='agentID'></param>
5490 /// <param name='position'></param>
5491 /// <param name='reason'></param>
5492 /// <returns></returns>
5453 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5493 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5454 { 5494 {
5455 reason = "You are banned from the region"; 5495 reason = "You are banned from the region";
5456 5496
5497 if (EntityTransferModule.IsInTransit(agentID))
5498 {
5499 reason = "Agent is still in transit from this region";
5500
5501 m_log.WarnFormat(
5502 "[SCENE]: Denying agent {0} entry into {1} since region still has them registered as in transit",
5503 agentID, RegionInfo.RegionName);
5504
5505 return false;
5506 }
5507
5457 if (Permissions.IsGod(agentID)) 5508 if (Permissions.IsGod(agentID))
5458 { 5509 {
5459 reason = String.Empty; 5510 reason = String.Empty;
5460 return true; 5511 return true;
5461 } 5512 }
5462 5513
5463 int num = m_sceneGraph.GetNumberOfScenePresences(); 5514 // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check.
5515 // However, the long term fix is to make sure root agent count is always accurate.
5516 m_sceneGraph.RecalculateStats();
5517
5518 int num = m_sceneGraph.GetRootAgentCount();
5464 5519
5465 if (num >= RegionInfo.RegionSettings.AgentLimit) 5520 if (num >= RegionInfo.RegionSettings.AgentLimit)
5466 { 5521 {
5467 if (!Permissions.IsAdministrator(agentID)) 5522 if (!Permissions.IsAdministrator(agentID))
5468 { 5523 {
5469 reason = "The region is full"; 5524 reason = "The region is full";
5525
5526 m_log.DebugFormat(
5527 "[SCENE]: Denying presence with id {0} entry into {1} since region is at agent limit of {2}",
5528 agentID, RegionInfo.RegionName, RegionInfo.RegionSettings.AgentLimit);
5529
5470 return false; 5530 return false;
5471 } 5531 }
5472 } 5532 }
@@ -5637,5 +5697,19 @@ Environment.Exit(1);
5637 } 5697 }
5638 } 5698 }
5639 } 5699 }
5700
5701 // manage and select spawn points in sequence
5702 public int SpawnPoint()
5703 {
5704 int spawnpoints = RegionInfo.RegionSettings.SpawnPoints().Count;
5705
5706 if (spawnpoints == 0)
5707 return 0;
5708
5709 m_SpawnPoint++;
5710 if (m_SpawnPoint > spawnpoints)
5711 m_SpawnPoint = 1;
5712 return m_SpawnPoint - 1;
5713 }
5640 } 5714 }
5641} 5715}
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index b806d91..c1414ee 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -84,16 +84,16 @@ namespace OpenSim.Region.Framework.Scenes
84 if (neighbourService != null) 84 if (neighbourService != null)
85 neighbour = neighbourService.HelloNeighbour(regionhandle, region); 85 neighbour = neighbourService.HelloNeighbour(regionhandle, region);
86 else 86 else
87 m_log.DebugFormat("[SCS]: No neighbour service provided for informing neigbhours of this region"); 87 m_log.DebugFormat("[SCENE COMMUNICATION SERVICE]: No neighbour service provided for informing neigbhours of this region");
88 88
89 if (neighbour != null) 89 if (neighbour != null)
90 { 90 {
91 // m_log.DebugFormat("[INTERGRID]: Successfully informed neighbour {0}-{1} that I'm here", x / Constants.RegionSize, y / Constants.RegionSize); 91 m_log.DebugFormat("[SCENE COMMUNICATION SERVICE]: Successfully informed neighbour {0}-{1} that I'm here", x / Constants.RegionSize, y / Constants.RegionSize);
92 m_scene.EventManager.TriggerOnRegionUp(neighbour); 92 m_scene.EventManager.TriggerOnRegionUp(neighbour);
93 } 93 }
94 else 94 else
95 { 95 {
96 m_log.InfoFormat("[INTERGRID]: Failed to inform neighbour {0}-{1} that I'm here.", x / Constants.RegionSize, y / Constants.RegionSize); 96 m_log.InfoFormat("[SCENE COMMUNICATION SERVICE]: Failed to inform neighbour {0}-{1} that I'm here.", x / Constants.RegionSize, y / Constants.RegionSize);
97 } 97 }
98 } 98 }
99 99
@@ -102,7 +102,7 @@ namespace OpenSim.Region.Framework.Scenes
102 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName); 102 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName);
103 103
104 List<GridRegion> neighbours = m_scene.GridService.GetNeighbours(m_scene.RegionInfo.ScopeID, m_scene.RegionInfo.RegionID); 104 List<GridRegion> neighbours = m_scene.GridService.GetNeighbours(m_scene.RegionInfo.ScopeID, m_scene.RegionInfo.RegionID);
105 //m_log.DebugFormat("[INTERGRID]: Informing {0} neighbours that this region is up", neighbours.Count); 105 m_log.DebugFormat("[SCENE COMMUNICATION SERVICE]: Informing {0} neighbours that this region is up", neighbours.Count);
106 foreach (GridRegion n in neighbours) 106 foreach (GridRegion n in neighbours)
107 { 107 {
108 InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync; 108 InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync;
@@ -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..4c12496 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
@@ -775,12 +782,6 @@ namespace OpenSim.Region.Framework.Scenes
775 782
776 public int GetChildAgentCount() 783 public int GetChildAgentCount()
777 { 784 {
778 // some network situations come in where child agents get closed twice.
779 if (m_numChildAgents < 0)
780 {
781 m_numChildAgents = 0;
782 }
783
784 return m_numChildAgents; 785 return m_numChildAgents;
785 } 786 }
786 787
@@ -852,11 +853,6 @@ namespace OpenSim.Region.Framework.Scenes
852 return m_scenePresenceArray; 853 return m_scenePresenceArray;
853 } 854 }
854 855
855 public int GetNumberOfScenePresences()
856 {
857 return m_scenePresenceArray.Count;
858 }
859
860 /// <summary> 856 /// <summary>
861 /// Request a scene presence by UUID. Fast, indexed lookup. 857 /// Request a scene presence by UUID. Fast, indexed lookup.
862 /// </summary> 858 /// </summary>
@@ -2063,12 +2059,14 @@ namespace OpenSim.Region.Framework.Scenes
2063 /// <param name="AgentID"></param> 2059 /// <param name="AgentID"></param>
2064 /// <param name="GroupID"></param> 2060 /// <param name="GroupID"></param>
2065 /// <param name="rot"></param> 2061 /// <param name="rot"></param>
2062 /// <returns>null if duplication fails, otherwise the duplicated object</returns>
2063 /// <summary>
2066 public SceneObjectGroup DuplicateObject(uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot) 2064 public SceneObjectGroup DuplicateObject(uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot)
2067 { 2065 {
2068// m_log.DebugFormat( 2066// m_log.DebugFormat(
2069// "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", 2067// "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}",
2070// originalPrimID, offset, AgentID); 2068// originalPrimID, offset, AgentID);
2071 2069
2072 SceneObjectGroup original = GetGroupByPrim(originalPrimID); 2070 SceneObjectGroup original = GetGroupByPrim(originalPrimID);
2073 if (original != null) 2071 if (original != null)
2074 { 2072 {
@@ -2098,25 +2096,25 @@ namespace OpenSim.Region.Framework.Scenes
2098 2096
2099 // FIXME: This section needs to be refactored so that it just calls AddSceneObject() 2097 // FIXME: This section needs to be refactored so that it just calls AddSceneObject()
2100 Entities.Add(copy); 2098 Entities.Add(copy);
2101 2099
2102 lock (SceneObjectGroupsByFullID) 2100 lock (SceneObjectGroupsByFullID)
2103 SceneObjectGroupsByFullID[copy.UUID] = copy; 2101 SceneObjectGroupsByFullID[copy.UUID] = copy;
2104 2102
2105 SceneObjectPart[] children = copy.Parts; 2103 SceneObjectPart[] children = copy.Parts;
2106 2104
2107 lock (SceneObjectGroupsByFullPartID) 2105 lock (SceneObjectGroupsByFullPartID)
2108 { 2106 {
2109 SceneObjectGroupsByFullPartID[copy.UUID] = copy; 2107 SceneObjectGroupsByFullPartID[copy.UUID] = copy;
2110 foreach (SceneObjectPart part in children) 2108 foreach (SceneObjectPart part in children)
2111 SceneObjectGroupsByFullPartID[part.UUID] = copy; 2109 SceneObjectGroupsByFullPartID[part.UUID] = copy;
2112 } 2110 }
2113 2111
2114 lock (SceneObjectGroupsByLocalPartID) 2112 lock (SceneObjectGroupsByLocalPartID)
2115 { 2113 {
2116 SceneObjectGroupsByLocalPartID[copy.LocalId] = copy; 2114 SceneObjectGroupsByLocalPartID[copy.LocalId] = copy;
2117 foreach (SceneObjectPart part in children) 2115 foreach (SceneObjectPart part in children)
2118 SceneObjectGroupsByLocalPartID[part.LocalId] = copy; 2116 SceneObjectGroupsByLocalPartID[part.LocalId] = copy;
2119 } 2117 }
2120 // PROBABLE END OF FIXME 2118 // PROBABLE END OF FIXME
2121 2119
2122 // Since we copy from a source group that is in selected 2120 // Since we copy from a source group that is in selected
@@ -2148,11 +2146,10 @@ namespace OpenSim.Region.Framework.Scenes
2148 { 2146 {
2149 m_log.WarnFormat("[SCENE]: Attempted to duplicate nonexistant prim id {0}", GroupID); 2147 m_log.WarnFormat("[SCENE]: Attempted to duplicate nonexistant prim id {0}", GroupID);
2150 } 2148 }
2151 2149
2152 return null; 2150 return null;
2153 } 2151 }
2154 2152
2155 /// <summary>
2156 /// Calculates the distance between two Vector3s 2153 /// Calculates the distance between two Vector3s
2157 /// </summary> 2154 /// </summary>
2158 /// <param name="v1"></param> 2155 /// <param name="v1"></param>
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
index 2effa25..1038111 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
@@ -54,16 +54,28 @@ namespace OpenSim.Region.Framework.Scenes
54 /// <summary> 54 /// <summary>
55 /// Start the scripts contained in all the prims in this group. 55 /// Start the scripts contained in all the prims in this group.
56 /// </summary> 56 /// </summary>
57 public void CreateScriptInstances(int startParam, bool postOnRez, 57 /// <param name="startParam"></param>
58 string engine, int stateSource) 58 /// <param name="postOnRez"></param>
59 /// <param name="engine"></param>
60 /// <param name="stateSource"></param>
61 /// <returns>
62 /// Number of scripts that were valid for starting. This does not guarantee that all these scripts
63 /// were actually started, but just that the start could be attempt (e.g. the asset data for the script could be found)
64 /// </returns>
65 public int CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
59 { 66 {
67 int scriptsStarted = 0;
68
60 // Don't start scripts if they're turned off in the region! 69 // Don't start scripts if they're turned off in the region!
61 if (!m_scene.RegionInfo.RegionSettings.DisableScripts) 70 if (!m_scene.RegionInfo.RegionSettings.DisableScripts)
62 { 71 {
63 SceneObjectPart[] parts = m_parts.GetArray(); 72 SceneObjectPart[] parts = m_parts.GetArray();
64 for (int i = 0; i < parts.Length; i++) 73 for (int i = 0; i < parts.Length; i++)
65 parts[i].Inventory.CreateScriptInstances(startParam, postOnRez, engine, stateSource); 74 scriptsStarted
75 += parts[i].Inventory.CreateScriptInstances(startParam, postOnRez, engine, stateSource);
66 } 76 }
77
78 return scriptsStarted;
67 } 79 }
68 80
69 /// <summary> 81 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index aab6a49..11d703a 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -244,6 +244,22 @@ namespace OpenSim.Region.Framework.Scenes
244 } 244 }
245 } 245 }
246 246
247 /// <summary>
248 /// If this scene object has an attachment point then indicate whether there is a point where
249 /// attachments are perceivable by avatars other than the avatar to which this object is attached.
250 /// </summary>
251 /// <remarks>
252 /// HUDs are not perceivable by other avatars.
253 /// </remarks>
254 public bool HasPrivateAttachmentPoint
255 {
256 get
257 {
258 return AttachmentPoint >= (uint)OpenMetaverse.AttachmentPoint.HUDCenter2
259 && AttachmentPoint <= (uint)OpenMetaverse.AttachmentPoint.HUDBottomRight;
260 }
261 }
262
247 public void ClearPartAttachmentData() 263 public void ClearPartAttachmentData()
248 { 264 {
249 AttachmentPoint = 0; 265 AttachmentPoint = 0;
@@ -1808,8 +1824,9 @@ namespace OpenSim.Region.Framework.Scenes
1808 part.ClearUpdateSchedule(); 1824 part.ClearUpdateSchedule();
1809 if (part == m_rootPart) 1825 if (part == m_rootPart)
1810 { 1826 {
1811 if (!IsAttachment || (AttachedAvatar == avatar.ControllingClient.AgentId) || 1827 if (!IsAttachment
1812 (AttachmentPoint < 31) || (AttachmentPoint > 38)) 1828 || AttachedAvatar == avatar.ControllingClient.AgentId
1829 || !HasPrivateAttachmentPoint)
1813 avatar.ControllingClient.SendKillObject(m_regionHandle, new List<uint> { part.LocalId }); 1830 avatar.ControllingClient.SendKillObject(m_regionHandle, new List<uint> { part.LocalId });
1814 } 1831 }
1815 } 1832 }
@@ -2670,6 +2687,10 @@ namespace OpenSim.Region.Framework.Scenes
2670 /// <summary> 2687 /// <summary>
2671 /// Link the prims in a given group to this group 2688 /// Link the prims in a given group to this group
2672 /// </summary> 2689 /// </summary>
2690 /// <remarks>
2691 /// Do not call this method directly - use Scene.LinkObjects() instead to avoid races between threads.
2692 /// FIXME: There are places where scripts call these methods directly without locking. This is a potential race condition.
2693 /// </remarks>
2673 /// <param name="objectGroup">The group of prims which should be linked to this group</param> 2694 /// <param name="objectGroup">The group of prims which should be linked to this group</param>
2674 public void LinkToGroup(SceneObjectGroup objectGroup) 2695 public void LinkToGroup(SceneObjectGroup objectGroup)
2675 { 2696 {
@@ -2751,6 +2772,7 @@ namespace OpenSim.Region.Framework.Scenes
2751 } 2772 }
2752 2773
2753 linkPart.LinkNum = linkNum++; 2774 linkPart.LinkNum = linkNum++;
2775 linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false);
2754 2776
2755 SceneObjectPart[] ogParts = objectGroup.Parts; 2777 SceneObjectPart[] ogParts = objectGroup.Parts;
2756 Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) 2778 Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b)
@@ -2802,6 +2824,11 @@ namespace OpenSim.Region.Framework.Scenes
2802 /// Delink the given prim from this group. The delinked prim is established as 2824 /// Delink the given prim from this group. The delinked prim is established as
2803 /// an independent SceneObjectGroup. 2825 /// an independent SceneObjectGroup.
2804 /// </summary> 2826 /// </summary>
2827 /// <remarks>
2828 /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race
2829 /// condition. But currently there is no
2830 /// alternative method that does take a lonk to delink a single prim.
2831 /// </remarks>
2805 /// <param name="partID"></param> 2832 /// <param name="partID"></param>
2806 /// <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>
2807 public SceneObjectGroup DelinkFromGroup(uint partID) 2834 public SceneObjectGroup DelinkFromGroup(uint partID)
@@ -2813,6 +2840,11 @@ namespace OpenSim.Region.Framework.Scenes
2813 /// Delink the given prim from this group. The delinked prim is established as 2840 /// Delink the given prim from this group. The delinked prim is established as
2814 /// an independent SceneObjectGroup. 2841 /// an independent SceneObjectGroup.
2815 /// </summary> 2842 /// </summary>
2843 /// <remarks>
2844 /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race
2845 /// condition. But currently there is no
2846 /// alternative method that does take a lonk to delink a single prim.
2847 /// </remarks>
2816 /// <param name="partID"></param> 2848 /// <param name="partID"></param>
2817 /// <param name="sendEvents"></param> 2849 /// <param name="sendEvents"></param>
2818 /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> 2850 /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns>
@@ -2838,6 +2870,11 @@ namespace OpenSim.Region.Framework.Scenes
2838 /// Delink the given prim from this group. The delinked prim is established as 2870 /// Delink the given prim from this group. The delinked prim is established as
2839 /// an independent SceneObjectGroup. 2871 /// an independent SceneObjectGroup.
2840 /// </summary> 2872 /// </summary>
2873 /// <remarks>
2874 /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race
2875 /// condition. But currently there is no
2876 /// alternative method that does take a lonk to delink a single prim.
2877 /// </remarks>
2841 /// <param name="partID"></param> 2878 /// <param name="partID"></param>
2842 /// <param name="sendEvents"></param> 2879 /// <param name="sendEvents"></param>
2843 /// <returns>The object group of the newly delinked prim.</returns> 2880 /// <returns>The object group of the newly delinked prim.</returns>
@@ -2971,6 +3008,8 @@ namespace OpenSim.Region.Framework.Scenes
2971 oldRot = part.RotationOffset; 3008 oldRot = part.RotationOffset;
2972 Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot; 3009 Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot;
2973 part.RotationOffset = newRot; 3010 part.RotationOffset = newRot;
3011
3012 part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false);
2974 } 3013 }
2975 3014
2976 /// <summary> 3015 /// <summary>
@@ -3486,7 +3525,7 @@ namespace OpenSim.Region.Framework.Scenes
3486 3525
3487 //we need to do a terse update even if the move wasn't allowed 3526 //we need to do a terse update even if the move wasn't allowed
3488 // so that the position is reset in the client (the object snaps back) 3527 // so that the position is reset in the client (the object snaps back)
3489 ScheduleGroupForTerseUpdate(); 3528 RootPart.ScheduleTerseUpdate();
3490 } 3529 }
3491 3530
3492 /// <summary> 3531 /// <summary>
@@ -3601,6 +3640,11 @@ namespace OpenSim.Region.Framework.Scenes
3601 m_scene.PhysicsScene.AddPhysicsActorTaint(actor); 3640 m_scene.PhysicsScene.AddPhysicsActorTaint(actor);
3602 } 3641 }
3603 3642
3643 if (IsAttachment)
3644 {
3645 m_rootPart.AttachedPos = pos;
3646 }
3647
3604 AbsolutePosition = pos; 3648 AbsolutePosition = pos;
3605 3649
3606 HasGroupChanged = true; 3650 HasGroupChanged = true;
@@ -4187,7 +4231,72 @@ namespace OpenSim.Region.Framework.Scenes
4187 for (int i = 0; i < parts.Length; i++) 4231 for (int i = 0; i < parts.Length; i++)
4188 parts[i].TriggerScriptChangedEvent(val); 4232 parts[i].TriggerScriptChangedEvent(val);
4189 } 4233 }
4190 4234
4235 /// <summary>
4236 /// Returns a count of the number of scripts in this groups parts.
4237 /// </summary>
4238 public int ScriptCount()
4239 {
4240 int count = 0;
4241 SceneObjectPart[] parts = m_parts.GetArray();
4242 for (int i = 0; i < parts.Length; i++)
4243 count += parts[i].Inventory.ScriptCount();
4244
4245 return count;
4246 }
4247
4248 /// <summary>
4249 /// A float the value is a representative execution time in milliseconds of all scripts in the link set.
4250 /// </summary>
4251 public float ScriptExecutionTime()
4252 {
4253 IScriptModule[] engines = Scene.RequestModuleInterfaces<IScriptModule>();
4254
4255 if (engines.Length == 0) // No engine at all
4256 return 0.0f;
4257
4258 float time = 0.0f;
4259
4260 // get all the scripts in all parts
4261 SceneObjectPart[] parts = m_parts.GetArray();
4262 List<TaskInventoryItem> scripts = new List<TaskInventoryItem>();
4263 for (int i = 0; i < parts.Length; i++)
4264 {
4265 scripts.AddRange(parts[i].Inventory.GetInventoryItems(InventoryType.LSL));
4266 }
4267 // extract the UUIDs
4268 List<UUID> ids = new List<UUID>(scripts.Count);
4269 foreach (TaskInventoryItem script in scripts)
4270 {
4271 if (!ids.Contains(script.ItemID))
4272 {
4273 ids.Add(script.ItemID);
4274 }
4275 }
4276 // Offer the list of script UUIDs to each engine found and accumulate the time
4277 foreach (IScriptModule e in engines)
4278 {
4279 if (e != null)
4280 {
4281 time += e.GetScriptExecutionTime(ids);
4282 }
4283 }
4284 return time;
4285 }
4286
4287 /// <summary>
4288 /// Returns a count of the number of running scripts in this groups parts.
4289 /// </summary>
4290 public int RunningScriptCount()
4291 {
4292 int count = 0;
4293 SceneObjectPart[] parts = m_parts.GetArray();
4294 for (int i = 0; i < parts.Length; i++)
4295 count += parts[i].Inventory.RunningScriptCount();
4296
4297 return count;
4298 }
4299
4191 public override string ToString() 4300 public override string ToString()
4192 { 4301 {
4193 return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); 4302 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..f1e781c 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
@@ -2048,7 +2059,7 @@ namespace OpenSim.Region.Framework.Scenes
2048 else 2059 else
2049 m_log.WarnFormat( 2060 m_log.WarnFormat(
2050 "[SCENE OBJECT PART]: Part {0} {1} requested mesh/sculpt data for asset id {2} from asset service but received no data", 2061 "[SCENE OBJECT PART]: Part {0} {1} requested mesh/sculpt data for asset id {2} from asset service but received no data",
2051 Name, LocalId, id); 2062 Name, UUID, id);
2052 } 2063 }
2053 2064
2054 /// <summary> 2065 /// <summary>
@@ -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
@@ -3111,8 +3125,9 @@ namespace OpenSim.Region.Framework.Scenes
3111 if (ParentGroup.IsDeleted) 3125 if (ParentGroup.IsDeleted)
3112 return; 3126 return;
3113 3127
3114 if (ParentGroup.IsAttachment && (ParentGroup.AttachedAvatar != remoteClient.AgentId) && 3128 if (ParentGroup.IsAttachment
3115 (ParentGroup.AttachmentPoint >= 31) && (ParentGroup.AttachmentPoint <= 38)) 3129 && ParentGroup.AttachedAvatar != remoteClient.AgentId
3130 && ParentGroup.HasPrivateAttachmentPoint)
3116 return; 3131 return;
3117 3132
3118 if (remoteClient.AgentId == OwnerID) 3133 if (remoteClient.AgentId == OwnerID)
@@ -3631,7 +3646,6 @@ namespace OpenSim.Region.Framework.Scenes
3631 hasProfileCut = hasDimple; // is it the same thing? 3646 hasProfileCut = hasDimple; // is it the same thing?
3632 } 3647 }
3633 3648
3634
3635 public void SetGroup(UUID groupID, IClientAPI client) 3649 public void SetGroup(UUID groupID, IClientAPI client)
3636 { 3650 {
3637 // Scene.AddNewPrims() calls with client == null so can't use this. 3651 // Scene.AddNewPrims() calls with client == null so can't use this.
@@ -3661,10 +3675,12 @@ namespace OpenSim.Region.Framework.Scenes
3661 3675
3662 public void SetPhysicsAxisRotation() 3676 public void SetPhysicsAxisRotation()
3663 { 3677 {
3664 if (PhysActor != null) 3678 PhysicsActor pa = PhysActor;
3679
3680 if (pa != null)
3665 { 3681 {
3666 PhysActor.LockAngularMotion(RotationAxis); 3682 pa.LockAngularMotion(RotationAxis);
3667 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); 3683 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa);
3668 } 3684 }
3669 } 3685 }
3670 3686
@@ -4381,7 +4397,7 @@ namespace OpenSim.Region.Framework.Scenes
4381 // For now, we use the NINJA naming scheme for identifying joints. 4397 // 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 4398 // In the future, we can support other joint specification schemes such as a
4383 // custom checkbox in the viewer GUI. 4399 // custom checkbox in the viewer GUI.
4384 if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) 4400 if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
4385 { 4401 {
4386 string hingeString = "hingejoint"; 4402 string hingeString = "hingejoint";
4387 return (Name.Length >= hingeString.Length && Name.Substring(0, hingeString.Length) == hingeString); 4403 return (Name.Length >= hingeString.Length && Name.Substring(0, hingeString.Length) == hingeString);
@@ -4397,7 +4413,7 @@ namespace OpenSim.Region.Framework.Scenes
4397 // For now, we use the NINJA naming scheme for identifying joints. 4413 // 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 4414 // In the future, we can support other joint specification schemes such as a
4399 // custom checkbox in the viewer GUI. 4415 // custom checkbox in the viewer GUI.
4400 if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) 4416 if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
4401 { 4417 {
4402 string ballString = "balljoint"; 4418 string ballString = "balljoint";
4403 return (Name.Length >= ballString.Length && Name.Substring(0, ballString.Length) == ballString); 4419 return (Name.Length >= ballString.Length && Name.Substring(0, ballString.Length) == ballString);
@@ -4413,7 +4429,7 @@ namespace OpenSim.Region.Framework.Scenes
4413 // For now, we use the NINJA naming scheme for identifying joints. 4429 // 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 4430 // In the future, we can support other joint specification schemes such as a
4415 // custom checkbox in the viewer GUI. 4431 // custom checkbox in the viewer GUI.
4416 if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) 4432 if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
4417 { 4433 {
4418 return IsHingeJoint() || IsBallJoint(); 4434 return IsHingeJoint() || IsBallJoint();
4419 } 4435 }
@@ -4534,7 +4550,6 @@ namespace OpenSim.Region.Framework.Scenes
4534 } 4550 }
4535 */ 4551 */
4536 } 4552 }
4537
4538 else // it already has a physical representation 4553 else // it already has a physical representation
4539 { 4554 {
4540 DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. 4555 DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status.
@@ -5011,8 +5026,9 @@ namespace OpenSim.Region.Framework.Scenes
5011 if (ParentGroup.IsDeleted) 5026 if (ParentGroup.IsDeleted)
5012 return; 5027 return;
5013 5028
5014 if (ParentGroup.IsAttachment && ((ParentGroup.RootPart != this) || 5029 if (ParentGroup.IsAttachment
5015 ((ParentGroup.AttachedAvatar != remoteClient.AgentId) && (ParentGroup.AttachmentPoint >= 31) && (ParentGroup.AttachmentPoint <= 38)))) 5030 && (ParentGroup.RootPart != this
5031 || ParentGroup.AttachedAvatar != remoteClient.AgentId && ParentGroup.HasPrivateAttachmentPoint))
5016 return; 5032 return;
5017 5033
5018 // Causes this thread to dig into the Client Thread Data. 5034 // Causes this thread to dig into the Client Thread Data.
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 959046a..14ef0fb 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -176,16 +176,14 @@ namespace OpenSim.Region.Framework.Scenes
176 /// <param name="ownerId"></param> 176 /// <param name="ownerId"></param>
177 public void ChangeInventoryOwner(UUID ownerId) 177 public void ChangeInventoryOwner(UUID ownerId)
178 { 178 {
179 m_items.LockItemsForWrite(true); 179 List<TaskInventoryItem> items = GetInventoryItems();
180 if (0 == Items.Count) 180
181 { 181 if (items.Count == 0)
182 m_items.LockItemsForWrite(false);
183 return; 182 return;
184 }
185 183
184 m_items.LockItemsForWrite(true);
186 HasInventoryChanged = true; 185 HasInventoryChanged = true;
187 m_part.ParentGroup.HasGroupChanged = true; 186 m_part.ParentGroup.HasGroupChanged = true;
188 List<TaskInventoryItem> items = GetInventoryItems();
189 foreach (TaskInventoryItem item in items) 187 foreach (TaskInventoryItem item in items)
190 { 188 {
191 if (ownerId != item.OwnerID) 189 if (ownerId != item.OwnerID)
@@ -262,19 +260,16 @@ namespace OpenSim.Region.Framework.Scenes
262 Items.LockItemsForRead(false); 260 Items.LockItemsForRead(false);
263 } 261 }
264 262
265 /// <summary> 263 public int CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
266 /// Start all the scripts contained in this prim's inventory
267 /// </summary>
268 public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
269 { 264 {
270 Items.LockItemsForRead(true); 265 int scriptsValidForStarting = 0;
271 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); 266
272 Items.LockItemsForRead(false); 267 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
273 foreach (TaskInventoryItem item in items) 268 foreach (TaskInventoryItem item in scripts)
274 { 269 if (CreateScriptInstance(item, startParam, postOnRez, engine, stateSource))
275 if ((int)InventoryType.LSL == item.InvType) 270 scriptsValidForStarting++;
276 CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); 271
277 } 272 return scriptsValidForStarting;
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
@@ -323,8 +312,8 @@ namespace OpenSim.Region.Framework.Scenes
323 /// Start a script which is in this prim's inventory. 312 /// Start a script which is in this prim's inventory.
324 /// </summary> 313 /// </summary>
325 /// <param name="item"></param> 314 /// <param name="item"></param>
326 /// <returns></returns> 315 /// <returns>true if the script instance was created, false otherwise</returns>
327 public void CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez, string engine, int stateSource) 316 public bool CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez, string engine, int stateSource)
328 { 317 {
329// m_log.DebugFormat("[PRIM INVENTORY]: Starting script {0} {1} in prim {2} {3} in {4}", 318// m_log.DebugFormat("[PRIM INVENTORY]: Starting script {0} {1} in prim {2} {3} in {4}",
330// item.Name, item.ItemID, m_part.Name, m_part.UUID, m_part.ParentGroup.Scene.RegionInfo.RegionName); 319// item.Name, item.ItemID, m_part.Name, m_part.UUID, m_part.ParentGroup.Scene.RegionInfo.RegionName);
@@ -332,61 +321,70 @@ namespace OpenSim.Region.Framework.Scenes
332 if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) 321 if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID))
333 { 322 {
334 StoreScriptError(item.ItemID, "no permission"); 323 StoreScriptError(item.ItemID, "no permission");
335 return; 324 return false;
336 } 325 }
337 326
338 m_part.AddFlag(PrimFlags.Scripted); 327 m_part.AddFlag(PrimFlags.Scripted);
339 328
340 if (!m_part.ParentGroup.Scene.RegionInfo.RegionSettings.DisableScripts) 329 if (m_part.ParentGroup.Scene.RegionInfo.RegionSettings.DisableScripts)
330 return false;
331
332 if (stateSource == 2 && // Prim crossing
333 m_part.ParentGroup.Scene.m_trustBinaries)
341 { 334 {
342 if (stateSource == 2 && // Prim crossing 335 m_items.LockItemsForWrite(true);
343 m_part.ParentGroup.Scene.m_trustBinaries) 336 m_items[item.ItemID].PermsMask = 0;
344 { 337 m_items[item.ItemID].PermsGranter = UUID.Zero;
345 m_items.LockItemsForWrite(true); 338 m_items.LockItemsForWrite(false);
346 m_items[item.ItemID].PermsMask = 0; 339 m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
347 m_items[item.ItemID].PermsGranter = UUID.Zero; 340 m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource);
348 m_items.LockItemsForWrite(false); 341 StoreScriptErrors(item.ItemID, null);
349 m_part.ParentGroup.Scene.EventManager.TriggerRezScript( 342 m_part.ParentGroup.AddActiveScriptCount(1);
350 m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); 343 m_part.ScheduleFullUpdate();
351 StoreScriptErrors(item.ItemID, null); 344 return true;
352 m_part.ParentGroup.AddActiveScriptCount(1); 345 }
353 m_part.ScheduleFullUpdate();
354 return;
355 }
356 346
357 AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); 347 AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString());
358 if (null == asset) 348 if (null == asset)
359 { 349 {
360 string msg = String.Format("asset ID {0} could not be found", item.AssetID); 350 m_log.ErrorFormat(
361 StoreScriptError(item.ItemID, msg); 351 "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found",
362 m_log.ErrorFormat( 352 item.Name, item.ItemID, m_part.AbsolutePosition,
353 m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID);
354
355 return false;
356 }
357 else
358 {
359 if (m_part.ParentGroup.m_savedScriptState != null)
360 item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID);
361
362 string msg = String.Format("asset ID {0} could not be found", item.AssetID);
363 StoreScriptError(item.ItemID, msg);
364 m_log.ErrorFormat(
363 "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", 365 "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found",
364 item.Name, item.ItemID, m_part.AbsolutePosition, 366 item.Name, item.ItemID, m_part.AbsolutePosition,
365 m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID); 367 m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID);
366 }
367 else
368 {
369 if (m_part.ParentGroup.m_savedScriptState != null)
370 item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID);
371 368
372 m_items.LockItemsForWrite(true); 369 m_items.LockItemsForWrite(true);
373 370
374 m_items[item.ItemID].OldItemID = item.OldItemID; 371 m_items[item.ItemID].OldItemID = item.OldItemID;
375 m_items[item.ItemID].PermsMask = 0; 372 m_items[item.ItemID].PermsMask = 0;
376 m_items[item.ItemID].PermsGranter = UUID.Zero; 373 m_items[item.ItemID].PermsGranter = UUID.Zero;
377 374
378 m_items.LockItemsForWrite(false); 375 m_items.LockItemsForWrite(false);
379 376
380 string script = Utils.BytesToString(asset.Data); 377 string script = Utils.BytesToString(asset.Data);
381 m_part.ParentGroup.Scene.EventManager.TriggerRezScript( 378 m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
382 m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); 379 m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
383 StoreScriptErrors(item.ItemID, null); 380 StoreScriptErrors(item.ItemID, null);
384 if (!item.ScriptRunning) 381 if (!item.ScriptRunning)
385 m_part.ParentGroup.Scene.EventManager.TriggerStopScript( 382 m_part.ParentGroup.Scene.EventManager.TriggerStopScript(
386 m_part.LocalId, item.ItemID); 383 m_part.LocalId, item.ItemID);
387 m_part.ParentGroup.AddActiveScriptCount(1); 384 m_part.ParentGroup.AddActiveScriptCount(1);
388 m_part.ScheduleFullUpdate(); 385 m_part.ScheduleFullUpdate();
389 } 386
387 return true;
390 } 388 }
391 } 389 }
392 390
@@ -459,7 +457,7 @@ namespace OpenSim.Region.Framework.Scenes
459 /// <param name="itemId"> 457 /// <param name="itemId">
460 /// A <see cref="UUID"/> 458 /// A <see cref="UUID"/>
461 /// </param> 459 /// </param>
462 public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) 460 public bool CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)
463 { 461 {
464 lock (m_scriptErrors) 462 lock (m_scriptErrors)
465 { 463 {
@@ -467,6 +465,7 @@ namespace OpenSim.Region.Framework.Scenes
467 m_scriptErrors.Remove(itemId); 465 m_scriptErrors.Remove(itemId);
468 } 466 }
469 CreateScriptInstanceInternal(itemId, startParam, postOnRez, engine, stateSource); 467 CreateScriptInstanceInternal(itemId, startParam, postOnRez, engine, stateSource);
468 return true;
470 } 469 }
471 470
472 private void CreateScriptInstanceInternal(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) 471 private void CreateScriptInstanceInternal(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)
@@ -770,14 +769,22 @@ namespace OpenSim.Region.Framework.Scenes
770 return item; 769 return item;
771 } 770 }
772 771
773 /// <summary> 772 public TaskInventoryItem GetInventoryItem(string name)
774 /// Get inventory items by name. 773 {
775 /// </summary> 774 m_items.LockItemsForRead(true);
776 /// <param name="name"></param> 775 foreach (TaskInventoryItem item in m_items.Values)
777 /// <returns> 776 {
778 /// A list of inventory items with that name. 777 if (item.Name == name)
779 /// If no inventory item has that name then an empty list is returned. 778 {
780 /// </returns> 779 m_items.LockItemsForRead(false);
780 return item;
781 }
782 }
783 m_items.LockItemsForRead(false);
784
785 return null;
786 }
787
781 public List<TaskInventoryItem> GetInventoryItems(string name) 788 public List<TaskInventoryItem> GetInventoryItems(string name)
782 { 789 {
783 List<TaskInventoryItem> items = new List<TaskInventoryItem>(); 790 List<TaskInventoryItem> items = new List<TaskInventoryItem>();
@@ -1247,10 +1254,10 @@ namespace OpenSim.Region.Framework.Scenes
1247 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) 1254 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
1248 item.CurrentPermissions &= ~(uint)PermissionMask.Modify; 1255 item.CurrentPermissions &= ~(uint)PermissionMask.Modify;
1249 } 1256 }
1250 item.OwnerChanged = true;
1251 item.CurrentPermissions &= item.NextPermissions; 1257 item.CurrentPermissions &= item.NextPermissions;
1252 item.BasePermissions &= item.NextPermissions; 1258 item.BasePermissions &= item.NextPermissions;
1253 item.EveryonePermissions &= item.NextPermissions; 1259 item.EveryonePermissions &= item.NextPermissions;
1260 item.OwnerChanged = true;
1254 item.PermsMask = 0; 1261 item.PermsMask = 0;
1255 item.PermsGranter = UUID.Zero; 1262 item.PermsGranter = UUID.Zero;
1256 } 1263 }
@@ -1281,9 +1288,57 @@ namespace OpenSim.Region.Framework.Scenes
1281 return true; 1288 return true;
1282 } 1289 }
1283 } 1290 }
1291
1284 return false; 1292 return false;
1285 } 1293 }
1286 1294
1295 /// <summary>
1296 /// Returns the count of scripts in this parts inventory.
1297 /// </summary>
1298 /// <returns></returns>
1299 public int ScriptCount()
1300 {
1301 int count = 0;
1302 Items.LockItemsForRead(true);
1303 foreach (TaskInventoryItem item in m_items.Values)
1304 {
1305 if (item.InvType == (int)InventoryType.LSL)
1306 {
1307 count++;
1308 }
1309 }
1310 Items.LockItemsForRead(false);
1311 return count;
1312 }
1313 /// <summary>
1314 /// Returns the count of running scripts in this parts inventory.
1315 /// </summary>
1316 /// <returns></returns>
1317 public int RunningScriptCount()
1318 {
1319 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
1320 if (engines.Length == 0)
1321 return 0;
1322
1323 int count = 0;
1324 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
1325
1326 foreach (TaskInventoryItem item in scripts)
1327 {
1328 foreach (IScriptModule engine in engines)
1329 {
1330 if (engine != null)
1331 {
1332 if (engine.GetScriptState(item.ItemID))
1333 {
1334 count++;
1335 }
1336 }
1337 }
1338 }
1339 return count;
1340 }
1341
1287 public List<UUID> GetInventoryList() 1342 public List<UUID> GetInventoryList()
1288 { 1343 {
1289 List<UUID> ret = new List<UUID>(); 1344 List<UUID> ret = new List<UUID>();
@@ -1298,22 +1353,24 @@ namespace OpenSim.Region.Framework.Scenes
1298 { 1353 {
1299 List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); 1354 List<TaskInventoryItem> ret = new List<TaskInventoryItem>();
1300 1355
1301 lock (m_items) 1356 Items.LockItemsForRead(true);
1302 ret = new List<TaskInventoryItem>(m_items.Values); 1357 ret = new List<TaskInventoryItem>(m_items.Values);
1358 Items.LockItemsForRead(false);
1303 1359
1304 return ret; 1360 return ret;
1305 } 1361 }
1306 1362
1307 public List<TaskInventoryItem> GetInventoryScripts() 1363 public List<TaskInventoryItem> GetInventoryItems(InventoryType type)
1308 { 1364 {
1309 List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); 1365 List<TaskInventoryItem> ret = new List<TaskInventoryItem>();
1310 1366
1311 lock (m_items) 1367 Items.LockItemsForRead(true);
1312 { 1368
1313 foreach (TaskInventoryItem item in m_items.Values) 1369 foreach (TaskInventoryItem item in m_items.Values)
1314 if (item.InvType == (int)InventoryType.LSL) 1370 if (item.InvType == (int)type)
1315 ret.Add(item); 1371 ret.Add(item);
1316 } 1372
1373 Items.LockItemsForRead(false);
1317 1374
1318 return ret; 1375 return ret;
1319 } 1376 }
@@ -1335,35 +1392,32 @@ namespace OpenSim.Region.Framework.Scenes
1335 if (engines.Length == 0) // No engine at all 1392 if (engines.Length == 0) // No engine at all
1336 return ret; 1393 return ret;
1337 1394
1338 Items.LockItemsForRead(true); 1395 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
1339 foreach (TaskInventoryItem item in m_items.Values) 1396
1397 foreach (TaskInventoryItem item in scripts)
1340 { 1398 {
1341 if (item.InvType == (int)InventoryType.LSL) 1399 foreach (IScriptModule e in engines)
1342 { 1400 {
1343 foreach (IScriptModule e in engines) 1401 if (e != null)
1344 { 1402 {
1345 if (e != null) 1403 string n = e.GetXMLState(item.ItemID);
1404 if (n != String.Empty)
1346 { 1405 {
1347 string n = e.GetXMLState(item.ItemID); 1406 if (oldIDs)
1348 if (n != String.Empty)
1349 { 1407 {
1350 if (oldIDs) 1408 if (!ret.ContainsKey(item.OldItemID))
1351 { 1409 ret[item.OldItemID] = 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 } 1410 }
1411 else
1412 {
1413 if (!ret.ContainsKey(item.ItemID))
1414 ret[item.ItemID] = n;
1415 }
1416 break;
1362 } 1417 }
1363 } 1418 }
1364 } 1419 }
1365 } 1420 }
1366 Items.LockItemsForRead(false);
1367 return ret; 1421 return ret;
1368 } 1422 }
1369 1423
@@ -1373,27 +1427,27 @@ namespace OpenSim.Region.Framework.Scenes
1373 if (engines.Length == 0) 1427 if (engines.Length == 0)
1374 return; 1428 return;
1375 1429
1430 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
1376 1431
1377 Items.LockItemsForRead(true); 1432 foreach (TaskInventoryItem item in scripts)
1378
1379 foreach (TaskInventoryItem item in m_items.Values)
1380 { 1433 {
1381 if (item.InvType == (int)InventoryType.LSL) 1434 foreach (IScriptModule engine in engines)
1382 { 1435 {
1383 foreach (IScriptModule engine in engines) 1436 if (engine != null)
1384 { 1437 {
1385 if (engine != null) 1438// m_log.DebugFormat(
1386 { 1439// "[PRIM INVENTORY]: Resuming script {0} {1} for {2}, OwnerChanged {3}",
1387 if (item.OwnerChanged) 1440// item.Name, item.ItemID, item.OwnerID, item.OwnerChanged);
1388 engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER }); 1441
1389 item.OwnerChanged = false; 1442 engine.ResumeScript(item.ItemID);
1390 engine.ResumeScript(item.ItemID); 1443
1391 } 1444 if (item.OwnerChanged)
1445 engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER });
1446
1447 item.OwnerChanged = false;
1392 } 1448 }
1393 } 1449 }
1394 } 1450 }
1395
1396 Items.LockItemsForRead(false);
1397 } 1451 }
1398 } 1452 }
1399} 1453}
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 87b4d9f..159a92a 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
@@ -1086,23 +1094,13 @@ namespace OpenSim.Region.Framework.Scenes
1086 /// <param name="pos"></param> 1094 /// <param name="pos"></param>
1087 public void Teleport(Vector3 pos) 1095 public void Teleport(Vector3 pos)
1088 { 1096 {
1089 bool isFlying = Flying; 1097 TeleportWithMomentum(pos, Vector3.Zero);
1090 RemoveFromPhysicalScene();
1091 Velocity = Vector3.Zero;
1092 CheckLandingPoint(ref pos);
1093 AbsolutePosition = pos;
1094 AddToPhysicalScene(isFlying);
1095
1096 SendTerseUpdateToAllClients();
1097 }
1098
1099 public void TeleportWithMomentum(Vector3 pos)
1100 {
1101 TeleportWithMomentum(pos, null);
1102 } 1098 }
1103 1099
1104 public void TeleportWithMomentum(Vector3 pos, Vector3? v) 1100 public void TeleportWithMomentum(Vector3 pos, Vector3? v)
1105 { 1101 {
1102 if (ParentID != (uint)0)
1103 StandUp();
1106 bool isFlying = Flying; 1104 bool isFlying = Flying;
1107 Vector3 vel = Velocity; 1105 Vector3 vel = Velocity;
1108 RemoveFromPhysicalScene(); 1106 RemoveFromPhysicalScene();
@@ -1282,17 +1280,33 @@ namespace OpenSim.Region.Framework.Scenes
1282 1280
1283 bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); 1281 bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
1284 MakeRootAgent(AbsolutePosition, flying); 1282 MakeRootAgent(AbsolutePosition, flying);
1283 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
1284
1285// m_log.DebugFormat("[SCENE PRESENCE] Completed movement");
1285 1286
1286 if ((m_callbackURI != null) && !m_callbackURI.Equals("")) 1287 if ((m_callbackURI != null) && !m_callbackURI.Equals(""))
1287 { 1288 {
1288 m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); 1289 // We cannot sleep here since this would hold up the inbound packet processing thread, as
1290 // CompleteMovement() is executed synchronously. However, it might be better to delay the release
1291 // here until we know for sure that the agent is active in this region. Sending AgentMovementComplete
1292 // is not enough for Imprudence clients - there appears to be a small delay (<200ms, <500ms) until they regard this
1293 // region as the current region, meaning that a close sent before then will fail the teleport.
1294// System.Threading.Thread.Sleep(2000);
1295
1296 m_log.DebugFormat(
1297 "[SCENE PRESENCE]: Releasing {0} {1} with callback to {2}",
1298 client.Name, client.AgentId, m_callbackURI);
1299
1289 Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI); 1300 Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI);
1290 m_callbackURI = null; 1301 m_callbackURI = null;
1291 } 1302 }
1303// else
1304// {
1305// m_log.DebugFormat(
1306// "[SCENE PRESENCE]: No callback provided on CompleteMovement of {0} {1} to {2}",
1307// client.Name, client.AgentId, m_scene.RegionInfo.RegionName);
1308// }
1292 1309
1293// m_log.DebugFormat("[SCENE PRESENCE] Completed movement");
1294
1295 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
1296 ValidateAndSendAppearanceAndAgentData(); 1310 ValidateAndSendAppearanceAndAgentData();
1297 1311
1298 // Create child agents in neighbouring regions 1312 // Create child agents in neighbouring regions
@@ -1307,7 +1321,6 @@ namespace OpenSim.Region.Framework.Scenes
1307 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); 1321 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient);
1308 } 1322 }
1309 1323
1310
1311// m_log.DebugFormat( 1324// m_log.DebugFormat(
1312// "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms", 1325// "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms",
1313// client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds); 1326// client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds);
@@ -1360,7 +1373,7 @@ namespace OpenSim.Region.Framework.Scenes
1360 { 1373 {
1361// m_log.DebugFormat( 1374// m_log.DebugFormat(
1362// "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}", 1375// "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}",
1363// Scene.RegionInfo.RegionName, remoteClient.Name, agentData.ControlFlags); 1376// Scene.RegionInfo.RegionName, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags);
1364 1377
1365 if (IsChildAgent) 1378 if (IsChildAgent)
1366 { 1379 {
@@ -1470,14 +1483,8 @@ namespace OpenSim.Region.Framework.Scenes
1470 } 1483 }
1471 } 1484 }
1472 1485
1473 lock (scriptedcontrols) 1486 uint flagsForScripts = (uint)flags;
1474 { 1487 flags = RemoveIgnoredControls(flags, IgnoredControls);
1475 if (scriptedcontrols.Count > 0)
1476 {
1477 SendControlToScripts((uint)flags);
1478 flags = RemoveIgnoredControls(flags, IgnoredControls);
1479 }
1480 }
1481 1488
1482 if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) 1489 if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0)
1483 HandleAgentSitOnGround(); 1490 HandleAgentSitOnGround();
@@ -1491,6 +1498,7 @@ namespace OpenSim.Region.Framework.Scenes
1491 PhysicsActor actor = PhysicsActor; 1498 PhysicsActor actor = PhysicsActor;
1492 if (actor == null) 1499 if (actor == null)
1493 { 1500 {
1501 SendControlsToScripts(flagsForScripts);
1494 return; 1502 return;
1495 } 1503 }
1496 1504
@@ -1570,7 +1578,7 @@ namespace OpenSim.Region.Framework.Scenes
1570 MovementFlag |= (byte)nudgehack; 1578 MovementFlag |= (byte)nudgehack;
1571 } 1579 }
1572 1580
1573// m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF); 1581 //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF);
1574 MovementFlag += (byte)(uint)DCF; 1582 MovementFlag += (byte)(uint)DCF;
1575 update_movementflag = true; 1583 update_movementflag = true;
1576 } 1584 }
@@ -1583,7 +1591,7 @@ namespace OpenSim.Region.Framework.Scenes
1583 && ((MovementFlag & (byte)nudgehack) == nudgehack)) 1591 && ((MovementFlag & (byte)nudgehack) == nudgehack))
1584 ) // This or is for Nudge forward 1592 ) // This or is for Nudge forward
1585 { 1593 {
1586// m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF); 1594 //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF);
1587 MovementFlag -= ((byte)(uint)DCF); 1595 MovementFlag -= ((byte)(uint)DCF);
1588 update_movementflag = true; 1596 update_movementflag = true;
1589 1597
@@ -1664,11 +1672,14 @@ namespace OpenSim.Region.Framework.Scenes
1664// } 1672// }
1665// } 1673// }
1666 1674
1667// if (update_movementflag && ParentID == 0) 1675 if (update_movementflag && ParentID == 0)
1668// Animator.UpdateMovementAnimations(); 1676 Animator.UpdateMovementAnimations();
1677
1678 SendControlsToScripts(flagsForScripts);
1669 } 1679 }
1670 1680
1671 m_scene.EventManager.TriggerOnClientMovement(this); 1681 m_scene.EventManager.TriggerOnClientMovement(this);
1682 TriggerScenePresenceUpdated();
1672 } 1683 }
1673 1684
1674 /// <summary> 1685 /// <summary>
@@ -2042,9 +2053,9 @@ namespace OpenSim.Region.Framework.Scenes
2042 { 2053 {
2043 if (SitTargetUnOccupied) 2054 if (SitTargetUnOccupied)
2044 { 2055 {
2045 m_log.DebugFormat( 2056// m_log.DebugFormat(
2046 "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is set and unoccupied", 2057// "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is set and unoccupied",
2047 Name, part.Name, part.LocalId); 2058// Name, part.Name, part.LocalId);
2048 2059
2049 part.SitTargetAvatar = UUID; 2060 part.SitTargetAvatar = UUID;
2050 offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); 2061 offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z);
@@ -2056,9 +2067,9 @@ namespace OpenSim.Region.Framework.Scenes
2056 { 2067 {
2057 if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) 2068 if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10)
2058 { 2069 {
2059 m_log.DebugFormat( 2070// m_log.DebugFormat(
2060 "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is unset and within 10m", 2071// "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is unset and within 10m",
2061 Name, part.Name, part.LocalId); 2072// Name, part.Name, part.LocalId);
2062 2073
2063 AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); 2074 AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight);
2064 canSit = true; 2075 canSit = true;
@@ -2614,6 +2625,7 @@ namespace OpenSim.Region.Framework.Scenes
2614 2625
2615 m_scene.ForEachClient(SendTerseUpdateToClient); 2626 m_scene.ForEachClient(SendTerseUpdateToClient);
2616 } 2627 }
2628 TriggerScenePresenceUpdated();
2617 } 2629 }
2618 2630
2619 public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs) 2631 public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs)
@@ -2692,7 +2704,7 @@ namespace OpenSim.Region.Framework.Scenes
2692 // If we are using the the cached appearance then send it out to everyone 2704 // If we are using the the cached appearance then send it out to everyone
2693 if (cachedappearance) 2705 if (cachedappearance)
2694 { 2706 {
2695 m_log.DebugFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name); 2707 m_log.DebugFormat("[SCENE PRESENCE]: baked textures are in the cache for {0}", Name);
2696 2708
2697 // If the avatars baked textures are all in the cache, then we have a 2709 // If the avatars baked textures are all in the cache, then we have a
2698 // complete appearance... send it out, if not, then we'll send it when 2710 // complete appearance... send it out, if not, then we'll send it when
@@ -3097,8 +3109,8 @@ namespace OpenSim.Region.Framework.Scenes
3097 x = x / Constants.RegionSize; 3109 x = x / Constants.RegionSize;
3098 y = y / Constants.RegionSize; 3110 y = y / Constants.RegionSize;
3099 3111
3100 //m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); 3112// m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX)));
3101 //m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); 3113// m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY)));
3102 if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY)) 3114 if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY))
3103 { 3115 {
3104 byebyeRegions.Add(handle); 3116 byebyeRegions.Add(handle);
@@ -3155,7 +3167,7 @@ namespace OpenSim.Region.Framework.Scenes
3155 3167
3156 public void ChildAgentDataUpdate(AgentData cAgentData) 3168 public void ChildAgentDataUpdate(AgentData cAgentData)
3157 { 3169 {
3158 //m_log.Debug(" >>> ChildAgentDataUpdate <<< " + Scene.RegionInfo.RegionName); 3170// m_log.Debug(" >>> ChildAgentDataUpdate <<< " + Scene.RegionInfo.RegionName);
3159 if (!IsChildAgent) 3171 if (!IsChildAgent)
3160 return; 3172 return;
3161 3173
@@ -3267,31 +3279,8 @@ namespace OpenSim.Region.Framework.Scenes
3267 catch { } 3279 catch { }
3268 cAgent.DefaultAnim = Animator.Animations.DefaultAnimation; 3280 cAgent.DefaultAnim = Animator.Animations.DefaultAnimation;
3269 3281
3270 // Attachment objects 3282 if (Scene.AttachmentsModule != null)
3271 List<SceneObjectGroup> attachments = GetAttachments(); 3283 Scene.AttachmentsModule.CopyAttachments(this, cAgent);
3272 if (attachments.Count > 0)
3273 {
3274 cAgent.AttachmentObjects = new List<ISceneObject>();
3275 cAgent.AttachmentObjectStates = new List<string>();
3276// IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>();
3277 InTransitScriptStates.Clear();
3278
3279 foreach (SceneObjectGroup sog in attachments)
3280 {
3281 // We need to make a copy and pass that copy
3282 // because of transfers withn the same sim
3283 ISceneObject clone = sog.CloneForNewScene();
3284 // Attachment module assumes that GroupPosition holds the offsets...!
3285 ((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos;
3286 ((SceneObjectGroup)clone).IsAttachment = false;
3287 cAgent.AttachmentObjects.Add(clone);
3288 string state = sog.GetStateSnapshot();
3289 cAgent.AttachmentObjectStates.Add(state);
3290 InTransitScriptStates.Add(state);
3291 // Let's remove the scripts of the original object here
3292 sog.RemoveScriptInstances(true);
3293 }
3294 }
3295 } 3284 }
3296 3285
3297 private void CopyFrom(AgentData cAgent) 3286 private void CopyFrom(AgentData cAgent)
@@ -3299,6 +3288,9 @@ namespace OpenSim.Region.Framework.Scenes
3299 m_originRegionID = cAgent.RegionID; 3288 m_originRegionID = cAgent.RegionID;
3300 3289
3301 m_callbackURI = cAgent.CallbackURI; 3290 m_callbackURI = cAgent.CallbackURI;
3291// m_log.DebugFormat(
3292// "[SCENE PRESENCE]: Set callback for {0} in {1} to {2} in CopyFrom()",
3293// Name, m_scene.RegionInfo.RegionName, m_callbackURI);
3302 3294
3303 m_pos = cAgent.Position; 3295 m_pos = cAgent.Position;
3304 m_velocity = cAgent.Velocity; 3296 m_velocity = cAgent.Velocity;
@@ -3363,18 +3355,8 @@ namespace OpenSim.Region.Framework.Scenes
3363 if (cAgent.DefaultAnim != null) 3355 if (cAgent.DefaultAnim != null)
3364 Animator.Animations.SetDefaultAnimation(cAgent.DefaultAnim.AnimID, cAgent.DefaultAnim.SequenceNum, UUID.Zero); 3356 Animator.Animations.SetDefaultAnimation(cAgent.DefaultAnim.AnimID, cAgent.DefaultAnim.SequenceNum, UUID.Zero);
3365 3357
3366 if (cAgent.AttachmentObjects != null && cAgent.AttachmentObjects.Count > 0) 3358 if (Scene.AttachmentsModule != null)
3367 { 3359 Scene.AttachmentsModule.CopyAttachments(cAgent, this);
3368 m_attachments = new List<SceneObjectGroup>();
3369 int i = 0;
3370 foreach (ISceneObject so in cAgent.AttachmentObjects)
3371 {
3372 ((SceneObjectGroup)so).LocalId = 0;
3373 ((SceneObjectGroup)so).RootPart.ClearUpdateSchedule();
3374 so.SetState(cAgent.AttachmentObjectStates[i++], m_scene);
3375 m_scene.IncomingCreateObject(Vector3.Zero, so);
3376 }
3377 }
3378 } 3360 }
3379 3361
3380 public bool CopyAgent(out IAgentData agent) 3362 public bool CopyAgent(out IAgentData agent)
@@ -3400,6 +3382,7 @@ namespace OpenSim.Region.Framework.Scenes
3400 Velocity = force; 3382 Velocity = force;
3401 3383
3402 m_forceToApply = null; 3384 m_forceToApply = null;
3385 TriggerScenePresenceUpdated();
3403 } 3386 }
3404 } 3387 }
3405 3388
@@ -3507,23 +3490,53 @@ namespace OpenSim.Region.Framework.Scenes
3507 3490
3508 RaiseCollisionScriptEvents(coldata); 3491 RaiseCollisionScriptEvents(coldata);
3509 3492
3510 if (Invulnerable || GodLevel >= 200) 3493 // Gods do not take damage and Invulnerable is set depending on parcel/region flags
3494 if (Invulnerable || GodLevel > 0)
3511 return; 3495 return;
3512 3496
3497 // The following may be better in the ICombatModule
3498 // probably tweaking of the values for ground and normal prim collisions will be needed
3513 float starthealth = Health; 3499 float starthealth = Health;
3514 uint killerObj = 0; 3500 uint killerObj = 0;
3501 SceneObjectPart part = null;
3515 foreach (uint localid in coldata.Keys) 3502 foreach (uint localid in coldata.Keys)
3516 { 3503 {
3517 SceneObjectPart part = Scene.GetSceneObjectPart(localid); 3504 if (localid == 0)
3518 3505 {
3519 if (part != null && part.ParentGroup.Damage != -1.0f) 3506 part = null;
3520 Health -= part.ParentGroup.Damage; 3507 }
3508 else
3509 {
3510 part = Scene.GetSceneObjectPart(localid);
3511 }
3512 if (part != null)
3513 {
3514 // Ignore if it has been deleted or volume detect
3515 if (!part.ParentGroup.IsDeleted && !part.ParentGroup.IsVolumeDetect)
3516 {
3517 if (part.ParentGroup.Damage > 0.0f)
3518 {
3519 // Something with damage...
3520 Health -= part.ParentGroup.Damage;
3521 part.ParentGroup.Scene.DeleteSceneObject(part.ParentGroup, false);
3522 }
3523 else
3524 {
3525 // An ordinary prim
3526 if (coldata[localid].PenetrationDepth >= 0.10f)
3527 Health -= coldata[localid].PenetrationDepth * 5.0f;
3528 }
3529 }
3530 }
3521 else 3531 else
3522 { 3532 {
3523 if (coldata[localid].PenetrationDepth >= 0.10f) 3533 // 0 is the ground
3534 // what about collisions with other avatars?
3535 if (localid == 0 && coldata[localid].PenetrationDepth >= 0.10f)
3524 Health -= coldata[localid].PenetrationDepth * 5.0f; 3536 Health -= coldata[localid].PenetrationDepth * 5.0f;
3525 } 3537 }
3526 3538
3539
3527 if (Health <= 0.0f) 3540 if (Health <= 0.0f)
3528 { 3541 {
3529 if (localid != 0) 3542 if (localid != 0)
@@ -3539,7 +3552,16 @@ namespace OpenSim.Region.Framework.Scenes
3539 ControllingClient.SendHealth(Health); 3552 ControllingClient.SendHealth(Health);
3540 } 3553 }
3541 if (Health <= 0) 3554 if (Health <= 0)
3555 {
3542 m_scene.EventManager.TriggerAvatarKill(killerObj, this); 3556 m_scene.EventManager.TriggerAvatarKill(killerObj, this);
3557 }
3558 if (starthealth == Health && Health < 100.0f)
3559 {
3560 Health += 0.03f;
3561 if (Health > 100.0f)
3562 Health = 100.0f;
3563 ControllingClient.SendHealth(Health);
3564 }
3543 } 3565 }
3544 } 3566 }
3545 3567
@@ -3551,9 +3573,6 @@ namespace OpenSim.Region.Framework.Scenes
3551 3573
3552 public void Close() 3574 public void Close()
3553 { 3575 {
3554 if (!IsChildAgent)
3555 m_scene.AttachmentsModule.DeleteAttachmentsFromScene(this, false);
3556
3557 // Clear known regions 3576 // Clear known regions
3558 KnownRegions = new Dictionary<ulong, string>(); 3577 KnownRegions = new Dictionary<ulong, string>();
3559 3578
@@ -3621,6 +3640,63 @@ namespace OpenSim.Region.Framework.Scenes
3621 return m_attachments.Count > 0; 3640 return m_attachments.Count > 0;
3622 } 3641 }
3623 3642
3643 /// <summary>
3644 /// Returns the total count of scripts in all parts inventories.
3645 /// </summary>
3646 public int ScriptCount()
3647 {
3648 int count = 0;
3649 lock (m_attachments)
3650 {
3651 foreach (SceneObjectGroup gobj in m_attachments)
3652 {
3653 if (gobj != null)
3654 {
3655 count += gobj.ScriptCount();
3656 }
3657 }
3658 }
3659 return count;
3660 }
3661
3662 /// <summary>
3663 /// A float the value is a representative execution time in milliseconds of all scripts in all attachments.
3664 /// </summary>
3665 public float ScriptExecutionTime()
3666 {
3667 float time = 0.0f;
3668 lock (m_attachments)
3669 {
3670 foreach (SceneObjectGroup gobj in m_attachments)
3671 {
3672 if (gobj != null)
3673 {
3674 time += gobj.ScriptExecutionTime();
3675 }
3676 }
3677 }
3678 return time;
3679 }
3680
3681 /// <summary>
3682 /// Returns the total count of running scripts in all parts.
3683 /// </summary>
3684 public int RunningScriptCount()
3685 {
3686 int count = 0;
3687 lock (m_attachments)
3688 {
3689 foreach (SceneObjectGroup gobj in m_attachments)
3690 {
3691 if (gobj != null)
3692 {
3693 count += gobj.RunningScriptCount();
3694 }
3695 }
3696 }
3697 return count;
3698 }
3699
3624 public bool HasScriptedAttachments() 3700 public bool HasScriptedAttachments()
3625 { 3701 {
3626 lock (m_attachments) 3702 lock (m_attachments)
@@ -3838,77 +3914,92 @@ namespace OpenSim.Region.Framework.Scenes
3838 } 3914 }
3839 } 3915 }
3840 3916
3841 internal void SendControlToScripts(uint flags) 3917 private void SendControlsToScripts(uint flags)
3842 { 3918 {
3843 ScriptControlled allflags = ScriptControlled.CONTROL_ZERO; 3919 // Notify the scripts only after calling UpdateMovementAnimations(), so that if a script
3844 3920 // (e.g., a walking script) checks which animation is active it will be the correct animation.
3845 if (MouseDown) 3921 lock (scriptedcontrols)
3846 { 3922 {
3847 allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON); 3923 if (scriptedcontrols.Count <= 0)
3848 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0) 3924 return;
3925
3926 ScriptControlled allflags = ScriptControlled.CONTROL_ZERO;
3927
3928 if (MouseDown)
3929 {
3930 allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON);
3931 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0)
3932 {
3933 allflags = ScriptControlled.CONTROL_ZERO;
3934 MouseDown = true;
3935 }
3936 }
3937
3938 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0)
3849 { 3939 {
3850 allflags = ScriptControlled.CONTROL_ZERO; 3940 allflags |= ScriptControlled.CONTROL_ML_LBUTTON;
3851 MouseDown = true; 3941 MouseDown = true;
3852 } 3942 }
3853 } 3943
3944 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0)
3945 {
3946 allflags |= ScriptControlled.CONTROL_LBUTTON;
3947 MouseDown = true;
3948 }
3949
3950 // find all activated controls, whether the scripts are interested in them or not
3951 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0)
3952 {
3953 allflags |= ScriptControlled.CONTROL_FWD;
3954 }
3955
3956 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0)
3957 {
3958 allflags |= ScriptControlled.CONTROL_BACK;
3959 }
3960
3961 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0)
3962 {
3963 allflags |= ScriptControlled.CONTROL_UP;
3964 }
3965
3966 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)
3967 {
3968 allflags |= ScriptControlled.CONTROL_DOWN;
3969 }
3854 3970
3855 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0) 3971 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0)
3856 { 3972 {
3857 allflags |= ScriptControlled.CONTROL_ML_LBUTTON; 3973 allflags |= ScriptControlled.CONTROL_LEFT;
3858 MouseDown = true; 3974 }
3859 } 3975
3860 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0) 3976 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0)
3861 { 3977 {
3862 allflags |= ScriptControlled.CONTROL_LBUTTON; 3978 allflags |= ScriptControlled.CONTROL_RIGHT;
3863 MouseDown = true; 3979 }
3864 } 3980
3981 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
3982 {
3983 allflags |= ScriptControlled.CONTROL_ROT_RIGHT;
3984 }
3985
3986 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)
3987 {
3988 allflags |= ScriptControlled.CONTROL_ROT_LEFT;
3989 }
3865 3990
3866 // find all activated controls, whether the scripts are interested in them or not 3991 // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that
3867 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0) 3992 if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands)
3868 {
3869 allflags |= ScriptControlled.CONTROL_FWD;
3870 }
3871 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0)
3872 {
3873 allflags |= ScriptControlled.CONTROL_BACK;
3874 }
3875 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0)
3876 {
3877 allflags |= ScriptControlled.CONTROL_UP;
3878 }
3879 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)
3880 {
3881 allflags |= ScriptControlled.CONTROL_DOWN;
3882 }
3883 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0)
3884 {
3885 allflags |= ScriptControlled.CONTROL_LEFT;
3886 }
3887 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0)
3888 {
3889 allflags |= ScriptControlled.CONTROL_RIGHT;
3890 }
3891 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
3892 {
3893 allflags |= ScriptControlled.CONTROL_ROT_RIGHT;
3894 }
3895 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)
3896 {
3897 allflags |= ScriptControlled.CONTROL_ROT_LEFT;
3898 }
3899 // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that
3900 if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands)
3901 {
3902 lock (scriptedcontrols)
3903 { 3993 {
3904 foreach (KeyValuePair<UUID, ScriptControllers> kvp in scriptedcontrols) 3994 foreach (KeyValuePair<UUID, ScriptControllers> kvp in scriptedcontrols)
3905 { 3995 {
3906 UUID scriptUUID = kvp.Key; 3996 UUID scriptUUID = kvp.Key;
3907 ScriptControllers scriptControlData = kvp.Value; 3997 ScriptControllers scriptControlData = kvp.Value;
3908 3998
3909 ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us 3999 ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us
3910 ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle 4000 ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle
3911 ScriptControlled localChange = localHeld ^ localLast; // the changed bits 4001 ScriptControlled localChange = localHeld ^ localLast; // the changed bits
4002
3912 if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO) 4003 if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO)
3913 { 4004 {
3914 // only send if still pressed or just changed 4005 // only send if still pressed or just changed
@@ -3916,9 +4007,9 @@ namespace OpenSim.Region.Framework.Scenes
3916 } 4007 }
3917 } 4008 }
3918 } 4009 }
4010
4011 LastCommands = allflags;
3919 } 4012 }
3920
3921 LastCommands = allflags;
3922 } 4013 }
3923 4014
3924 internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored) 4015 internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored)
@@ -3998,7 +4089,7 @@ namespace OpenSim.Region.Framework.Scenes
3998 land.LandData.UserLocation != Vector3.Zero && 4089 land.LandData.UserLocation != Vector3.Zero &&
3999 land.LandData.OwnerID != m_uuid && 4090 land.LandData.OwnerID != m_uuid &&
4000 (!m_scene.Permissions.IsGod(m_uuid)) && 4091 (!m_scene.Permissions.IsGod(m_uuid)) &&
4001 (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) 4092 (!m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)))
4002 { 4093 {
4003 float curr = Vector3.Distance(AbsolutePosition, pos); 4094 float curr = Vector3.Distance(AbsolutePosition, pos);
4004 if (Vector3.Distance(land.LandData.UserLocation, pos) < curr) 4095 if (Vector3.Distance(land.LandData.UserLocation, pos) < curr)
@@ -4012,13 +4103,13 @@ namespace OpenSim.Region.Framework.Scenes
4012 { 4103 {
4013 if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) == 4104 if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) ==
4014 (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) || 4105 (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) ||
4015 (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 || 4106 (m_scene.TelehubAllowLandmarks == true ? false : ((m_teleportFlags & TeleportFlags.ViaLandmark) != 0 )) ||
4016 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || 4107 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
4017 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0) 4108 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)
4018 { 4109 {
4019 if (GodLevel < 200 && 4110 if (GodLevel < 200 &&
4020 ((!m_scene.Permissions.IsGod(m_uuid) && 4111 ((!m_scene.Permissions.IsGod(m_uuid) &&
4021 !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) || 4112 !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) ||
4022 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || 4113 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
4023 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) 4114 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0))
4024 { 4115 {
@@ -4026,28 +4117,92 @@ namespace OpenSim.Region.Framework.Scenes
4026 if (spawnPoints.Length == 0) 4117 if (spawnPoints.Length == 0)
4027 return; 4118 return;
4028 4119
4029 float distance = 9999; 4120 int index;
4030 int closest = -1; 4121 bool selected = false;
4031 4122
4032 for (int i = 0 ; i < spawnPoints.Length ; i++) 4123 switch (m_scene.SpawnPointRouting)
4033 { 4124 {
4034 Vector3 spawnPosition = spawnPoints[i].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); 4125 case "random":
4035 Vector3 offset = spawnPosition - pos;
4036 float d = Vector3.Mag(offset);
4037 if (d >= distance)
4038 continue;
4039 ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y);
4040 if (land == null)
4041 continue;
4042 if (land.IsEitherBannedOrRestricted(UUID))
4043 continue;
4044 distance = d;
4045 closest = i;
4046 }
4047 if (closest == -1)
4048 return;
4049 4126
4050 pos = spawnPoints[closest].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); 4127 do
4128 {
4129 index = Util.RandomClass.Next(spawnPoints.Length - 1);
4130
4131 Vector3 spawnPosition = spawnPoints[index].GetLocation(
4132 telehub.AbsolutePosition,
4133 telehub.GroupRotation
4134 );
4135 // SpawnPoint sp = spawnPoints[index];
4136
4137 ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y);
4138 if (land == null || land.IsEitherBannedOrRestricted(UUID))
4139 selected = false;
4140 else
4141 selected = true;
4142
4143 } while ( selected == false);
4144
4145 pos = spawnPoints[index].GetLocation(
4146 telehub.AbsolutePosition,
4147 telehub.GroupRotation
4148 );
4149 return;
4150
4151 case "sequence":
4152
4153 do
4154 {
4155 index = m_scene.SpawnPoint();
4156
4157 Vector3 spawnPosition = spawnPoints[index].GetLocation(
4158 telehub.AbsolutePosition,
4159 telehub.GroupRotation
4160 );
4161 // SpawnPoint sp = spawnPoints[index];
4162
4163 ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y);
4164 if (land == null || land.IsEitherBannedOrRestricted(UUID))
4165 selected = false;
4166 else
4167 selected = true;
4168
4169 } while (selected == false);
4170
4171 pos = spawnPoints[index].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation);
4172 ;
4173 return;
4174
4175 default:
4176 case "closest":
4177
4178 float distance = 9999;
4179 int closest = -1;
4180
4181 for (int i = 0; i < spawnPoints.Length; i++)
4182 {
4183 Vector3 spawnPosition = spawnPoints[i].GetLocation(
4184 telehub.AbsolutePosition,
4185 telehub.GroupRotation
4186 );
4187 Vector3 offset = spawnPosition - pos;
4188 float d = Vector3.Mag(offset);
4189 if (d >= distance)
4190 continue;
4191 ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y);
4192 if (land == null)
4193 continue;
4194 if (land.IsEitherBannedOrRestricted(UUID))
4195 continue;
4196 distance = d;
4197 closest = i;
4198 }
4199 if (closest == -1)
4200 return;
4201
4202 pos = spawnPoints[closest].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation);
4203 return;
4204
4205 }
4051 } 4206 }
4052 } 4207 }
4053 } 4208 }
@@ -4092,7 +4247,7 @@ namespace OpenSim.Region.Framework.Scenes
4092 GodLevel < 200 && 4247 GodLevel < 200 &&
4093 ((land.LandData.OwnerID != m_uuid && 4248 ((land.LandData.OwnerID != m_uuid &&
4094 !m_scene.Permissions.IsGod(m_uuid) && 4249 !m_scene.Permissions.IsGod(m_uuid) &&
4095 !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) || 4250 !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) ||
4096 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || 4251 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
4097 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) 4252 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0))
4098 { 4253 {
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..81add43 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,10 +185,15 @@ 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
191 Assert.That(part.ParentGroup.IsDeleted, Is.False);
192
190 scene.DeleteSceneObject(part.ParentGroup, false); 193 scene.DeleteSceneObject(part.ParentGroup, false);
191 194
195 Assert.That(part.ParentGroup.IsDeleted, Is.True);
196
192 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); 197 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
193 Assert.That(retrievedPart, Is.Null); 198 Assert.That(retrievedPart, Is.Null);
194 } 199 }
@@ -204,7 +209,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
204 209
205 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); 210 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001");
206 211
207 TestScene scene = SceneHelpers.SetupScene(); 212 TestScene scene = new SceneHelpers().SetupScene();
208 213
209 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. 214 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
210 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; 215 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
@@ -219,8 +224,12 @@ namespace OpenSim.Region.Framework.Scenes.Tests
219 224
220 Assert.That(retrievedPart, Is.Not.Null); 225 Assert.That(retrievedPart, Is.Not.Null);
221 226
227 Assert.That(part.ParentGroup.IsDeleted, Is.False);
228
222 sogd.InventoryDeQueueAndDelete(); 229 sogd.InventoryDeQueueAndDelete();
223 230
231 Assert.That(part.ParentGroup.IsDeleted, Is.True);
232
224 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId); 233 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId);
225 Assert.That(retrievedPart2, Is.Null); 234 Assert.That(retrievedPart2, Is.Null);
226 } 235 }
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..02c45ef 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());
@@ -99,9 +101,9 @@ namespace OpenSim.Region.Framework.Scenes.Tests
99 public void TestCloseAgent() 101 public void TestCloseAgent()
100 { 102 {
101 TestHelpers.InMethod(); 103 TestHelpers.InMethod();
102// log4net.Config.XmlConfigurator.Configure(); 104// TestHelpers.EnableLogging();
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);
@@ -112,6 +114,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
112 Assert.That(scene.GetScenePresence(sp.UUID), Is.Null); 114 Assert.That(scene.GetScenePresence(sp.UUID), Is.Null);
113 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Null); 115 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Null);
114 Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(0)); 116 Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(0));
117
118// TestHelpers.DisableLogging();
115 } 119 }
116 120
117 [Test] 121 [Test]
@@ -126,7 +130,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
126 IConfig config = configSource.AddConfig("Modules"); 130 IConfig config = configSource.AddConfig("Modules");
127 config.Set("SimulationServices", "LocalSimulationConnectorModule"); 131 config.Set("SimulationServices", "LocalSimulationConnectorModule");
128 132
129 TestScene scene = SceneHelpers.SetupScene(); 133 SceneHelpers sceneHelpers = new SceneHelpers();
134 TestScene scene = sceneHelpers.SetupScene();
130 SceneHelpers.SetupSceneModules(scene, configSource, lsc); 135 SceneHelpers.SetupSceneModules(scene, configSource, lsc);
131 136
132 UUID agentId = TestHelpers.ParseTail(0x01); 137 UUID agentId = TestHelpers.ParseTail(0x01);
@@ -176,8 +181,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
176 181
177// UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001"); 182// UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001");
178 183
179 TestScene myScene1 = SceneHelpers.SetupScene("Neighbour y", UUID.Random(), 1000, 1000); 184 TestScene myScene1 = new SceneHelpers().SetupScene("Neighbour y", UUID.Random(), 1000, 1000);
180 TestScene myScene2 = SceneHelpers.SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000); 185 TestScene myScene2 = new SceneHelpers().SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000);
181 186
182 IConfigSource configSource = new IniConfigSource(); 187 IConfigSource configSource = new IniConfigSource();
183 IConfig config = configSource.AddConfig("Startup"); 188 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..a407f01 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,367 @@ 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);
88
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);
63 97
64 Thread testThread = new Thread(testClass.run); 98 Assert.That(sp.AbsolutePosition, Is.EqualTo(teleportPosition));
65 99
66 // Seems kind of redundant to start a thread and then join it, however.. We need to protect against 100 Assert.That(scene.GetRootAgentCount(), Is.EqualTo(1));
67 // A thread abort exception in the simulator code. 101 Assert.That(scene.GetChildAgentCount(), Is.EqualTo(0));
68 testThread.Start();
69 testThread.Join();
70 102
71 Assert.That(testClass.results.Result, Is.EqualTo(true), testClass.results.Message); 103 // 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()); 104 // position instead).
105// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
73 } 106 }
74 107
75 [TearDown] 108 [Test]
76 public void TearDown() 109 public void TestSameSimulatorSeparatedRegionsTeleport()
77 { 110 {
78 try 111 TestHelpers.InMethod();
79 { 112// log4net.Config.XmlConfigurator.Configure();
80 if (MainServer.Instance != null) MainServer.Instance.Stop(); 113
81 } 114 UUID userId = TestHelpers.ParseTail(0x1);
82 catch (NullReferenceException) 115
83 { } 116 EntityTransferModule etmA = new EntityTransferModule();
117 EntityTransferModule etmB = new EntityTransferModule();
118 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
119
120 IConfigSource config = new IniConfigSource();
121 IConfig modulesConfig = config.AddConfig("Modules");
122 modulesConfig.Set("EntityTransferModule", etmA.Name);
123 modulesConfig.Set("SimulationServices", lscm.Name);
124 IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
125
126 // In order to run a single threaded regression test we do not want the entity transfer module waiting
127 // for a callback from the destination scene before removing its avatar data.
128 entityTransferConfig.Set("wait_for_callback", false);
129
130 SceneHelpers sh = new SceneHelpers();
131 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
132 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000);
133
134 SceneHelpers.SetupSceneModules(sceneA, config, etmA);
135 SceneHelpers.SetupSceneModules(sceneB, config, etmB);
136 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
137
138 Vector3 teleportPosition = new Vector3(10, 11, 12);
139 Vector3 teleportLookAt = new Vector3(20, 21, 22);
140
141 ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager);
142 sp.AbsolutePosition = new Vector3(30, 31, 32);
143
144 // XXX: A very nasty hack to tell the client about the destination scene without having to crank the whole
145 // UDP stack (?)
146// ((TestClient)sp.ControllingClient).TeleportTargetScene = sceneB;
147
148 sceneA.RequestTeleportLocation(
149 sp.ControllingClient,
150 sceneB.RegionInfo.RegionHandle,
151 teleportPosition,
152 teleportLookAt,
153 (uint)TeleportFlags.ViaLocation);
154
155 ((TestClient)sp.ControllingClient).CompleteTeleportClientSide();
156
157 Assert.That(sceneA.GetScenePresence(userId), Is.Null);
158
159 ScenePresence sceneBSp = sceneB.GetScenePresence(userId);
160 Assert.That(sceneBSp, Is.Not.Null);
161 Assert.That(sceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
162 Assert.That(sceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));
163
164 Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0));
165 Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0));
166 Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1));
167 Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));
168
169 // TODO: Add assertions to check correct circuit details in both scenes.
170
171 // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
172 // position instead).
173// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
84 } 174 }
85 175
86 } 176 /// <summary>
177 /// Test teleport procedures when the target simulator returns false when queried about access.
178 /// </summary>
179 [Test]
180 public void TestSameSimulatorSeparatedRegionsQueryAccessFails()
181 {
182 TestHelpers.InMethod();
183// TestHelpers.EnableLogging();
87 184
88 public class ThreadRunResults 185 UUID userId = TestHelpers.ParseTail(0x1);
89 { 186 Vector3 preTeleportPosition = new Vector3(30, 31, 32);
90 public bool Result = false;
91 public string Message = string.Empty;
92 }
93 187
94 public class TestRunning 188 EntityTransferModule etmA = new EntityTransferModule();
95 { 189 EntityTransferModule etmB = new EntityTransferModule();
96 public ThreadRunResults results; 190
97 public TestRunning(ThreadRunResults t) 191 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
192
193 IConfigSource config = new IniConfigSource();
194 config.AddConfig("Modules");
195 config.Configs["Modules"].Set("EntityTransferModule", etmA.Name);
196 config.Configs["Modules"].Set("SimulationServices", lscm.Name);
197
198 config.AddConfig("EntityTransfer");
199
200 // In order to run a single threaded regression test we do not want the entity transfer module waiting
201 // for a callback from the destination scene before removing its avatar data.
202 config.Configs["EntityTransfer"].Set("wait_for_callback", false);
203
204 config.AddConfig("Startup");
205 config.Configs["Startup"].Set("serverside_object_permissions", true);
206
207 SceneHelpers sh = new SceneHelpers();
208 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
209 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000);
210
211 SceneHelpers.SetupSceneModules(sceneA, config, etmA );
212
213 // We need to set up the permisions module on scene B so that our later use of agent limit to deny
214 // QueryAccess won't succeed anyway because administrators are always allowed in and the default
215 // IsAdministrator if no permissions module is present is true.
216 SceneHelpers.SetupSceneModules(sceneB, config, new object[] { new PermissionsModule(), etmB });
217
218 // Shared scene modules
219 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
220
221 Vector3 teleportPosition = new Vector3(10, 11, 12);
222 Vector3 teleportLookAt = new Vector3(20, 21, 22);
223
224 ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager);
225 sp.AbsolutePosition = preTeleportPosition;
226
227 // Make sceneB return false on query access
228 sceneB.RegionInfo.RegionSettings.AgentLimit = 0;
229
230 sceneA.RequestTeleportLocation(
231 sp.ControllingClient,
232 sceneB.RegionInfo.RegionHandle,
233 teleportPosition,
234 teleportLookAt,
235 (uint)TeleportFlags.ViaLocation);
236
237// ((TestClient)sp.ControllingClient).CompleteTeleportClientSide();
238
239 Assert.That(sceneB.GetScenePresence(userId), Is.Null);
240
241 ScenePresence sceneASp = sceneA.GetScenePresence(userId);
242 Assert.That(sceneASp, Is.Not.Null);
243 Assert.That(sceneASp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneA.RegionInfo.RegionName));
244 Assert.That(sceneASp.AbsolutePosition, Is.EqualTo(preTeleportPosition));
245
246 Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(1));
247 Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0));
248 Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(0));
249 Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));
250
251 // TODO: Add assertions to check correct circuit details in both scenes.
252
253 // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
254 // position instead).
255// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
256
257// TestHelpers.DisableLogging();
258 }
259
260 /// <summary>
261 /// Test teleport procedures when the target simulator create agent step is refused.
262 /// </summary>
263 [Test]
264 public void TestSameSimulatorSeparatedRegionsCreateAgentFails()
98 { 265 {
99 results = t; 266 TestHelpers.InMethod();
267// TestHelpers.EnableLogging();
268
269 UUID userId = TestHelpers.ParseTail(0x1);
270 Vector3 preTeleportPosition = new Vector3(30, 31, 32);
271
272 EntityTransferModule etmA = new EntityTransferModule();
273 EntityTransferModule etmB = new EntityTransferModule();
274 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
275
276 IConfigSource config = new IniConfigSource();
277 config.AddConfig("Modules");
278 config.Configs["Modules"].Set("EntityTransferModule", etmA.Name);
279 config.Configs["Modules"].Set("SimulationServices", lscm.Name);
280
281 config.AddConfig("EntityTransfer");
282
283 // In order to run a single threaded regression test we do not want the entity transfer module waiting
284 // for a callback from the destination scene before removing its avatar data.
285 config.Configs["EntityTransfer"].Set("wait_for_callback", false);
286
287 SceneHelpers sh = new SceneHelpers();
288 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
289 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000);
290
291 SceneHelpers.SetupSceneModules(sceneA, config, etmA);
292 SceneHelpers.SetupSceneModules(sceneB, config, etmB);
293
294 // Shared scene modules
295 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
296
297 Vector3 teleportPosition = new Vector3(10, 11, 12);
298 Vector3 teleportLookAt = new Vector3(20, 21, 22);
299
300 ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager);
301 sp.AbsolutePosition = preTeleportPosition;
302
303 // Make sceneB refuse CreateAgent
304 sceneB.LoginsDisabled = true;
305
306 sceneA.RequestTeleportLocation(
307 sp.ControllingClient,
308 sceneB.RegionInfo.RegionHandle,
309 teleportPosition,
310 teleportLookAt,
311 (uint)TeleportFlags.ViaLocation);
312
313// ((TestClient)sp.ControllingClient).CompleteTeleportClientSide();
314
315 Assert.That(sceneB.GetScenePresence(userId), Is.Null);
316
317 ScenePresence sceneASp = sceneA.GetScenePresence(userId);
318 Assert.That(sceneASp, Is.Not.Null);
319 Assert.That(sceneASp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneA.RegionInfo.RegionName));
320 Assert.That(sceneASp.AbsolutePosition, Is.EqualTo(preTeleportPosition));
321
322 Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(1));
323 Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0));
324 Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(0));
325 Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));
326
327 // TODO: Add assertions to check correct circuit details in both scenes.
328
329 // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
330 // position instead).
331// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
332
333// TestHelpers.DisableLogging();
100 } 334 }
101 public void run(object o) 335
336 [Test]
337 public void TestSameSimulatorNeighbouringRegionsTeleport()
102 { 338 {
103 339 TestHelpers.InMethod();
104 //results.Result = true; 340// TestHelpers.EnableLogging();
105 log4net.Config.XmlConfigurator.Configure(); 341
106 342 UUID userId = TestHelpers.ParseTail(0x1);
107 UUID sceneAId = UUID.Parse("00000000-0000-0000-0000-000000000100"); 343
108 UUID sceneBId = UUID.Parse("00000000-0000-0000-0000-000000000200"); 344 EntityTransferModule etmA = new EntityTransferModule();
109 345 EntityTransferModule etmB = new EntityTransferModule();
110 // shared module 346 LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
111 ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); 347
112 348 IConfigSource config = new IniConfigSource();
113 349 IConfig modulesConfig = config.AddConfig("Modules");
114 Scene sceneB = SceneHelpers.SetupScene("sceneB", sceneBId, 1010, 1010); 350 modulesConfig.Set("EntityTransferModule", etmA.Name);
115 SceneHelpers.SetupSceneModules(sceneB, new IniConfigSource(), interregionComms); 351 modulesConfig.Set("SimulationServices", lscm.Name);
116 sceneB.RegisterRegionWithGrid(); 352 IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
117 353
118 Scene sceneA = SceneHelpers.SetupScene("sceneA", sceneAId, 1000, 1000); 354 // 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); 355 // for a callback from the destination scene before removing its avatar data.
120 sceneA.RegisterRegionWithGrid(); 356 entityTransferConfig.Set("wait_for_callback", false);
121 357
122 UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000041"); 358 SceneHelpers sh = new SceneHelpers();
123 TestClient client = (TestClient)SceneHelpers.AddScenePresence(sceneA, agentId).ControllingClient; 359 TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
124 360 TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000);
125 ICapabilitiesModule sceneACapsModule = sceneA.RequestModuleInterface<ICapabilitiesModule>(); 361
126 362 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
127 results.Result = (sceneACapsModule.GetCapsPath(agentId) == client.CapsSeedUrl); 363 SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
128 364 SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);
129 if (!results.Result) 365
130 { 366 Vector3 teleportPosition = new Vector3(10, 11, 12);
131 results.Message = "Incorrect caps object path set up in sceneA"; 367 Vector3 teleportLookAt = new Vector3(20, 21, 22);
132 return; 368
133 } 369 ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager);
134 370 originalSp.AbsolutePosition = new Vector3(30, 31, 32);
135 /* 371
136 Assert.That( 372 ScenePresence beforeSceneASp = sceneA.GetScenePresence(userId);
137 sceneACapsModule.GetCapsPath(agentId), 373 Assert.That(beforeSceneASp, Is.Not.Null);
138 Is.EqualTo(client.CapsSeedUrl), 374 Assert.That(beforeSceneASp.IsChildAgent, Is.False);
139 "Incorrect caps object path set up in sceneA"); 375
140 */ 376 ScenePresence beforeSceneBSp = sceneB.GetScenePresence(userId);
141 // FIXME: This is a hack to get the test working - really the normal OpenSim mechanisms should be used. 377 Assert.That(beforeSceneBSp, Is.Not.Null);
142 378 Assert.That(beforeSceneBSp.IsChildAgent, Is.True);
143 379
144 client.TeleportTargetScene = sceneB; 380 // 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)); 381 // UDP stack (?)
146 382// ((TestClient)beforeSceneASp.ControllingClient).TeleportTargetScene = sceneB;
147 results.Result = (sceneB.GetScenePresence(agentId) != null); 383
148 if (!results.Result) 384 sceneA.RequestTeleportLocation(
149 { 385 beforeSceneASp.ControllingClient,
150 results.Message = "Client does not have an agent in sceneB"; 386 sceneB.RegionInfo.RegionHandle,
151 return; 387 teleportPosition,
152 } 388 teleportLookAt,
153 389 (uint)TeleportFlags.ViaLocation);
154 //Assert.That(sceneB.GetScenePresence(agentId), Is.Not.Null, "Client does not have an agent in sceneB"); 390
155 391 ((TestClient)beforeSceneASp.ControllingClient).CompleteTeleportClientSide();
156 //Assert.That(sceneA.GetScenePresence(agentId), Is.Null, "Client still had an agent in sceneA"); 392
157 393 ScenePresence afterSceneASp = sceneA.GetScenePresence(userId);
158 results.Result = (sceneA.GetScenePresence(agentId) == null); 394 Assert.That(afterSceneASp, Is.Not.Null);
159 if (!results.Result) 395 Assert.That(afterSceneASp.IsChildAgent, Is.True);
160 { 396
161 results.Message = "Client still had an agent in sceneA"; 397 ScenePresence afterSceneBSp = sceneB.GetScenePresence(userId);
162 return; 398 Assert.That(afterSceneBSp, Is.Not.Null);
163 } 399 Assert.That(afterSceneBSp.IsChildAgent, Is.False);
164 400 Assert.That(afterSceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
165 ICapabilitiesModule sceneBCapsModule = sceneB.RequestModuleInterface<ICapabilitiesModule>(); 401 Assert.That(afterSceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));
166 402
167 403 Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0));
168 results.Result = ("http://" + sceneB.RegionInfo.ExternalHostName + ":" + sceneB.RegionInfo.HttpPort + 404 Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(1));
169 "/CAPS/" + sceneBCapsModule.GetCapsPath(agentId) + "0000/" == client.CapsSeedUrl); 405 Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1));
170 if (!results.Result) 406 Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));
171 { 407
172 results.Message = "Incorrect caps object path set up in sceneB"; 408 // TODO: Add assertions to check correct circuit details in both scenes.
173 return; 409
174 } 410 // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
175 411 // position instead).
176 // Temporary assertion - caps url construction should at least be doable through a method. 412// Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
177 /* 413
178 Assert.That( 414// TestHelpers.DisableLogging();
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 } 415 }
190 } 416 }
191} 417} \ 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 }