Thank you, HomerHorwitz, for a patch that corrects and improves TP
to landmark and home position handling.
0.6.0-stable
Melanie Thielker 2008-08-14 00:04:37 +00:00
parent fb4eb05ae1
commit e3157e61aa
12 changed files with 105 additions and 16 deletions

View File

@ -538,6 +538,10 @@ namespace OpenSim.Data.MySQL
Convert.ToSingle(reader["homeLookAtY"].ToString()), Convert.ToSingle(reader["homeLookAtY"].ToString()),
Convert.ToSingle(reader["homeLookAtZ"].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.Created = Convert.ToInt32(reader["created"].ToString());
retval.LastLogin = Convert.ToInt32(reader["lastLogin"].ToString()); retval.LastLogin = Convert.ToInt32(reader["lastLogin"].ToString());
@ -583,6 +587,7 @@ namespace OpenSim.Data.MySQL
LLUUID.TryParse((string)reader["webLoginKey"], out tmp); LLUUID.TryParse((string)reader["webLoginKey"], out tmp);
retval.WebLoginKey = tmp; retval.WebLoginKey = tmp;
} }
} }
else else
{ {
@ -806,7 +811,7 @@ namespace OpenSim.Data.MySQL
/// <param name="webLoginKey">UUID for weblogin Key</param> /// <param name="webLoginKey">UUID for weblogin Key</param>
/// <returns>Success?</returns> /// <returns>Success?</returns>
public bool updateUserRow(LLUUID uuid, string username, string lastname, string passwordHash, 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, float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin,
string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask,
string aboutText, string firstText, string aboutText, string firstText,
@ -814,7 +819,7 @@ namespace OpenSim.Data.MySQL
{ {
string sql = "UPDATE users SET `username` = ?username , `lastname` = ?lastname "; string sql = "UPDATE users SET `username` = ?username , `lastname` = ?lastname ";
sql += ", `passwordHash` = ?passwordHash , `passwordSalt` = ?passwordSalt , "; sql += ", `passwordHash` = ?passwordHash , `passwordSalt` = ?passwordSalt , ";
sql += "`homeRegion` = ?homeRegion , `homeLocationX` = ?homeLocationX , "; sql += "`homeRegion` = ?homeRegion , `homeRegionID` = ?homeRegionID, `homeLocationX` = ?homeLocationX , ";
sql += "`homeLocationY` = ?homeLocationY , `homeLocationZ` = ?homeLocationZ , "; sql += "`homeLocationY` = ?homeLocationY , `homeLocationZ` = ?homeLocationZ , ";
sql += "`homeLookAtX` = ?homeLookAtX , `homeLookAtY` = ?homeLookAtY , "; sql += "`homeLookAtX` = ?homeLookAtX , `homeLookAtY` = ?homeLookAtY , ";
sql += "`homeLookAtZ` = ?homeLookAtZ , `created` = ?created , `lastLogin` = ?lastLogin , "; sql += "`homeLookAtZ` = ?homeLookAtZ , `created` = ?created , `lastLogin` = ?lastLogin , ";
@ -831,6 +836,7 @@ namespace OpenSim.Data.MySQL
parameters["?passwordHash"] = passwordHash.ToString(); parameters["?passwordHash"] = passwordHash.ToString();
parameters["?passwordSalt"] = passwordSalt.ToString(); parameters["?passwordSalt"] = passwordSalt.ToString();
parameters["?homeRegion"] = homeRegion.ToString(); parameters["?homeRegion"] = homeRegion.ToString();
parameters["?homeRegionID"] = homeRegionID.ToString();
parameters["?homeLocationX"] = homeLocX.ToString(); parameters["?homeLocationX"] = homeLocX.ToString();
parameters["?homeLocationY"] = homeLocY.ToString(); parameters["?homeLocationY"] = homeLocY.ToString();
parameters["?homeLocationZ"] = homeLocZ.ToString(); parameters["?homeLocationZ"] = homeLocZ.ToString();

View File

@ -682,7 +682,7 @@ namespace OpenSim.Data.MySQL
lock (database) lock (database)
{ {
database.updateUserRow(user.ID, user.FirstName, user.SurName, user.PasswordHash, user.PasswordSalt, 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.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, user.UserInventoryURI,
user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText,
user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey); user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey);

View File

@ -662,6 +662,7 @@ namespace OpenSim.Data.SQLite
SQLiteUtil.createCol(users, "homeRegionX", typeof (Int32)); SQLiteUtil.createCol(users, "homeRegionX", typeof (Int32));
SQLiteUtil.createCol(users, "homeRegionY", typeof (Int32)); SQLiteUtil.createCol(users, "homeRegionY", typeof (Int32));
SQLiteUtil.createCol(users, "homeRegionID", typeof (String));
SQLiteUtil.createCol(users, "homeLocationX", typeof (Double)); SQLiteUtil.createCol(users, "homeLocationX", typeof (Double));
SQLiteUtil.createCol(users, "homeLocationY", typeof (Double)); SQLiteUtil.createCol(users, "homeLocationY", typeof (Double));
SQLiteUtil.createCol(users, "homeLocationZ", typeof (Double)); SQLiteUtil.createCol(users, "homeLocationZ", typeof (Double));
@ -769,6 +770,11 @@ namespace OpenSim.Data.SQLite
Convert.ToSingle(row["homeLookAtY"]), Convert.ToSingle(row["homeLookAtY"]),
Convert.ToSingle(row["homeLookAtZ"]) 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.Created = Convert.ToInt32(row["created"]);
user.LastLogin = Convert.ToInt32(row["lastLogin"]); user.LastLogin = Convert.ToInt32(row["lastLogin"]);
user.RootInventoryFolderID = new LLUUID((String) row["rootInventoryFolderID"]); user.RootInventoryFolderID = new LLUUID((String) row["rootInventoryFolderID"]);
@ -803,6 +809,7 @@ namespace OpenSim.Data.SQLite
row["homeRegionX"] = user.HomeRegionX; row["homeRegionX"] = user.HomeRegionX;
row["homeRegionY"] = user.HomeRegionY; row["homeRegionY"] = user.HomeRegionY;
row["homeRegionID"] = user.HomeRegionID;
row["homeLocationX"] = user.HomeLocation.X; row["homeLocationX"] = user.HomeLocation.X;
row["homeLocationY"] = user.HomeLocation.Y; row["homeLocationY"] = user.HomeLocation.Y;
row["homeLocationZ"] = user.HomeLocation.Z; row["homeLocationZ"] = user.HomeLocation.Z;

View File

@ -26,6 +26,7 @@
*/ */
using System.Collections.Generic; using System.Collections.Generic;
using libsecondlife;
namespace OpenSim.Framework.Communications namespace OpenSim.Framework.Communications
{ {
@ -52,6 +53,7 @@ namespace OpenSim.Framework.Communications
List<SimpleRegionInfo> RequestNeighbours(uint x, uint y); List<SimpleRegionInfo> RequestNeighbours(uint x, uint y);
RegionInfo RequestNeighbourInfo(ulong regionHandle); RegionInfo RequestNeighbourInfo(ulong regionHandle);
RegionInfo RequestNeighbourInfo(LLUUID regionID);
RegionInfo RequestClosestRegion(string regionName); RegionInfo RequestClosestRegion(string regionName);
Dictionary<string, string> GetGridSettings(); Dictionary<string, string> GetGridSettings();
List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY);

View File

@ -81,7 +81,7 @@ namespace OpenSim.Framework
IClientAPI remoteClient, ulong regionHandle, LLVector3 position, LLVector3 lookAt, uint flags); IClientAPI remoteClient, ulong regionHandle, LLVector3 position, LLVector3 lookAt, uint flags);
public delegate void TeleportLandmarkRequest( public delegate void TeleportLandmarkRequest(
IClientAPI remoteClient, ulong regionHandle, LLVector3 position); IClientAPI remoteClient, LLUUID regionID, LLVector3 position);
public delegate void DisconnectUser(); public delegate void DisconnectUser();

View File

@ -149,6 +149,16 @@ namespace OpenSim.Framework
} }
} }
private LLUUID _homeRegionID;
/// <summary>
/// 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.
/// </summary>
public LLUUID HomeRegionID
{
get { return _homeRegionID; }
set { _homeRegionID = value; }
}
// Property wrappers // Property wrappers
public virtual LLUUID ID public virtual LLUUID ID
{ {

View File

@ -151,6 +151,7 @@ namespace OpenSim.Grid.UserServer
responseData["home_coordinates_z"] = profile.HomeLocation.Z.ToString(); responseData["home_coordinates_z"] = profile.HomeLocation.Z.ToString();
responseData["home_region"] = profile.HomeRegion.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_x"] = profile.HomeLookAt.X.ToString();
responseData["home_look_y"] = profile.HomeLookAt.Y.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")) if (requestData.Contains("home_pos_x"))
{ {
try try

View File

@ -5241,7 +5241,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
handlerTeleportLandmarkRequest = OnTeleportLandmarkRequest; handlerTeleportLandmarkRequest = OnTeleportLandmarkRequest;
if (handlerTeleportLandmarkRequest != null) if (handlerTeleportLandmarkRequest != null)
{ {
handlerTeleportLandmarkRequest(this, lm.RegionHandle, lm.Position); handlerTeleportLandmarkRequest(this, lm.RegionID, lm.Position);
} }
else else
{ {

View File

@ -172,6 +172,16 @@ namespace OpenSim.Region.Communications.Local
return null; 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) public RegionInfo RequestClosestRegion(string regionName)
{ {
foreach (RegionInfo regInfo in m_regions.Values) foreach (RegionInfo regInfo in m_regions.Values)

View File

@ -75,6 +75,8 @@ namespace OpenSim.Region.Communications.OGS1
userData.Image = new LLUUID((string) data["profile_image"]); userData.Image = new LLUUID((string) data["profile_image"]);
userData.LastLogin = Convert.ToInt32((string) data["profile_lastlogin"]); userData.LastLogin = Convert.ToInt32((string) data["profile_lastlogin"]);
userData.HomeRegion = Convert.ToUInt64((string) data["home_region"]); 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 = userData.HomeLocation =
new LLVector3((float) Convert.ToDecimal((string) data["home_coordinates_x"]), new LLVector3((float) Convert.ToDecimal((string) data["home_coordinates_x"]),
(float) Convert.ToDecimal((string) data["home_coordinates_y"]), (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"]), 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_y"]),
(float) Convert.ToDecimal((string) data["home_look_z"])); (float) Convert.ToDecimal((string) data["home_look_z"]));
return userData; return userData;
} }
@ -453,6 +454,7 @@ namespace OpenSim.Region.Communications.OGS1
//param["ProfileURL"] = UserProfile.ProfileURL.ToString(); //param["ProfileURL"] = UserProfile.ProfileURL.ToString();
param["home_region"] = UserProfile.HomeRegion.ToString(); param["home_region"] = UserProfile.HomeRegion.ToString();
param["home_region_id"] = UserProfile.HomeRegionID.ToString();
param["home_pos_x"] = UserProfile.HomeLocationX.ToString(); param["home_pos_x"] = UserProfile.HomeLocationX.ToString();
param["home_pos_y"] = UserProfile.HomeLocationY.ToString(); param["home_pos_y"] = UserProfile.HomeLocationY.ToString();

View File

@ -2104,10 +2104,34 @@ namespace OpenSim.Region.Environment.Scenes
UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(AgentId); UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(AgentId);
if (UserProfile != null) if (UserProfile != null)
{ {
ulong homeRegion = UserProfile.HomeRegion; LLUUID homeRegionID = UserProfile.HomeRegionID;
LLVector3 homePostion = new LLVector3(UserProfile.HomeLocationX,UserProfile.HomeLocationY,UserProfile.HomeLocationZ); LLVector3 homePostion = new LLVector3(UserProfile.HomeLocationX,UserProfile.HomeLocationY,UserProfile.HomeLocationZ);
LLVector3 homeLookat = new LLVector3(UserProfile.HomeLookAt); 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. // I know I'm ignoring the regionHandle provided by the teleport location request.
// reusing the TeleportLocationRequest delegate, so regionHandle isn't valid // 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; UserProfile.HomeRegion = RegionInfo.RegionHandle;
// We cast these to an int so as not to cause a breaking change with old regions // 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
/// <param name="remoteClient"></param> /// <param name="remoteClient"></param>
/// <param name="regionHandle"></param> /// <param name="regionHandle"></param>
/// <param name="position"></param> /// <param name="position"></param>
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) lock (m_scenePresences)
{ {
if (m_scenePresences.ContainsKey(remoteClient.AgentId)) 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); position, LLVector3.Zero, 0);
} }
} }

View File

@ -531,6 +531,17 @@ namespace OpenSim.Region.Environment.Scenes
return m_commsProvider.GridService.RequestNeighbourInfo(regionHandle); return m_commsProvider.GridService.RequestNeighbourInfo(regionHandle);
} }
/// <summary>
/// Helper function to request neighbors from grid-comms
/// </summary>
/// <param name="regionID"></param>
/// <returns></returns>
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);
}
/// <summary> /// <summary>
/// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates /// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates
/// </summary> /// </summary>
@ -597,8 +608,8 @@ namespace OpenSim.Region.Environment.Scenes
// once we reach here... // once we reach here...
avatar.Scene.RemoveCapsHandler(avatar.UUID); avatar.Scene.RemoveCapsHandler(avatar.UUID);
m_commsProvider.InterRegion.InformRegionOfChildAgent(regionHandle, agent); m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agent);
m_commsProvider.InterRegion.ExpectAvatarCrossing(regionHandle, avatar.ControllingClient.AgentId, m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId,
position, false); position, false);
AgentCircuitData circuitdata = avatar.ControllingClient.RequestClientInfo(); AgentCircuitData circuitdata = avatar.ControllingClient.RequestClientInfo();
@ -610,17 +621,17 @@ namespace OpenSim.Region.Environment.Scenes
m_log.DebugFormat( m_log.DebugFormat(
"[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, avatar.UUID); "[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); capsPath);
avatar.MakeChildAgent(); avatar.MakeChildAgent();
Thread.Sleep(5000); Thread.Sleep(5000);
avatar.CrossAttachmentsIntoNewRegion(regionHandle); avatar.CrossAttachmentsIntoNewRegion(reg.RegionHandle);
if (KillObject != null) if (KillObject != null)
{ {
KillObject(avatar.LocalId); KillObject(avatar.LocalId);
} }
uint newRegionX = (uint)(regionHandle >> 40); uint newRegionX = (uint)(reg.RegionHandle >> 40);
uint newRegionY = (((uint)(regionHandle)) >> 8); uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40); uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40);
uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8); uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8);
if (Util.fast_distance2d((int)(newRegionX - oldRegionX), (int)(newRegionY - oldRegionY)) > 3) if (Util.fast_distance2d((int)(newRegionX - oldRegionX), (int)(newRegionY - oldRegionY)) > 3)