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.cs31
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityInventory.cs69
-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.cs44
-rw-r--r--OpenSim/Region/Framework/Interfaces/IRegionCombinerModule.cs59
-rw-r--r--OpenSim/Region/Framework/Interfaces/IScenePresence.cs10
-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.cs830
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneBase.cs12
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs12
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs61
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs28
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs164
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs173
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs363
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs569
-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.cs33
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs34
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs6
-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.cs34
-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.cs17
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs2
54 files changed, 2894 insertions, 1276 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
index 0516cb1..e7b9ba5 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
@@ -95,11 +114,11 @@ namespace OpenSim.Region.Framework.Interfaces
95 void DetachSingleAttachmentToGround(IScenePresence sp, uint objectLocalID); 114 void DetachSingleAttachmentToGround(IScenePresence sp, uint objectLocalID);
96 115
97 /// <summary> 116 /// <summary>
98 /// Detach the given item so that it remains in the user's inventory. 117 /// Detach the given attachment so that it remains in the user's inventory.
99 /// </summary> 118 /// </summary>
100 /// <param name="sp">/param> 119 /// <param name="sp">/param>
101 /// <param name="itemID"></param> 120 /// <param name="grp">The attachment to detach.</param>
102 void DetachSingleAttachmentToInv(IScenePresence sp, UUID itemID); 121 void DetachSingleAttachmentToInv(IScenePresence sp, SceneObjectGroup grp);
103 122
104 /// Update the position of an attachment. 123 /// Update the position of an attachment.
105 /// </summary> 124 /// </summary>
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
index 32f4eea..4274cbe 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
@@ -81,13 +81,18 @@ 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();
88 93
89 /// <summary> 94 /// <summary>
90 /// Stop all the scripts in this entity. 95 /// Stop and remove all the scripts in this entity from the scene.
91 /// </summary> 96 /// </summary>
92 /// <param name="sceneObjectBeingDeleted"> 97 /// <param name="sceneObjectBeingDeleted">
93 /// Should be true if these scripts are being removed because the scene 98 /// Should be true if these scripts are being removed because the scene
@@ -96,13 +101,22 @@ namespace OpenSim.Region.Framework.Interfaces
96 void RemoveScriptInstances(bool sceneObjectBeingDeleted); 101 void RemoveScriptInstances(bool sceneObjectBeingDeleted);
97 102
98 /// <summary> 103 /// <summary>
104 /// Stop all the scripts in this entity.
105 /// </summary>
106 void StopScriptInstances();
107
108 /// <summary>
99 /// Start a script which is in this entity's inventory. 109 /// Start a script which is in this entity's inventory.
100 /// </summary> 110 /// </summary>
101 /// <param name="item"></param> 111 /// <param name="item"></param>
102 /// <param name="postOnRez"></param> 112 /// <param name="postOnRez"></param>
103 /// <param name="engine"></param> 113 /// <param name="engine"></param>
104 /// <param name="stateSource"></param> 114 /// <param name="stateSource"></param>
105 void CreateScriptInstance( 115 /// <returns>
116 /// true if the script instance was valid for starting, false otherwise. This does not guarantee
117 /// that the script was actually started, just that the script was valid (i.e. its asset data could be found, etc.)
118 /// </returns>
119 bool CreateScriptInstance(
106 TaskInventoryItem item, int startParam, bool postOnRez, string engine, int stateSource); 120 TaskInventoryItem item, int startParam, bool postOnRez, string engine, int stateSource);
107 121
108 /// <summary> 122 /// <summary>
@@ -113,12 +127,16 @@ namespace OpenSim.Region.Framework.Interfaces
113 /// <param name="postOnRez"></param> 127 /// <param name="postOnRez"></param>
114 /// <param name="engine"></param> 128 /// <param name="engine"></param>
115 /// <param name="stateSource"></param> 129 /// <param name="stateSource"></param>
116 void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource); 130 /// <returns>
131 /// true if the script instance was valid for starting, false otherwise. This does not guarantee
132 /// that the script was actually started, just that the script was valid (i.e. its asset data could be found, etc.)
133 /// </returns>
134 bool CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource);
117 135
118 ArrayList CreateScriptInstanceEr(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource); 136 ArrayList CreateScriptInstanceEr(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource);
119 137
120 /// <summary> 138 /// <summary>
121 /// Stop a script which is in this prim's inventory. 139 /// Stop and remove a script which is in this prim's inventory from the scene.
122 /// </summary> 140 /// </summary>
123 /// <param name="itemId"></param> 141 /// <param name="itemId"></param>
124 /// <param name="sceneObjectBeingDeleted"> 142 /// <param name="sceneObjectBeingDeleted">
@@ -128,6 +146,12 @@ namespace OpenSim.Region.Framework.Interfaces
128 void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted); 146 void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted);
129 147
130 /// <summary> 148 /// <summary>
149 /// Stop a script which is in this prim's inventory.
150 /// </summary>
151 /// <param name="itemId"></param>
152 void StopScriptInstance(UUID itemId);
153
154 /// <summary>
131 /// Add an item to this entity's inventory. If an item with the same name already exists, then an alternative 155 /// Add an item to this entity's inventory. If an item with the same name already exists, then an alternative
132 /// name is chosen. 156 /// name is chosen.
133 /// </summary> 157 /// </summary>
@@ -166,6 +190,19 @@ namespace OpenSim.Region.Framework.Interfaces
166 List<TaskInventoryItem> GetInventoryItems(); 190 List<TaskInventoryItem> GetInventoryItems();
167 191
168 /// <summary> 192 /// <summary>
193 /// Gets an inventory item by name
194 /// </summary>
195 /// <remarks>
196 /// This method returns the first inventory item that matches the given name. In SL this is all you need
197 /// since each item in a prim inventory must have a unique name.
198 /// </remarks>
199 /// <param name='name'></param>
200 /// <returns>
201 /// The inventory item. Null if no such item was found.
202 /// </returns>
203 TaskInventoryItem GetInventoryItem(string name);
204
205 /// <summary>
169 /// Get inventory items by name. 206 /// Get inventory items by name.
170 /// </summary> 207 /// </summary>
171 /// <param name="name"></param> 208 /// <param name="name"></param>
@@ -174,7 +211,17 @@ namespace OpenSim.Region.Framework.Interfaces
174 /// If no inventory item has that name then an empty list is returned. 211 /// If no inventory item has that name then an empty list is returned.
175 /// </returns> 212 /// </returns>
176 List<TaskInventoryItem> GetInventoryItems(string name); 213 List<TaskInventoryItem> GetInventoryItems(string name);
177 214
215 /// <summary>
216 /// Get inventory items by type.
217 /// </summary>
218 /// <param type="name"></param>
219 /// <returns>
220 /// A list of inventory items of that type.
221 /// If no inventory items of that type then an empty list is returned.
222 /// </returns>
223 List<TaskInventoryItem> GetInventoryItems(InventoryType type);
224
178 /// <summary> 225 /// <summary>
179 /// Get the scene object referenced by an inventory item. 226 /// Get the scene object referenced by an inventory item.
180 /// </summary> 227 /// </summary>
@@ -228,6 +275,16 @@ namespace OpenSim.Region.Framework.Interfaces
228 bool ContainsScripts(); 275 bool ContainsScripts();
229 276
230 /// <summary> 277 /// <summary>
278 /// Returns the count of scripts contained
279 /// </summary></returns>
280 int ScriptCount();
281
282 /// <summary>
283 /// Returns the count of running scripts contained
284 /// </summary></returns>
285 int RunningScriptCount();
286
287 /// <summary>
231 /// Get the uuids of all items in this inventory 288 /// Get the uuids of all items in this inventory
232 /// </summary> 289 /// </summary>
233 /// <returns></returns> 290 /// <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..d582149 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>
@@ -152,6 +184,14 @@ namespace OpenSim.Region.Framework.Interfaces
152 bool Stand(UUID agentID, Scene scene); 184 bool Stand(UUID agentID, Scene scene);
153 185
154 /// <summary> 186 /// <summary>
187 /// Get the NPC to touch an object.
188 /// </summary>
189 /// <param name="agentID"></param>
190 /// <param name="partID"></param>
191 /// <returns>true if the touch is actually attempted, false if not</returns>
192 bool Touch(UUID agentID, UUID partID);
193
194 /// <summary>
155 /// Delete an NPC. 195 /// Delete an NPC.
156 /// </summary> 196 /// </summary>
157 /// <param name="agentID">The UUID of the NPC</param> 197 /// <param name="agentID">The UUID of the NPC</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..e6b926c 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>
@@ -66,6 +72,10 @@ namespace OpenSim.Region.Framework.Interfaces
66 /// <returns></returns> 72 /// <returns></returns>
67 List<SceneObjectGroup> GetAttachments(uint attachmentPoint); 73 List<SceneObjectGroup> GetAttachments(uint attachmentPoint);
68 74
75 /// <summary>
76 /// Does this avatar have any attachments?
77 /// </summary>
78 /// <returns></returns>
69 bool HasAttachments(); 79 bool HasAttachments();
70 80
71 // Don't use these methods directly. Instead, use the AttachmentsModule 81 // Don't use these methods directly. Instead, use the AttachmentsModule
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..eae8b8e 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.
@@ -114,6 +120,9 @@ namespace OpenSim.Region.Framework.Scenes
114 { 120 {
115 get { return m_defaultDrawDistance; } 121 get { return m_defaultDrawDistance; }
116 } 122 }
123
124 private List<string> m_AllowedViewers = new List<string>();
125 private List<string> m_BannedViewers = new List<string>();
117 126
118 // TODO: need to figure out how allow client agents but deny 127 // TODO: need to figure out how allow client agents but deny
119 // root agents when ACL denies access to root agent 128 // root agents when ACL denies access to root agent
@@ -163,7 +172,6 @@ namespace OpenSim.Region.Framework.Scenes
163 protected IConfigSource m_config; 172 protected IConfigSource m_config;
164 protected IRegionSerialiserModule m_serialiser; 173 protected IRegionSerialiserModule m_serialiser;
165 protected IDialogModule m_dialogModule; 174 protected IDialogModule m_dialogModule;
166 protected IEntityTransferModule m_teleportModule;
167 protected ICapabilitiesModule m_capsModule; 175 protected ICapabilitiesModule m_capsModule;
168 protected IGroupsModule m_groupsModule; 176 protected IGroupsModule m_groupsModule;
169 177
@@ -217,6 +225,7 @@ namespace OpenSim.Region.Framework.Scenes
217 private int backupMS; 225 private int backupMS;
218 private int terrainMS; 226 private int terrainMS;
219 private int landMS; 227 private int landMS;
228 private int spareMS;
220 229
221 /// <summary> 230 /// <summary>
222 /// Tick at which the last frame was processed. 231 /// Tick at which the last frame was processed.
@@ -458,6 +467,7 @@ namespace OpenSim.Region.Framework.Scenes
458 { 467 {
459 if (m_simulationService == null) 468 if (m_simulationService == null)
460 m_simulationService = RequestModuleInterface<ISimulationService>(); 469 m_simulationService = RequestModuleInterface<ISimulationService>();
470
461 return m_simulationService; 471 return m_simulationService;
462 } 472 }
463 } 473 }
@@ -513,6 +523,9 @@ namespace OpenSim.Region.Framework.Scenes
513 } 523 }
514 524
515 public IAttachmentsModule AttachmentsModule { get; set; } 525 public IAttachmentsModule AttachmentsModule { get; set; }
526 public IEntityTransferModule EntityTransferModule { get; private set; }
527 public IAgentAssetTransactions AgentTransactionsModule { get; private set; }
528 public IUserManagement UserManagementModule { get; private set; }
516 529
517 public IAvatarFactoryModule AvatarFactory 530 public IAvatarFactoryModule AvatarFactory
518 { 531 {
@@ -589,6 +602,20 @@ namespace OpenSim.Region.Framework.Scenes
589 get { return m_sceneGraph.Entities; } 602 get { return m_sceneGraph.Entities; }
590 } 603 }
591 604
605
606 // used in sequence see: SpawnPoint()
607 private int m_SpawnPoint;
608 // can be closest/random/sequence
609 public string SpawnPointRouting
610 {
611 get; private set;
612 }
613 // allow landmarks to pass
614 public bool TelehubAllowLandmarks
615 {
616 get; private set;
617 }
618
592 #endregion Properties 619 #endregion Properties
593 620
594 #region Constructors 621 #region Constructors
@@ -606,14 +633,13 @@ namespace OpenSim.Region.Framework.Scenes
606 633
607 Random random = new Random(); 634 Random random = new Random();
608 635
609 m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4); 636 m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue / 2)) + (uint)(uint.MaxValue / 4);
610 m_moduleLoader = moduleLoader; 637 m_moduleLoader = moduleLoader;
611 m_authenticateHandler = authen; 638 m_authenticateHandler = authen;
612 m_sceneGridService = sceneGridService; 639 m_sceneGridService = sceneGridService;
613 m_SimulationDataService = simDataService; 640 m_SimulationDataService = simDataService;
614 m_EstateDataService = estateDataService; 641 m_EstateDataService = estateDataService;
615 m_regionHandle = m_regInfo.RegionHandle; 642 m_regionHandle = m_regInfo.RegionHandle;
616 m_regionName = m_regInfo.RegionName;
617 m_lastIncoming = 0; 643 m_lastIncoming = 0;
618 m_lastOutgoing = 0; 644 m_lastOutgoing = 0;
619 645
@@ -630,7 +656,7 @@ namespace OpenSim.Region.Framework.Scenes
630 // resave. 656 // resave.
631 // FIXME: It shouldn't be up to the database plugins to create this data - we should do it when a new 657 // FIXME: It shouldn't be up to the database plugins to create this data - we should do it when a new
632 // region is set up and avoid these gyrations. 658 // region is set up and avoid these gyrations.
633 RegionSettings rs = simDataService.LoadRegionSettings(m_regInfo.RegionID); 659 RegionSettings rs = simDataService.LoadRegionSettings(RegionInfo.RegionID);
634 bool updatedTerrainTextures = false; 660 bool updatedTerrainTextures = false;
635 if (rs.TerrainTexture1 == UUID.Zero) 661 if (rs.TerrainTexture1 == UUID.Zero)
636 { 662 {
@@ -659,10 +685,10 @@ namespace OpenSim.Region.Framework.Scenes
659 if (updatedTerrainTextures) 685 if (updatedTerrainTextures)
660 rs.Save(); 686 rs.Save();
661 687
662 m_regInfo.RegionSettings = rs; 688 RegionInfo.RegionSettings = rs;
663 689
664 if (estateDataService != null) 690 if (estateDataService != null)
665 m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false); 691 RegionInfo.EstateSettings = estateDataService.LoadEstateSettings(RegionInfo.RegionID, false);
666 692
667 #endregion Region Settings 693 #endregion Region Settings
668 694
@@ -726,6 +752,9 @@ namespace OpenSim.Region.Framework.Scenes
726 m_maxPhys = RegionInfo.PhysPrimMax; 752 m_maxPhys = RegionInfo.PhysPrimMax;
727 } 753 }
728 754
755 SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest");
756 TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false);
757
729 // Here, if clamping is requested in either global or 758 // Here, if clamping is requested in either global or
730 // local config, it will be used 759 // local config, it will be used
731 // 760 //
@@ -735,6 +764,7 @@ namespace OpenSim.Region.Framework.Scenes
735 m_clampPrimSize = true; 764 m_clampPrimSize = true;
736 } 765 }
737 766
767 m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete);
738 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); 768 m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries);
739 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); 769 m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings);
740 m_dontPersistBefore = 770 m_dontPersistBefore =
@@ -781,6 +811,24 @@ namespace OpenSim.Region.Framework.Scenes
781 } 811 }
782 } 812 }
783 813
814 string grant = startupConfig.GetString("AllowedViewerList", String.Empty);
815 if (grant.Length > 0)
816 {
817 foreach (string viewer in grant.Split(','))
818 {
819 m_AllowedViewers.Add(viewer.Trim().ToLower());
820 }
821 }
822
823 grant = startupConfig.GetString("BannedViewerList", String.Empty);
824 if (grant.Length > 0)
825 {
826 foreach (string viewer in grant.Split(','))
827 {
828 m_BannedViewers.Add(viewer.Trim().ToLower());
829 }
830 }
831
784 MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); 832 MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime);
785 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); 833 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup);
786 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); 834 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations);
@@ -833,13 +881,11 @@ namespace OpenSim.Region.Framework.Scenes
833 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; 881 StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;
834 } 882 }
835 883
836 /// <summary> 884 public Scene(RegionInfo regInfo) : base(regInfo)
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)
842 { 885 {
886 PhysicalPrims = true;
887 CollidablePrims = true;
888
843 BordersLocked = true; 889 BordersLocked = true;
844 Border northBorder = new Border(); 890 Border northBorder = new Border();
845 northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<--- 891 northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<---
@@ -862,12 +908,9 @@ namespace OpenSim.Region.Framework.Scenes
862 WestBorders.Add(westBorder); 908 WestBorders.Add(westBorder);
863 BordersLocked = false; 909 BordersLocked = false;
864 910
865 m_regInfo = regInfo;
866 m_eventManager = new EventManager(); 911 m_eventManager = new EventManager();
867 912
868 m_permissions = new ScenePermissions(this); 913 m_permissions = new ScenePermissions(this);
869
870// m_lastUpdate = Util.EnvironmentTickCount();
871 } 914 }
872 915
873 #endregion 916 #endregion
@@ -936,8 +979,8 @@ namespace OpenSim.Region.Framework.Scenes
936 List<ulong> old = new List<ulong>(); 979 List<ulong> old = new List<ulong>();
937 old.Add(otherRegion.RegionHandle); 980 old.Add(otherRegion.RegionHandle);
938 agent.DropOldNeighbours(old); 981 agent.DropOldNeighbours(old);
939 if (m_teleportModule != null && agent.PresenceType != PresenceType.Npc) 982 if (EntityTransferModule != null && agent.PresenceType != PresenceType.Npc)
940 m_teleportModule.EnableChildAgent(agent, otherRegion); 983 EntityTransferModule.EnableChildAgent(agent, otherRegion);
941 }); 984 });
942 } 985 }
943 catch (NullReferenceException) 986 catch (NullReferenceException)
@@ -950,7 +993,7 @@ namespace OpenSim.Region.Framework.Scenes
950 else 993 else
951 { 994 {
952 m_log.InfoFormat( 995 m_log.InfoFormat(
953 "[INTERGRID]: Got notice about far away Region: {0} at ({1}, {2})", 996 "[SCENE]: Got notice about far away Region: {0} at ({1}, {2})",
954 otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY); 997 otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY);
955 } 998 }
956 } 999 }
@@ -1044,13 +1087,13 @@ namespace OpenSim.Region.Framework.Scenes
1044 } 1087 }
1045 } 1088 }
1046 1089
1090 m_log.Error("[REGION]: Closing");
1091 Close();
1092
1047 if (PhysicsScene != null) 1093 if (PhysicsScene != null)
1048 { 1094 {
1049 PhysicsScene.Dispose(); 1095 PhysicsScene.Dispose();
1050 } 1096 }
1051
1052 m_log.Error("[REGION]: Closing");
1053 Close();
1054 1097
1055 m_log.Error("[REGION]: Firing Region Restart Message"); 1098 m_log.Error("[REGION]: Firing Region Restart Message");
1056 1099
@@ -1074,8 +1117,8 @@ namespace OpenSim.Region.Framework.Scenes
1074 { 1117 {
1075 ForEachRootScenePresence(delegate(ScenePresence agent) 1118 ForEachRootScenePresence(delegate(ScenePresence agent)
1076 { 1119 {
1077 if (m_teleportModule != null && agent.PresenceType != PresenceType.Npc) 1120 if (EntityTransferModule != null && agent.PresenceType != PresenceType.Npc)
1078 m_teleportModule.EnableChildAgent(agent, r); 1121 EntityTransferModule.EnableChildAgent(agent, r);
1079 }); 1122 });
1080 } 1123 }
1081 catch (NullReferenceException) 1124 catch (NullReferenceException)
@@ -1208,8 +1251,8 @@ namespace OpenSim.Region.Framework.Scenes
1208 1251
1209 m_sceneGraph.Close(); 1252 m_sceneGraph.Close();
1210 1253
1211 if (!GridService.DeregisterRegion(m_regInfo.RegionID)) 1254 if (!GridService.DeregisterRegion(RegionInfo.RegionID))
1212 m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", m_regInfo.RegionName); 1255 m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", Name);
1213 1256
1214 // call the base class Close method. 1257 // call the base class Close method.
1215 base.Close(); 1258 base.Close();
@@ -1265,8 +1308,10 @@ namespace OpenSim.Region.Framework.Scenes
1265 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>(); 1308 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>();
1266 m_dialogModule = RequestModuleInterface<IDialogModule>(); 1309 m_dialogModule = RequestModuleInterface<IDialogModule>();
1267 m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); 1310 m_capsModule = RequestModuleInterface<ICapabilitiesModule>();
1268 m_teleportModule = RequestModuleInterface<IEntityTransferModule>(); 1311 EntityTransferModule = RequestModuleInterface<IEntityTransferModule>();
1269 m_groupsModule = RequestModuleInterface<IGroupsModule>(); 1312 m_groupsModule = RequestModuleInterface<IGroupsModule>();
1313 AgentTransactionsModule = RequestModuleInterface<IAgentAssetTransactions>();
1314 UserManagementModule = RequestModuleInterface<IUserManagement>();
1270 } 1315 }
1271 1316
1272 #endregion 1317 #endregion
@@ -1387,37 +1432,41 @@ namespace OpenSim.Region.Framework.Scenes
1387 endFrame = Frame + frames; 1432 endFrame = Frame + frames;
1388 1433
1389 float physicsFPS = 0f; 1434 float physicsFPS = 0f;
1390 int tmpPhysicsMS, tmpPhysicsMS2, tmpAgentMS, tmpTempOnRezMS, evMS, backMS, terMS; 1435 int previousFrameTick, tmpMS;
1391 int previousFrameTick; 1436 int maintc = Util.EnvironmentTickCount();
1392 int maintc;
1393 int sleepMS;
1394 int framestart;
1395 1437
1396 while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) 1438 while (!m_shuttingDown && (endFrame == null || Frame < endFrame))
1397 { 1439 {
1398 framestart = Util.EnvironmentTickCount();
1399 ++Frame; 1440 ++Frame;
1400 1441
1401// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); 1442// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName);
1402 1443
1403 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; 1444 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0;
1404 1445
1405 try 1446 try
1406 { 1447 {
1407 tmpPhysicsMS2 = Util.EnvironmentTickCount(); 1448 // Apply taints in terrain module to terrain in physics scene
1449 if (Frame % m_update_terrain == 0)
1450 {
1451 tmpMS = Util.EnvironmentTickCount();
1452 UpdateTerrain();
1453 terrainMS = Util.EnvironmentTickCountSubtract(tmpMS);
1454 }
1455
1456 tmpMS = Util.EnvironmentTickCount();
1408 if ((Frame % m_update_physics == 0) && m_physics_enabled) 1457 if ((Frame % m_update_physics == 0) && m_physics_enabled)
1409 m_sceneGraph.UpdatePreparePhysics(); 1458 m_sceneGraph.UpdatePreparePhysics();
1410 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2); 1459 physicsMS2 = Util.EnvironmentTickCountSubtract(tmpMS);
1411 1460
1412 // Apply any pending avatar force input to the avatar's velocity 1461 // Apply any pending avatar force input to the avatar's velocity
1413 tmpAgentMS = Util.EnvironmentTickCount(); 1462 tmpMS = Util.EnvironmentTickCount();
1414 if (Frame % m_update_entitymovement == 0) 1463 if (Frame % m_update_entitymovement == 0)
1415 m_sceneGraph.UpdateScenePresenceMovement(); 1464 m_sceneGraph.UpdateScenePresenceMovement();
1416 agentMS = Util.EnvironmentTickCountSubtract(tmpAgentMS); 1465 agentMS = Util.EnvironmentTickCountSubtract(tmpMS);
1417 1466
1418 // Perform the main physics update. This will do the actual work of moving objects and avatars according to their 1467 // Perform the main physics update. This will do the actual work of moving objects and avatars according to their
1419 // velocity 1468 // velocity
1420 tmpPhysicsMS = Util.EnvironmentTickCount(); 1469 tmpMS = Util.EnvironmentTickCount();
1421 if (Frame % m_update_physics == 0) 1470 if (Frame % m_update_physics == 0)
1422 { 1471 {
1423 if (m_physics_enabled) 1472 if (m_physics_enabled)
@@ -1426,9 +1475,9 @@ namespace OpenSim.Region.Framework.Scenes
1426 if (SynchronizeScene != null) 1475 if (SynchronizeScene != null)
1427 SynchronizeScene(this); 1476 SynchronizeScene(this);
1428 } 1477 }
1429 physicsMS = Util.EnvironmentTickCountSubtract(tmpPhysicsMS); 1478 physicsMS = Util.EnvironmentTickCountSubtract(tmpMS);
1430 1479
1431 tmpAgentMS = Util.EnvironmentTickCount(); 1480 tmpMS = Util.EnvironmentTickCount();
1432 1481
1433 // Check if any objects have reached their targets 1482 // Check if any objects have reached their targets
1434 CheckAtTargets(); 1483 CheckAtTargets();
@@ -1443,36 +1492,29 @@ namespace OpenSim.Region.Framework.Scenes
1443 if (Frame % m_update_presences == 0) 1492 if (Frame % m_update_presences == 0)
1444 m_sceneGraph.UpdatePresences(); 1493 m_sceneGraph.UpdatePresences();
1445 1494
1446 agentMS += Util.EnvironmentTickCountSubtract(tmpAgentMS); 1495 agentMS += Util.EnvironmentTickCountSubtract(tmpMS);
1447 1496
1448 // Delete temp-on-rez stuff 1497 // Delete temp-on-rez stuff
1449 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) 1498 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps)
1450 { 1499 {
1451 tmpTempOnRezMS = Util.EnvironmentTickCount(); 1500 tmpMS = Util.EnvironmentTickCount();
1452 m_cleaningTemps = true; 1501 m_cleaningTemps = true;
1453 Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; }); 1502 Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; });
1454 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS); 1503 tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpMS);
1455 } 1504 }
1456 1505
1457 if (Frame % m_update_events == 0) 1506 if (Frame % m_update_events == 0)
1458 { 1507 {
1459 evMS = Util.EnvironmentTickCount(); 1508 tmpMS = Util.EnvironmentTickCount();
1460 UpdateEvents(); 1509 UpdateEvents();
1461 eventMS = Util.EnvironmentTickCountSubtract(evMS); 1510 eventMS = Util.EnvironmentTickCountSubtract(tmpMS);
1462 } 1511 }
1463 1512
1464 if (Frame % m_update_backup == 0) 1513 if (Frame % m_update_backup == 0)
1465 { 1514 {
1466 backMS = Util.EnvironmentTickCount(); 1515 tmpMS = Util.EnvironmentTickCount();
1467 UpdateStorageBackup(); 1516 UpdateStorageBackup();
1468 backupMS = Util.EnvironmentTickCountSubtract(backMS); 1517 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 } 1518 }
1477 1519
1478 //if (Frame % m_update_land == 0) 1520 //if (Frame % m_update_land == 0)
@@ -1481,29 +1523,6 @@ namespace OpenSim.Region.Framework.Scenes
1481 // UpdateLand(); 1523 // UpdateLand();
1482 // landMS = Util.EnvironmentTickCountSubtract(ldMS); 1524 // landMS = Util.EnvironmentTickCountSubtract(ldMS);
1483 //} 1525 //}
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 1526
1508 if (LoginsDisabled && Frame == 20) 1527 if (LoginsDisabled && Frame == 20)
1509 { 1528 {
@@ -1524,11 +1543,11 @@ namespace OpenSim.Region.Framework.Scenes
1524 LoginLock = false; 1543 LoginLock = false;
1525 EventManager.TriggerLoginsEnabled(RegionInfo.RegionName); 1544 EventManager.TriggerLoginsEnabled(RegionInfo.RegionName);
1526 } 1545 }
1527 m_log.DebugFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName);
1528 1546
1529 // For RegionReady lockouts 1547 // For RegionReady lockouts
1530 if(LoginLock == false) 1548 if (!LoginLock)
1531 { 1549 {
1550 m_log.InfoFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName);
1532 LoginsDisabled = false; 1551 LoginsDisabled = false;
1533 } 1552 }
1534 1553
@@ -1554,23 +1573,36 @@ namespace OpenSim.Region.Framework.Scenes
1554 1573
1555 previousFrameTick = m_lastFrameTick; 1574 previousFrameTick = m_lastFrameTick;
1556 m_lastFrameTick = Util.EnvironmentTickCount(); 1575 m_lastFrameTick = Util.EnvironmentTickCount();
1557 maintc = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart); 1576 tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc);
1558 maintc = (int)(MinFrameTime * 1000) - maintc; 1577 tmpMS = (int)(MinFrameTime * 1000) - tmpMS;
1559 1578
1560 m_firstHeartbeat = false; 1579 m_firstHeartbeat = false;
1561 1580
1581 if (tmpMS > 0)
1582 {
1583 Thread.Sleep(tmpMS);
1584 spareMS += tmpMS;
1585 }
1586
1587 frameMS = Util.EnvironmentTickCountSubtract(maintc);
1588 maintc = Util.EnvironmentTickCount();
1562 1589
1563 sleepMS = Util.EnvironmentTickCount(); 1590 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1564 1591
1565 if (maintc > 0) 1592 // if (Frame%m_update_avatars == 0)
1566 Thread.Sleep(maintc); 1593 // UpdateInWorldTime();
1594 StatsReporter.AddPhysicsFPS(physicsFPS);
1595 StatsReporter.AddTimeDilation(TimeDilation);
1596 StatsReporter.AddFPS(1);
1567 1597
1568 sleepMS = Util.EnvironmentTickCountSubtract(sleepMS);
1569 frameMS = Util.EnvironmentTickCountSubtract(framestart);
1570 StatsReporter.addSleepMS(sleepMS);
1571 StatsReporter.addFrameMS(frameMS); 1598 StatsReporter.addFrameMS(frameMS);
1572 1599 StatsReporter.addAgentMS(agentMS);
1573 // Optionally warn if a frame takes double the amount of time that it should. 1600 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1601 StatsReporter.addOtherMS(otherMS);
1602 StatsReporter.AddSpareMS(spareMS);
1603 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1604
1605 // Optionally warn if a frame takes double the amount of time that it should.
1574 if (DebugUpdates 1606 if (DebugUpdates
1575 && Util.EnvironmentTickCountSubtract( 1607 && Util.EnvironmentTickCountSubtract(
1576 m_lastFrameTick, previousFrameTick) > (int)(MinFrameTime * 1000 * 2)) 1608 m_lastFrameTick, previousFrameTick) > (int)(MinFrameTime * 1000 * 2))
@@ -1757,14 +1789,14 @@ namespace OpenSim.Region.Framework.Scenes
1757 1789
1758 public void StoreWindlightProfile(RegionLightShareData wl) 1790 public void StoreWindlightProfile(RegionLightShareData wl)
1759 { 1791 {
1760 m_regInfo.WindlightSettings = wl; 1792 RegionInfo.WindlightSettings = wl;
1761 SimulationDataService.StoreRegionWindlightSettings(wl); 1793 SimulationDataService.StoreRegionWindlightSettings(wl);
1762 m_eventManager.TriggerOnSaveNewWindlightProfile(); 1794 m_eventManager.TriggerOnSaveNewWindlightProfile();
1763 } 1795 }
1764 1796
1765 public void LoadWindlightProfile() 1797 public void LoadWindlightProfile()
1766 { 1798 {
1767 m_regInfo.WindlightSettings = SimulationDataService.LoadRegionWindlightSettings(RegionInfo.RegionID); 1799 RegionInfo.WindlightSettings = SimulationDataService.LoadRegionWindlightSettings(RegionInfo.RegionID);
1768 m_eventManager.TriggerOnSaveNewWindlightProfile(); 1800 m_eventManager.TriggerOnSaveNewWindlightProfile();
1769 } 1801 }
1770 1802
@@ -2083,9 +2115,8 @@ namespace OpenSim.Region.Framework.Scenes
2083 sceneObject.SetGroup(groupID, null); 2115 sceneObject.SetGroup(groupID, null);
2084 } 2116 }
2085 2117
2086 IUserManagement uman = RequestModuleInterface<IUserManagement>(); 2118 if (UserManagementModule != null)
2087 if (uman != null) 2119 sceneObject.RootPart.CreatorIdentification = UserManagementModule.GetUserUUI(ownerID);
2088 sceneObject.RootPart.CreatorIdentification = uman.GetUserUUI(ownerID);
2089 2120
2090 sceneObject.ScheduleGroupForFullUpdate(); 2121 sceneObject.ScheduleGroupForFullUpdate();
2091 2122
@@ -2250,13 +2281,30 @@ namespace OpenSim.Region.Framework.Scenes
2250 /// <summary> 2281 /// <summary>
2251 /// Synchronously delete the given object from the scene. 2282 /// Synchronously delete the given object from the scene.
2252 /// </summary> 2283 /// </summary>
2284 /// <remarks>
2285 /// Scripts are also removed.
2286 /// </remarks>
2253 /// <param name="group">Object Id</param> 2287 /// <param name="group">Object Id</param>
2254 /// <param name="silent">Suppress broadcasting changes to other clients.</param> 2288 /// <param name="silent">Suppress broadcasting changes to other clients.</param>
2255 public void DeleteSceneObject(SceneObjectGroup group, bool silent) 2289 public void DeleteSceneObject(SceneObjectGroup group, bool silent)
2290 {
2291 DeleteSceneObject(group, silent, true);
2292 }
2293
2294 /// <summary>
2295 /// Synchronously delete the given object from the scene.
2296 /// </summary>
2297 /// <param name="group">Object Id</param>
2298 /// <param name="silent">Suppress broadcasting changes to other clients.</param>
2299 /// <param name="removeScripts">If true, then scripts are removed. If false, then they are only stopped.</para>
2300 public void DeleteSceneObject(SceneObjectGroup group, bool silent, bool removeScripts)
2256 { 2301 {
2257// m_log.DebugFormat("[SCENE]: Deleting scene object {0} {1}", group.Name, group.UUID); 2302// m_log.DebugFormat("[SCENE]: Deleting scene object {0} {1}", group.Name, group.UUID);
2258 2303
2259 group.RemoveScriptInstances(true); 2304 if (removeScripts)
2305 group.RemoveScriptInstances(true);
2306 else
2307 group.StopScriptInstances();
2260 2308
2261 SceneObjectPart[] partList = group.Parts; 2309 SceneObjectPart[] partList = group.Parts;
2262 2310
@@ -2306,7 +2354,7 @@ namespace OpenSim.Region.Framework.Scenes
2306 ForceSceneObjectBackup(so); 2354 ForceSceneObjectBackup(so);
2307 2355
2308 so.DetachFromBackup(); 2356 so.DetachFromBackup();
2309 SimulationDataService.RemoveObject(so.UUID, m_regInfo.RegionID); 2357 SimulationDataService.RemoveObject(so.UUID, RegionInfo.RegionID);
2310 } 2358 }
2311 2359
2312 // We need to keep track of this state in case this group is still queued for further backup. 2360 // We need to keep track of this state in case this group is still queued for further backup.
@@ -2363,8 +2411,8 @@ namespace OpenSim.Region.Framework.Scenes
2363 return; 2411 return;
2364 } 2412 }
2365 2413
2366 if (m_teleportModule != null) 2414 if (EntityTransferModule != null)
2367 m_teleportModule.Cross(grp, attemptedPosition, silent); 2415 EntityTransferModule.Cross(grp, attemptedPosition, silent);
2368 } 2416 }
2369 2417
2370 public Border GetCrossedBorder(Vector3 position, Cardinals gridline) 2418 public Border GetCrossedBorder(Vector3 position, Cardinals gridline)
@@ -2564,7 +2612,16 @@ namespace OpenSim.Region.Framework.Scenes
2564 } 2612 }
2565 catch (Exception e) 2613 catch (Exception e)
2566 { 2614 {
2567 m_log.WarnFormat("[SCENE]: Problem casting object, exception {0}{1}", e.Message, e.StackTrace); 2615 m_log.WarnFormat("[INTERREGION]: Problem casting object, exception {0}{1}", e.Message, e.StackTrace);
2616 return false;
2617 }
2618
2619 // If the user is banned, we won't let any of their objects
2620 // enter. Period.
2621 //
2622 if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID, 36))
2623 {
2624 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID);
2568 return false; 2625 return false;
2569 } 2626 }
2570 2627
@@ -2575,32 +2632,30 @@ namespace OpenSim.Region.Framework.Scenes
2575 2632
2576 if (!AddSceneObject(newObject)) 2633 if (!AddSceneObject(newObject))
2577 { 2634 {
2578 m_log.DebugFormat("[SCENE]: Problem adding scene object {0} in {1} ", sog.UUID, RegionInfo.RegionName); 2635 m_log.DebugFormat(
2636 "[INTERREGION]: Problem adding scene object {0} in {1} ", newObject.UUID, RegionInfo.RegionName);
2579 return false; 2637 return false;
2580 } 2638 }
2581 2639
2582 // For attachments, we need to wait until the agent is root
2583 // before we restart the scripts, or else some functions won't work.
2584 if (!newObject.IsAttachment) 2640 if (!newObject.IsAttachment)
2585 { 2641 {
2586 newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject)); 2642 // FIXME: It would be better to never add the scene object at all rather than add it and then delete
2587 newObject.ResumeScripts(); 2643 // it
2588 } 2644 if (!Permissions.CanObjectEntry(newObject.UUID, true, newObject.AbsolutePosition))
2589 else
2590 {
2591 ScenePresence sp;
2592 if (TryGetScenePresence(newObject.OwnerID, out sp))
2593 { 2645 {
2594 // If the scene presence is here and already a root 2646 // Deny non attachments based on parcel settings
2595 // agent, we came from a ;egacy region. Start the scripts 2647 //
2596 // here as they used to start. 2648 m_log.Info("[INTERREGION]: Denied prim crossing because of parcel settings");
2597 // TODO: Remove in 0.7.3 2649
2598 if (!sp.IsChildAgent) 2650 DeleteSceneObject(newObject, false);
2599 { 2651
2600 newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject)); 2652 return false;
2601 newObject.ResumeScripts();
2602 }
2603 } 2653 }
2654
2655 // For attachments, we need to wait until the agent is root
2656 // before we restart the scripts, or else some functions won't work.
2657 newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject));
2658 newObject.ResumeScripts();
2604 } 2659 }
2605 2660
2606 // Do this as late as possible so that listeners have full access to the incoming object 2661 // Do this as late as possible so that listeners have full access to the incoming object
@@ -2610,28 +2665,6 @@ namespace OpenSim.Region.Framework.Scenes
2610 } 2665 }
2611 2666
2612 /// <summary> 2667 /// <summary>
2613 /// Attachment rezzing
2614 /// </summary>
2615 /// <param name="userID">Agent Unique ID</param>
2616 /// <param name="itemID">Object ID</param>
2617 /// <returns>False</returns>
2618 public virtual bool IncomingCreateObject(UUID userID, UUID itemID)
2619 {
2620 m_log.DebugFormat(" >>> IncomingCreateObject(userID, itemID) <<< {0} {1}", userID, itemID);
2621
2622 // Commented out since this is as yet unused and is arguably not the appropriate place to do this, as
2623 // attachments are being rezzed elsewhere in AddNewClient()
2624// ScenePresence sp = GetScenePresence(userID);
2625// if (sp != null && AttachmentsModule != null)
2626// {
2627// uint attPt = (uint)sp.Appearance.GetAttachpoint(itemID);
2628// AttachmentsModule.RezSingleAttachmentFromInventory(sp.ControllingClient, itemID, attPt);
2629// }
2630
2631 return false;
2632 }
2633
2634 /// <summary>
2635 /// Adds a Scene Object group to the Scene. 2668 /// Adds a Scene Object group to the Scene.
2636 /// Verifies that the creator of the object is not banned from the simulator. 2669 /// Verifies that the creator of the object is not banned from the simulator.
2637 /// Checks if the item is an Attachment 2670 /// Checks if the item is an Attachment
@@ -2650,15 +2683,13 @@ namespace OpenSim.Region.Framework.Scenes
2650 // enter. Period. 2683 // enter. Period.
2651 // 2684 //
2652 int flags = GetUserFlags(sceneObject.OwnerID); 2685 int flags = GetUserFlags(sceneObject.OwnerID);
2653 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) 2686 if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2654 { 2687 {
2655 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); 2688 m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID);
2656 2689
2657 return false; 2690 return false;
2658 } 2691 }
2659 2692
2660 sceneObject.SetScene(this);
2661
2662 // Force allocation of new LocalId 2693 // Force allocation of new LocalId
2663 // 2694 //
2664 SceneObjectPart[] parts = sceneObject.Parts; 2695 SceneObjectPart[] parts = sceneObject.Parts;
@@ -2684,10 +2715,10 @@ namespace OpenSim.Region.Framework.Scenes
2684 { 2715 {
2685 SceneObjectGroup grp = sceneObject; 2716 SceneObjectGroup grp = sceneObject;
2686 2717
2687 m_log.DebugFormat( 2718// m_log.DebugFormat(
2688 "[ATTACHMENT]: Received attachment {0}, inworld asset id {1}", grp.FromItemID, grp.UUID); 2719// "[ATTACHMENT]: Received attachment {0}, inworld asset id {1}", grp.FromItemID, grp.UUID);
2689 m_log.DebugFormat( 2720// m_log.DebugFormat(
2690 "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition); 2721// "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition);
2691 2722
2692 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2723 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2693 2724
@@ -2714,18 +2745,6 @@ namespace OpenSim.Region.Framework.Scenes
2714 return false; 2745 return false;
2715 } 2746 }
2716 AddRestoredSceneObject(sceneObject, true, false); 2747 AddRestoredSceneObject(sceneObject, true, false);
2717
2718 if (!Permissions.CanObjectEntry(sceneObject.UUID,
2719 true, sceneObject.AbsolutePosition))
2720 {
2721 // Deny non attachments based on parcel settings
2722 //
2723 m_log.Info("[INTERREGION]: Denied prim crossing because of parcel settings");
2724
2725 DeleteSceneObject(sceneObject, false);
2726
2727 return false;
2728 }
2729 } 2748 }
2730 2749
2731 return true; 2750 return true;
@@ -2783,7 +2802,8 @@ namespace OpenSim.Region.Framework.Scenes
2783 if (sp == null) 2802 if (sp == null)
2784 { 2803 {
2785 m_log.DebugFormat( 2804 m_log.DebugFormat(
2786 "[SCENE]: Adding new child scene presence {0} to scene {1} at pos {2}", client.Name, RegionInfo.RegionName, client.StartPos); 2805 "[SCENE]: Adding new child scene presence {0} {1} to scene {2} at pos {3}",
2806 client.Name, client.AgentId, RegionInfo.RegionName, client.StartPos);
2787 2807
2788 m_clientManager.Add(client); 2808 m_clientManager.Add(client);
2789 SubscribeToClientEvents(client); 2809 SubscribeToClientEvents(client);
@@ -2843,14 +2863,13 @@ namespace OpenSim.Region.Framework.Scenes
2843 /// <param name="aCircuit"></param> 2863 /// <param name="aCircuit"></param>
2844 private void CacheUserName(ScenePresence sp, AgentCircuitData aCircuit) 2864 private void CacheUserName(ScenePresence sp, AgentCircuitData aCircuit)
2845 { 2865 {
2846 IUserManagement uMan = RequestModuleInterface<IUserManagement>(); 2866 if (UserManagementModule != null)
2847 if (uMan != null)
2848 { 2867 {
2849 string first = aCircuit.firstname, last = aCircuit.lastname; 2868 string first = aCircuit.firstname, last = aCircuit.lastname;
2850 2869
2851 if (sp.PresenceType == PresenceType.Npc) 2870 if (sp.PresenceType == PresenceType.Npc)
2852 { 2871 {
2853 uMan.AddUser(aCircuit.AgentID, first, last); 2872 UserManagementModule.AddUser(aCircuit.AgentID, first, last);
2854 } 2873 }
2855 else 2874 else
2856 { 2875 {
@@ -2869,7 +2888,7 @@ namespace OpenSim.Region.Framework.Scenes
2869 } 2888 }
2870 } 2889 }
2871 2890
2872 uMan.AddUser(aCircuit.AgentID, first, last, homeURL); 2891 UserManagementModule.AddUser(aCircuit.AgentID, first, last, homeURL);
2873 } 2892 }
2874 } 2893 }
2875 } 2894 }
@@ -3207,8 +3226,10 @@ namespace OpenSim.Region.Framework.Scenes
3207 /// <param name="client">The IClientAPI for the client</param> 3226 /// <param name="client">The IClientAPI for the client</param>
3208 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) 3227 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
3209 { 3228 {
3210 if (m_teleportModule != null) 3229 if (EntityTransferModule != null)
3211 return m_teleportModule.TeleportHome(agentId, client); 3230 {
3231 EntityTransferModule.TeleportHome(agentId, client);
3232 }
3212 else 3233 else
3213 { 3234 {
3214 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3235 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
@@ -3370,65 +3391,82 @@ namespace OpenSim.Region.Framework.Scenes
3370// CheckHeartbeat(); 3391// CheckHeartbeat();
3371 bool isChildAgent = false; 3392 bool isChildAgent = false;
3372 ScenePresence avatar = GetScenePresence(agentID); 3393 ScenePresence avatar = GetScenePresence(agentID);
3373 if (avatar != null) 3394
3395 if (avatar == null)
3396 {
3397 m_log.WarnFormat(
3398 "[SCENE]: Called RemoveClient() with agent ID {0} but no such presence is in the scene.", agentID);
3399
3400 return;
3401 }
3402
3403 try
3374 { 3404 {
3375 isChildAgent = avatar.IsChildAgent; 3405 isChildAgent = avatar.IsChildAgent;
3376 3406
3377 if (avatar.ParentID != 0) 3407 m_log.DebugFormat(
3408 "[SCENE]: Removing {0} agent {1} {2} from {3}",
3409 (isChildAgent ? "child" : "root"), avatar.Name, agentID, RegionInfo.RegionName);
3410
3411 // Don't do this to root agents, it's not nice for the viewer
3412 if (closeChildAgents && isChildAgent)
3378 { 3413 {
3379 avatar.StandUp(); 3414 // Tell a single agent to disconnect from the region.
3415 IEventQueue eq = RequestModuleInterface<IEventQueue>();
3416 if (eq != null)
3417 {
3418 eq.DisableSimulator(RegionInfo.RegionHandle, avatar.UUID);
3419 }
3420 else
3421 {
3422 avatar.ControllingClient.SendShutdownConnectionNotice();
3423 }
3380 } 3424 }
3381 3425
3382 try 3426 // Only applies to root agents.
3427 if (avatar.ParentID != 0)
3383 { 3428 {
3384 m_log.DebugFormat( 3429 avatar.StandUp();
3385 "[SCENE]: Removing {0} agent {1} from region {2}", 3430 }
3386 (isChildAgent ? "child" : "root"), agentID, RegionInfo.RegionName);
3387 3431
3388 m_sceneGraph.removeUserCount(!isChildAgent); 3432 m_sceneGraph.removeUserCount(!isChildAgent);
3389 3433
3390 // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop 3434 // 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 3435 // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI
3392 if (closeChildAgents && CapsModule != null) 3436 if (closeChildAgents && CapsModule != null)
3393 CapsModule.RemoveCaps(agentID); 3437 CapsModule.RemoveCaps(agentID);
3394 3438
3395 // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever 3439 // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever
3396 // this method is doing is HORRIBLE!!! 3440 // this method is doing is HORRIBLE!!!
3397 avatar.Scene.NeedSceneCacheClear(avatar.UUID); 3441 avatar.Scene.NeedSceneCacheClear(avatar.UUID);
3398 3442
3399 if (closeChildAgents && !avatar.IsChildAgent) 3443 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 { 3444 {
3411 // We don't know which count to remove it from 3445 List<ulong> regions = avatar.KnownRegionHandles;
3412 // Avatar is already disposed :/ 3446 regions.Remove(RegionInfo.RegionHandle);
3447 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3413 } 3448 }
3414 3449
3415 try 3450 m_eventManager.TriggerClientClosed(agentID, this);
3451 m_eventManager.TriggerOnRemovePresence(agentID);
3452
3453 if (!isChildAgent)
3416 { 3454 {
3417 m_eventManager.TriggerOnRemovePresence(agentID); 3455 if (AttachmentsModule != null)
3418
3419 if (AttachmentsModule != null && !isChildAgent && avatar.PresenceType != PresenceType.Npc)
3420 { 3456 {
3421 IUserManagement uMan = RequestModuleInterface<IUserManagement>();
3422 // Don't save attachments for HG visitors, it 3457 // Don't save attachments for HG visitors, it
3423 // messes up their inventory. When a HG visitor logs 3458 // messes up their inventory. When a HG visitor logs
3424 // out on a foreign grid, their attachments will be 3459 // out on a foreign grid, their attachments will be
3425 // reloaded in the state they were in when they left 3460 // reloaded in the state they were in when they left
3426 // the home grid. This is best anyway as the visited 3461 // the home grid. This is best anyway as the visited
3427 // grid may use an incompatible script engine. 3462 // grid may use an incompatible script engine.
3428 if (uMan == null || uMan.IsLocalGridUser(avatar.UUID)) 3463 bool saveChanged
3429 AttachmentsModule.SaveChangedAttachments(avatar, false); 3464 = avatar.PresenceType != PresenceType.Npc
3465 && (UserManagementModule == null || UserManagementModule.IsLocalGridUser(avatar.UUID));
3466
3467 AttachmentsModule.DeRezAttachments(avatar, saveChanged, false);
3430 } 3468 }
3431 3469
3432 ForEachClient( 3470 ForEachClient(
3433 delegate(IClientAPI client) 3471 delegate(IClientAPI client)
3434 { 3472 {
@@ -3436,43 +3474,35 @@ namespace OpenSim.Region.Framework.Scenes
3436 try { client.SendKillObject(avatar.RegionHandle, new List<uint> { avatar.LocalId }); } 3474 try { client.SendKillObject(avatar.RegionHandle, new List<uint> { avatar.LocalId }); }
3437 catch (NullReferenceException) { } 3475 catch (NullReferenceException) { }
3438 }); 3476 });
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 } 3477 }
3456 3478
3457 try 3479 // It's possible for child agents to have transactions if changes are being made cross-border.
3458 { 3480 if (AgentTransactionsModule != null)
3459 avatar.Close(); 3481 AgentTransactionsModule.RemoveAgentAssetTransactions(agentID);
3460 } 3482
3461 catch (NullReferenceException) 3483 avatar.Close();
3462 { 3484
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); 3485 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3471// CleanDroppedAttachments();
3472 m_log.Debug("[Scene] The avatar has left the building"); 3486 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 } 3487 }
3488 catch (Exception e)
3489 {
3490 m_log.Error(
3491 string.Format("[SCENE]: Exception removing {0} from {1}, ", avatar.Name, RegionInfo.RegionName), e);
3492 }
3493 finally
3494 {
3495 // Always clean these structures up so that any failure above doesn't cause them to remain in the
3496 // scene with possibly bad effects (e.g. continually timing out on unacked packets and triggering
3497 // the same cleanup exception continually.
3498 // TODO: This should probably extend to the whole method, but we don't want to also catch the NRE
3499 // since this would hide the underlying failure and other associated problems.
3500 m_sceneGraph.RemoveScenePresence(agentID);
3501 m_clientManager.Remove(agentID);
3502 }
3503
3504 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3505 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3476 } 3506 }
3477 3507
3478 /// <summary> 3508 /// <summary>
@@ -3554,7 +3584,7 @@ namespace OpenSim.Region.Framework.Scenes
3554 public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason, bool requirePresenceLookup) 3584 public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason, bool requirePresenceLookup)
3555 { 3585 {
3556 bool vialogin = ((teleportFlags & (uint)TPFlags.ViaLogin) != 0 || 3586 bool vialogin = ((teleportFlags & (uint)TPFlags.ViaLogin) != 0 ||
3557 (teleportFlags & (uint)TPFlags.ViaHGLogin) != 0); 3587 (teleportFlags & (uint)TPFlags.ViaHGLogin) != 0);
3558 bool viahome = ((teleportFlags & (uint)TPFlags.ViaHome) != 0); 3588 bool viahome = ((teleportFlags & (uint)TPFlags.ViaHome) != 0);
3559 bool godlike = ((teleportFlags & (uint)TPFlags.Godlike) != 0); 3589 bool godlike = ((teleportFlags & (uint)TPFlags.Godlike) != 0);
3560 3590
@@ -3570,8 +3600,17 @@ namespace OpenSim.Region.Framework.Scenes
3570 // Don't disable this log message - it's too helpful 3600 // Don't disable this log message - it's too helpful
3571 m_log.DebugFormat( 3601 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})", 3602 "[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, 3603 RegionInfo.RegionName,
3574 agent.AgentID, agent.circuitcode, agent.IPAddress, agent.Viewer, ((TPFlags)teleportFlags).ToString(), agent.startpos); 3604 (agent.child ? "child" : "root"),
3605 agent.firstname,
3606 agent.lastname,
3607 agent.AgentID,
3608 agent.circuitcode,
3609 agent.IPAddress,
3610 agent.Viewer,
3611 ((TPFlags)teleportFlags).ToString(),
3612 agent.startpos
3613 );
3575 3614
3576 if (LoginsDisabled) 3615 if (LoginsDisabled)
3577 { 3616 {
@@ -3579,6 +3618,50 @@ namespace OpenSim.Region.Framework.Scenes
3579 return false; 3618 return false;
3580 } 3619 }
3581 3620
3621 //Check if the viewer is banned or in the viewer access list
3622 //We check if the substring is listed for higher flexebility
3623 bool ViewerDenied = true;
3624
3625 //Check if the specific viewer is listed in the allowed viewer list
3626 if (m_AllowedViewers.Count > 0)
3627 {
3628 foreach (string viewer in m_AllowedViewers)
3629 {
3630 if (viewer == agent.Viewer.Substring(0, viewer.Length).Trim().ToLower())
3631 {
3632 ViewerDenied = false;
3633 break;
3634 }
3635 }
3636 }
3637 else
3638 {
3639 ViewerDenied = false;
3640 }
3641
3642 //Check if the viewer is in the banned list
3643 if (m_BannedViewers.Count > 0)
3644 {
3645 foreach (string viewer in m_BannedViewers)
3646 {
3647 if (viewer == agent.Viewer.Substring(0, viewer.Length).Trim().ToLower())
3648 {
3649 ViewerDenied = true;
3650 break;
3651 }
3652 }
3653 }
3654
3655 if (ViewerDenied)
3656 {
3657 m_log.DebugFormat(
3658 "[SCENE]: Access denied for {0} {1} using {2}",
3659 agent.firstname, agent.lastname, agent.Viewer);
3660 reason = "Access denied, your viewer is banned by the region owner";
3661 return false;
3662 }
3663
3664
3582 ScenePresence sp = GetScenePresence(agent.AgentID); 3665 ScenePresence sp = GetScenePresence(agent.AgentID);
3583 3666
3584 if (sp != null && !sp.IsChildAgent) 3667 if (sp != null && !sp.IsChildAgent)
@@ -3586,7 +3669,10 @@ namespace OpenSim.Region.Framework.Scenes
3586 // We have a zombie from a crashed session. 3669 // We have a zombie from a crashed session.
3587 // Or the same user is trying to be root twice here, won't work. 3670 // Or the same user is trying to be root twice here, won't work.
3588 // Kill it. 3671 // Kill it.
3589 m_log.DebugFormat("[SCENE]: Zombie scene presence detected for {0} in {1}", agent.AgentID, RegionInfo.RegionName); 3672 m_log.DebugFormat(
3673 "[SCENE]: Zombie scene presence detected for {0} {1} in {2}",
3674 sp.Name, sp.UUID, RegionInfo.RegionName);
3675
3590 sp.ControllingClient.Close(); 3676 sp.ControllingClient.Close();
3591 sp = null; 3677 sp = null;
3592 } 3678 }
@@ -3613,8 +3699,7 @@ namespace OpenSim.Region.Framework.Scenes
3613 { 3699 {
3614 if (!VerifyUserPresence(agent, out reason)) 3700 if (!VerifyUserPresence(agent, out reason))
3615 return false; 3701 return false;
3616 } 3702 } catch (Exception e)
3617 catch (Exception e)
3618 { 3703 {
3619 m_log.ErrorFormat( 3704 m_log.ErrorFormat(
3620 "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace); 3705 "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace);
@@ -3649,8 +3734,7 @@ namespace OpenSim.Region.Framework.Scenes
3649 CapsModule.SetAgentCapsSeeds(agent); 3734 CapsModule.SetAgentCapsSeeds(agent);
3650 CapsModule.CreateCaps(agent.AgentID); 3735 CapsModule.CreateCaps(agent.AgentID);
3651 } 3736 }
3652 } 3737 } else
3653 else
3654 { 3738 {
3655 // Let the SP know how we got here. This has a lot of interesting 3739 // Let the SP know how we got here. This has a lot of interesting
3656 // uses down the line. 3740 // uses down the line.
@@ -3673,7 +3757,7 @@ namespace OpenSim.Region.Framework.Scenes
3673 agent.teleportFlags = teleportFlags; 3757 agent.teleportFlags = teleportFlags;
3674 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); 3758 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
3675 3759
3676 if (vialogin) 3760 if (vialogin)
3677 { 3761 {
3678// CleanDroppedAttachments(); 3762// CleanDroppedAttachments();
3679 3763
@@ -3714,8 +3798,7 @@ namespace OpenSim.Region.Framework.Scenes
3714 agent.startpos.Z = 720; 3798 agent.startpos.Z = 720;
3715 } 3799 }
3716 } 3800 }
3717 } 3801 } else
3718 else
3719 { 3802 {
3720 if (agent.startpos.X > EastBorders[0].BorderLine.Z) 3803 if (agent.startpos.X > EastBorders[0].BorderLine.Z)
3721 { 3804 {
@@ -3741,10 +3824,19 @@ namespace OpenSim.Region.Framework.Scenes
3741 SceneObjectGroup telehub = GetSceneObjectGroup(RegionInfo.RegionSettings.TelehubObject); 3824 SceneObjectGroup telehub = GetSceneObjectGroup(RegionInfo.RegionSettings.TelehubObject);
3742 // Can have multiple SpawnPoints 3825 // Can have multiple SpawnPoints
3743 List<SpawnPoint> spawnpoints = RegionInfo.RegionSettings.SpawnPoints(); 3826 List<SpawnPoint> spawnpoints = RegionInfo.RegionSettings.SpawnPoints();
3744 if ( spawnpoints.Count > 1) 3827 if (spawnpoints.Count > 1)
3745 { 3828 {
3746 // We have multiple SpawnPoints, Route the agent to a random one 3829 // 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); 3830 if (SpawnPointRouting == "random")
3831 agent.startpos = spawnpoints[Util.RandomClass.Next(spawnpoints.Count) - 1].GetLocation(
3832 telehub.AbsolutePosition,
3833 telehub.GroupRotation
3834 );
3835 else
3836 agent.startpos = spawnpoints[SpawnPoint()].GetLocation(
3837 telehub.AbsolutePosition,
3838 telehub.GroupRotation
3839 );
3748 } 3840 }
3749 else 3841 else
3750 { 3842 {
@@ -3867,9 +3959,9 @@ namespace OpenSim.Region.Framework.Scenes
3867 } 3959 }
3868 } 3960 }
3869 3961
3870 if (m_regInfo.EstateSettings != null) 3962 if (RegionInfo.EstateSettings != null)
3871 { 3963 {
3872 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0)) 3964 if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, 0))
3873 { 3965 {
3874 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3966 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
3875 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3967 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -3901,7 +3993,7 @@ namespace OpenSim.Region.Framework.Scenes
3901 } 3993 }
3902 3994
3903 bool groupAccess = false; 3995 bool groupAccess = false;
3904 UUID[] estateGroups = m_regInfo.EstateSettings.EstateGroups; 3996 UUID[] estateGroups = RegionInfo.EstateSettings.EstateGroups;
3905 3997
3906 if (estateGroups != null) 3998 if (estateGroups != null)
3907 { 3999 {
@@ -3919,8 +4011,8 @@ namespace OpenSim.Region.Framework.Scenes
3919 m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!"); 4011 m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!");
3920 } 4012 }
3921 4013
3922 if (!m_regInfo.EstateSettings.PublicAccess && 4014 if (!RegionInfo.EstateSettings.PublicAccess &&
3923 !m_regInfo.EstateSettings.HasAccess(agent.AgentID) && 4015 !RegionInfo.EstateSettings.HasAccess(agent.AgentID) &&
3924 !groupAccess) 4016 !groupAccess)
3925 { 4017 {
3926 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the estate", 4018 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the estate",
@@ -3981,41 +4073,41 @@ namespace OpenSim.Region.Framework.Scenes
3981 return m_authenticateHandler.TryChangeCiruitCode(oldcc, newcc); 4073 return m_authenticateHandler.TryChangeCiruitCode(oldcc, newcc);
3982 } 4074 }
3983 4075
3984 /// <summary> 4076// /// <summary>
3985 /// The Grid has requested that we log-off a user. Log them off. 4077// /// The Grid has requested that we log-off a user. Log them off.
3986 /// </summary> 4078// /// </summary>
3987 /// <param name="AvatarID">Unique ID of the avatar to log-off</param> 4079// /// <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> 4080// /// <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> 4081// /// <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) 4082// public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message)
3991 { 4083// {
3992 ScenePresence loggingOffUser = GetScenePresence(AvatarID); 4084// ScenePresence loggingOffUser = GetScenePresence(AvatarID);
3993 if (loggingOffUser != null) 4085// if (loggingOffUser != null)
3994 { 4086// {
3995 UUID localRegionSecret = UUID.Zero; 4087// UUID localRegionSecret = UUID.Zero;
3996 bool parsedsecret = UUID.TryParse(m_regInfo.regionSecret, out localRegionSecret); 4088// bool parsedsecret = UUID.TryParse(RegionInfo.regionSecret, out localRegionSecret);
3997 4089//
3998 // Region Secret is used here in case a new sessionid overwrites an old one on the user server. 4090// // 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. 4091// // Will update the user server in a few revisions to use it.
4000 4092//
4001 if (RegionSecret == loggingOffUser.ControllingClient.SecureSessionId || (parsedsecret && RegionSecret == localRegionSecret)) 4093// if (RegionSecret == loggingOffUser.ControllingClient.SecureSessionId || (parsedsecret && RegionSecret == localRegionSecret))
4002 { 4094// {
4003 m_sceneGridService.SendCloseChildAgentConnections(loggingOffUser.UUID, loggingOffUser.KnownRegionHandles); 4095// m_sceneGridService.SendCloseChildAgentConnections(loggingOffUser.UUID, loggingOffUser.KnownRegionHandles);
4004 loggingOffUser.ControllingClient.Kick(message); 4096// loggingOffUser.ControllingClient.Kick(message);
4005 // Give them a second to receive the message! 4097// // Give them a second to receive the message!
4006 Thread.Sleep(1000); 4098// Thread.Sleep(1000);
4007 loggingOffUser.ControllingClient.Close(); 4099// loggingOffUser.ControllingClient.Close();
4008 } 4100// }
4009 else 4101// else
4010 { 4102// {
4011 m_log.Info("[USERLOGOFF]: System sending the LogOff user message failed to sucessfully authenticate"); 4103// m_log.Info("[USERLOGOFF]: System sending the LogOff user message failed to sucessfully authenticate");
4012 } 4104// }
4013 } 4105// }
4014 else 4106// else
4015 { 4107// {
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()); 4108// 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 } 4109// }
4018 } 4110// }
4019 4111
4020 /// <summary> 4112 /// <summary>
4021 /// Triggered when an agent crosses into this sim. Also happens on initial login. 4113 /// Triggered when an agent crosses into this sim. Also happens on initial login.
@@ -4068,21 +4160,19 @@ namespace OpenSim.Region.Framework.Scenes
4068 return false; 4160 return false;
4069 } 4161 }
4070 4162
4163 // TODO: This check should probably be in QueryAccess().
4071 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 4164 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
4072 if (nearestParcel == null) 4165 if (nearestParcel == null)
4073 { 4166 {
4074 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: no allowed parcel", cAgentData.AgentID); 4167 m_log.DebugFormat(
4075 return false; 4168 "[SCENE]: Denying root agent entry to {0} in {1}: no allowed parcel",
4076 } 4169 cAgentData.AgentID, RegionInfo.RegionName);
4077
4078 int num = m_sceneGraph.GetNumberOfScenePresences();
4079 4170
4080 if (num >= RegionInfo.RegionSettings.AgentLimit) 4171 return false;
4081 {
4082 if (!Permissions.IsAdministrator(cAgentData.AgentID))
4083 return false;
4084 } 4172 }
4085 4173
4174 // We have to wait until the viewer contacts this region after receiving EAC.
4175 // That calls AddNewClient, which finally creates the ScenePresence
4086 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); 4176 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID);
4087 4177
4088 if (childAgentUpdate != null) 4178 if (childAgentUpdate != null)
@@ -4126,14 +4216,28 @@ namespace OpenSim.Region.Framework.Scenes
4126 return false; 4216 return false;
4127 } 4217 }
4128 4218
4219 /// <summary>
4220 /// Poll until the requested ScenePresence appears or we timeout.
4221 /// </summary>
4222 /// <returns>The scene presence is found, else null.</returns>
4223 /// <param name='agentID'></param>
4129 protected virtual ScenePresence WaitGetScenePresence(UUID agentID) 4224 protected virtual ScenePresence WaitGetScenePresence(UUID agentID)
4130 { 4225 {
4131 int ntimes = 10; 4226 int ntimes = 10;
4132 ScenePresence childAgentUpdate = null; 4227 ScenePresence sp = null;
4133 while ((childAgentUpdate = GetScenePresence(agentID)) == null && (ntimes-- > 0)) 4228 while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0))
4134 Thread.Sleep(1000); 4229 Thread.Sleep(1000);
4135 return childAgentUpdate;
4136 4230
4231 if (sp == null)
4232 m_log.WarnFormat(
4233 "[SCENE PRESENCE]: Did not find presence with id {0} in {1} before timeout",
4234 agentID, RegionInfo.RegionName);
4235// else
4236// m_log.DebugFormat(
4237// "[SCENE PRESENCE]: Found presence {0} {1} {2} in {3} after {4} waits",
4238// sp.Name, sp.UUID, sp.IsChildAgent ? "child" : "root", RegionInfo.RegionName, 10 - ntimes);
4239
4240 return sp;
4137 } 4241 }
4138 4242
4139 public virtual bool IncomingRetrieveRootAgent(UUID id, out IAgentData agent) 4243 public virtual bool IncomingRetrieveRootAgent(UUID id, out IAgentData agent)
@@ -4171,33 +4275,7 @@ namespace OpenSim.Region.Framework.Scenes
4171 ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); 4275 ScenePresence presence = m_sceneGraph.GetScenePresence(agentID);
4172 if (presence != null) 4276 if (presence != null)
4173 { 4277 {
4174 // Nothing is removed here, so down count it as such 4278 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; 4279 return true;
4202 } 4280 }
4203 4281
@@ -4245,13 +4323,13 @@ namespace OpenSim.Region.Framework.Scenes
4245 ScenePresence sp = GetScenePresence(remoteClient.AgentId); 4323 ScenePresence sp = GetScenePresence(remoteClient.AgentId);
4246 if (sp != null) 4324 if (sp != null)
4247 { 4325 {
4248 uint regionX = m_regInfo.RegionLocX; 4326 uint regionX = RegionInfo.RegionLocX;
4249 uint regionY = m_regInfo.RegionLocY; 4327 uint regionY = RegionInfo.RegionLocY;
4250 4328
4251 Utils.LongToUInts(regionHandle, out regionX, out regionY); 4329 Utils.LongToUInts(regionHandle, out regionX, out regionY);
4252 4330
4253 int shiftx = (int) regionX - (int) m_regInfo.RegionLocX * (int)Constants.RegionSize; 4331 int shiftx = (int) regionX - (int) RegionInfo.RegionLocX * (int)Constants.RegionSize;
4254 int shifty = (int) regionY - (int) m_regInfo.RegionLocY * (int)Constants.RegionSize; 4332 int shifty = (int) regionY - (int) RegionInfo.RegionLocY * (int)Constants.RegionSize;
4255 4333
4256 position.X += shiftx; 4334 position.X += shiftx;
4257 position.Y += shifty; 4335 position.Y += shifty;
@@ -4274,7 +4352,7 @@ namespace OpenSim.Region.Framework.Scenes
4274 4352
4275 if (!result) 4353 if (!result)
4276 { 4354 {
4277 regionHandle = m_regInfo.RegionHandle; 4355 regionHandle = RegionInfo.RegionHandle;
4278 } 4356 }
4279 else 4357 else
4280 { 4358 {
@@ -4283,8 +4361,10 @@ namespace OpenSim.Region.Framework.Scenes
4283 position.Y -= shifty; 4361 position.Y -= shifty;
4284 } 4362 }
4285 4363
4286 if (m_teleportModule != null) 4364 if (EntityTransferModule != null)
4287 m_teleportModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags); 4365 {
4366 EntityTransferModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags);
4367 }
4288 else 4368 else
4289 { 4369 {
4290 m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active"); 4370 m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active");
@@ -4295,8 +4375,10 @@ namespace OpenSim.Region.Framework.Scenes
4295 4375
4296 public bool CrossAgentToNewRegion(ScenePresence agent, bool isFlying) 4376 public bool CrossAgentToNewRegion(ScenePresence agent, bool isFlying)
4297 { 4377 {
4298 if (m_teleportModule != null) 4378 if (EntityTransferModule != null)
4299 return m_teleportModule.Cross(agent, isFlying); 4379 {
4380 return EntityTransferModule.Cross(agent, isFlying);
4381 }
4300 else 4382 else
4301 { 4383 {
4302 m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule"); 4384 m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule");
@@ -4598,6 +4680,17 @@ namespace OpenSim.Region.Framework.Scenes
4598 } 4680 }
4599 4681
4600 /// <summary> 4682 /// <summary>
4683 /// Get all the scene object groups.
4684 /// </summary>
4685 /// <returns>
4686 /// The scene object groups. If the scene is empty then an empty list is returned.
4687 /// </returns>
4688 public List<SceneObjectGroup> GetSceneObjectGroups()
4689 {
4690 return m_sceneGraph.GetSceneObjectGroups();
4691 }
4692
4693 /// <summary>
4601 /// Get a group via its UUID 4694 /// Get a group via its UUID
4602 /// </summary> 4695 /// </summary>
4603 /// <param name="fullID"></param> 4696 /// <param name="fullID"></param>
@@ -4776,7 +4869,7 @@ namespace OpenSim.Region.Framework.Scenes
4776 4869
4777 public void DeleteFromStorage(UUID uuid) 4870 public void DeleteFromStorage(UUID uuid)
4778 { 4871 {
4779 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); 4872 SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID);
4780 } 4873 }
4781 4874
4782 public int GetHealth(out int flags, out string message) 4875 public int GetHealth(out int flags, out string message)
@@ -5257,7 +5350,7 @@ Environment.Exit(1);
5257 IEstateDataService estateDataService = EstateDataService; 5350 IEstateDataService estateDataService = EstateDataService;
5258 if (estateDataService != null) 5351 if (estateDataService != null)
5259 { 5352 {
5260 m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false); 5353 RegionInfo.EstateSettings = estateDataService.LoadEstateSettings(RegionInfo.RegionID, false);
5261 TriggerEstateSunUpdate(); 5354 TriggerEstateSunUpdate();
5262 } 5355 }
5263 } 5356 }
@@ -5444,29 +5537,58 @@ Environment.Exit(1);
5444 throw new Exception(error); 5537 throw new Exception(error);
5445 } 5538 }
5446 5539
5447 // This method is called across the simulation connector to 5540 /// <summary>
5448 // determine if a given agent is allowed in this region 5541 /// This method is called across the simulation connector to
5449 // AS A ROOT AGENT. Returning false here will prevent them 5542 /// determine if a given agent is allowed in this region
5450 // from logging into the region, teleporting into the region 5543 /// AS A ROOT AGENT
5451 // or corssing the broder walking, but will NOT prevent 5544 /// </summary>
5452 // child agent creation, thereby emulating the SL behavior. 5545 /// <remarks>
5546 /// Returning false here will prevent them
5547 /// from logging into the region, teleporting into the region
5548 /// or corssing the broder walking, but will NOT prevent
5549 /// child agent creation, thereby emulating the SL behavior.
5550 /// </remarks>
5551 /// <param name='agentID'></param>
5552 /// <param name='position'></param>
5553 /// <param name='reason'></param>
5554 /// <returns></returns>
5453 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5555 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5454 { 5556 {
5455 reason = "You are banned from the region"; 5557 reason = "You are banned from the region";
5456 5558
5559 if (EntityTransferModule.IsInTransit(agentID))
5560 {
5561 reason = "Agent is still in transit from this region";
5562
5563 m_log.WarnFormat(
5564 "[SCENE]: Denying agent {0} entry into {1} since region still has them registered as in transit",
5565 agentID, RegionInfo.RegionName);
5566
5567 return false;
5568 }
5569
5457 if (Permissions.IsGod(agentID)) 5570 if (Permissions.IsGod(agentID))
5458 { 5571 {
5459 reason = String.Empty; 5572 reason = String.Empty;
5460 return true; 5573 return true;
5461 } 5574 }
5462 5575
5463 int num = m_sceneGraph.GetNumberOfScenePresences(); 5576 // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check.
5577 // However, the long term fix is to make sure root agent count is always accurate.
5578 m_sceneGraph.RecalculateStats();
5579
5580 int num = m_sceneGraph.GetRootAgentCount();
5464 5581
5465 if (num >= RegionInfo.RegionSettings.AgentLimit) 5582 if (num >= RegionInfo.RegionSettings.AgentLimit)
5466 { 5583 {
5467 if (!Permissions.IsAdministrator(agentID)) 5584 if (!Permissions.IsAdministrator(agentID))
5468 { 5585 {
5469 reason = "The region is full"; 5586 reason = "The region is full";
5587
5588 m_log.DebugFormat(
5589 "[SCENE]: Denying presence with id {0} entry into {1} since region is at agent limit of {2}",
5590 agentID, RegionInfo.RegionName, RegionInfo.RegionSettings.AgentLimit);
5591
5470 return false; 5592 return false;
5471 } 5593 }
5472 } 5594 }
@@ -5637,5 +5759,19 @@ Environment.Exit(1);
5637 } 5759 }
5638 } 5760 }
5639 } 5761 }
5762
5763 // manage and select spawn points in sequence
5764 public int SpawnPoint()
5765 {
5766 int spawnpoints = RegionInfo.RegionSettings.SpawnPoints().Count;
5767
5768 if (spawnpoints == 0)
5769 return 0;
5770
5771 m_SpawnPoint++;
5772 if (m_SpawnPoint > spawnpoints)
5773 m_SpawnPoint = 1;
5774 return m_SpawnPoint - 1;
5775 }
5640 } 5776 }
5641} 5777}
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index 9b8a3ae..e8134cd 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -51,6 +51,8 @@ namespace OpenSim.Region.Framework.Scenes
51 #endregion 51 #endregion
52 52
53 #region Fields 53 #region Fields
54
55 public string Name { get { return RegionInfo.RegionName; } }
54 56
55 public IConfigSource Config 57 public IConfigSource Config
56 { 58 {
@@ -148,6 +150,11 @@ namespace OpenSim.Region.Framework.Scenes
148 150
149 #endregion 151 #endregion
150 152
153 public SceneBase(RegionInfo regInfo)
154 {
155 RegionInfo = regInfo;
156 }
157
151 #region Update Methods 158 #region Update Methods
152 159
153 /// <summary> 160 /// <summary>
@@ -211,10 +218,7 @@ namespace OpenSim.Region.Framework.Scenes
211 /// 218 ///
212 /// </summary> 219 /// </summary>
213 /// <returns></returns> 220 /// <returns></returns>
214 public virtual RegionInfo RegionInfo 221 public virtual RegionInfo RegionInfo { get; private set; }
215 {
216 get { return m_regInfo; }
217 }
218 222
219 #region admin stuff 223 #region admin stuff
220 224
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 0587846..c3d66eb 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
@@ -394,9 +401,9 @@ namespace OpenSim.Region.Framework.Scenes
394 401
395 if (Entities.ContainsKey(sceneObject.UUID)) 402 if (Entities.ContainsKey(sceneObject.UUID))
396 { 403 {
397// m_log.DebugFormat( 404 m_log.DebugFormat(
398// "[SCENEGRAPH]: Scene graph for {0} already contains object {1} in AddSceneObject()", 405 "[SCENEGRAPH]: Scene graph for {0} already contains object {1} in AddSceneObject()",
399// m_parentScene.RegionInfo.RegionName, sceneObject.UUID); 406 m_parentScene.RegionInfo.RegionName, sceneObject.UUID);
400 407
401 return false; 408 return false;
402 } 409 }
@@ -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>
@@ -1042,6 +1038,18 @@ namespace OpenSim.Region.Framework.Scenes
1042 } 1038 }
1043 1039
1044 /// <summary> 1040 /// <summary>
1041 /// Get all the scene object groups.
1042 /// </summary>
1043 /// <returns>
1044 /// The scene object groups. If the scene is empty then an empty list is returned.
1045 /// </returns>
1046 protected internal List<SceneObjectGroup> GetSceneObjectGroups()
1047 {
1048 lock (SceneObjectGroupsByFullID)
1049 return new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values);
1050 }
1051
1052 /// <summary>
1045 /// Get a group in the scene 1053 /// Get a group in the scene
1046 /// </summary> 1054 /// </summary>
1047 /// <param name="fullID">UUID of the group</param> 1055 /// <param name="fullID">UUID of the group</param>
@@ -1184,11 +1192,7 @@ namespace OpenSim.Region.Framework.Scenes
1184 /// <param name="action"></param> 1192 /// <param name="action"></param>
1185 protected internal void ForEachSOG(Action<SceneObjectGroup> action) 1193 protected internal void ForEachSOG(Action<SceneObjectGroup> action)
1186 { 1194 {
1187 List<SceneObjectGroup> objlist; 1195 foreach (SceneObjectGroup obj in GetSceneObjectGroups())
1188 lock (SceneObjectGroupsByFullID)
1189 objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values);
1190
1191 foreach (SceneObjectGroup obj in objlist)
1192 { 1196 {
1193 try 1197 try
1194 { 1198 {
@@ -2065,12 +2069,14 @@ namespace OpenSim.Region.Framework.Scenes
2065 /// <param name="AgentID"></param> 2069 /// <param name="AgentID"></param>
2066 /// <param name="GroupID"></param> 2070 /// <param name="GroupID"></param>
2067 /// <param name="rot"></param> 2071 /// <param name="rot"></param>
2072 /// <returns>null if duplication fails, otherwise the duplicated object</returns>
2073 /// <summary>
2068 public SceneObjectGroup DuplicateObject(uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot) 2074 public SceneObjectGroup DuplicateObject(uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot)
2069 { 2075 {
2070// m_log.DebugFormat( 2076// m_log.DebugFormat(
2071// "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", 2077// "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}",
2072// originalPrimID, offset, AgentID); 2078// originalPrimID, offset, AgentID);
2073 2079
2074 SceneObjectGroup original = GetGroupByPrim(originalPrimID); 2080 SceneObjectGroup original = GetGroupByPrim(originalPrimID);
2075 if (original != null) 2081 if (original != null)
2076 { 2082 {
@@ -2100,25 +2106,25 @@ namespace OpenSim.Region.Framework.Scenes
2100 2106
2101 // FIXME: This section needs to be refactored so that it just calls AddSceneObject() 2107 // FIXME: This section needs to be refactored so that it just calls AddSceneObject()
2102 Entities.Add(copy); 2108 Entities.Add(copy);
2103 2109
2104 lock (SceneObjectGroupsByFullID) 2110 lock (SceneObjectGroupsByFullID)
2105 SceneObjectGroupsByFullID[copy.UUID] = copy; 2111 SceneObjectGroupsByFullID[copy.UUID] = copy;
2106 2112
2107 SceneObjectPart[] children = copy.Parts; 2113 SceneObjectPart[] children = copy.Parts;
2108 2114
2109 lock (SceneObjectGroupsByFullPartID) 2115 lock (SceneObjectGroupsByFullPartID)
2110 { 2116 {
2111 SceneObjectGroupsByFullPartID[copy.UUID] = copy; 2117 SceneObjectGroupsByFullPartID[copy.UUID] = copy;
2112 foreach (SceneObjectPart part in children) 2118 foreach (SceneObjectPart part in children)
2113 SceneObjectGroupsByFullPartID[part.UUID] = copy; 2119 SceneObjectGroupsByFullPartID[part.UUID] = copy;
2114 } 2120 }
2115 2121
2116 lock (SceneObjectGroupsByLocalPartID) 2122 lock (SceneObjectGroupsByLocalPartID)
2117 { 2123 {
2118 SceneObjectGroupsByLocalPartID[copy.LocalId] = copy; 2124 SceneObjectGroupsByLocalPartID[copy.LocalId] = copy;
2119 foreach (SceneObjectPart part in children) 2125 foreach (SceneObjectPart part in children)
2120 SceneObjectGroupsByLocalPartID[part.LocalId] = copy; 2126 SceneObjectGroupsByLocalPartID[part.LocalId] = copy;
2121 } 2127 }
2122 // PROBABLE END OF FIXME 2128 // PROBABLE END OF FIXME
2123 2129
2124 // Since we copy from a source group that is in selected 2130 // Since we copy from a source group that is in selected
@@ -2150,11 +2156,10 @@ namespace OpenSim.Region.Framework.Scenes
2150 { 2156 {
2151 m_log.WarnFormat("[SCENE]: Attempted to duplicate nonexistant prim id {0}", GroupID); 2157 m_log.WarnFormat("[SCENE]: Attempted to duplicate nonexistant prim id {0}", GroupID);
2152 } 2158 }
2153 2159
2154 return null; 2160 return null;
2155 } 2161 }
2156 2162
2157 /// <summary>
2158 /// Calculates the distance between two Vector3s 2163 /// Calculates the distance between two Vector3s
2159 /// </summary> 2164 /// </summary>
2160 /// <param name="v1"></param> 2165 /// <param name="v1"></param>
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
index 2effa25..26524fb 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
@@ -54,20 +54,32 @@ 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>
70 /// Stop the scripts contained in all the prims in this group 82 /// Stop and remove the scripts contained in all the prims in this group
71 /// </summary> 83 /// </summary>
72 public void RemoveScriptInstances(bool sceneObjectBeingDeleted) 84 public void RemoveScriptInstances(bool sceneObjectBeingDeleted)
73 { 85 {
@@ -77,6 +89,14 @@ namespace OpenSim.Region.Framework.Scenes
77 } 89 }
78 90
79 /// <summary> 91 /// <summary>
92 /// Stop the scripts contained in all the prims in this group
93 /// </summary>
94 public void StopScriptInstances()
95 {
96 Array.ForEach<SceneObjectPart>(m_parts.GetArray(), p => p.Inventory.StopScriptInstances());
97 }
98
99 /// <summary>
80 /// Add an inventory item from a user's inventory to a prim in this scene object. 100 /// Add an inventory item from a user's inventory to a prim in this scene object.
81 /// </summary> 101 /// </summary>
82 /// <param name="agentID">The agent adding the item.</param> 102 /// <param name="agentID">The agent adding the item.</param>
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 96eeec4..cc7d0fb 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -131,6 +131,15 @@ namespace OpenSim.Region.Framework.Scenes
131 } 131 }
132 } 132 }
133 133
134 /// <summary>
135 /// This indicates whether the object has changed such that it needs to be repersisted to permenant storage
136 /// (the database).
137 /// </summary>
138 /// <remarks>
139 /// Ultimately, this should be managed such that region modules can change it at the end of a set of operations
140 /// so that either all changes are preserved or none at all. However, currently, a large amount of internal
141 /// code will set this anyway when some object properties are changed.
142 /// </remarks>
134 public bool HasGroupChanged 143 public bool HasGroupChanged
135 { 144 {
136 set 145 set
@@ -244,6 +253,22 @@ namespace OpenSim.Region.Framework.Scenes
244 } 253 }
245 } 254 }
246 255
256 /// <summary>
257 /// If this scene object has an attachment point then indicate whether there is a point where
258 /// attachments are perceivable by avatars other than the avatar to which this object is attached.
259 /// </summary>
260 /// <remarks>
261 /// HUDs are not perceivable by other avatars.
262 /// </remarks>
263 public bool HasPrivateAttachmentPoint
264 {
265 get
266 {
267 return AttachmentPoint >= (uint)OpenMetaverse.AttachmentPoint.HUDCenter2
268 && AttachmentPoint <= (uint)OpenMetaverse.AttachmentPoint.HUDBottomRight;
269 }
270 }
271
247 public void ClearPartAttachmentData() 272 public void ClearPartAttachmentData()
248 { 273 {
249 AttachmentPoint = 0; 274 AttachmentPoint = 0;
@@ -1649,16 +1674,6 @@ namespace OpenSim.Region.Framework.Scenes
1649 { 1674 {
1650 return Utils.FloatToUInt16(m_scene.TimeDilation, 0.0f, 1.0f); 1675 return Utils.FloatToUInt16(m_scene.TimeDilation, 0.0f, 1.0f);
1651 } 1676 }
1652
1653 /// <summary>
1654 /// Added as a way for the storage provider to reset the scene,
1655 /// most likely a better way to do this sort of thing but for now...
1656 /// </summary>
1657 /// <param name="scene"></param>
1658 public void SetScene(Scene scene)
1659 {
1660 m_scene = scene;
1661 }
1662 1677
1663 /// <summary> 1678 /// <summary>
1664 /// Set a part to act as the root part for this scene object 1679 /// Set a part to act as the root part for this scene object
@@ -1816,8 +1831,9 @@ namespace OpenSim.Region.Framework.Scenes
1816 part.ClearUpdateSchedule(); 1831 part.ClearUpdateSchedule();
1817 if (part == m_rootPart) 1832 if (part == m_rootPart)
1818 { 1833 {
1819 if (!IsAttachment || (AttachedAvatar == avatar.ControllingClient.AgentId) || 1834 if (!IsAttachment
1820 (AttachmentPoint < 31) || (AttachmentPoint > 38)) 1835 || AttachedAvatar == avatar.ControllingClient.AgentId
1836 || !HasPrivateAttachmentPoint)
1821 avatar.ControllingClient.SendKillObject(m_regionHandle, new List<uint> { part.LocalId }); 1837 avatar.ControllingClient.SendKillObject(m_regionHandle, new List<uint> { part.LocalId });
1822 } 1838 }
1823 } 1839 }
@@ -2527,8 +2543,13 @@ namespace OpenSim.Region.Framework.Scenes
2527 } 2543 }
2528 2544
2529 /// <summary> 2545 /// <summary>
2530 /// Schedule a full update for this scene object 2546 /// Schedule a full update for this scene object to all interested viewers.
2531 /// </summary> 2547 /// </summary>
2548 /// <remarks>
2549 /// Ultimately, this should be managed such that region modules can invoke it at the end of a set of operations
2550 /// so that either all changes are sent at once. However, currently, a large amount of internal
2551 /// code will set this anyway when some object properties are changed.
2552 /// </remarks>
2532 public void ScheduleGroupForFullUpdate() 2553 public void ScheduleGroupForFullUpdate()
2533 { 2554 {
2534// if (IsAttachment) 2555// if (IsAttachment)
@@ -2547,8 +2568,13 @@ namespace OpenSim.Region.Framework.Scenes
2547 } 2568 }
2548 2569
2549 /// <summary> 2570 /// <summary>
2550 /// Schedule a terse update for this scene object 2571 /// Schedule a terse update for this scene object to all interested viewers.
2551 /// </summary> 2572 /// </summary>
2573 /// <remarks>
2574 /// Ultimately, this should be managed such that region modules can invoke it at the end of a set of operations
2575 /// so that either all changes are sent at once. However, currently, a large amount of internal
2576 /// code will set this anyway when some object properties are changed.
2577 /// </remarks>
2552 public void ScheduleGroupForTerseUpdate() 2578 public void ScheduleGroupForTerseUpdate()
2553 { 2579 {
2554// m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1}", Name, UUID); 2580// m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1}", Name, UUID);
@@ -2678,6 +2704,10 @@ namespace OpenSim.Region.Framework.Scenes
2678 /// <summary> 2704 /// <summary>
2679 /// Link the prims in a given group to this group 2705 /// Link the prims in a given group to this group
2680 /// </summary> 2706 /// </summary>
2707 /// <remarks>
2708 /// Do not call this method directly - use Scene.LinkObjects() instead to avoid races between threads.
2709 /// FIXME: There are places where scripts call these methods directly without locking. This is a potential race condition.
2710 /// </remarks>
2681 /// <param name="objectGroup">The group of prims which should be linked to this group</param> 2711 /// <param name="objectGroup">The group of prims which should be linked to this group</param>
2682 public void LinkToGroup(SceneObjectGroup objectGroup) 2712 public void LinkToGroup(SceneObjectGroup objectGroup)
2683 { 2713 {
@@ -2759,6 +2789,7 @@ namespace OpenSim.Region.Framework.Scenes
2759 } 2789 }
2760 2790
2761 linkPart.LinkNum = linkNum++; 2791 linkPart.LinkNum = linkNum++;
2792 linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false);
2762 2793
2763 SceneObjectPart[] ogParts = objectGroup.Parts; 2794 SceneObjectPart[] ogParts = objectGroup.Parts;
2764 Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) 2795 Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b)
@@ -2810,6 +2841,11 @@ namespace OpenSim.Region.Framework.Scenes
2810 /// Delink the given prim from this group. The delinked prim is established as 2841 /// Delink the given prim from this group. The delinked prim is established as
2811 /// an independent SceneObjectGroup. 2842 /// an independent SceneObjectGroup.
2812 /// </summary> 2843 /// </summary>
2844 /// <remarks>
2845 /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race
2846 /// condition. But currently there is no
2847 /// alternative method that does take a lonk to delink a single prim.
2848 /// </remarks>
2813 /// <param name="partID"></param> 2849 /// <param name="partID"></param>
2814 /// <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>
2815 public SceneObjectGroup DelinkFromGroup(uint partID) 2851 public SceneObjectGroup DelinkFromGroup(uint partID)
@@ -2821,6 +2857,11 @@ namespace OpenSim.Region.Framework.Scenes
2821 /// Delink the given prim from this group. The delinked prim is established as 2857 /// Delink the given prim from this group. The delinked prim is established as
2822 /// an independent SceneObjectGroup. 2858 /// an independent SceneObjectGroup.
2823 /// </summary> 2859 /// </summary>
2860 /// <remarks>
2861 /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race
2862 /// condition. But currently there is no
2863 /// alternative method that does take a lonk to delink a single prim.
2864 /// </remarks>
2824 /// <param name="partID"></param> 2865 /// <param name="partID"></param>
2825 /// <param name="sendEvents"></param> 2866 /// <param name="sendEvents"></param>
2826 /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> 2867 /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns>
@@ -2846,6 +2887,11 @@ namespace OpenSim.Region.Framework.Scenes
2846 /// Delink the given prim from this group. The delinked prim is established as 2887 /// Delink the given prim from this group. The delinked prim is established as
2847 /// an independent SceneObjectGroup. 2888 /// an independent SceneObjectGroup.
2848 /// </summary> 2889 /// </summary>
2890 /// <remarks>
2891 /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race
2892 /// condition. But currently there is no
2893 /// alternative method that does take a lonk to delink a single prim.
2894 /// </remarks>
2849 /// <param name="partID"></param> 2895 /// <param name="partID"></param>
2850 /// <param name="sendEvents"></param> 2896 /// <param name="sendEvents"></param>
2851 /// <returns>The object group of the newly delinked prim.</returns> 2897 /// <returns>The object group of the newly delinked prim.</returns>
@@ -2979,6 +3025,8 @@ namespace OpenSim.Region.Framework.Scenes
2979 oldRot = part.RotationOffset; 3025 oldRot = part.RotationOffset;
2980 Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot; 3026 Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot;
2981 part.RotationOffset = newRot; 3027 part.RotationOffset = newRot;
3028
3029 part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false);
2982 } 3030 }
2983 3031
2984 /// <summary> 3032 /// <summary>
@@ -3494,7 +3542,7 @@ namespace OpenSim.Region.Framework.Scenes
3494 3542
3495 //we need to do a terse update even if the move wasn't allowed 3543 //we need to do a terse update even if the move wasn't allowed
3496 // so that the position is reset in the client (the object snaps back) 3544 // so that the position is reset in the client (the object snaps back)
3497 ScheduleGroupForTerseUpdate(); 3545 RootPart.ScheduleTerseUpdate();
3498 } 3546 }
3499 3547
3500 /// <summary> 3548 /// <summary>
@@ -3609,6 +3657,11 @@ namespace OpenSim.Region.Framework.Scenes
3609 m_scene.PhysicsScene.AddPhysicsActorTaint(actor); 3657 m_scene.PhysicsScene.AddPhysicsActorTaint(actor);
3610 } 3658 }
3611 3659
3660 if (IsAttachment)
3661 {
3662 m_rootPart.AttachedPos = pos;
3663 }
3664
3612 AbsolutePosition = pos; 3665 AbsolutePosition = pos;
3613 3666
3614 HasGroupChanged = true; 3667 HasGroupChanged = true;
@@ -4195,7 +4248,86 @@ namespace OpenSim.Region.Framework.Scenes
4195 for (int i = 0; i < parts.Length; i++) 4248 for (int i = 0; i < parts.Length; i++)
4196 parts[i].TriggerScriptChangedEvent(val); 4249 parts[i].TriggerScriptChangedEvent(val);
4197 } 4250 }
4198 4251
4252 /// <summary>
4253 /// Returns a count of the number of scripts in this groups parts.
4254 /// </summary>
4255 public int ScriptCount()
4256 {
4257 int count = 0;
4258 SceneObjectPart[] parts = m_parts.GetArray();
4259 for (int i = 0; i < parts.Length; i++)
4260 count += parts[i].Inventory.ScriptCount();
4261
4262 return count;
4263 }
4264
4265 /// <summary>
4266 /// A float the value is a representative execution time in milliseconds of all scripts in the link set.
4267 /// </summary>
4268 public float ScriptExecutionTime()
4269 {
4270 IScriptModule[] engines = Scene.RequestModuleInterfaces<IScriptModule>();
4271
4272 if (engines.Length == 0) // No engine at all
4273 return 0.0f;
4274
4275 float time = 0.0f;
4276
4277 // get all the scripts in all parts
4278 SceneObjectPart[] parts = m_parts.GetArray();
4279 List<TaskInventoryItem> scripts = new List<TaskInventoryItem>();
4280 for (int i = 0; i < parts.Length; i++)
4281 {
4282 scripts.AddRange(parts[i].Inventory.GetInventoryItems(InventoryType.LSL));
4283 }
4284 // extract the UUIDs
4285 List<UUID> ids = new List<UUID>(scripts.Count);
4286 foreach (TaskInventoryItem script in scripts)
4287 {
4288 if (!ids.Contains(script.ItemID))
4289 {
4290 ids.Add(script.ItemID);
4291 }
4292 }
4293 // Offer the list of script UUIDs to each engine found and accumulate the time
4294 foreach (IScriptModule e in engines)
4295 {
4296 if (e != null)
4297 {
4298 time += e.GetScriptExecutionTime(ids);
4299 }
4300 }
4301 return time;
4302 }
4303
4304 /// <summary>
4305 /// Returns a count of the number of running scripts in this groups parts.
4306 /// </summary>
4307 public int RunningScriptCount()
4308 {
4309 int count = 0;
4310 SceneObjectPart[] parts = m_parts.GetArray();
4311 for (int i = 0; i < parts.Length; i++)
4312 count += parts[i].Inventory.RunningScriptCount();
4313
4314 return count;
4315 }
4316
4317 /// <summary>
4318 /// Gets the number of sitting avatars.
4319 /// </summary>
4320 /// <remarks>This applies to all sitting avatars whether there is a sit target set or not.</remarks>
4321 /// <returns></returns>
4322 public int GetSittingAvatarsCount()
4323 {
4324 int count = 0;
4325
4326 Array.ForEach<SceneObjectPart>(m_parts.GetArray(), p => count += p.GetSittingAvatarsCount());
4327
4328 return count;
4329 }
4330
4199 public override string ToString() 4331 public override string ToString()
4200 { 4332 {
4201 return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); 4333 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 16a8588..2410970 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -147,6 +147,21 @@ namespace OpenSim.Region.Framework.Scenes
147 get { return ParentGroup.RootPart == this; } 147 get { return ParentGroup.RootPart == this; }
148 } 148 }
149 149
150 /// <summary>
151 /// Is an explicit sit target set for this part?
152 /// </summary>
153 public bool IsSitTargetSet
154 {
155 get
156 {
157 return
158 !(SitTargetPosition == Vector3.Zero
159 && (SitTargetOrientation == Quaternion.Identity // Valid Zero Rotation quaternion
160 || SitTargetOrientation.X == 0f && SitTargetOrientation.Y == 0f && SitTargetOrientation.Z == 1f && SitTargetOrientation.W == 0f // W-Z Mapping was invalid at one point
161 || SitTargetOrientation.X == 0f && SitTargetOrientation.Y == 0f && SitTargetOrientation.Z == 0f && SitTargetOrientation.W == 0f)); // Invalid Quaternion
162 }
163 }
164
150 #region Fields 165 #region Fields
151 166
152 public bool AllowedDrop; 167 public bool AllowedDrop;
@@ -426,7 +441,6 @@ namespace OpenSim.Region.Framework.Scenes
426 private uint _category; 441 private uint _category;
427 private Int32 _creationDate; 442 private Int32 _creationDate;
428 private uint _parentID = 0; 443 private uint _parentID = 0;
429 private UUID m_sitTargetAvatar = UUID.Zero;
430 private uint _baseMask = (uint)PermissionMask.All; 444 private uint _baseMask = (uint)PermissionMask.All;
431 private uint _ownerMask = (uint)PermissionMask.All; 445 private uint _ownerMask = (uint)PermissionMask.All;
432 private uint _groupMask = (uint)PermissionMask.None; 446 private uint _groupMask = (uint)PermissionMask.None;
@@ -1024,7 +1038,18 @@ namespace OpenSim.Region.Framework.Scenes
1024 public int LinkNum 1038 public int LinkNum
1025 { 1039 {
1026 get { return m_linkNum; } 1040 get { return m_linkNum; }
1027 set { m_linkNum = value; } 1041 set
1042 {
1043// if (ParentGroup != null)
1044// {
1045// m_log.DebugFormat(
1046// "[SCENE OBJECT PART]: Setting linknum of {0}@{1} to {2} from {3}",
1047// Name, AbsolutePosition, value, m_linkNum);
1048// Util.PrintCallStack();
1049// }
1050
1051 m_linkNum = value;
1052 }
1028 } 1053 }
1029 1054
1030 public byte ClickAction 1055 public byte ClickAction
@@ -1309,13 +1334,20 @@ namespace OpenSim.Region.Framework.Scenes
1309 } 1334 }
1310 1335
1311 /// <summary> 1336 /// <summary>
1312 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero 1337 /// ID of the avatar that is sat on us if we have a sit target. If there is no such avatar then is UUID.Zero
1313 /// </summary> 1338 /// </summary>
1314 public UUID SitTargetAvatar 1339 public UUID SitTargetAvatar { get; set; }
1315 { 1340
1316 get { return m_sitTargetAvatar; } 1341 /// <summary>
1317 set { m_sitTargetAvatar = value; } 1342 /// IDs of all avatars start on this object part.
1318 } 1343 /// </summary>
1344 /// <remarks>
1345 /// We need to track this so that we can stop sat upon prims from being attached.
1346 /// </remarks>
1347 /// <value>
1348 /// null if there are no sitting avatars. This is to save us create a hashset for every prim in a scene.
1349 /// </value>
1350 private HashSet<UUID> m_sittingAvatars;
1319 1351
1320 public virtual UUID RegionID 1352 public virtual UUID RegionID
1321 { 1353 {
@@ -2111,7 +2143,7 @@ namespace OpenSim.Region.Framework.Scenes
2111 else 2143 else
2112 m_log.WarnFormat( 2144 m_log.WarnFormat(
2113 "[SCENE OBJECT PART]: Part {0} {1} requested mesh/sculpt data for asset id {2} from asset service but received no data", 2145 "[SCENE OBJECT PART]: Part {0} {1} requested mesh/sculpt data for asset id {2} from asset service but received no data",
2114 Name, LocalId, id); 2146 Name, UUID, id);
2115 } 2147 }
2116 2148
2117 /// <summary> 2149 /// <summary>
@@ -2216,6 +2248,9 @@ namespace OpenSim.Region.Framework.Scenes
2216 /// <param name="isNew"></param> 2248 /// <param name="isNew"></param>
2217 public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew) 2249 public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew)
2218 { 2250 {
2251 if (ParentGroup.Scene == null)
2252 return;
2253
2219 if (!ParentGroup.Scene.PhysicalPrims && UsePhysics) 2254 if (!ParentGroup.Scene.PhysicalPrims && UsePhysics)
2220 return; 2255 return;
2221 2256
@@ -3174,8 +3209,9 @@ namespace OpenSim.Region.Framework.Scenes
3174 if (ParentGroup.IsDeleted) 3209 if (ParentGroup.IsDeleted)
3175 return; 3210 return;
3176 3211
3177 if (ParentGroup.IsAttachment && (ParentGroup.AttachedAvatar != remoteClient.AgentId) && 3212 if (ParentGroup.IsAttachment
3178 (ParentGroup.AttachmentPoint >= 31) && (ParentGroup.AttachmentPoint <= 38)) 3213 && ParentGroup.AttachedAvatar != remoteClient.AgentId
3214 && ParentGroup.HasPrivateAttachmentPoint)
3179 return; 3215 return;
3180 3216
3181 if (remoteClient.AgentId == OwnerID) 3217 if (remoteClient.AgentId == OwnerID)
@@ -3694,7 +3730,6 @@ namespace OpenSim.Region.Framework.Scenes
3694 hasProfileCut = hasDimple; // is it the same thing? 3730 hasProfileCut = hasDimple; // is it the same thing?
3695 } 3731 }
3696 3732
3697
3698 public void SetGroup(UUID groupID, IClientAPI client) 3733 public void SetGroup(UUID groupID, IClientAPI client)
3699 { 3734 {
3700 // Scene.AddNewPrims() calls with client == null so can't use this. 3735 // Scene.AddNewPrims() calls with client == null so can't use this.
@@ -3724,10 +3759,12 @@ namespace OpenSim.Region.Framework.Scenes
3724 3759
3725 public void SetPhysicsAxisRotation() 3760 public void SetPhysicsAxisRotation()
3726 { 3761 {
3727 if (PhysActor != null) 3762 PhysicsActor pa = PhysActor;
3763
3764 if (pa != null)
3728 { 3765 {
3729 PhysActor.LockAngularMotion(RotationAxis); 3766 pa.LockAngularMotion(RotationAxis);
3730 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); 3767 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa);
3731 } 3768 }
3732 } 3769 }
3733 3770
@@ -4444,7 +4481,7 @@ namespace OpenSim.Region.Framework.Scenes
4444 // For now, we use the NINJA naming scheme for identifying joints. 4481 // For now, we use the NINJA naming scheme for identifying joints.
4445 // In the future, we can support other joint specification schemes such as a 4482 // In the future, we can support other joint specification schemes such as a
4446 // custom checkbox in the viewer GUI. 4483 // custom checkbox in the viewer GUI.
4447 if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) 4484 if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
4448 { 4485 {
4449 string hingeString = "hingejoint"; 4486 string hingeString = "hingejoint";
4450 return (Name.Length >= hingeString.Length && Name.Substring(0, hingeString.Length) == hingeString); 4487 return (Name.Length >= hingeString.Length && Name.Substring(0, hingeString.Length) == hingeString);
@@ -4460,7 +4497,7 @@ namespace OpenSim.Region.Framework.Scenes
4460 // For now, we use the NINJA naming scheme for identifying joints. 4497 // For now, we use the NINJA naming scheme for identifying joints.
4461 // In the future, we can support other joint specification schemes such as a 4498 // In the future, we can support other joint specification schemes such as a
4462 // custom checkbox in the viewer GUI. 4499 // custom checkbox in the viewer GUI.
4463 if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) 4500 if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
4464 { 4501 {
4465 string ballString = "balljoint"; 4502 string ballString = "balljoint";
4466 return (Name.Length >= ballString.Length && Name.Substring(0, ballString.Length) == ballString); 4503 return (Name.Length >= ballString.Length && Name.Substring(0, ballString.Length) == ballString);
@@ -4476,7 +4513,7 @@ namespace OpenSim.Region.Framework.Scenes
4476 // For now, we use the NINJA naming scheme for identifying joints. 4513 // For now, we use the NINJA naming scheme for identifying joints.
4477 // In the future, we can support other joint specification schemes such as a 4514 // In the future, we can support other joint specification schemes such as a
4478 // custom checkbox in the viewer GUI. 4515 // custom checkbox in the viewer GUI.
4479 if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) 4516 if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
4480 { 4517 {
4481 return IsHingeJoint() || IsBallJoint(); 4518 return IsHingeJoint() || IsBallJoint();
4482 } 4519 }
@@ -4598,7 +4635,6 @@ namespace OpenSim.Region.Framework.Scenes
4598 } 4635 }
4599*/ 4636*/
4600 } 4637 }
4601
4602 else // it already has a physical representation 4638 else // it already has a physical representation
4603 { 4639 {
4604 DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. 4640 DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status.
@@ -5074,8 +5110,9 @@ namespace OpenSim.Region.Framework.Scenes
5074 if (ParentGroup.IsDeleted) 5110 if (ParentGroup.IsDeleted)
5075 return; 5111 return;
5076 5112
5077 if (ParentGroup.IsAttachment && ((ParentGroup.RootPart != this) || 5113 if (ParentGroup.IsAttachment
5078 ((ParentGroup.AttachedAvatar != remoteClient.AgentId) && (ParentGroup.AttachmentPoint >= 31) && (ParentGroup.AttachmentPoint <= 38)))) 5114 && (ParentGroup.RootPart != this
5115 || ParentGroup.AttachedAvatar != remoteClient.AgentId && ParentGroup.HasPrivateAttachmentPoint))
5079 return; 5116 return;
5080 5117
5081 // Causes this thread to dig into the Client Thread Data. 5118 // Causes this thread to dig into the Client Thread Data.
@@ -5147,5 +5184,99 @@ namespace OpenSim.Region.Framework.Scenes
5147 Inventory.UpdateInventoryItem(item, false, false); 5184 Inventory.UpdateInventoryItem(item, false, false);
5148 } 5185 }
5149 } 5186 }
5187
5188 /// <summary>
5189 /// Record an avatar sitting on this part.
5190 /// </summary>
5191 /// <remarks>This is called for all the sitting avatars whether there is a sit target set or not.</remarks>
5192 /// <returns>
5193 /// true if the avatar was not already recorded, false otherwise.
5194 /// </returns>
5195 /// <param name='avatarId'></param>
5196 protected internal bool AddSittingAvatar(UUID avatarId)
5197 {
5198 if (IsSitTargetSet && SitTargetAvatar == UUID.Zero)
5199 SitTargetAvatar = avatarId;
5200
5201 HashSet<UUID> sittingAvatars = m_sittingAvatars;
5202
5203 if (sittingAvatars == null)
5204 sittingAvatars = new HashSet<UUID>();
5205
5206 lock (sittingAvatars)
5207 {
5208 m_sittingAvatars = sittingAvatars;
5209 return m_sittingAvatars.Add(avatarId);
5210 }
5211 }
5212
5213 /// <summary>
5214 /// Remove an avatar recorded as sitting on this part.
5215 /// </summary>
5216 /// <remarks>This applies to all sitting avatars whether there is a sit target set or not.</remarks>
5217 /// <returns>
5218 /// true if the avatar was present and removed, false if it was not present.
5219 /// </returns>
5220 /// <param name='avatarId'></param>
5221 protected internal bool RemoveSittingAvatar(UUID avatarId)
5222 {
5223 if (SitTargetAvatar == avatarId)
5224 SitTargetAvatar = UUID.Zero;
5225
5226 HashSet<UUID> sittingAvatars = m_sittingAvatars;
5227
5228 // This can occur under a race condition where another thread
5229 if (sittingAvatars == null)
5230 return false;
5231
5232 lock (sittingAvatars)
5233 {
5234 if (sittingAvatars.Remove(avatarId))
5235 {
5236 if (sittingAvatars.Count == 0)
5237 m_sittingAvatars = null;
5238
5239 return true;
5240 }
5241 }
5242
5243 return false;
5244 }
5245
5246 /// <summary>
5247 /// Get a copy of the list of sitting avatars.
5248 /// </summary>
5249 /// <remarks>This applies to all sitting avatars whether there is a sit target set or not.</remarks>
5250 /// <returns>A hashset of the sitting avatars. Returns null if there are no sitting avatars.</returns>
5251 public HashSet<UUID> GetSittingAvatars()
5252 {
5253 HashSet<UUID> sittingAvatars = m_sittingAvatars;
5254
5255 if (sittingAvatars == null)
5256 {
5257 return null;
5258 }
5259 else
5260 {
5261 lock (sittingAvatars)
5262 return new HashSet<UUID>(sittingAvatars);
5263 }
5264 }
5265
5266 /// <summary>
5267 /// Gets the number of sitting avatars.
5268 /// </summary>
5269 /// <remarks>This applies to all sitting avatars whether there is a sit target set or not.</remarks>
5270 /// <returns></returns>
5271 public int GetSittingAvatarsCount()
5272 {
5273 HashSet<UUID> sittingAvatars = m_sittingAvatars;
5274
5275 if (sittingAvatars == null)
5276 return 0;
5277
5278 lock (sittingAvatars)
5279 return sittingAvatars.Count;
5280 }
5150 } 5281 }
5151} 5282}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 959046a..e5e29d0 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)
@@ -234,7 +232,7 @@ namespace OpenSim.Region.Framework.Scenes
234 232
235 private void QueryScriptStates() 233 private void QueryScriptStates()
236 { 234 {
237 if (m_part == null || m_part.ParentGroup == null) 235 if (m_part == null || m_part.ParentGroup == null || m_part.ParentGroup.Scene == null)
238 return; 236 return;
239 237
240 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); 238 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
@@ -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)
@@ -297,7 +292,7 @@ namespace OpenSim.Region.Framework.Scenes
297 } 292 }
298 293
299 /// <summary> 294 /// <summary>
300 /// Stop all the scripts in this prim. 295 /// Stop and remove all the scripts in this prim.
301 /// </summary> 296 /// </summary>
302 /// <param name="sceneObjectBeingDeleted"> 297 /// <param name="sceneObjectBeingDeleted">
303 /// Should be true if these scripts are being removed because the scene 298 /// Should be true if these scripts are being removed because the scene
@@ -305,26 +300,28 @@ 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
322 /// <summary> 311 /// <summary>
312 /// Stop all the scripts in this prim.
313 /// </summary>
314 public void StopScriptInstances()
315 {
316 GetInventoryItems(InventoryType.LSL).ForEach(i => StopScriptInstance(i));
317 }
318
319 /// <summary>
323 /// Start a script which is in this prim's inventory. 320 /// Start a script which is in this prim's inventory.
324 /// </summary> 321 /// </summary>
325 /// <param name="item"></param> 322 /// <param name="item"></param>
326 /// <returns></returns> 323 /// <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) 324 public bool CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez, string engine, int stateSource)
328 { 325 {
329// m_log.DebugFormat("[PRIM INVENTORY]: Starting script {0} {1} in prim {2} {3} in {4}", 326// 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); 327// item.Name, item.ItemID, m_part.Name, m_part.UUID, m_part.ParentGroup.Scene.RegionInfo.RegionName);
@@ -332,61 +329,70 @@ namespace OpenSim.Region.Framework.Scenes
332 if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) 329 if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID))
333 { 330 {
334 StoreScriptError(item.ItemID, "no permission"); 331 StoreScriptError(item.ItemID, "no permission");
335 return; 332 return false;
336 } 333 }
337 334
338 m_part.AddFlag(PrimFlags.Scripted); 335 m_part.AddFlag(PrimFlags.Scripted);
339 336
340 if (!m_part.ParentGroup.Scene.RegionInfo.RegionSettings.DisableScripts) 337 if (m_part.ParentGroup.Scene.RegionInfo.RegionSettings.DisableScripts)
338 return false;
339
340 if (stateSource == 2 && // Prim crossing
341 m_part.ParentGroup.Scene.m_trustBinaries)
341 { 342 {
342 if (stateSource == 2 && // Prim crossing 343 m_items.LockItemsForWrite(true);
343 m_part.ParentGroup.Scene.m_trustBinaries) 344 m_items[item.ItemID].PermsMask = 0;
344 { 345 m_items[item.ItemID].PermsGranter = UUID.Zero;
345 m_items.LockItemsForWrite(true); 346 m_items.LockItemsForWrite(false);
346 m_items[item.ItemID].PermsMask = 0; 347 m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
347 m_items[item.ItemID].PermsGranter = UUID.Zero; 348 m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource);
348 m_items.LockItemsForWrite(false); 349 StoreScriptErrors(item.ItemID, null);
349 m_part.ParentGroup.Scene.EventManager.TriggerRezScript( 350 m_part.ParentGroup.AddActiveScriptCount(1);
350 m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); 351 m_part.ScheduleFullUpdate();
351 StoreScriptErrors(item.ItemID, null); 352 return true;
352 m_part.ParentGroup.AddActiveScriptCount(1); 353 }
353 m_part.ScheduleFullUpdate();
354 return;
355 }
356 354
357 AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); 355 AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString());
358 if (null == asset) 356 if (null == asset)
359 { 357 {
360 string msg = String.Format("asset ID {0} could not be found", item.AssetID); 358 m_log.ErrorFormat(
361 StoreScriptError(item.ItemID, msg); 359 "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found",
362 m_log.ErrorFormat( 360 item.Name, item.ItemID, m_part.AbsolutePosition,
361 m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID);
362
363 return false;
364 }
365 else
366 {
367 if (m_part.ParentGroup.m_savedScriptState != null)
368 item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID);
369
370 string msg = String.Format("asset ID {0} could not be found", item.AssetID);
371 StoreScriptError(item.ItemID, msg);
372 m_log.ErrorFormat(
363 "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", 373 "[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, 374 item.Name, item.ItemID, m_part.AbsolutePosition,
365 m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID); 375 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 376
372 m_items.LockItemsForWrite(true); 377 m_items.LockItemsForWrite(true);
373 378
374 m_items[item.ItemID].OldItemID = item.OldItemID; 379 m_items[item.ItemID].OldItemID = item.OldItemID;
375 m_items[item.ItemID].PermsMask = 0; 380 m_items[item.ItemID].PermsMask = 0;
376 m_items[item.ItemID].PermsGranter = UUID.Zero; 381 m_items[item.ItemID].PermsGranter = UUID.Zero;
377 382
378 m_items.LockItemsForWrite(false); 383 m_items.LockItemsForWrite(false);
379 384
380 string script = Utils.BytesToString(asset.Data); 385 string script = Utils.BytesToString(asset.Data);
381 m_part.ParentGroup.Scene.EventManager.TriggerRezScript( 386 m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
382 m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); 387 m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
383 StoreScriptErrors(item.ItemID, null); 388 StoreScriptErrors(item.ItemID, null);
384 if (!item.ScriptRunning) 389 if (!item.ScriptRunning)
385 m_part.ParentGroup.Scene.EventManager.TriggerStopScript( 390 m_part.ParentGroup.Scene.EventManager.TriggerStopScript(
386 m_part.LocalId, item.ItemID); 391 m_part.LocalId, item.ItemID);
387 m_part.ParentGroup.AddActiveScriptCount(1); 392 m_part.ParentGroup.AddActiveScriptCount(1);
388 m_part.ScheduleFullUpdate(); 393 m_part.ScheduleFullUpdate();
389 } 394
395 return true;
390 } 396 }
391 } 397 }
392 398
@@ -459,7 +465,7 @@ namespace OpenSim.Region.Framework.Scenes
459 /// <param name="itemId"> 465 /// <param name="itemId">
460 /// A <see cref="UUID"/> 466 /// A <see cref="UUID"/>
461 /// </param> 467 /// </param>
462 public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) 468 public bool CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)
463 { 469 {
464 lock (m_scriptErrors) 470 lock (m_scriptErrors)
465 { 471 {
@@ -467,6 +473,7 @@ namespace OpenSim.Region.Framework.Scenes
467 m_scriptErrors.Remove(itemId); 473 m_scriptErrors.Remove(itemId);
468 } 474 }
469 CreateScriptInstanceInternal(itemId, startParam, postOnRez, engine, stateSource); 475 CreateScriptInstanceInternal(itemId, startParam, postOnRez, engine, stateSource);
476 return true;
470 } 477 }
471 478
472 private void CreateScriptInstanceInternal(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) 479 private void CreateScriptInstanceInternal(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)
@@ -597,7 +604,7 @@ namespace OpenSim.Region.Framework.Scenes
597 } 604 }
598 605
599 /// <summary> 606 /// <summary>
600 /// Stop a script which is in this prim's inventory. 607 /// Stop and remove a script which is in this prim's inventory.
601 /// </summary> 608 /// </summary>
602 /// <param name="itemId"></param> 609 /// <param name="itemId"></param>
603 /// <param name="sceneObjectBeingDeleted"> 610 /// <param name="sceneObjectBeingDeleted">
@@ -616,7 +623,36 @@ namespace OpenSim.Region.Framework.Scenes
616 } 623 }
617 else 624 else
618 { 625 {
619 m_log.ErrorFormat( 626 m_log.WarnFormat(
627 "[PRIM INVENTORY]: " +
628 "Couldn't stop script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}",
629 itemId, m_part.Name, m_part.UUID,
630 m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
631 }
632 }
633
634 /// <summary>
635 /// Stop a script which is in this prim's inventory.
636 /// </summary>
637 /// <param name="itemId"></param>
638 /// <param name="sceneObjectBeingDeleted">
639 /// Should be true if this script is being removed because the scene
640 /// object is being deleted. This will prevent spurious updates to the client.
641 /// </param>
642 public void StopScriptInstance(UUID itemId)
643 {
644 TaskInventoryItem scriptItem;
645
646 lock (m_items)
647 m_items.TryGetValue(itemId, out scriptItem);
648
649 if (scriptItem != null)
650 {
651 StopScriptInstance(scriptItem);
652 }
653 else
654 {
655 m_log.WarnFormat(
620 "[PRIM INVENTORY]: " + 656 "[PRIM INVENTORY]: " +
621 "Couldn't stop script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", 657 "Couldn't stop script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}",
622 itemId, m_part.Name, m_part.UUID, 658 itemId, m_part.Name, m_part.UUID,
@@ -625,6 +661,22 @@ namespace OpenSim.Region.Framework.Scenes
625 } 661 }
626 662
627 /// <summary> 663 /// <summary>
664 /// Stop a script which is in this prim's inventory.
665 /// </summary>
666 /// <param name="itemId"></param>
667 /// <param name="sceneObjectBeingDeleted">
668 /// Should be true if this script is being removed because the scene
669 /// object is being deleted. This will prevent spurious updates to the client.
670 /// </param>
671 public void StopScriptInstance(TaskInventoryItem item)
672 {
673 m_part.ParentGroup.Scene.EventManager.TriggerStopScript(m_part.LocalId, item.ItemID);
674
675 // At the moment, even stopped scripts are counted as active, which is probably wrong.
676// m_part.ParentGroup.AddActiveScriptCount(-1);
677 }
678
679 /// <summary>
628 /// Check if the inventory holds an item with a given name. 680 /// Check if the inventory holds an item with a given name.
629 /// </summary> 681 /// </summary>
630 /// <param name="name"></param> 682 /// <param name="name"></param>
@@ -770,14 +822,22 @@ namespace OpenSim.Region.Framework.Scenes
770 return item; 822 return item;
771 } 823 }
772 824
773 /// <summary> 825 public TaskInventoryItem GetInventoryItem(string name)
774 /// Get inventory items by name. 826 {
775 /// </summary> 827 m_items.LockItemsForRead(true);
776 /// <param name="name"></param> 828 foreach (TaskInventoryItem item in m_items.Values)
777 /// <returns> 829 {
778 /// A list of inventory items with that name. 830 if (item.Name == name)
779 /// If no inventory item has that name then an empty list is returned. 831 {
780 /// </returns> 832 m_items.LockItemsForRead(false);
833 return item;
834 }
835 }
836 m_items.LockItemsForRead(false);
837
838 return null;
839 }
840
781 public List<TaskInventoryItem> GetInventoryItems(string name) 841 public List<TaskInventoryItem> GetInventoryItems(string name)
782 { 842 {
783 List<TaskInventoryItem> items = new List<TaskInventoryItem>(); 843 List<TaskInventoryItem> items = new List<TaskInventoryItem>();
@@ -1247,10 +1307,10 @@ namespace OpenSim.Region.Framework.Scenes
1247 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) 1307 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
1248 item.CurrentPermissions &= ~(uint)PermissionMask.Modify; 1308 item.CurrentPermissions &= ~(uint)PermissionMask.Modify;
1249 } 1309 }
1250 item.OwnerChanged = true;
1251 item.CurrentPermissions &= item.NextPermissions; 1310 item.CurrentPermissions &= item.NextPermissions;
1252 item.BasePermissions &= item.NextPermissions; 1311 item.BasePermissions &= item.NextPermissions;
1253 item.EveryonePermissions &= item.NextPermissions; 1312 item.EveryonePermissions &= item.NextPermissions;
1313 item.OwnerChanged = true;
1254 item.PermsMask = 0; 1314 item.PermsMask = 0;
1255 item.PermsGranter = UUID.Zero; 1315 item.PermsGranter = UUID.Zero;
1256 } 1316 }
@@ -1281,9 +1341,57 @@ namespace OpenSim.Region.Framework.Scenes
1281 return true; 1341 return true;
1282 } 1342 }
1283 } 1343 }
1344
1284 return false; 1345 return false;
1285 } 1346 }
1286 1347
1348 /// <summary>
1349 /// Returns the count of scripts in this parts inventory.
1350 /// </summary>
1351 /// <returns></returns>
1352 public int ScriptCount()
1353 {
1354 int count = 0;
1355 Items.LockItemsForRead(true);
1356 foreach (TaskInventoryItem item in m_items.Values)
1357 {
1358 if (item.InvType == (int)InventoryType.LSL)
1359 {
1360 count++;
1361 }
1362 }
1363 Items.LockItemsForRead(false);
1364 return count;
1365 }
1366 /// <summary>
1367 /// Returns the count of running scripts in this parts inventory.
1368 /// </summary>
1369 /// <returns></returns>
1370 public int RunningScriptCount()
1371 {
1372 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
1373 if (engines.Length == 0)
1374 return 0;
1375
1376 int count = 0;
1377 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
1378
1379 foreach (TaskInventoryItem item in scripts)
1380 {
1381 foreach (IScriptModule engine in engines)
1382 {
1383 if (engine != null)
1384 {
1385 if (engine.GetScriptState(item.ItemID))
1386 {
1387 count++;
1388 }
1389 }
1390 }
1391 }
1392 return count;
1393 }
1394
1287 public List<UUID> GetInventoryList() 1395 public List<UUID> GetInventoryList()
1288 { 1396 {
1289 List<UUID> ret = new List<UUID>(); 1397 List<UUID> ret = new List<UUID>();
@@ -1298,22 +1406,24 @@ namespace OpenSim.Region.Framework.Scenes
1298 { 1406 {
1299 List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); 1407 List<TaskInventoryItem> ret = new List<TaskInventoryItem>();
1300 1408
1301 lock (m_items) 1409 Items.LockItemsForRead(true);
1302 ret = new List<TaskInventoryItem>(m_items.Values); 1410 ret = new List<TaskInventoryItem>(m_items.Values);
1411 Items.LockItemsForRead(false);
1303 1412
1304 return ret; 1413 return ret;
1305 } 1414 }
1306 1415
1307 public List<TaskInventoryItem> GetInventoryScripts() 1416 public List<TaskInventoryItem> GetInventoryItems(InventoryType type)
1308 { 1417 {
1309 List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); 1418 List<TaskInventoryItem> ret = new List<TaskInventoryItem>();
1310 1419
1311 lock (m_items) 1420 Items.LockItemsForRead(true);
1312 { 1421
1313 foreach (TaskInventoryItem item in m_items.Values) 1422 foreach (TaskInventoryItem item in m_items.Values)
1314 if (item.InvType == (int)InventoryType.LSL) 1423 if (item.InvType == (int)type)
1315 ret.Add(item); 1424 ret.Add(item);
1316 } 1425
1426 Items.LockItemsForRead(false);
1317 1427
1318 return ret; 1428 return ret;
1319 } 1429 }
@@ -1335,35 +1445,32 @@ namespace OpenSim.Region.Framework.Scenes
1335 if (engines.Length == 0) // No engine at all 1445 if (engines.Length == 0) // No engine at all
1336 return ret; 1446 return ret;
1337 1447
1338 Items.LockItemsForRead(true); 1448 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
1339 foreach (TaskInventoryItem item in m_items.Values) 1449
1450 foreach (TaskInventoryItem item in scripts)
1340 { 1451 {
1341 if (item.InvType == (int)InventoryType.LSL) 1452 foreach (IScriptModule e in engines)
1342 { 1453 {
1343 foreach (IScriptModule e in engines) 1454 if (e != null)
1344 { 1455 {
1345 if (e != null) 1456 string n = e.GetXMLState(item.ItemID);
1457 if (n != String.Empty)
1346 { 1458 {
1347 string n = e.GetXMLState(item.ItemID); 1459 if (oldIDs)
1348 if (n != String.Empty) 1460 {
1461 if (!ret.ContainsKey(item.OldItemID))
1462 ret[item.OldItemID] = n;
1463 }
1464 else
1349 { 1465 {
1350 if (oldIDs) 1466 if (!ret.ContainsKey(item.ItemID))
1351 { 1467 ret[item.ItemID] = n;
1352 if (!ret.ContainsKey(item.OldItemID))
1353 ret[item.OldItemID] = n;
1354 }
1355 else
1356 {
1357 if (!ret.ContainsKey(item.ItemID))
1358 ret[item.ItemID] = n;
1359 }
1360 break;
1361 } 1468 }
1469 break;
1362 } 1470 }
1363 } 1471 }
1364 } 1472 }
1365 } 1473 }
1366 Items.LockItemsForRead(false);
1367 return ret; 1474 return ret;
1368 } 1475 }
1369 1476
@@ -1373,27 +1480,27 @@ namespace OpenSim.Region.Framework.Scenes
1373 if (engines.Length == 0) 1480 if (engines.Length == 0)
1374 return; 1481 return;
1375 1482
1483 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
1376 1484
1377 Items.LockItemsForRead(true); 1485 foreach (TaskInventoryItem item in scripts)
1378
1379 foreach (TaskInventoryItem item in m_items.Values)
1380 { 1486 {
1381 if (item.InvType == (int)InventoryType.LSL) 1487 foreach (IScriptModule engine in engines)
1382 { 1488 {
1383 foreach (IScriptModule engine in engines) 1489 if (engine != null)
1384 { 1490 {
1385 if (engine != null) 1491// m_log.DebugFormat(
1386 { 1492// "[PRIM INVENTORY]: Resuming script {0} {1} for {2}, OwnerChanged {3}",
1387 if (item.OwnerChanged) 1493// item.Name, item.ItemID, item.OwnerID, item.OwnerChanged);
1388 engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER }); 1494
1389 item.OwnerChanged = false; 1495 engine.ResumeScript(item.ItemID);
1390 engine.ResumeScript(item.ItemID); 1496
1391 } 1497 if (item.OwnerChanged)
1498 engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER });
1499
1500 item.OwnerChanged = false;
1392 } 1501 }
1393 } 1502 }
1394 } 1503 }
1395
1396 Items.LockItemsForRead(false);
1397 } 1504 }
1398 } 1505 }
1399} 1506}
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 4940063..e27d309 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
@@ -586,6 +594,12 @@ namespace OpenSim.Region.Framework.Scenes
586 private UUID m_parentUUID = UUID.Zero; 594 private UUID m_parentUUID = UUID.Zero;
587 595
588 /// <summary> 596 /// <summary>
597 /// Are we sitting on an object?
598 /// </summary>
599 /// <remarks>A more readable way of testing presence sit status than ParentID == 0</remarks>
600 public bool IsSatOnObject { get { return ParentID != 0; } }
601
602 /// <summary>
589 /// If the avatar is sitting, the prim that it's sitting on. If not sitting then null. 603 /// If the avatar is sitting, the prim that it's sitting on. If not sitting then null.
590 /// </summary> 604 /// </summary>
591 /// <remarks> 605 /// <remarks>
@@ -1087,23 +1101,13 @@ namespace OpenSim.Region.Framework.Scenes
1087 /// <param name="pos"></param> 1101 /// <param name="pos"></param>
1088 public void Teleport(Vector3 pos) 1102 public void Teleport(Vector3 pos)
1089 { 1103 {
1090 bool isFlying = Flying; 1104 TeleportWithMomentum(pos, Vector3.Zero);
1091 RemoveFromPhysicalScene();
1092 Velocity = Vector3.Zero;
1093 CheckLandingPoint(ref pos);
1094 AbsolutePosition = pos;
1095 AddToPhysicalScene(isFlying);
1096
1097 SendTerseUpdateToAllClients();
1098 }
1099
1100 public void TeleportWithMomentum(Vector3 pos)
1101 {
1102 TeleportWithMomentum(pos, null);
1103 } 1105 }
1104 1106
1105 public void TeleportWithMomentum(Vector3 pos, Vector3? v) 1107 public void TeleportWithMomentum(Vector3 pos, Vector3? v)
1106 { 1108 {
1109 if (ParentID != (uint)0)
1110 StandUp();
1107 bool isFlying = Flying; 1111 bool isFlying = Flying;
1108 Vector3 vel = Velocity; 1112 Vector3 vel = Velocity;
1109 RemoveFromPhysicalScene(); 1113 RemoveFromPhysicalScene();
@@ -1283,17 +1287,33 @@ namespace OpenSim.Region.Framework.Scenes
1283 1287
1284 bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); 1288 bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
1285 MakeRootAgent(AbsolutePosition, flying); 1289 MakeRootAgent(AbsolutePosition, flying);
1290 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
1291
1292// m_log.DebugFormat("[SCENE PRESENCE] Completed movement");
1286 1293
1287 if ((m_callbackURI != null) && !m_callbackURI.Equals("")) 1294 if ((m_callbackURI != null) && !m_callbackURI.Equals(""))
1288 { 1295 {
1289 m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); 1296 // We cannot sleep here since this would hold up the inbound packet processing thread, as
1297 // CompleteMovement() is executed synchronously. However, it might be better to delay the release
1298 // here until we know for sure that the agent is active in this region. Sending AgentMovementComplete
1299 // is not enough for Imprudence clients - there appears to be a small delay (<200ms, <500ms) until they regard this
1300 // region as the current region, meaning that a close sent before then will fail the teleport.
1301// System.Threading.Thread.Sleep(2000);
1302
1303 m_log.DebugFormat(
1304 "[SCENE PRESENCE]: Releasing {0} {1} with callback to {2}",
1305 client.Name, client.AgentId, m_callbackURI);
1306
1290 Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI); 1307 Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI);
1291 m_callbackURI = null; 1308 m_callbackURI = null;
1292 } 1309 }
1310// else
1311// {
1312// m_log.DebugFormat(
1313// "[SCENE PRESENCE]: No callback provided on CompleteMovement of {0} {1} to {2}",
1314// client.Name, client.AgentId, m_scene.RegionInfo.RegionName);
1315// }
1293 1316
1294// m_log.DebugFormat("[SCENE PRESENCE] Completed movement");
1295
1296 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
1297 ValidateAndSendAppearanceAndAgentData(); 1317 ValidateAndSendAppearanceAndAgentData();
1298 1318
1299 // Create child agents in neighbouring regions 1319 // Create child agents in neighbouring regions
@@ -1308,7 +1328,6 @@ namespace OpenSim.Region.Framework.Scenes
1308 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); 1328 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient);
1309 } 1329 }
1310 1330
1311
1312// m_log.DebugFormat( 1331// m_log.DebugFormat(
1313// "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms", 1332// "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms",
1314// client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds); 1333// client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds);
@@ -1361,7 +1380,7 @@ namespace OpenSim.Region.Framework.Scenes
1361 { 1380 {
1362// m_log.DebugFormat( 1381// m_log.DebugFormat(
1363// "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}", 1382// "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}",
1364// Scene.RegionInfo.RegionName, remoteClient.Name, agentData.ControlFlags); 1383// Scene.RegionInfo.RegionName, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags);
1365 1384
1366 if (IsChildAgent) 1385 if (IsChildAgent)
1367 { 1386 {
@@ -1471,14 +1490,8 @@ namespace OpenSim.Region.Framework.Scenes
1471 } 1490 }
1472 } 1491 }
1473 1492
1474 lock (scriptedcontrols) 1493 uint flagsForScripts = (uint)flags;
1475 { 1494 flags = RemoveIgnoredControls(flags, IgnoredControls);
1476 if (scriptedcontrols.Count > 0)
1477 {
1478 SendControlToScripts((uint)flags);
1479 flags = RemoveIgnoredControls(flags, IgnoredControls);
1480 }
1481 }
1482 1495
1483 if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) 1496 if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0)
1484 HandleAgentSitOnGround(); 1497 HandleAgentSitOnGround();
@@ -1492,6 +1505,7 @@ namespace OpenSim.Region.Framework.Scenes
1492 PhysicsActor actor = PhysicsActor; 1505 PhysicsActor actor = PhysicsActor;
1493 if (actor == null) 1506 if (actor == null)
1494 { 1507 {
1508 SendControlsToScripts(flagsForScripts);
1495 return; 1509 return;
1496 } 1510 }
1497 1511
@@ -1571,7 +1585,7 @@ namespace OpenSim.Region.Framework.Scenes
1571 MovementFlag |= (byte)nudgehack; 1585 MovementFlag |= (byte)nudgehack;
1572 } 1586 }
1573 1587
1574// m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF); 1588 //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF);
1575 MovementFlag += (byte)(uint)DCF; 1589 MovementFlag += (byte)(uint)DCF;
1576 update_movementflag = true; 1590 update_movementflag = true;
1577 } 1591 }
@@ -1584,7 +1598,7 @@ namespace OpenSim.Region.Framework.Scenes
1584 && ((MovementFlag & (byte)nudgehack) == nudgehack)) 1598 && ((MovementFlag & (byte)nudgehack) == nudgehack))
1585 ) // This or is for Nudge forward 1599 ) // This or is for Nudge forward
1586 { 1600 {
1587// m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF); 1601 //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF);
1588 MovementFlag -= ((byte)(uint)DCF); 1602 MovementFlag -= ((byte)(uint)DCF);
1589 update_movementflag = true; 1603 update_movementflag = true;
1590 1604
@@ -1665,11 +1679,14 @@ namespace OpenSim.Region.Framework.Scenes
1665// } 1679// }
1666// } 1680// }
1667 1681
1668// if (update_movementflag && ParentID == 0) 1682 if (update_movementflag && ParentID == 0)
1669// Animator.UpdateMovementAnimations(); 1683 Animator.UpdateMovementAnimations();
1684
1685 SendControlsToScripts(flagsForScripts);
1670 } 1686 }
1671 1687
1672 m_scene.EventManager.TriggerOnClientMovement(this); 1688 m_scene.EventManager.TriggerOnClientMovement(this);
1689 TriggerScenePresenceUpdated();
1673 } 1690 }
1674 1691
1675 /// <summary> 1692 /// <summary>
@@ -1929,10 +1946,6 @@ namespace OpenSim.Region.Framework.Scenes
1929 } 1946 }
1930 } 1947 }
1931 1948
1932 // Reset sit target.
1933 if (part.SitTargetAvatar == UUID)
1934 part.SitTargetAvatar = UUID.Zero;
1935
1936 part.ParentGroup.DeleteAvatar(UUID); 1949 part.ParentGroup.DeleteAvatar(UUID);
1937// ParentPosition = part.GetWorldPosition(); 1950// ParentPosition = part.GetWorldPosition();
1938 ControllingClient.SendClearFollowCamProperties(part.ParentUUID); 1951 ControllingClient.SendClearFollowCamProperties(part.ParentUUID);
@@ -1950,6 +1963,8 @@ namespace OpenSim.Region.Framework.Scenes
1950 SendAvatarDataToAllAgents(); 1963 SendAvatarDataToAllAgents();
1951 m_requestedSitTargetID = 0; 1964 m_requestedSitTargetID = 0;
1952 1965
1966 part.RemoveSittingAvatar(UUID);
1967
1953 if (part != null) 1968 if (part != null)
1954 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); 1969 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
1955 } 1970 }
@@ -1983,15 +1998,7 @@ namespace OpenSim.Region.Framework.Scenes
1983 //look for prims with explicit sit targets that are available 1998 //look for prims with explicit sit targets that are available
1984 foreach (SceneObjectPart part in partArray) 1999 foreach (SceneObjectPart part in partArray)
1985 { 2000 {
1986 // Is a sit target available? 2001 if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero)
1987 Vector3 avSitOffset = part.SitTargetPosition;
1988 Quaternion avSitOrientation = part.SitTargetOrientation;
1989 UUID avOnTargetAlready = part.SitTargetAvatar;
1990
1991 bool SitTargetUnOccupied = avOnTargetAlready == UUID.Zero;
1992 bool SitTargetisSet = avSitOffset != Vector3.Zero || avSitOrientation != Quaternion.Identity;
1993
1994 if (SitTargetisSet && SitTargetUnOccupied)
1995 { 2002 {
1996 //switch the target to this prim 2003 //switch the target to this prim
1997 return part; 2004 return part;
@@ -2002,10 +2009,8 @@ namespace OpenSim.Region.Framework.Scenes
2002 return targetPart; 2009 return targetPart;
2003 } 2010 }
2004 2011
2005 private void SendSitResponse(UUID targetID, Vector3 offset, Quaternion pSitOrientation) 2012 private void SendSitResponse(UUID targetID, Vector3 offset, Quaternion sitOrientation)
2006 { 2013 {
2007 Vector3 pos = new Vector3();
2008 Quaternion sitOrientation = pSitOrientation;
2009 Vector3 cameraEyeOffset = Vector3.Zero; 2014 Vector3 cameraEyeOffset = Vector3.Zero;
2010 Vector3 cameraAtOffset = Vector3.Zero; 2015 Vector3 cameraAtOffset = Vector3.Zero;
2011 bool forceMouselook = false; 2016 bool forceMouselook = false;
@@ -2017,54 +2022,39 @@ namespace OpenSim.Region.Framework.Scenes
2017 // TODO: determine position to sit at based on scene geometry; don't trust offset from client 2022 // TODO: determine position to sit at based on scene geometry; don't trust offset from client
2018 // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it 2023 // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it
2019 2024
2020 // Is a sit target available?
2021 Vector3 avSitOffSet = part.SitTargetPosition;
2022 Quaternion avSitOrientation = part.SitTargetOrientation;
2023 UUID avOnTargetAlready = part.SitTargetAvatar;
2024
2025 bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero));
2026 bool SitTargetisSet =
2027 (!(avSitOffSet == Vector3.Zero &&
2028 (
2029 avSitOrientation == Quaternion.Identity // Valid Zero Rotation quaternion
2030 || avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f && avSitOrientation.W == 0f // W-Z Mapping was invalid at one point
2031 || avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f && avSitOrientation.W == 0f // Invalid Quaternion
2032 )
2033 ));
2034
2035// m_log.DebugFormat("[SCENE PRESENCE]: {0} {1}", SitTargetisSet, SitTargetUnOccupied);
2036
2037 if (PhysicsActor != null) 2025 if (PhysicsActor != null)
2038 m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; 2026 m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f;
2039 2027
2040 bool canSit = false; 2028 bool canSit = false;
2041 pos = part.AbsolutePosition + offset; 2029 Vector3 pos = part.AbsolutePosition + offset;
2042 2030
2043 if (SitTargetisSet) 2031 if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero)
2044 { 2032 {
2045 if (SitTargetUnOccupied) 2033// m_log.DebugFormat(
2046 { 2034// "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is set and unoccupied",
2047 m_log.DebugFormat( 2035// Name, part.Name, part.LocalId);
2048 "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is set and unoccupied",
2049 Name, part.Name, part.LocalId);
2050 2036
2051 part.SitTargetAvatar = UUID; 2037 offset = part.SitTargetPosition;
2052 offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); 2038 sitOrientation = part.SitTargetOrientation;
2053 sitOrientation = avSitOrientation; 2039 canSit = true;
2054 canSit = true;
2055 }
2056 } 2040 }
2057 else 2041 else
2058 { 2042 {
2059 if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) 2043 if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10)
2060 { 2044 {
2061 m_log.DebugFormat( 2045// m_log.DebugFormat(
2062 "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is unset and within 10m", 2046// "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is unset and within 10m",
2063 Name, part.Name, part.LocalId); 2047// Name, part.Name, part.LocalId);
2064 2048
2065 AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); 2049 AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight);
2066 canSit = true; 2050 canSit = true;
2067 } 2051 }
2052// else
2053// {
2054// m_log.DebugFormat(
2055// "[SCENE PRESENCE]: Ignoring sit request of {0} on {1} {2} because sit target is unset and outside 10m",
2056// Name, part.Name, part.LocalId);
2057// }
2068 } 2058 }
2069 2059
2070 if (canSit) 2060 if (canSit)
@@ -2075,6 +2065,8 @@ namespace OpenSim.Region.Framework.Scenes
2075 RemoveFromPhysicalScene(); 2065 RemoveFromPhysicalScene();
2076 } 2066 }
2077 2067
2068 part.AddSittingAvatar(UUID);
2069
2078 cameraAtOffset = part.GetCameraAtOffset(); 2070 cameraAtOffset = part.GetCameraAtOffset();
2079 cameraEyeOffset = part.GetCameraEyeOffset(); 2071 cameraEyeOffset = part.GetCameraEyeOffset();
2080 forceMouselook = part.GetForceMouselook(); 2072 forceMouselook = part.GetForceMouselook();
@@ -2351,6 +2343,15 @@ namespace OpenSim.Region.Framework.Scenes
2351 2343
2352 if (part != null) 2344 if (part != null)
2353 { 2345 {
2346 if (part.ParentGroup.IsAttachment)
2347 {
2348 m_log.WarnFormat(
2349 "[SCENE PRESENCE]: Avatar {0} tried to sit on part {1} from object {2} in {3} but this is an attachment for avatar id {4}",
2350 Name, part.Name, part.ParentGroup.Name, Scene.Name, part.ParentGroup.AttachedAvatar);
2351
2352 return;
2353 }
2354
2354 if (part.SitTargetAvatar == UUID) 2355 if (part.SitTargetAvatar == UUID)
2355 { 2356 {
2356 Vector3 sitTargetPos = part.SitTargetPosition; 2357 Vector3 sitTargetPos = part.SitTargetPosition;
@@ -2616,6 +2617,7 @@ namespace OpenSim.Region.Framework.Scenes
2616 2617
2617 m_scene.ForEachClient(SendTerseUpdateToClient); 2618 m_scene.ForEachClient(SendTerseUpdateToClient);
2618 } 2619 }
2620 TriggerScenePresenceUpdated();
2619 } 2621 }
2620 2622
2621 public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs) 2623 public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs)
@@ -2694,7 +2696,7 @@ namespace OpenSim.Region.Framework.Scenes
2694 // If we are using the the cached appearance then send it out to everyone 2696 // If we are using the the cached appearance then send it out to everyone
2695 if (cachedappearance) 2697 if (cachedappearance)
2696 { 2698 {
2697 m_log.DebugFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name); 2699 m_log.DebugFormat("[SCENE PRESENCE]: baked textures are in the cache for {0}", Name);
2698 2700
2699 // If the avatars baked textures are all in the cache, then we have a 2701 // If the avatars baked textures are all in the cache, then we have a
2700 // complete appearance... send it out, if not, then we'll send it when 2702 // complete appearance... send it out, if not, then we'll send it when
@@ -3099,8 +3101,8 @@ namespace OpenSim.Region.Framework.Scenes
3099 x = x / Constants.RegionSize; 3101 x = x / Constants.RegionSize;
3100 y = y / Constants.RegionSize; 3102 y = y / Constants.RegionSize;
3101 3103
3102 //m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); 3104// m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX)));
3103 //m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); 3105// m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY)));
3104 if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY)) 3106 if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY))
3105 { 3107 {
3106 byebyeRegions.Add(handle); 3108 byebyeRegions.Add(handle);
@@ -3157,7 +3159,7 @@ namespace OpenSim.Region.Framework.Scenes
3157 3159
3158 public void ChildAgentDataUpdate(AgentData cAgentData) 3160 public void ChildAgentDataUpdate(AgentData cAgentData)
3159 { 3161 {
3160 //m_log.Debug(" >>> ChildAgentDataUpdate <<< " + Scene.RegionInfo.RegionName); 3162// m_log.Debug(" >>> ChildAgentDataUpdate <<< " + Scene.RegionInfo.RegionName);
3161 if (!IsChildAgent) 3163 if (!IsChildAgent)
3162 return; 3164 return;
3163 3165
@@ -3269,31 +3271,8 @@ namespace OpenSim.Region.Framework.Scenes
3269 catch { } 3271 catch { }
3270 cAgent.DefaultAnim = Animator.Animations.DefaultAnimation; 3272 cAgent.DefaultAnim = Animator.Animations.DefaultAnimation;
3271 3273
3272 // Attachment objects 3274 if (Scene.AttachmentsModule != null)
3273 List<SceneObjectGroup> attachments = GetAttachments(); 3275 Scene.AttachmentsModule.CopyAttachments(this, cAgent);
3274 if (attachments.Count > 0)
3275 {
3276 cAgent.AttachmentObjects = new List<ISceneObject>();
3277 cAgent.AttachmentObjectStates = new List<string>();
3278// IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>();
3279 InTransitScriptStates.Clear();
3280
3281 foreach (SceneObjectGroup sog in attachments)
3282 {
3283 // We need to make a copy and pass that copy
3284 // because of transfers withn the same sim
3285 ISceneObject clone = sog.CloneForNewScene();
3286 // Attachment module assumes that GroupPosition holds the offsets...!
3287 ((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos;
3288 ((SceneObjectGroup)clone).IsAttachment = false;
3289 cAgent.AttachmentObjects.Add(clone);
3290 string state = sog.GetStateSnapshot();
3291 cAgent.AttachmentObjectStates.Add(state);
3292 InTransitScriptStates.Add(state);
3293 // Let's remove the scripts of the original object here
3294 sog.RemoveScriptInstances(true);
3295 }
3296 }
3297 } 3276 }
3298 3277
3299 private void CopyFrom(AgentData cAgent) 3278 private void CopyFrom(AgentData cAgent)
@@ -3301,6 +3280,9 @@ namespace OpenSim.Region.Framework.Scenes
3301 m_originRegionID = cAgent.RegionID; 3280 m_originRegionID = cAgent.RegionID;
3302 3281
3303 m_callbackURI = cAgent.CallbackURI; 3282 m_callbackURI = cAgent.CallbackURI;
3283// m_log.DebugFormat(
3284// "[SCENE PRESENCE]: Set callback for {0} in {1} to {2} in CopyFrom()",
3285// Name, m_scene.RegionInfo.RegionName, m_callbackURI);
3304 3286
3305 m_pos = cAgent.Position; 3287 m_pos = cAgent.Position;
3306 m_velocity = cAgent.Velocity; 3288 m_velocity = cAgent.Velocity;
@@ -3365,18 +3347,8 @@ namespace OpenSim.Region.Framework.Scenes
3365 if (cAgent.DefaultAnim != null) 3347 if (cAgent.DefaultAnim != null)
3366 Animator.Animations.SetDefaultAnimation(cAgent.DefaultAnim.AnimID, cAgent.DefaultAnim.SequenceNum, UUID.Zero); 3348 Animator.Animations.SetDefaultAnimation(cAgent.DefaultAnim.AnimID, cAgent.DefaultAnim.SequenceNum, UUID.Zero);
3367 3349
3368 if (cAgent.AttachmentObjects != null && cAgent.AttachmentObjects.Count > 0) 3350 if (Scene.AttachmentsModule != null)
3369 { 3351 Scene.AttachmentsModule.CopyAttachments(cAgent, this);
3370 m_attachments = new List<SceneObjectGroup>();
3371 int i = 0;
3372 foreach (ISceneObject so in cAgent.AttachmentObjects)
3373 {
3374 ((SceneObjectGroup)so).LocalId = 0;
3375 ((SceneObjectGroup)so).RootPart.ClearUpdateSchedule();
3376 so.SetState(cAgent.AttachmentObjectStates[i++], m_scene);
3377 m_scene.IncomingCreateObject(Vector3.Zero, so);
3378 }
3379 }
3380 } 3352 }
3381 3353
3382 public bool CopyAgent(out IAgentData agent) 3354 public bool CopyAgent(out IAgentData agent)
@@ -3402,6 +3374,7 @@ namespace OpenSim.Region.Framework.Scenes
3402 Velocity = force; 3374 Velocity = force;
3403 3375
3404 m_forceToApply = null; 3376 m_forceToApply = null;
3377 TriggerScenePresenceUpdated();
3405 } 3378 }
3406 } 3379 }
3407 3380
@@ -3509,23 +3482,53 @@ namespace OpenSim.Region.Framework.Scenes
3509 3482
3510 RaiseCollisionScriptEvents(coldata); 3483 RaiseCollisionScriptEvents(coldata);
3511 3484
3512 if (Invulnerable || GodLevel >= 200) 3485 // Gods do not take damage and Invulnerable is set depending on parcel/region flags
3486 if (Invulnerable || GodLevel > 0)
3513 return; 3487 return;
3514 3488
3489 // The following may be better in the ICombatModule
3490 // probably tweaking of the values for ground and normal prim collisions will be needed
3515 float starthealth = Health; 3491 float starthealth = Health;
3516 uint killerObj = 0; 3492 uint killerObj = 0;
3493 SceneObjectPart part = null;
3517 foreach (uint localid in coldata.Keys) 3494 foreach (uint localid in coldata.Keys)
3518 { 3495 {
3519 SceneObjectPart part = Scene.GetSceneObjectPart(localid); 3496 if (localid == 0)
3520 3497 {
3521 if (part != null && part.ParentGroup.Damage != -1.0f) 3498 part = null;
3522 Health -= part.ParentGroup.Damage; 3499 }
3500 else
3501 {
3502 part = Scene.GetSceneObjectPart(localid);
3503 }
3504 if (part != null)
3505 {
3506 // Ignore if it has been deleted or volume detect
3507 if (!part.ParentGroup.IsDeleted && !part.ParentGroup.IsVolumeDetect)
3508 {
3509 if (part.ParentGroup.Damage > 0.0f)
3510 {
3511 // Something with damage...
3512 Health -= part.ParentGroup.Damage;
3513 part.ParentGroup.Scene.DeleteSceneObject(part.ParentGroup, false);
3514 }
3515 else
3516 {
3517 // An ordinary prim
3518 if (coldata[localid].PenetrationDepth >= 0.10f)
3519 Health -= coldata[localid].PenetrationDepth * 5.0f;
3520 }
3521 }
3522 }
3523 else 3523 else
3524 { 3524 {
3525 if (coldata[localid].PenetrationDepth >= 0.10f) 3525 // 0 is the ground
3526 // what about collisions with other avatars?
3527 if (localid == 0 && coldata[localid].PenetrationDepth >= 0.10f)
3526 Health -= coldata[localid].PenetrationDepth * 5.0f; 3528 Health -= coldata[localid].PenetrationDepth * 5.0f;
3527 } 3529 }
3528 3530
3531
3529 if (Health <= 0.0f) 3532 if (Health <= 0.0f)
3530 { 3533 {
3531 if (localid != 0) 3534 if (localid != 0)
@@ -3541,7 +3544,16 @@ namespace OpenSim.Region.Framework.Scenes
3541 ControllingClient.SendHealth(Health); 3544 ControllingClient.SendHealth(Health);
3542 } 3545 }
3543 if (Health <= 0) 3546 if (Health <= 0)
3547 {
3544 m_scene.EventManager.TriggerAvatarKill(killerObj, this); 3548 m_scene.EventManager.TriggerAvatarKill(killerObj, this);
3549 }
3550 if (starthealth == Health && Health < 100.0f)
3551 {
3552 Health += 0.03f;
3553 if (Health > 100.0f)
3554 Health = 100.0f;
3555 ControllingClient.SendHealth(Health);
3556 }
3545 } 3557 }
3546 } 3558 }
3547 3559
@@ -3553,9 +3565,6 @@ namespace OpenSim.Region.Framework.Scenes
3553 3565
3554 public void Close() 3566 public void Close()
3555 { 3567 {
3556 if (!IsChildAgent)
3557 m_scene.AttachmentsModule.DeleteAttachmentsFromScene(this, false);
3558
3559 // Clear known regions 3568 // Clear known regions
3560 KnownRegions = new Dictionary<ulong, string>(); 3569 KnownRegions = new Dictionary<ulong, string>();
3561 3570
@@ -3624,6 +3633,63 @@ namespace OpenSim.Region.Framework.Scenes
3624 return m_attachments.Count > 0; 3633 return m_attachments.Count > 0;
3625 } 3634 }
3626 3635
3636 /// <summary>
3637 /// Returns the total count of scripts in all parts inventories.
3638 /// </summary>
3639 public int ScriptCount()
3640 {
3641 int count = 0;
3642 lock (m_attachments)
3643 {
3644 foreach (SceneObjectGroup gobj in m_attachments)
3645 {
3646 if (gobj != null)
3647 {
3648 count += gobj.ScriptCount();
3649 }
3650 }
3651 }
3652 return count;
3653 }
3654
3655 /// <summary>
3656 /// A float the value is a representative execution time in milliseconds of all scripts in all attachments.
3657 /// </summary>
3658 public float ScriptExecutionTime()
3659 {
3660 float time = 0.0f;
3661 lock (m_attachments)
3662 {
3663 foreach (SceneObjectGroup gobj in m_attachments)
3664 {
3665 if (gobj != null)
3666 {
3667 time += gobj.ScriptExecutionTime();
3668 }
3669 }
3670 }
3671 return time;
3672 }
3673
3674 /// <summary>
3675 /// Returns the total count of running scripts in all parts.
3676 /// </summary>
3677 public int RunningScriptCount()
3678 {
3679 int count = 0;
3680 lock (m_attachments)
3681 {
3682 foreach (SceneObjectGroup gobj in m_attachments)
3683 {
3684 if (gobj != null)
3685 {
3686 count += gobj.RunningScriptCount();
3687 }
3688 }
3689 }
3690 return count;
3691 }
3692
3627 public bool HasScriptedAttachments() 3693 public bool HasScriptedAttachments()
3628 { 3694 {
3629 lock (m_attachments) 3695 lock (m_attachments)
@@ -3841,77 +3907,92 @@ namespace OpenSim.Region.Framework.Scenes
3841 } 3907 }
3842 } 3908 }
3843 3909
3844 internal void SendControlToScripts(uint flags) 3910 private void SendControlsToScripts(uint flags)
3845 { 3911 {
3846 ScriptControlled allflags = ScriptControlled.CONTROL_ZERO; 3912 // Notify the scripts only after calling UpdateMovementAnimations(), so that if a script
3847 3913 // (e.g., a walking script) checks which animation is active it will be the correct animation.
3848 if (MouseDown) 3914 lock (scriptedcontrols)
3849 { 3915 {
3850 allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON); 3916 if (scriptedcontrols.Count <= 0)
3851 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0) 3917 return;
3918
3919 ScriptControlled allflags = ScriptControlled.CONTROL_ZERO;
3920
3921 if (MouseDown)
3852 { 3922 {
3853 allflags = ScriptControlled.CONTROL_ZERO; 3923 allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON);
3924 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0)
3925 {
3926 allflags = ScriptControlled.CONTROL_ZERO;
3927 MouseDown = true;
3928 }
3929 }
3930
3931 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0)
3932 {
3933 allflags |= ScriptControlled.CONTROL_ML_LBUTTON;
3854 MouseDown = true; 3934 MouseDown = true;
3855 } 3935 }
3856 } 3936
3937 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0)
3938 {
3939 allflags |= ScriptControlled.CONTROL_LBUTTON;
3940 MouseDown = true;
3941 }
3942
3943 // find all activated controls, whether the scripts are interested in them or not
3944 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0)
3945 {
3946 allflags |= ScriptControlled.CONTROL_FWD;
3947 }
3948
3949 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0)
3950 {
3951 allflags |= ScriptControlled.CONTROL_BACK;
3952 }
3953
3954 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0)
3955 {
3956 allflags |= ScriptControlled.CONTROL_UP;
3957 }
3958
3959 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)
3960 {
3961 allflags |= ScriptControlled.CONTROL_DOWN;
3962 }
3857 3963
3858 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0) 3964 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0)
3859 { 3965 {
3860 allflags |= ScriptControlled.CONTROL_ML_LBUTTON; 3966 allflags |= ScriptControlled.CONTROL_LEFT;
3861 MouseDown = true; 3967 }
3862 } 3968
3863 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0) 3969 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0)
3864 { 3970 {
3865 allflags |= ScriptControlled.CONTROL_LBUTTON; 3971 allflags |= ScriptControlled.CONTROL_RIGHT;
3866 MouseDown = true; 3972 }
3867 } 3973
3974 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
3975 {
3976 allflags |= ScriptControlled.CONTROL_ROT_RIGHT;
3977 }
3978
3979 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)
3980 {
3981 allflags |= ScriptControlled.CONTROL_ROT_LEFT;
3982 }
3868 3983
3869 // find all activated controls, whether the scripts are interested in them or not 3984 // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that
3870 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0) 3985 if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands)
3871 {
3872 allflags |= ScriptControlled.CONTROL_FWD;
3873 }
3874 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0)
3875 {
3876 allflags |= ScriptControlled.CONTROL_BACK;
3877 }
3878 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0)
3879 {
3880 allflags |= ScriptControlled.CONTROL_UP;
3881 }
3882 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)
3883 {
3884 allflags |= ScriptControlled.CONTROL_DOWN;
3885 }
3886 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0)
3887 {
3888 allflags |= ScriptControlled.CONTROL_LEFT;
3889 }
3890 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0)
3891 {
3892 allflags |= ScriptControlled.CONTROL_RIGHT;
3893 }
3894 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
3895 {
3896 allflags |= ScriptControlled.CONTROL_ROT_RIGHT;
3897 }
3898 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)
3899 {
3900 allflags |= ScriptControlled.CONTROL_ROT_LEFT;
3901 }
3902 // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that
3903 if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands)
3904 {
3905 lock (scriptedcontrols)
3906 { 3986 {
3907 foreach (KeyValuePair<UUID, ScriptControllers> kvp in scriptedcontrols) 3987 foreach (KeyValuePair<UUID, ScriptControllers> kvp in scriptedcontrols)
3908 { 3988 {
3909 UUID scriptUUID = kvp.Key; 3989 UUID scriptUUID = kvp.Key;
3910 ScriptControllers scriptControlData = kvp.Value; 3990 ScriptControllers scriptControlData = kvp.Value;
3911 3991
3912 ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us 3992 ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us
3913 ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle 3993 ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle
3914 ScriptControlled localChange = localHeld ^ localLast; // the changed bits 3994 ScriptControlled localChange = localHeld ^ localLast; // the changed bits
3995
3915 if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO) 3996 if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO)
3916 { 3997 {
3917 // only send if still pressed or just changed 3998 // only send if still pressed or just changed
@@ -3919,9 +4000,9 @@ namespace OpenSim.Region.Framework.Scenes
3919 } 4000 }
3920 } 4001 }
3921 } 4002 }
4003
4004 LastCommands = allflags;
3922 } 4005 }
3923
3924 LastCommands = allflags;
3925 } 4006 }
3926 4007
3927 internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored) 4008 internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored)
@@ -4001,7 +4082,7 @@ namespace OpenSim.Region.Framework.Scenes
4001 land.LandData.UserLocation != Vector3.Zero && 4082 land.LandData.UserLocation != Vector3.Zero &&
4002 land.LandData.OwnerID != m_uuid && 4083 land.LandData.OwnerID != m_uuid &&
4003 (!m_scene.Permissions.IsGod(m_uuid)) && 4084 (!m_scene.Permissions.IsGod(m_uuid)) &&
4004 (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) 4085 (!m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)))
4005 { 4086 {
4006 float curr = Vector3.Distance(AbsolutePosition, pos); 4087 float curr = Vector3.Distance(AbsolutePosition, pos);
4007 if (Vector3.Distance(land.LandData.UserLocation, pos) < curr) 4088 if (Vector3.Distance(land.LandData.UserLocation, pos) < curr)
@@ -4015,13 +4096,13 @@ namespace OpenSim.Region.Framework.Scenes
4015 { 4096 {
4016 if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) == 4097 if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) ==
4017 (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) || 4098 (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) ||
4018 (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 || 4099 (m_scene.TelehubAllowLandmarks == true ? false : ((m_teleportFlags & TeleportFlags.ViaLandmark) != 0 )) ||
4019 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || 4100 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
4020 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0) 4101 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)
4021 { 4102 {
4022 if (GodLevel < 200 && 4103 if (GodLevel < 200 &&
4023 ((!m_scene.Permissions.IsGod(m_uuid) && 4104 ((!m_scene.Permissions.IsGod(m_uuid) &&
4024 !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) || 4105 !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) ||
4025 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || 4106 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
4026 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) 4107 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0))
4027 { 4108 {
@@ -4029,28 +4110,92 @@ namespace OpenSim.Region.Framework.Scenes
4029 if (spawnPoints.Length == 0) 4110 if (spawnPoints.Length == 0)
4030 return; 4111 return;
4031 4112
4032 float distance = 9999; 4113 int index;
4033 int closest = -1; 4114 bool selected = false;
4034 4115
4035 for (int i = 0 ; i < spawnPoints.Length ; i++) 4116 switch (m_scene.SpawnPointRouting)
4036 { 4117 {
4037 Vector3 spawnPosition = spawnPoints[i].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); 4118 case "random":
4038 Vector3 offset = spawnPosition - pos;
4039 float d = Vector3.Mag(offset);
4040 if (d >= distance)
4041 continue;
4042 ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y);
4043 if (land == null)
4044 continue;
4045 if (land.IsEitherBannedOrRestricted(UUID))
4046 continue;
4047 distance = d;
4048 closest = i;
4049 }
4050 if (closest == -1)
4051 return;
4052 4119
4053 pos = spawnPoints[closest].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); 4120 do
4121 {
4122 index = Util.RandomClass.Next(spawnPoints.Length - 1);
4123
4124 Vector3 spawnPosition = spawnPoints[index].GetLocation(
4125 telehub.AbsolutePosition,
4126 telehub.GroupRotation
4127 );
4128 // SpawnPoint sp = spawnPoints[index];
4129
4130 ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y);
4131 if (land == null || land.IsEitherBannedOrRestricted(UUID))
4132 selected = false;
4133 else
4134 selected = true;
4135
4136 } while ( selected == false);
4137
4138 pos = spawnPoints[index].GetLocation(
4139 telehub.AbsolutePosition,
4140 telehub.GroupRotation
4141 );
4142 return;
4143
4144 case "sequence":
4145
4146 do
4147 {
4148 index = m_scene.SpawnPoint();
4149
4150 Vector3 spawnPosition = spawnPoints[index].GetLocation(
4151 telehub.AbsolutePosition,
4152 telehub.GroupRotation
4153 );
4154 // SpawnPoint sp = spawnPoints[index];
4155
4156 ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y);
4157 if (land == null || land.IsEitherBannedOrRestricted(UUID))
4158 selected = false;
4159 else
4160 selected = true;
4161
4162 } while (selected == false);
4163
4164 pos = spawnPoints[index].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation);
4165 ;
4166 return;
4167
4168 default:
4169 case "closest":
4170
4171 float distance = 9999;
4172 int closest = -1;
4173
4174 for (int i = 0; i < spawnPoints.Length; i++)
4175 {
4176 Vector3 spawnPosition = spawnPoints[i].GetLocation(
4177 telehub.AbsolutePosition,
4178 telehub.GroupRotation
4179 );
4180 Vector3 offset = spawnPosition - pos;
4181 float d = Vector3.Mag(offset);
4182 if (d >= distance)
4183 continue;
4184 ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y);
4185 if (land == null)
4186 continue;
4187 if (land.IsEitherBannedOrRestricted(UUID))
4188 continue;
4189 distance = d;
4190 closest = i;
4191 }
4192 if (closest == -1)
4193 return;
4194
4195 pos = spawnPoints[closest].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation);
4196 return;
4197
4198 }
4054 } 4199 }
4055 } 4200 }
4056 } 4201 }
@@ -4095,7 +4240,7 @@ namespace OpenSim.Region.Framework.Scenes
4095 GodLevel < 200 && 4240 GodLevel < 200 &&
4096 ((land.LandData.OwnerID != m_uuid && 4241 ((land.LandData.OwnerID != m_uuid &&
4097 !m_scene.Permissions.IsGod(m_uuid) && 4242 !m_scene.Permissions.IsGod(m_uuid) &&
4098 !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) || 4243 !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) ||
4099 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || 4244 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
4100 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) 4245 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0))
4101 { 4246 {
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 abca14f..2372d6b 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -1537,51 +1537,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1537 } 1537 }
1538 } 1538 }
1539 1539
1540 //////// Read /////////
1541 public static bool Xml2ToSOG(XmlTextReader reader, SceneObjectGroup sog)
1542 {
1543 reader.Read();
1544 reader.ReadStartElement("SceneObjectGroup");
1545 SceneObjectPart root = Xml2ToSOP(reader);
1546 if (root != null)
1547 sog.SetRootPart(root);
1548 else
1549 {
1550 return false;
1551 }
1552
1553 if (sog.UUID == UUID.Zero)
1554 sog.UUID = sog.RootPart.UUID;
1555
1556 reader.Read(); // OtherParts
1557
1558 while (!reader.EOF)
1559 {
1560 switch (reader.NodeType)
1561 {
1562 case XmlNodeType.Element:
1563 if (reader.Name == "SceneObjectPart")
1564 {
1565 SceneObjectPart child = Xml2ToSOP(reader);
1566 if (child != null)
1567 sog.AddPart(child);
1568 }
1569 else
1570 {
1571 //Logger.Log("Found unexpected prim XML element " + reader.Name, Helpers.LogLevel.Debug);
1572 reader.Read();
1573 }
1574 break;
1575 case XmlNodeType.EndElement:
1576 default:
1577 reader.Read();
1578 break;
1579 }
1580
1581 }
1582 return true;
1583 }
1584
1585 public static SceneObjectPart Xml2ToSOP(XmlTextReader reader) 1540 public static SceneObjectPart Xml2ToSOP(XmlTextReader reader)
1586 { 1541 {
1587 SceneObjectPart obj = new SceneObjectPart(); 1542 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..3398a53 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,11 +185,16 @@ 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 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene);
190 scene.DeleteSceneObject(part.ParentGroup, false);
191 190
192 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); 191 Assert.That(so.IsDeleted, Is.False);
192
193 scene.DeleteSceneObject(so, false);
194
195 Assert.That(so.IsDeleted, Is.True);
196
197 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);
193 Assert.That(retrievedPart, Is.Null); 198 Assert.That(retrievedPart, Is.Null);
194 } 199 }
195 200
@@ -204,24 +209,28 @@ 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;
211 sogd.Enabled = false; 216 sogd.Enabled = false;
212 217
213 SceneObjectPart part = SceneHelpers.AddSceneObject(scene); 218 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene);
214 219
215 IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient; 220 IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient;
216 scene.DeRezObjects(client, new System.Collections.Generic.List<uint>() { part.LocalId }, UUID.Zero, DeRezAction.Delete, UUID.Zero); 221 scene.DeRezObjects(client, new System.Collections.Generic.List<uint>() { so.LocalId }, UUID.Zero, DeRezAction.Delete, UUID.Zero);
217 222
218 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); 223 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);
219 224
220 Assert.That(retrievedPart, Is.Not.Null); 225 Assert.That(retrievedPart, Is.Not.Null);
221 226
227 Assert.That(so.IsDeleted, Is.False);
228
222 sogd.InventoryDeQueueAndDelete(); 229 sogd.InventoryDeQueueAndDelete();
223 230
224 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId); 231 Assert.That(so.IsDeleted, Is.True);
232
233 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId);
225 Assert.That(retrievedPart2, Is.Null); 234 Assert.That(retrievedPart2, Is.Null);
226 } 235 }
227 236
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..0e525c9 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,11 +71,11 @@ 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 SceneObjectGroup grp1 = SceneHelpers.AddSceneObject(scene);
76 SceneObjectGroup grp1 = part1.ParentGroup; 76 SceneObjectPart part1 = grp1.RootPart;
77 SceneObjectPart part2 = SceneHelpers.AddSceneObject(scene); 77 SceneObjectGroup grp2 = SceneHelpers.AddSceneObject(scene);
78 SceneObjectGroup grp2 = part2.ParentGroup; 78 SceneObjectPart part2 = grp2.RootPart;
79 79
80 grp1.AbsolutePosition = new Vector3(10, 10, 10); 80 grp1.AbsolutePosition = new Vector3(10, 10, 10);
81 grp2.AbsolutePosition = Vector3.Zero; 81 grp2.AbsolutePosition = Vector3.Zero;
@@ -153,15 +153,15 @@ 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 SceneObjectGroup grp1 = SceneHelpers.AddSceneObject(scene);
158 SceneObjectGroup grp1 = part1.ParentGroup; 158 SceneObjectPart part1 = grp1.RootPart;
159 SceneObjectPart part2 = SceneHelpers.AddSceneObject(scene); 159 SceneObjectGroup grp2 = SceneHelpers.AddSceneObject(scene);
160 SceneObjectGroup grp2 = part2.ParentGroup; 160 SceneObjectPart part2 = grp2.RootPart;
161 SceneObjectPart part3 = SceneHelpers.AddSceneObject(scene); 161 SceneObjectGroup grp3 = SceneHelpers.AddSceneObject(scene);
162 SceneObjectGroup grp3 = part3.ParentGroup; 162 SceneObjectPart part3 = grp3.RootPart;
163 SceneObjectPart part4 = SceneHelpers.AddSceneObject(scene); 163 SceneObjectGroup grp4 = SceneHelpers.AddSceneObject(scene);
164 SceneObjectGroup grp4 = part4.ParentGroup; 164 SceneObjectPart part4 = grp4.RootPart;
165 165
166 grp1.AbsolutePosition = new Vector3(10, 10, 10); 166 grp1.AbsolutePosition = new Vector3(10, 10, 10);
167 grp2.AbsolutePosition = Vector3.Zero; 167 grp2.AbsolutePosition = Vector3.Zero;
@@ -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..e931859 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
@@ -52,8 +52,8 @@ 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);
57 57
58 g1.GroupResize(new Vector3(2, 3, 4)); 58 g1.GroupResize(new Vector3(2, 3, 4));
59 59
@@ -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..493ab70 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using System.Reflection; 30using System.Reflection;
30using Nini.Config; 31using Nini.Config;
31using NUnit.Framework; 32using NUnit.Framework;
@@ -50,7 +51,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
50 [SetUp] 51 [SetUp]
51 public void Init() 52 public void Init()
52 { 53 {
53 m_scene = SceneHelpers.SetupScene(); 54 m_scene = new SceneHelpers().SetupScene();
54 m_sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); 55 m_sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1));
55 } 56 }
56 57
@@ -64,11 +65,13 @@ namespace OpenSim.Region.Framework.Scenes.Tests
64 Vector3 startPos = new Vector3(10.1f, 0, 0); 65 Vector3 startPos = new Vector3(10.1f, 0, 0);
65 m_sp.AbsolutePosition = startPos; 66 m_sp.AbsolutePosition = startPos;
66 67
67 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); 68 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart;
68 69
69 m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); 70 m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero);
70 71
71 Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); 72 Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
73 Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(0));
74 Assert.That(part.GetSittingAvatars(), Is.Null);
72 Assert.That(m_sp.ParentID, Is.EqualTo(0)); 75 Assert.That(m_sp.ParentID, Is.EqualTo(0));
73 } 76 }
74 77
@@ -82,11 +85,17 @@ namespace OpenSim.Region.Framework.Scenes.Tests
82 Vector3 startPos = new Vector3(9.9f, 0, 0); 85 Vector3 startPos = new Vector3(9.9f, 0, 0);
83 m_sp.AbsolutePosition = startPos; 86 m_sp.AbsolutePosition = startPos;
84 87
85 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); 88 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart;
86 89
87 m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); 90 m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero);
88 91
92 Assert.That(m_sp.PhysicsActor, Is.Null);
93
89 Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); 94 Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
95 Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(1));
96 HashSet<UUID> sittingAvatars = part.GetSittingAvatars();
97 Assert.That(sittingAvatars.Count, Is.EqualTo(1));
98 Assert.That(sittingAvatars.Contains(m_sp.UUID));
90 Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId)); 99 Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId));
91 } 100 }
92 101
@@ -100,14 +109,10 @@ namespace OpenSim.Region.Framework.Scenes.Tests
100 Vector3 startPos = new Vector3(1, 1, 1); 109 Vector3 startPos = new Vector3(1, 1, 1);
101 m_sp.AbsolutePosition = startPos; 110 m_sp.AbsolutePosition = startPos;
102 111
103 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); 112 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart;
104 113
105 m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); 114 m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero);
106 115
107 Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
108 Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId));
109 Assert.That(m_sp.PhysicsActor, Is.Null);
110
111 // FIXME: This is different for live avatars - z position is adjusted. This is half the height of the 116 // FIXME: This is different for live avatars - z position is adjusted. This is half the height of the
112 // default avatar. 117 // default avatar.
113 // Curiously, Vector3.ToString() will not display the last two places of the float. For example, 118 // Curiously, Vector3.ToString() will not display the last two places of the float. For example,
@@ -119,6 +124,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
119 m_sp.StandUp(); 124 m_sp.StandUp();
120 125
121 Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); 126 Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
127 Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(0));
128 Assert.That(part.GetSittingAvatars(), Is.Null);
122 Assert.That(m_sp.ParentID, Is.EqualTo(0)); 129 Assert.That(m_sp.ParentID, Is.EqualTo(0));
123 Assert.That(m_sp.PhysicsActor, Is.Not.Null); 130 Assert.That(m_sp.PhysicsActor, Is.Not.Null);
124 } 131 }
@@ -133,7 +140,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
133 Vector3 startPos = new Vector3(128, 128, 30); 140 Vector3 startPos = new Vector3(128, 128, 30);
134 m_sp.AbsolutePosition = startPos; 141 m_sp.AbsolutePosition = startPos;
135 142
136 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); 143 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart;
137 part.SitTargetPosition = new Vector3(0, 0, 1); 144 part.SitTargetPosition = new Vector3(0, 0, 1);
138 145
139 m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); 146 m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero);
@@ -145,11 +152,20 @@ namespace OpenSim.Region.Framework.Scenes.Tests
145 Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT)); 152 Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT));
146 Assert.That(m_sp.PhysicsActor, Is.Null); 153 Assert.That(m_sp.PhysicsActor, Is.Null);
147 154
155 Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(1));
156 HashSet<UUID> sittingAvatars = part.GetSittingAvatars();
157 Assert.That(sittingAvatars.Count, Is.EqualTo(1));
158 Assert.That(sittingAvatars.Contains(m_sp.UUID));
159
148 m_sp.StandUp(); 160 m_sp.StandUp();
149 161
150 Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); 162 Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
151 Assert.That(m_sp.ParentID, Is.EqualTo(0)); 163 Assert.That(m_sp.ParentID, Is.EqualTo(0));
152 Assert.That(m_sp.PhysicsActor, Is.Not.Null); 164 Assert.That(m_sp.PhysicsActor, Is.Not.Null);
165
166 Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
167 Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(0));
168 Assert.That(part.GetSittingAvatars(), Is.Null);
153 } 169 }
154 170
155 [Test] 171 [Test]
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..a51e4e3 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,11 +124,13 @@ 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;
131 TaskInventoryItem sopItem1 = TaskInventoryHelpers.AddNotecard(scene, sop1); 131 TaskInventoryItem sopItem1
132 = TaskInventoryHelpers.AddNotecard(
133 scene, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900));
132 134
133 InventoryFolderBase folder 135 InventoryFolderBase folder
134 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, user1.PrincipalID, "Objects")[0]; 136 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, user1.PrincipalID, "Objects")[0];
@@ -153,11 +155,14 @@ namespace OpenSim.Region.Framework.Tests
153 TestHelpers.InMethod(); 155 TestHelpers.InMethod();
154// log4net.Config.XmlConfigurator.Configure(); 156// log4net.Config.XmlConfigurator.Configure();
155 157
156 Scene scene = SceneHelpers.SetupScene(); 158 Scene scene = new SceneHelpers().SetupScene();
157 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); 159 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene);
158 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); 160 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID);
161
159 SceneObjectPart sop1 = sog1.RootPart; 162 SceneObjectPart sop1 = sog1.RootPart;
160 TaskInventoryItem sopItem1 = TaskInventoryHelpers.AddNotecard(scene, sop1); 163 TaskInventoryItem sopItem1
164 = TaskInventoryHelpers.AddNotecard(
165 scene, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900));
161 166
162 // Perform test 167 // Perform test
163 scene.MoveTaskInventoryItem(user1.PrincipalID, UUID.Zero, sop1, sopItem1.ItemID); 168 scene.MoveTaskInventoryItem(user1.PrincipalID, UUID.Zero, sop1, sopItem1.ItemID);
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 }