From 093adb2113d748f28554393cc8a6fe53502126dc Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 15 Jan 2009 21:27:55 +0000 Subject: * Add new unit test for simple teleport in a standalone. * Does not yet check results. --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 1 + .../Communications/Local/LocalBackEndServices.cs | 1 + .../Communications/Local/LocalInterregionComms.cs | 9 +++--- OpenSim/Region/Environment/Scenes/Scene.cs | 4 ++- .../Scenes/SceneCommunicationService.cs | 2 +- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 2 -- .../Environment/Scenes/Tests/EntityManagerTests.cs | 4 +-- .../Environment/Scenes/Tests/SceneTestUtils.cs | 32 ++++++++++++++++------ OpenSim/Tests/Common/Mock/TestClient.cs | 11 ++++++++ .../Tests/Common/Mock/TestCommunicationsManager.cs | 3 +- 10 files changed, 49 insertions(+), 20 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index ebbecb7..30f6f0f 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -5824,6 +5824,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; + case PacketType.TeleportLocationRequest: TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack; // Console.WriteLine(tpLocReq.ToString()); diff --git a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs index 552f8c3..6a3b80d 100644 --- a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs +++ b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs @@ -250,6 +250,7 @@ namespace OpenSim.Region.Communications.Local { return m_regionListeners[regionHandle].TriggerTellRegionToCloseChildConnection(agentID); } + return false; } diff --git a/OpenSim/Region/Environment/Modules/Communications/Local/LocalInterregionComms.cs b/OpenSim/Region/Environment/Modules/Communications/Local/LocalInterregionComms.cs index efc5c39..5fcb4bc 100644 --- a/OpenSim/Region/Environment/Modules/Communications/Local/LocalInterregionComms.cs +++ b/OpenSim/Region/Environment/Modules/Communications/Local/LocalInterregionComms.cs @@ -75,7 +75,6 @@ namespace OpenSim.Region.Environment.Modules.Communications.Local return; Init(scene); - } public void PostInitialise() @@ -119,17 +118,17 @@ namespace OpenSim.Region.Environment.Modules.Communications.Local #region IInterregionComms public bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit) - { + { foreach (Scene s in m_sceneList) - { + { if (s.RegionInfo.RegionHandle == regionHandle) { - //m_log.Debug("[LOCAL COMMS]: Found region to send SendCreateChildAgent"); +// m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", regionHandle); s.NewUserConnection(aCircuit); return true; } } - //m_log.Debug("[LOCAL COMMS]: region not found for SendCreateChildAgent"); +// m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", regionHandle); return false; } diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 94ca07c..fad90fa 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -3129,6 +3129,7 @@ namespace OpenSim.Region.Environment.Scenes remoteClient.SendTeleportFailed("The region '" + regionName + "' could not be found."); return; } + RequestTeleportLocation(remoteClient, regionInfo.RegionHandle, position, lookat, teleportFlags); } @@ -3149,7 +3150,8 @@ namespace OpenSim.Region.Environment.Scenes if (m_scenePresences.ContainsKey(remoteClient.AgentId)) sp = m_scenePresences[remoteClient.AgentId]; } - if (sp!= null) + + if (sp != null) { m_sceneGridService.RequestTeleportToLocation(sp, regionHandle, position, lookAt, teleportFlags); diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs index ab4e7d8..65e62ef 100644 --- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs @@ -701,6 +701,7 @@ namespace OpenSim.Region.Environment.Scenes position, avatar.Name, avatar.UUID, emergencyPos); position = emergencyPos; } + // TODO: Get proper AVG Height float localAVHeight = 1.56f; float posZLimit = (float)avatar.Scene.GetLandHeight((int)position.X, (int)position.Y); @@ -713,7 +714,6 @@ namespace OpenSim.Region.Environment.Scenes // Only send this if the event queue is null if (eq == null) avatar.ControllingClient.SendTeleportLocationStart(); - avatar.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); avatar.Teleport(position); diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 00e5548..d2d8335 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -42,7 +42,6 @@ using OpenSim.Region.Interfaces; using OpenSim.Region.Physics.Manager; using OSD = OpenMetaverse.StructuredData.OSD; - namespace OpenSim.Region.Environment.Scenes { enum ScriptControlled : uint @@ -2757,7 +2756,6 @@ namespace OpenSim.Region.Environment.Scenes static ScenePresence() { - Primitive.TextureEntry textu = AvatarAppearance.GetDefaultTexture(); DefaultTexture = textu.ToBytes(); } diff --git a/OpenSim/Region/Environment/Scenes/Tests/EntityManagerTests.cs b/OpenSim/Region/Environment/Scenes/Tests/EntityManagerTests.cs index 5923a2c..cc9cc03 100644 --- a/OpenSim/Region/Environment/Scenes/Tests/EntityManagerTests.cs +++ b/OpenSim/Region/Environment/Scenes/Tests/EntityManagerTests.cs @@ -25,17 +25,17 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using NUnit.Framework.SyntaxHelpers; using System; using System.Threading; using System.Text; using System.Collections.Generic; using Nini.Config; using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; +using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Region.Environment.Scenes; -using OpenMetaverse; namespace OpenSim.Region.Environment.Scenes.Tests { diff --git a/OpenSim/Region/Environment/Scenes/Tests/SceneTestUtils.cs b/OpenSim/Region/Environment/Scenes/Tests/SceneTestUtils.cs index a9a9ecd..3c4049d 100644 --- a/OpenSim/Region/Environment/Scenes/Tests/SceneTestUtils.cs +++ b/OpenSim/Region/Environment/Scenes/Tests/SceneTestUtils.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System.Net; using Nini.Config; using OpenMetaverse; using OpenSim.Framework; @@ -32,6 +33,7 @@ using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Servers; using OpenSim.Region.Physics.Manager; +using OpenSim.Region.Environment; using OpenSim.Region.Environment.Scenes; using OpenSim.Tests.Common.Mock; @@ -48,18 +50,31 @@ namespace OpenSim.Region.Environment.Scenes.Tests /// public static TestScene SetupScene() { - RegionInfo regInfo = new RegionInfo(1000, 1000, null, null); - regInfo.RegionName = "Unit test region"; - regInfo.ExternalHostName = "1.2.3.4"; + return SetupScene("Unit test region", UUID.Random(), 1000, 1000, new TestCommunicationsManager()); + } + + /// + /// Set up a test scene + /// + /// Name of the region + /// ID of the region + /// X co-ordinate of the region + /// Y co-ordinate of the region + /// This should be the same if simulating two scenes within a standalone + /// + public static TestScene SetupScene(string name, UUID id, uint x, uint y, CommunicationsManager cm) + { + RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1"); + regInfo.RegionName = name; + regInfo.RegionID = id; AgentCircuitManager acm = new AgentCircuitManager(); - CommunicationsManager cm = new TestCommunicationsManager(); SceneCommunicationService scs = new SceneCommunicationService(cm); SQLAssetServer assetService = new SQLAssetServer(new TestAssetDataPlugin()); AssetCache ac = new AssetCache(assetService); - StorageManager sm = new OpenSim.Region.Environment.StorageManager("OpenSim.Data.Null.dll", "", ""); + StorageManager sm = new StorageManager("OpenSim.Data.Null.dll", "", ""); IConfigSource configSource = new IniConfigSource(); TestScene testScene = new TestScene( @@ -70,7 +85,8 @@ namespace OpenSim.Region.Environment.Scenes.Tests PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager(); physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll"); - testScene.PhysicsScene = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", configSource, "test"); + testScene.PhysicsScene + = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", configSource, "test"); return testScene; } @@ -81,7 +97,7 @@ namespace OpenSim.Region.Environment.Scenes.Tests /// /// /// - public static IClientAPI AddRootAgent(Scene scene, UUID agentId) + public static TestClient AddRootAgent(Scene scene, UUID agentId) { string firstName = "testfirstname"; @@ -102,7 +118,7 @@ namespace OpenSim.Region.Environment.Scenes.Tests scene.NewUserConnection(agent); // Stage 2: add the new client as a child agent to the scene - IClientAPI client = new TestClient(agent); + TestClient client = new TestClient(agent); scene.AddNewClient(client); // Stage 3: Invoke agent crossing, which converts the child agent into a root agent (with appearance, diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index 428f599..5b3b27b 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -365,6 +365,17 @@ namespace OpenSim.Tests.Common.Mock m_firstName = agentData.firstname; m_lastName = agentData.lastname; } + + /// + /// Attempt a teleport to the given region. + /// + /// + /// + /// + public void Teleport(ulong regionHandle, Vector3 position, Vector3 lookAt) + { + OnTeleportLocationRequest(this, regionHandle, position, lookAt, 16); + } public virtual void ActivateGesture(UUID assetId, UUID gestureId) { diff --git a/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs b/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs index 738bc15..1663ac1 100644 --- a/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs +++ b/OpenSim/Tests/Common/Mock/TestCommunicationsManager.cs @@ -69,7 +69,8 @@ namespace OpenSim.Tests.Common.Mock m_userAdminService = lus; LocalBackEndServices gs = new LocalBackEndServices(); - m_gridService = gs; + m_gridService = gs; + m_interRegion = gs; } } } -- cgit v1.1