From bc02ddf5231d7731af33cc0aa5dc914cbdeb5ee7 Mon Sep 17 00:00:00 2001
From: mingchen
Date: Fri, 6 Jul 2007 20:40:03 +0000
Subject: *Fixed several bugs that crashed the viewer and opensim server when
 logging in on grid mode *Note: Grid Mode now works in sugilite, but is still
 unstable **Known bug in which the grid server crashes after being relaunched
 from a previously create configuration **Crashing of the viewer crashes the
 OpenSim server which then crashes the grid server -- needs better handling of
 exceptions **Multiple sims is still untested, but should connect correctly.
 Moving between the sims may be a different story

---
 OpenSim/Framework/UserManager/UserManagerBase.cs   |  9 +++++--
 OpenSim/Grid/GridServer/GridManager.cs             |  4 +--
 OpenSim/Grid/UserServer/Main.cs                    |  4 +--
 OpenSim/Grid/UserServer/UserManager.cs             |  1 +
 .../ClientStack/ClientView.ProcessPackets.cs       |  3 ++-
 OpenSim/Region/ClientStack/ClientViewBase.cs       |  2 ++
 .../Region/Communications/OGS1/OGS1GridServices.cs | 31 ++++++++++++----------
 .../Region/Communications/OGS1/OGS1UserServices.cs |  5 ++--
 8 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/OpenSim/Framework/UserManager/UserManagerBase.cs b/OpenSim/Framework/UserManager/UserManagerBase.cs
index af5feac..df6fbb2 100644
--- a/OpenSim/Framework/UserManager/UserManagerBase.cs
+++ b/OpenSim/Framework/UserManager/UserManagerBase.cs
@@ -565,10 +565,15 @@ namespace OpenSim.Framework.UserManagement
             responseData["profile_created"] = profile.created.ToString();
             responseData["profile_lastlogin"] = profile.lastLogin.ToString();
             // Home region information
-            responseData["home_coordinates"]  = profile.homeLocation.ToString();
+            responseData["home_coordinates_x"] = profile.homeLocation.X.ToString();
+            responseData["home_coordinates_y"] = profile.homeLocation.Y.ToString();
+            responseData["home_coordinates_z"] = profile.homeLocation.Z.ToString();
+
             responseData["home_region"]  = profile.homeRegion.ToString();
-            responseData["home_look"]  = profile.homeLookAt.ToString();
 
+            responseData["home_look_x"] = profile.homeLookAt.X.ToString();
+            responseData["home_look_y"] = profile.homeLookAt.Y.ToString();
+            responseData["home_look_z"] = profile.homeLookAt.Z.ToString();
             response.Value = responseData;
             return response;
         }
diff --git a/OpenSim/Grid/GridServer/GridManager.cs b/OpenSim/Grid/GridServer/GridManager.cs
index 422385d..814d7c1 100644
--- a/OpenSim/Grid/GridServer/GridManager.cs
+++ b/OpenSim/Grid/GridServer/GridManager.cs
@@ -400,8 +400,8 @@ namespace OpenSim.Grid.GridServer
             {
                 responseData["sim_ip"] = simData.serverIP;
                 responseData["sim_port"] = simData.serverPort.ToString();
-                responseData["region_locx"] = simData.regionLocX;
-                responseData["region_locy"] = simData.regionLocY;
+                responseData["region_locx"] = simData.regionLocX.ToString() ;
+                responseData["region_locy"] = simData.regionLocY.ToString();
                 responseData["region_UUID"] = simData.UUID.UUID.ToString();
                 responseData["region_name"] = simData.regionName;
             }
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
index 30465a3..c792918 100644
--- a/OpenSim/Grid/UserServer/Main.cs
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -120,8 +120,8 @@ namespace OpenSim.Grid.UserServer
                     string tempfirstname;
                     string templastname;
                     string tempMD5Passwd;
-                    uint regX = 997;
-                    uint regY = 996;
+                    uint regX = 1000;
+                    uint regY = 1000;
 
                     tempfirstname = m_console.CmdPrompt("First name");
                     templastname = m_console.CmdPrompt("Last name");
diff --git a/OpenSim/Grid/UserServer/UserManager.cs b/OpenSim/Grid/UserServer/UserManager.cs
index 4216515..7ae7853 100644
--- a/OpenSim/Grid/UserServer/UserManager.cs
+++ b/OpenSim/Grid/UserServer/UserManager.cs
@@ -57,6 +57,7 @@ namespace OpenSim.Grid.UserServer
                 "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
 
             // Destination
