From da244d1e90843264e5db3b0d9f91a1509e974dd1 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Fri, 5 Sep 2008 23:38:42 +0000 Subject: [PATCH] Mantis#2048. Thank you kindly, HomerHorwitz for a patch that: The attached patch (against r6075) fixes it for grid-mode. If the home-region isn't available, the stored regionHandle will be used to compute the region-coordinates of the home. This will be wrong if the home-region has moved, of course, but without the region being online we can't request the RegionInfo of it for finding out. Doing that (before the patch) and accessing the (null) RegionInfo led to a NullReferenceException, which prevented logging in to the last location. --- OpenSim/Grid/UserServer/UserLoginService.cs | 36 ++++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs index 198f95c3b9..1f8434633d 100644 --- a/OpenSim/Grid/UserServer/UserLoginService.cs +++ b/OpenSim/Grid/UserServer/UserLoginService.cs @@ -215,13 +215,33 @@ namespace OpenSim.Grid.UserServer // Customise the response //CFK: This is redundant and the next message should always appear. //CFK: m_log.Info("[LOGIN]: Home Location"); - response.Home = - string.Format( - "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", - (HomeInfo.regionLocX*Constants.RegionSize), - (HomeInfo.regionLocY*Constants.RegionSize), - theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, - theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); + if (HomeInfo != null) + { + response.Home = + string.Format( + "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", + (HomeInfo.regionLocX*Constants.RegionSize), + (HomeInfo.regionLocY*Constants.RegionSize), + theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, + theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); + } + else + { + // Emergency mode: Home-region isn't available, so we can't request the region info. + // Use the stored home regionHandle instead. + // NOTE: If the home-region moves, this will be wrong until the users update their user-profile again + ulong regionX = theUser.HomeRegion >> 32; + ulong regionY = theUser.HomeRegion & 0xffffffff; + response.Home = + string.Format( + "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", + regionX, regionY, + theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, + theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); + m_log.InfoFormat("[LOGIN] Home region of user {0} {1} is not available; using computed region position {2} {3}", + theUser.FirstName, theUser.SurName, + regionX, regionY); + } // Destination //CFK: The "Notifying" message always seems to appear, so subsume the data from this message into @@ -507,4 +527,4 @@ namespace OpenSim.Grid.UserServer userID)); } } -} \ No newline at end of file +}