From e3157e61aa50d057b4345cb9d49c973afeb26b15 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 14 Aug 2008 00:04:37 +0000 Subject: Mantis #1946 Thank you, HomerHorwitz, for a patch that corrects and improves TP to landmark and home position handling. --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 2 +- .../Communications/Local/LocalBackEndServices.cs | 10 ++++++ .../Region/Communications/OGS1/OGS1UserServices.cs | 4 ++- OpenSim/Region/Environment/Scenes/Scene.cs | 42 +++++++++++++++++++--- .../Scenes/SceneCommunicationService.cs | 23 ++++++++---- 5 files changed, 69 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 12e5452..245f533 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -5241,7 +5241,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP handlerTeleportLandmarkRequest = OnTeleportLandmarkRequest; if (handlerTeleportLandmarkRequest != null) { - handlerTeleportLandmarkRequest(this, lm.RegionHandle, lm.Position); + handlerTeleportLandmarkRequest(this, lm.RegionID, lm.Position); } else { diff --git a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs index 8d6bbcc..a608da0 100644 --- a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs +++ b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs @@ -172,6 +172,16 @@ namespace OpenSim.Region.Communications.Local return null; } + public RegionInfo RequestNeighbourInfo(LLUUID regionID) + { + // TODO add a dictionary for faster lookup + foreach(RegionInfo info in m_regions.Values) + { + if(info.RegionID == regionID) return info; + } + return null; + } + public RegionInfo RequestClosestRegion(string regionName) { foreach (RegionInfo regInfo in m_regions.Values) diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs index c6f905f..2d37e2f 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs @@ -75,6 +75,8 @@ namespace OpenSim.Region.Communications.OGS1 userData.Image = new LLUUID((string) data["profile_image"]); userData.LastLogin = Convert.ToInt32((string) data["profile_lastlogin"]); userData.HomeRegion = Convert.ToUInt64((string) data["home_region"]); + if(data.Contains("home_region_id")) userData.HomeRegionID = new LLUUID((string)data["home_region_id"]); + else userData.HomeRegionID = LLUUID.Zero; userData.HomeLocation = new LLVector3((float) Convert.ToDecimal((string) data["home_coordinates_x"]), (float) Convert.ToDecimal((string) data["home_coordinates_y"]), @@ -83,7 +85,6 @@ namespace OpenSim.Region.Communications.OGS1 new LLVector3((float) Convert.ToDecimal((string) data["home_look_x"]), (float) Convert.ToDecimal((string) data["home_look_y"]), (float) Convert.ToDecimal((string) data["home_look_z"])); - return userData; } @@ -453,6 +454,7 @@ namespace OpenSim.Region.Communications.OGS1 //param["ProfileURL"] = UserProfile.ProfileURL.ToString(); param["home_region"] = UserProfile.HomeRegion.ToString(); + param["home_region_id"] = UserProfile.HomeRegionID.ToString(); param["home_pos_x"] = UserProfile.HomeLocationX.ToString(); param["home_pos_y"] = UserProfile.HomeLocationY.ToString(); diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 3b961a5..b4bb2f6 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -2104,10 +2104,34 @@ namespace OpenSim.Region.Environment.Scenes UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(AgentId); if (UserProfile != null) { - ulong homeRegion = UserProfile.HomeRegion; + LLUUID homeRegionID = UserProfile.HomeRegionID; LLVector3 homePostion = new LLVector3(UserProfile.HomeLocationX,UserProfile.HomeLocationY,UserProfile.HomeLocationZ); LLVector3 homeLookat = new LLVector3(UserProfile.HomeLookAt); - RequestTeleportLocation(client, homeRegion, homePostion,homeLookat,(uint)0); + ulong homeRegionHandle = UserProfile.HomeRegion; + if(homeRegionID == LLUUID.Zero) + { + RegionInfo info = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegion); + if(info == null) + { + // can't find the region: Tell viewer and abort + client.SendTeleportFailed("Your home-region could not be found."); + return; + } + UserProfile.HomeRegionID = info.RegionID; + CommsManager.UserService.UpdateUserProfileProperties(UserProfile); + } + else + { + RegionInfo info = CommsManager.GridService.RequestNeighbourInfo(homeRegionID); + if(info == null) + { + // can't find the region: Tell viewer and abort + client.SendTeleportFailed("Your home-region could not be found."); + return; + } + homeRegionHandle = info.RegionHandle; + } + RequestTeleportLocation(client, homeRegionHandle, homePostion,homeLookat,(uint)0); } } @@ -2189,6 +2213,9 @@ namespace OpenSim.Region.Environment.Scenes { // I know I'm ignoring the regionHandle provided by the teleport location request. // reusing the TeleportLocationRequest delegate, so regionHandle isn't valid + UserProfile.HomeRegionID = RegionInfo.RegionID; + // TODO: The next line can be removed, as soon as only homeRegionID based UserServers are around. + // TODO: The HomeRegion property can be removed then, too UserProfile.HomeRegion = RegionInfo.RegionHandle; // We cast these to an int so as not to cause a breaking change with old regions @@ -2718,13 +2745,20 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public void RequestTeleportLandmark(IClientAPI remoteClient, ulong regionHandle, LLVector3 position) + public void RequestTeleportLandmark(IClientAPI remoteClient, LLUUID regionID, LLVector3 position) { + RegionInfo info = CommsManager.GridService.RequestNeighbourInfo(regionID); + if(info == null) + { + // can't find the region: Tell viewer and abort + remoteClient.SendTeleportFailed("The teleport destination could not be found."); + return; + } lock (m_scenePresences) { if (m_scenePresences.ContainsKey(remoteClient.AgentId)) { - m_sceneGridService.RequestTeleportToLocation(m_scenePresences[remoteClient.AgentId], regionHandle, + m_sceneGridService.RequestTeleportToLocation(m_scenePresences[remoteClient.AgentId], info.RegionHandle, position, LLVector3.Zero, 0); } } diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs index 348b643..008d67a 100644 --- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs @@ -532,6 +532,17 @@ namespace OpenSim.Region.Environment.Scenes } /// + /// Helper function to request neighbors from grid-comms + /// + /// + /// + public virtual RegionInfo RequestNeighbouringRegionInfo(LLUUID regionID) + { + //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending Grid Services Request about neighbor " + regionID); + return m_commsProvider.GridService.RequestNeighbourInfo(regionID); + } + + /// /// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates /// /// @@ -597,8 +608,8 @@ namespace OpenSim.Region.Environment.Scenes // once we reach here... avatar.Scene.RemoveCapsHandler(avatar.UUID); - m_commsProvider.InterRegion.InformRegionOfChildAgent(regionHandle, agent); - m_commsProvider.InterRegion.ExpectAvatarCrossing(regionHandle, avatar.ControllingClient.AgentId, + m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agent); + m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId, position, false); AgentCircuitData circuitdata = avatar.ControllingClient.RequestClientInfo(); @@ -610,17 +621,17 @@ namespace OpenSim.Region.Environment.Scenes m_log.DebugFormat( "[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, avatar.UUID); - avatar.ControllingClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4), + avatar.ControllingClient.SendRegionTeleport(reg.RegionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4), capsPath); avatar.MakeChildAgent(); Thread.Sleep(5000); - avatar.CrossAttachmentsIntoNewRegion(regionHandle); + avatar.CrossAttachmentsIntoNewRegion(reg.RegionHandle); if (KillObject != null) { KillObject(avatar.LocalId); } - uint newRegionX = (uint)(regionHandle >> 40); - uint newRegionY = (((uint)(regionHandle)) >> 8); + uint newRegionX = (uint)(reg.RegionHandle >> 40); + uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40); uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8); if (Util.fast_distance2d((int)(newRegionX - oldRegionX), (int)(newRegionY - oldRegionY)) > 3) -- cgit v1.1