+            Console.WriteLine("CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " + SimInfo.regionLocY);
             response.SimAddress = SimInfo.serverIP;
             response.SimPort = (Int32)SimInfo.serverPort;
             response.RegionX = SimInfo.regionLocX;
diff --git a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs
index 64856ea..0114fb1 100644
--- a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs
+++ b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs
@@ -41,11 +41,12 @@ namespace OpenSim.Region.ClientStack
         protected override void ProcessInPacket(Packet Pack)
         {
             ack_pack(Pack);
+            debug = true;
             if (debug)
             {
                 if (Pack.Type != PacketType.AgentUpdate)
                 {
-                    Console.WriteLine(Pack.Type.ToString());
+                    Console.WriteLine("IN: " + Pack.Type.ToString());
                 }
             }
 
diff --git a/OpenSim/Region/ClientStack/ClientViewBase.cs b/OpenSim/Region/ClientStack/ClientViewBase.cs
index f105978..24c6911 100644
--- a/OpenSim/Region/ClientStack/ClientViewBase.cs
+++ b/OpenSim/Region/ClientStack/ClientViewBase.cs
@@ -71,6 +71,8 @@ namespace OpenSim.Region.ClientStack
             // Keep track of when this packet was sent out
             Pack.TickCount = Environment.TickCount;
 
+            Console.WriteLine("OUT: " + Pack.Type.ToString());
+
             if (!Pack.Header.Resent)
             {
                 // Set the sequence number
diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
index 4d93cc9..b7d62ed 100644
--- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
+++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
@@ -83,26 +83,29 @@ namespace OpenSim.Region.Communications.OGS1
 
             List<RegionInfo> neighbours = new List<RegionInfo>();
 
-            foreach (Hashtable n in (Hashtable)respData.Values)
+            foreach (ArrayList a in respData.Values)
             {
-                string internalIpStr = (string)n["sim_ip"];
-                int port = (int)n["sim_port"];
-                string externalUri = (string)n["sim_uri"];
-                
-                IPEndPoint neighbourInternalEndPoint = new IPEndPoint( IPAddress.Parse( internalIpStr ), port);
-                string neighbourExternalUri = externalUri;
+                foreach (Hashtable n in a)
+                {
+                    string internalIpStr = (string)n["sim_ip"];
+                    int port = (int)n["sim_port"];
+                    string externalUri = (string)n["sim_uri"];
 
-                RegionInfo neighbour = new RegionInfo((uint)n["x"], (uint)n["y"], neighbourInternalEndPoint, neighbourExternalUri );
+                    IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), port);
+                    string neighbourExternalUri = externalUri;
 
-                //OGS1
-                //neighbour.RegionHandle = (ulong)n["regionhandle"]; is now calculated locally
+                    RegionInfo neighbour = new RegionInfo((uint)n["x"], (uint)n["y"], neighbourInternalEndPoint, neighbourExternalUri);
 
-                neighbour.RegionName = (string)n["name"];
+                    //OGS1
+                    //neighbour.RegionHandle = (ulong)n["regionhandle"]; is now calculated locally
 
-                //OGS1+
-                neighbour.SimUUID = (string)n["uuid"];
+                    neighbour.RegionName = (string)n["name"];
 
-                neighbours.Add(neighbour);
+                    //OGS1+
+                    neighbour.SimUUID = (string)n["uuid"];
+
+                    neighbours.Add(neighbour);
+                }
             }
 
             return neighbours;
diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
index 7c7db03..3a3bccb 100644
--- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
+++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
@@ -35,8 +35,9 @@ namespace OpenSim.Region.Communications.OGS1
             userData.profileWantDoMask = Convert.ToUInt32(data["profile_want_do"]);
             userData.profileImage = new LLUUID((string)data["profile_image"]);
             userData.lastLogin = Convert.ToInt32((string)data["profile_lastlogin"]);
-            userData.homeLocation = new LLVector3();
-            userData.homeLookAt = new LLVector3();
+            userData.homeRegion = Convert.ToUInt64((string)data["home_region"]);
+            userData.homeLocation = 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_z"]));
+            userData.homeLookAt = 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;
         }
-- 
cgit v1.1