aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2014-01-24 19:16:59 +0000
committerJustin Clark-Casey (justincc)2014-01-24 19:16:59 +0000
commit87e725cd2474efcdfec3d85794ef2b877c8b78d6 (patch)
treeffd2f4e5fffecb84e76f07d3fd87d9f29b5fcada /OpenSim/Region/Framework/Scenes
parentChange version to 0.7.6.1-rc1 instead (diff)
parentProperly dispose of drawing objects to reduce/stop memory leakage on generati... (diff)
downloadopensim-SC_OLD-87e725cd2474efcdfec3d85794ef2b877c8b78d6.zip
opensim-SC_OLD-87e725cd2474efcdfec3d85794ef2b877c8b78d6.tar.gz
opensim-SC_OLD-87e725cd2474efcdfec3d85794ef2b877c8b78d6.tar.bz2
opensim-SC_OLD-87e725cd2474efcdfec3d85794ef2b877c8b78d6.tar.xz
Merge branch '0.7.6-extended' into 0.7.6-post-fixes
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs50
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs33
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs92
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneTelehubTests.cs119
4 files changed, 222 insertions, 72 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 7772f94..420c0b5 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -3946,32 +3946,52 @@ namespace OpenSim.Region.Framework.Scenes
3946 } 3946 }
3947 } 3947 }
3948 3948
3949// m_log.DebugFormat(
3950// "[SCENE]: Found telehub object {0} for new user connection {1} to {2}",
3951// RegionInfo.RegionSettings.TelehubObject, acd.Name, Name);
3952
3949 // Honor Estate teleport routing via Telehubs excluding ViaHome and GodLike TeleportFlags 3953 // Honor Estate teleport routing via Telehubs excluding ViaHome and GodLike TeleportFlags
3950 if (RegionInfo.RegionSettings.TelehubObject != UUID.Zero && 3954 if (RegionInfo.RegionSettings.TelehubObject != UUID.Zero &&
3951 RegionInfo.EstateSettings.AllowDirectTeleport == false && 3955 RegionInfo.EstateSettings.AllowDirectTeleport == false &&
3952 !viahome && !godlike) 3956 !viahome && !godlike)
3953 { 3957 {
3954 SceneObjectGroup telehub = GetSceneObjectGroup(RegionInfo.RegionSettings.TelehubObject); 3958 SceneObjectGroup telehub = GetSceneObjectGroup(RegionInfo.RegionSettings.TelehubObject);
3955 // Can have multiple SpawnPoints 3959
3956 List<SpawnPoint> spawnpoints = RegionInfo.RegionSettings.SpawnPoints(); 3960 if (telehub != null)
3957 if (spawnpoints.Count > 1)
3958 { 3961 {
3959 // We have multiple SpawnPoints, Route the agent to a random or sequential one 3962 // Can have multiple SpawnPoints
3960 if (SpawnPointRouting == "random") 3963 List<SpawnPoint> spawnpoints = RegionInfo.RegionSettings.SpawnPoints();
3961 acd.startpos = spawnpoints[Util.RandomClass.Next(spawnpoints.Count) - 1].GetLocation( 3964 if (spawnpoints.Count > 1)
3962 telehub.AbsolutePosition, 3965 {
3963 telehub.GroupRotation 3966 // We have multiple SpawnPoints, Route the agent to a random or sequential one
3964 ); 3967 if (SpawnPointRouting == "random")
3968 acd.startpos = spawnpoints[Util.RandomClass.Next(spawnpoints.Count) - 1].GetLocation(
3969 telehub.AbsolutePosition,
3970 telehub.GroupRotation
3971 );
3972 else
3973 acd.startpos = spawnpoints[SpawnPoint()].GetLocation(
3974 telehub.AbsolutePosition,
3975 telehub.GroupRotation
3976 );
3977 }
3978 else if (spawnpoints.Count == 1)
3979 {
3980 // We have a single SpawnPoint and will route the agent to it
3981 acd.startpos = spawnpoints[0].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation);
3982 }
3965 else 3983 else
3966 acd.startpos = spawnpoints[SpawnPoint()].GetLocation( 3984 {
3967 telehub.AbsolutePosition, 3985 m_log.DebugFormat(
3968 telehub.GroupRotation 3986 "[SCENE]: No spawnpoints defined for telehub {0} for {1} in {2}. Continuing.",
3969 ); 3987 RegionInfo.RegionSettings.TelehubObject, acd.Name, Name);
3988 }
3970 } 3989 }
3971 else 3990 else
3972 { 3991 {
3973 // We have a single SpawnPoint and will route the agent to it 3992 m_log.DebugFormat(
3974 acd.startpos = spawnpoints[0].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); 3993 "[SCENE]: No telehub {0} found to direct {1} in {2}. Continuing.",
3994 RegionInfo.RegionSettings.TelehubObject, acd.Name, Name);
3975 } 3995 }
3976 3996
3977 return true; 3997 return true;
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 7243db1..c2554d8 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -108,6 +108,16 @@ namespace OpenSim.Region.Framework.Scenes
108 } 108 }
109 } 109 }
110 110
111 /// <summary>
112 /// This exists to prevent race conditions between two CompleteMovement threads if the simulator is slow and
113 /// the viewer fires these in quick succession.
114 /// </summary>
115 /// <remarks>
116 /// TODO: The child -> agent transition should be folded into LifecycleState and the CompleteMovement
117 /// regulation done there.
118 /// </remarks>
119 private object m_completeMovementLock = new object();
120
111// private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); 121// private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes();
112 private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags)); 122 private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags));
113 private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f); 123 private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f);
@@ -904,6 +914,7 @@ namespace OpenSim.Region.Framework.Scenes
904 /// <summary> 914 /// <summary>
905 /// Turns a child agent into a root agent. 915 /// Turns a child agent into a root agent.
906 /// </summary> 916 /// </summary>
917 /// <remarks>
907 /// Child agents are logged into neighbouring sims largely to observe changes. Root agents exist when the 918 /// Child agents are logged into neighbouring sims largely to observe changes. Root agents exist when the
908 /// avatar is actual in the sim. They can perform all actions. 919 /// avatar is actual in the sim. They can perform all actions.
909 /// This change is made whenever an avatar enters a region, whether by crossing over from a neighbouring sim, 920 /// This change is made whenever an avatar enters a region, whether by crossing over from a neighbouring sim,
@@ -911,8 +922,8 @@ namespace OpenSim.Region.Framework.Scenes
911 /// 922 ///
912 /// This method is on the critical path for transferring an avatar from one region to another. Delay here 923 /// This method is on the critical path for transferring an avatar from one region to another. Delay here
913 /// delays that crossing. 924 /// delays that crossing.
914 /// </summary> 925 /// </remarks>
915 private void MakeRootAgent(Vector3 pos, bool isFlying) 926 private bool MakeRootAgent(Vector3 pos, bool isFlying)
916 { 927 {
917// m_log.InfoFormat( 928// m_log.InfoFormat(
918// "[SCENE]: Upgrading child to root agent for {0} in {1}", 929// "[SCENE]: Upgrading child to root agent for {0} in {1}",
@@ -920,7 +931,13 @@ namespace OpenSim.Region.Framework.Scenes
920 931
921 //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); 932 //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count);
922 933
923 IsChildAgent = false; 934 lock (m_completeMovementLock)
935 {
936 if (!IsChildAgent)
937 return false;
938
939 IsChildAgent = false;
940 }
924 941
925 // Must reset this here so that a teleport to a region next to an existing region does not keep the flag 942 // Must reset this here so that a teleport to a region next to an existing region does not keep the flag
926 // set and prevent the close of the connection on a subsequent re-teleport. 943 // set and prevent the close of the connection on a subsequent re-teleport.
@@ -1069,6 +1086,7 @@ namespace OpenSim.Region.Framework.Scenes
1069 1086
1070 m_scene.EventManager.TriggerOnMakeRootAgent(this); 1087 m_scene.EventManager.TriggerOnMakeRootAgent(this);
1071 1088
1089 return true;
1072 } 1090 }
1073 1091
1074 public int GetStateSource() 1092 public int GetStateSource()
@@ -1442,7 +1460,14 @@ namespace OpenSim.Region.Framework.Scenes
1442 } 1460 }
1443 1461
1444 bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); 1462 bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
1445 MakeRootAgent(AbsolutePosition, flying); 1463 if (!MakeRootAgent(AbsolutePosition, flying))
1464 {
1465 m_log.DebugFormat(
1466 "[SCENE PRESENCE]: Aborting CompleteMovement call for {0} in {1} as they are already root",
1467 Name, Scene.Name);
1468
1469 return;
1470 }
1446 1471
1447 // Tell the client that we're totally ready 1472 // Tell the client that we're totally ready
1448 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); 1473 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
index d1aeaee..1ff1329 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
@@ -111,6 +111,45 @@ namespace OpenSim.Region.Framework.Scenes.Tests
111 Assert.That(scene.GetScenePresences().Count, Is.EqualTo(1)); 111 Assert.That(scene.GetScenePresences().Count, Is.EqualTo(1));
112 } 112 }
113 113
114 /// <summary>
115 /// Test that duplicate complete movement calls are ignored.
116 /// </summary>
117 /// <remarks>
118 /// If duplicate calls are not ignored then there is a risk of race conditions or other unexpected effects.
119 /// </remarks>
120 [Test]
121 public void TestDupeCompleteMovementCalls()
122 {
123 TestHelpers.InMethod();
124// TestHelpers.EnableLogging();
125
126 UUID spUuid = TestHelpers.ParseTail(0x1);
127
128 TestScene scene = new SceneHelpers().SetupScene();
129
130 int makeRootAgentEvents = 0;
131 scene.EventManager.OnMakeRootAgent += spi => makeRootAgentEvents++;
132
133 ScenePresence sp = SceneHelpers.AddScenePresence(scene, spUuid);
134
135 Assert.That(makeRootAgentEvents, Is.EqualTo(1));
136
137 // Normally these would be invoked by a CompleteMovement message coming in to the UDP stack. But for
138 // convenience, here we will invoke it manually.
139 sp.CompleteMovement(sp.ControllingClient, true);
140
141 Assert.That(makeRootAgentEvents, Is.EqualTo(1));
142
143 // Check rest of exepcted parameters.
144 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(spUuid), Is.Not.Null);
145 Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1));
146
147 Assert.That(sp.IsChildAgent, Is.False);
148 Assert.That(sp.UUID, Is.EqualTo(spUuid));
149
150 Assert.That(scene.GetScenePresences().Count, Is.EqualTo(1));
151 }
152
114 [Test] 153 [Test]
115 public void TestCreateDuplicateRootScenePresence() 154 public void TestCreateDuplicateRootScenePresence()
116 { 155 {
@@ -249,58 +288,5 @@ namespace OpenSim.Region.Framework.Scenes.Tests
249// Assert.That(childPresence, Is.Not.Null); 288// Assert.That(childPresence, Is.Not.Null);
250// Assert.That(childPresence.IsChildAgent, Is.True); 289// Assert.That(childPresence.IsChildAgent, Is.True);
251 } 290 }
252
253// /// <summary>
254// /// Test adding a root agent to a scene. Doesn't yet actually complete crossing the agent into the scene.
255// /// </summary>
256// [Test]
257// public void T010_TestAddRootAgent()
258// {
259// TestHelpers.InMethod();
260//
261// string firstName = "testfirstname";
262//
263// AgentCircuitData agent = new AgentCircuitData();
264// agent.AgentID = agent1;
265// agent.firstname = firstName;
266// agent.lastname = "testlastname";
267// agent.SessionID = UUID.Random();
268// agent.SecureSessionID = UUID.Random();
269// agent.circuitcode = 123;
270// agent.BaseFolder = UUID.Zero;
271// agent.InventoryFolder = UUID.Zero;
272// agent.startpos = Vector3.Zero;
273// agent.CapsPath = GetRandomCapsObjectPath();
274// agent.ChildrenCapSeeds = new Dictionary<ulong, string>();
275// agent.child = true;
276//
277// scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID);
278//
279// string reason;
280// scene.NewUserConnection(agent, (uint)TeleportFlags.ViaLogin, out reason);
281// testclient = new TestClient(agent, scene);
282// scene.AddNewAgent(testclient);
283//
284// ScenePresence presence = scene.GetScenePresence(agent1);
285//
286// Assert.That(presence, Is.Not.Null, "presence is null");
287// Assert.That(presence.Firstname, Is.EqualTo(firstName), "First name not same");
288// acd1 = agent;
289// }
290//
291// /// <summary>
292// /// Test removing an uncrossed root agent from a scene.
293// /// </summary>
294// [Test]
295// public void T011_TestRemoveRootAgent()
296// {
297// TestHelpers.InMethod();
298//
299// scene.RemoveClient(agent1);
300//
301// ScenePresence presence = scene.GetScenePresence(agent1);
302//
303// Assert.That(presence, Is.Null, "presence is not null");
304// }
305 } 291 }
306} \ No newline at end of file 292} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTelehubTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTelehubTests.cs
new file mode 100644
index 0000000..9a97acc
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTelehubTests.cs
@@ -0,0 +1,119 @@
1/*
2 * Redistribution and use in source and binary forms, with or without
3 * modification, are permitted provided that the following conditions are met:
4 * * Redistributions of source code must retain the above copyright
5 * notice, this list of conditions and the following disclaimer.
6 * * Redistributions in binary form must reproduce the above copyright
7 * notice, this list of conditions and the following disclaimer in the
8 * documentation and/or other materials provided with the distribution.
9 * * Neither the name of the OpenSimulator Project nor the
10 * names of its contributors may be used to endorse or promote products
11 * derived from this software without specific prior written permission.
12 *
13 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */
24
25using System;
26using Nini.Config;
27using NUnit.Framework;
28using OpenMetaverse;
29using OpenSim.Framework;
30using OpenSim.Region.CoreModules.World.Estate;
31using OpenSim.Region.Framework.Scenes;
32using OpenSim.Region.Framework.Interfaces;
33using OpenSim.Services.Interfaces;
34using OpenSim.Tests.Common;
35using OpenSim.Tests.Common.Mock;
36
37namespace OpenSim.Region.Framework.Scenes.Tests
38{
39 /// <summary>
40 /// Scene telehub tests
41 /// </summary>
42 /// <remarks>
43 /// TODO: Tests which run through normal functionality. Currently, the only test is one that checks behaviour
44 /// in the case of an error condition
45 /// </remarks>
46 [TestFixture]
47 public class SceneTelehubTests : OpenSimTestCase
48 {
49 /// <summary>
50 /// Test for desired behaviour when a telehub has no spawn points
51 /// </summary>
52 [Test]
53 public void TestNoTelehubSpawnPoints()
54 {
55 TestHelpers.InMethod();
56// TestHelpers.EnableLogging();
57
58 EstateManagementModule emm = new EstateManagementModule();
59
60 SceneHelpers sh = new SceneHelpers();
61 Scene scene = sh.SetupScene();
62 SceneHelpers.SetupSceneModules(scene, emm);
63
64 UUID telehubSceneObjectOwner = TestHelpers.ParseTail(0x1);
65
66 SceneObjectGroup telehubSo = SceneHelpers.AddSceneObject(scene, "telehubObject", telehubSceneObjectOwner);
67
68 emm.HandleOnEstateManageTelehub(null, UUID.Zero, UUID.Zero, "connect", telehubSo.LocalId);
69 scene.RegionInfo.EstateSettings.AllowDirectTeleport = false;
70
71 // Must still be possible to successfully log in
72 UUID loggingInUserId = TestHelpers.ParseTail(0x2);
73
74 UserAccount ua
75 = UserAccountHelpers.CreateUserWithInventory(scene, "Test", "User", loggingInUserId, "password");
76
77 SceneHelpers.AddScenePresence(scene, ua);
78
79 Assert.That(scene.GetScenePresence(loggingInUserId), Is.Not.Null);
80 }
81
82 /// <summary>
83 /// Test for desired behaviour when the scene object nominated as a telehub object does not exist.
84 /// </summary>
85 [Test]
86 public void TestNoTelehubSceneObject()
87 {
88 TestHelpers.InMethod();
89// TestHelpers.EnableLogging();
90
91 EstateManagementModule emm = new EstateManagementModule();
92
93 SceneHelpers sh = new SceneHelpers();
94 Scene scene = sh.SetupScene();
95 SceneHelpers.SetupSceneModules(scene, emm);
96
97 UUID telehubSceneObjectOwner = TestHelpers.ParseTail(0x1);
98
99 SceneObjectGroup telehubSo = SceneHelpers.AddSceneObject(scene, "telehubObject", telehubSceneObjectOwner);
100 SceneObjectGroup spawnPointSo = SceneHelpers.AddSceneObject(scene, "spawnpointObject", telehubSceneObjectOwner);
101
102 emm.HandleOnEstateManageTelehub(null, UUID.Zero, UUID.Zero, "connect", telehubSo.LocalId);
103 emm.HandleOnEstateManageTelehub(null, UUID.Zero, UUID.Zero, "spawnpoint add", spawnPointSo.LocalId);
104 scene.RegionInfo.EstateSettings.AllowDirectTeleport = false;
105
106 scene.DeleteSceneObject(telehubSo, false);
107
108 // Must still be possible to successfully log in
109 UUID loggingInUserId = TestHelpers.ParseTail(0x2);
110
111 UserAccount ua
112 = UserAccountHelpers.CreateUserWithInventory(scene, "Test", "User", loggingInUserId, "password");
113
114 SceneHelpers.AddScenePresence(scene, ua);
115
116 Assert.That(scene.GetScenePresence(loggingInUserId), Is.Not.Null);
117 }
118 }
119} \ No newline at end of file