diff options
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 50 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Tests/SceneTelehubTests.cs | 119 |
2 files changed, 154 insertions, 15 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a9fe556..c3110a2 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -3951,32 +3951,52 @@ namespace OpenSim.Region.Framework.Scenes | |||
3951 | } | 3951 | } |
3952 | } | 3952 | } |
3953 | 3953 | ||
3954 | // m_log.DebugFormat( | ||
3955 | // "[SCENE]: Found telehub object {0} for new user connection {1} to {2}", | ||
3956 | // RegionInfo.RegionSettings.TelehubObject, acd.Name, Name); | ||
3957 | |||
3954 | // Honor Estate teleport routing via Telehubs excluding ViaHome and GodLike TeleportFlags | 3958 | // Honor Estate teleport routing via Telehubs excluding ViaHome and GodLike TeleportFlags |
3955 | if (RegionInfo.RegionSettings.TelehubObject != UUID.Zero && | 3959 | if (RegionInfo.RegionSettings.TelehubObject != UUID.Zero && |
3956 | RegionInfo.EstateSettings.AllowDirectTeleport == false && | 3960 | RegionInfo.EstateSettings.AllowDirectTeleport == false && |
3957 | !viahome && !godlike) | 3961 | !viahome && !godlike) |
3958 | { | 3962 | { |
3959 | SceneObjectGroup telehub = GetSceneObjectGroup(RegionInfo.RegionSettings.TelehubObject); | 3963 | SceneObjectGroup telehub = GetSceneObjectGroup(RegionInfo.RegionSettings.TelehubObject); |
3960 | // Can have multiple SpawnPoints | 3964 | |
3961 | List<SpawnPoint> spawnpoints = RegionInfo.RegionSettings.SpawnPoints(); | 3965 | if (telehub != null) |
3962 | if (spawnpoints.Count > 1) | ||
3963 | { | 3966 | { |
3964 | // We have multiple SpawnPoints, Route the agent to a random or sequential one | 3967 | // Can have multiple SpawnPoints |
3965 | if (SpawnPointRouting == "random") | 3968 | List<SpawnPoint> spawnpoints = RegionInfo.RegionSettings.SpawnPoints(); |
3966 | acd.startpos = spawnpoints[Util.RandomClass.Next(spawnpoints.Count) - 1].GetLocation( | 3969 | if (spawnpoints.Count > 1) |
3967 | telehub.AbsolutePosition, | 3970 | { |
3968 | telehub.GroupRotation | 3971 | // We have multiple SpawnPoints, Route the agent to a random or sequential one |
3969 | ); | 3972 | if (SpawnPointRouting == "random") |
3973 | acd.startpos = spawnpoints[Util.RandomClass.Next(spawnpoints.Count) - 1].GetLocation( | ||
3974 | telehub.AbsolutePosition, | ||
3975 | telehub.GroupRotation | ||
3976 | ); | ||
3977 | else | ||
3978 | acd.startpos = spawnpoints[SpawnPoint()].GetLocation( | ||
3979 | telehub.AbsolutePosition, | ||
3980 | telehub.GroupRotation | ||
3981 | ); | ||
3982 | } | ||
3983 | else if (spawnpoints.Count == 1) | ||
3984 | { | ||
3985 | // We have a single SpawnPoint and will route the agent to it | ||
3986 | acd.startpos = spawnpoints[0].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); | ||
3987 | } | ||
3970 | else | 3988 | else |
3971 | acd.startpos = spawnpoints[SpawnPoint()].GetLocation( | 3989 | { |
3972 | telehub.AbsolutePosition, | 3990 | m_log.DebugFormat( |
3973 | telehub.GroupRotation | 3991 | "[SCENE]: No spawnpoints defined for telehub {0} for {1} in {2}. Continuing.", |
3974 | ); | 3992 | RegionInfo.RegionSettings.TelehubObject, acd.Name, Name); |
3993 | } | ||
3975 | } | 3994 | } |
3976 | else | 3995 | else |
3977 | { | 3996 | { |
3978 | // We have a single SpawnPoint and will route the agent to it | 3997 | m_log.DebugFormat( |
3979 | acd.startpos = spawnpoints[0].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); | 3998 | "[SCENE]: No telehub {0} found to direct {1} in {2}. Continuing.", |
3999 | RegionInfo.RegionSettings.TelehubObject, acd.Name, Name); | ||
3980 | } | 4000 | } |
3981 | 4001 | ||
3982 | return true; | 4002 | return true; |
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 | |||
25 | using System; | ||
26 | using Nini.Config; | ||
27 | using NUnit.Framework; | ||
28 | using OpenMetaverse; | ||
29 | using OpenSim.Framework; | ||
30 | using OpenSim.Region.CoreModules.World.Estate; | ||
31 | using OpenSim.Region.Framework.Scenes; | ||
32 | using OpenSim.Region.Framework.Interfaces; | ||
33 | using OpenSim.Services.Interfaces; | ||
34 | using OpenSim.Tests.Common; | ||
35 | using OpenSim.Tests.Common.Mock; | ||
36 | |||
37 | namespace 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 | ||