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. --- OpenSim/Data/MySQL/MySQLManager.cs | 10 ++++-- OpenSim/Data/MySQL/MySQLUserData.cs | 2 +- OpenSim/Data/SQLite/SQLiteUserData.cs | 7 ++++ OpenSim/Framework/Communications/IGridServices.cs | 2 ++ OpenSim/Framework/IClientAPI.cs | 2 +- OpenSim/Framework/UserProfileData.cs | 10 ++++++ OpenSim/Grid/UserServer/UserManager.cs | 7 ++++ .../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 ++++++++---- 12 files changed, 105 insertions(+), 16 deletions(-) diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index 89d0672..297b1a7 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -538,6 +538,10 @@ namespace OpenSim.Data.MySQL Convert.ToSingle(reader["homeLookAtY"].ToString()), Convert.ToSingle(reader["homeLookAtZ"].ToString())); + LLUUID regionID = LLUUID.Zero; + LLUUID.TryParse(reader["homeRegionID"].ToString(), out regionID); // it's ok if it doesn't work; just use LLUUID.Zero + retval.HomeRegionID = regionID; + retval.Created = Convert.ToInt32(reader["created"].ToString()); retval.LastLogin = Convert.ToInt32(reader["lastLogin"].ToString()); @@ -583,6 +587,7 @@ namespace OpenSim.Data.MySQL LLUUID.TryParse((string)reader["webLoginKey"], out tmp); retval.WebLoginKey = tmp; } + } else { @@ -806,7 +811,7 @@ namespace OpenSim.Data.MySQL /// UUID for weblogin Key /// Success? public bool updateUserRow(LLUUID uuid, string username, string lastname, string passwordHash, - string passwordSalt, UInt64 homeRegion, float homeLocX, float homeLocY, float homeLocZ, + string passwordSalt, UInt64 homeRegion, LLUUID homeRegionID, float homeLocX, float homeLocY, float homeLocZ, float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, string aboutText, string firstText, @@ -814,7 +819,7 @@ namespace OpenSim.Data.MySQL { string sql = "UPDATE users SET `username` = ?username , `lastname` = ?lastname "; sql += ", `passwordHash` = ?passwordHash , `passwordSalt` = ?passwordSalt , "; - sql += "`homeRegion` = ?homeRegion , `homeLocationX` = ?homeLocationX , "; + sql += "`homeRegion` = ?homeRegion , `homeRegionID` = ?homeRegionID, `homeLocationX` = ?homeLocationX , "; sql += "`homeLocationY` = ?homeLocationY , `homeLocationZ` = ?homeLocationZ , "; sql += "`homeLookAtX` = ?homeLookAtX , `homeLookAtY` = ?homeLookAtY , "; sql += "`homeLookAtZ` = ?homeLookAtZ , `created` = ?created , `lastLogin` = ?lastLogin , "; @@ -831,6 +836,7 @@ namespace OpenSim.Data.MySQL parameters["?passwordHash"] = passwordHash.ToString(); parameters["?passwordSalt"] = passwordSalt.ToString(); parameters["?homeRegion"] = homeRegion.ToString(); + parameters["?homeRegionID"] = homeRegionID.ToString(); parameters["?homeLocationX"] = homeLocX.ToString(); parameters["?homeLocationY"] = homeLocY.ToString(); parameters["?homeLocationZ"] = homeLocZ.ToString(); diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 131823a..d7bf2a8 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -682,7 +682,7 @@ namespace OpenSim.Data.MySQL lock (database) { database.updateUserRow(user.ID, user.FirstName, user.SurName, user.PasswordHash, user.PasswordSalt, - user.HomeRegion, user.HomeLocation.X, user.HomeLocation.Y, user.HomeLocation.Z, user.HomeLookAt.X, + user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, user.HomeLocation.Z, user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, user.UserInventoryURI, user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey); diff --git a/OpenSim/Data/SQLite/SQLiteUserData.cs b/OpenSim/Data/SQLite/SQLiteUserData.cs index 45b4dc6..21c9dbc 100644 --- a/OpenSim/Data/SQLite/SQLiteUserData.cs +++ b/OpenSim/Data/SQLite/SQLiteUserData.cs @@ -662,6 +662,7 @@ namespace OpenSim.Data.SQLite SQLiteUtil.createCol(users, "homeRegionX", typeof (Int32)); SQLiteUtil.createCol(users, "homeRegionY", typeof (Int32)); + SQLiteUtil.createCol(users, "homeRegionID", typeof (String)); SQLiteUtil.createCol(users, "homeLocationX", typeof (Double)); SQLiteUtil.createCol(users, "homeLocationY", typeof (Double)); SQLiteUtil.createCol(users, "homeLocationZ", typeof (Double)); @@ -769,6 +770,11 @@ namespace OpenSim.Data.SQLite Convert.ToSingle(row["homeLookAtY"]), Convert.ToSingle(row["homeLookAtZ"]) ); + + LLUUID regionID = LLUUID.Zero; + LLUUID.TryParse(row["homeRegionID"].ToString(), out regionID); // it's ok if it doesn't work; just use LLUUID.Zero + user.HomeRegionID = regionID; + user.Created = Convert.ToInt32(row["created"]); user.LastLogin = Convert.ToInt32(row["lastLogin"]); user.RootInventoryFolderID = new LLUUID((String) row["rootInventoryFolderID"]); @@ -803,6 +809,7 @@ namespace OpenSim.Data.SQLite row["homeRegionX"] = user.HomeRegionX; row["homeRegionY"] = user.HomeRegionY; + row["homeRegionID"] = user.HomeRegionID; row["homeLocationX"] = user.HomeLocation.X; row["homeLocationY"] = user.HomeLocation.Y; row["homeLocationZ"] = user.HomeLocation.Z; diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index 39f04c3..3ecda68 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -26,6 +26,7 @@ */ using System.Collections.Generic; +using libsecondlife; namespace OpenSim.Framework.Communications { @@ -52,6 +53,7 @@ namespace OpenSim.Framework.Communications List RequestNeighbours(uint x, uint y); RegionInfo RequestNeighbourInfo(ulong regionHandle); + RegionInfo RequestNeighbourInfo(LLUUID regionID); RegionInfo RequestClosestRegion(string regionName); Dictionary GetGridSettings(); List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 893a783..66ea3ea 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -81,7 +81,7 @@ namespace OpenSim.Framework IClientAPI remoteClient, ulong regionHandle, LLVector3 position, LLVector3 lookAt, uint flags); public delegate void TeleportLandmarkRequest( - IClientAPI remoteClient, ulong regionHandle, LLVector3 position); + IClientAPI remoteClient, LLUUID regionID, LLVector3 position); public delegate void DisconnectUser(); diff --git a/OpenSim/Framework/UserProfileData.cs b/OpenSim/Framework/UserProfileData.cs index 17d339e..2b0e15f 100644 --- a/OpenSim/Framework/UserProfileData.cs +++ b/OpenSim/Framework/UserProfileData.cs @@ -149,6 +149,16 @@ namespace OpenSim.Framework } } + private LLUUID _homeRegionID; + /// + /// The regionID of the users home region. This is unique; even if the position of the region changes within the grid, this will refer to the same region. + /// + public LLUUID HomeRegionID + { + get { return _homeRegionID; } + set { _homeRegionID = value; } + } + // Property wrappers public virtual LLUUID ID { diff --git a/OpenSim/Grid/UserServer/UserManager.cs b/OpenSim/Grid/UserServer/UserManager.cs index a43ade1..36f2a0d 100644 --- a/OpenSim/Grid/UserServer/UserManager.cs +++ b/OpenSim/Grid/UserServer/UserManager.cs @@ -151,6 +151,7 @@ namespace OpenSim.Grid.UserServer responseData["home_coordinates_z"] = profile.HomeLocation.Z.ToString(); responseData["home_region"] = profile.HomeRegion.ToString(); + responseData["home_region_id"] = profile.HomeRegionID.ToString(); responseData["home_look_x"] = profile.HomeLookAt.X.ToString(); responseData["home_look_y"] = profile.HomeLookAt.Y.ToString(); @@ -564,6 +565,12 @@ namespace OpenSim.Grid.UserServer } } + if (requestData.Contains("home_region_id")) + { + LLUUID regionID = LLUUID.Zero; + LLUUID.TryParse((string)requestData["home_region_id"], out regionID); + userProfile.HomeRegionID = regionID; + } if (requestData.Contains("home_pos_x")) { try 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