From 26e3a8ee4b63f67b7fd3957b9f8b94d874ed5627 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Sat, 19 Dec 2009 10:16:07 -0800
Subject: * Bug fix in HG: preserve the home region coordinates across multiple
 HG TPs. * Removed unnecessary debug messages.

---
 .../ServiceConnectorsOut/Grid/HGGridConnector.cs            | 13 +++++++++++--
 .../Interregion/LocalInterregionComms.cs                    |  4 +++-
 .../Services/Connectors/Grid/HypergridServiceConnector.cs   |  4 ++--
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
index 4d347cd..93cb60c 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
@@ -405,6 +405,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
             if (parts.Length >= 2)
             {
                 portstr = parts[1];
+                //m_log.Debug("-- port = " + portstr);
                 if (!UInt32.TryParse(portstr, out port))
                     regionName = parts[1];
             }
@@ -620,8 +621,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
                 clonedRegion.RegionLocX = (int)x;
                 clonedRegion.RegionLocY = (int)y;
 
-                // Get the user's home region information
-                GridRegion home = m_aScene.GridService.GetRegionByUUID(m_aScene.RegionInfo.ScopeID, uinfo.UserProfile.HomeRegionID);
+                // Get the user's home region information and adapt the region handle
+                GridRegion home = GetRegionByUUID(m_aScene.RegionInfo.ScopeID, uinfo.UserProfile.HomeRegionID);
+                if (m_HyperlinkHandles.ContainsKey(uinfo.UserProfile.HomeRegionID))
+                {
+                    ulong realHandle = m_HyperlinkHandles[uinfo.UserProfile.HomeRegionID];
+                    Utils.LongToUInts(realHandle, out x, out y);
+                    m_log.DebugFormat("[HGrid]: Foreign user is going elsewhere. Adjusting home handle from {0}-{1} to {2}-{3}", home.RegionLocX, home.RegionLocY, x, y);
+                    home.RegionLocX = (int)x;
+                    home.RegionLocY = (int)y;
+                }
 
                 // Get the user's service URLs
                 string serverURI = "";
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs
index d9f6e33..bdfe3b1 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs
@@ -157,7 +157,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
             }
 
 //            m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", regionHandle);
-            reason = "Did not find region.";
+            uint x = 0, y = 0;
+            Utils.LongToUInts(regionHandle, out x, out y);
+            reason = "Did not find region " + x + "-" + y;
             return false;
         }
 
diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
index 2f33bab..968a6d6 100644
--- a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
@@ -92,12 +92,12 @@ namespace OpenSim.Services.Connectors.Grid
                 try
                 {
                     UUID.TryParse((string)hash["uuid"], out uuid);
-                    m_log.Debug(">> HERE, uuid: " + uuid);
+                    //m_log.Debug(">> HERE, uuid: " + uuid);
                     info.RegionID = uuid;
                     if ((string)hash["handle"] != null)
                     {
                         realHandle = Convert.ToUInt64((string)hash["handle"]);
-                        m_log.Debug(">> HERE, realHandle: " + realHandle);
+                        //m_log.Debug(">> HERE, realHandle: " + realHandle);
                     }
                     //if (hash["region_image"] != null)
                     //{
-- 
cgit v1.1