From 42857fe4e9e898c8e350da2f9acb3b252b31694a Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Tue, 18 Mar 2008 05:44:25 +0000 Subject: * Added the ability to type the partial name of a region in the start location box and go to that region if it's there. If no close match was found, it sends you home. This is tested on mySQL. There's untested code on grids that are based on sqlite and MSSQL. The SQL statements *should* be right, but your results may very. * Ex, if you want to go to Wright Plaza, you simply need to type Wright Plaza in the start location in the client when you log-in. --- OpenSim/Framework/Communications/IGridServices.cs | 1 + OpenSim/Framework/Data.DB4o/DB4oGridData.cs | 5 +++ OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs | 43 ++++++++++++++++++++ OpenSim/Framework/Data.MySQL/MySQLGridData.cs | 41 +++++++++++++++++++ OpenSim/Framework/Data.SQLite/SQLiteGridData.cs | 32 +++++++++++++++ OpenSim/Framework/Data/GridData.cs | 7 ++++ OpenSim/Framework/Data/RegionProfileData.cs | 42 ++++++++++++++++++++ OpenSim/Framework/Util.cs | 48 +++++++++++++++++++++++ 8 files changed, 219 insertions(+) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index 14baf3f..3e2a5da 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -36,6 +36,7 @@ namespace OpenSim.Framework.Communications bool DeregisterRegion(RegionInfo regionInfo); List RequestNeighbours(uint x, uint y); RegionInfo RequestNeighbourInfo(ulong regionHandle); + RegionInfo RequestClosestRegion(string regionName); Dictionary GetGridSettings(); List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); } diff --git a/OpenSim/Framework/Data.DB4o/DB4oGridData.cs b/OpenSim/Framework/Data.DB4o/DB4oGridData.cs index b11af82..999d4f8 100644 --- a/OpenSim/Framework/Data.DB4o/DB4oGridData.cs +++ b/OpenSim/Framework/Data.DB4o/DB4oGridData.cs @@ -98,6 +98,11 @@ namespace OpenSim.Framework.Data.DB4o "). Total Registered Regions: " + manager.simProfiles.Count); } + public RegionProfileData GetProfileByString(string regionName) + { + throw new Exception("GetProfileByString Not supported in DB4oGridData"); + //return null; + } /// /// Adds a new specified region to the database /// diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs b/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs index 2b91cf9..38a1d08 100644 --- a/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs +++ b/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs @@ -180,6 +180,49 @@ namespace OpenSim.Framework.Data.MSSQL return row; } + + /// + /// Returns a sim profile from it's Region name string + /// + /// The region name search query + /// The sim profile + public RegionProfileData GetProfileByString(string regionName) + { + if (regionName.Length > 2) + { + try + { + lock (database) + { + Dictionary param = new Dictionary(); + // Add % because this is a like query. + param["?regionName"] = regionName + "%"; + // Order by statement will return shorter matches first. Only returns one record or no record. + IDbCommand result = database.Query("SELECT top 1 * FROM " + m_regionsTableName + " WHERE regionName like ?regionName order by regionName", param); + IDataReader reader = result.ExecuteReader(); + + RegionProfileData row = database.getRegionRow(reader); + reader.Close(); + result.Dispose(); + + return row; + } + } + catch (Exception e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + return null; + } + } + else + { + m_log.Error("[DATABASE]: Searched for a Region Name shorter then 3 characters"); + return null; + } + } + + /// /// Adds a new specified region to the database /// diff --git a/OpenSim/Framework/Data.MySQL/MySQLGridData.cs b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs index 584d49c..3855d99 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLGridData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs @@ -249,6 +249,47 @@ namespace OpenSim.Framework.Data.MySQL } /// + /// Returns a sim profile from it's Region name string + /// + /// The region name search query + /// The sim profile + public RegionProfileData GetProfileByString(string regionName) + { + if (regionName.Length > 2) + { + try + { + lock (database) + { + Dictionary param = new Dictionary(); + // Add % because this is a like query. + param["?regionName"] = regionName + "%"; + // Order by statement will return shorter matches first. Only returns one record or no record. + IDbCommand result = database.Query("SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1", param); + IDataReader reader = result.ExecuteReader(); + + RegionProfileData row = database.readSimRow(reader); + reader.Close(); + result.Dispose(); + + return row; + } + } + catch (Exception e) + { + database.Reconnect(); + m_log.Error(e.ToString()); + return null; + } + } + else + { + m_log.Error("[DATABASE]: Searched for a Region Name shorter then 3 characters"); + return null; + } + } + + /// /// Adds a new profile to the database /// /// The profile to add diff --git a/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs b/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs index 6487ba7..4d42f19 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs @@ -112,6 +112,38 @@ namespace OpenSim.Framework.Data.SQLite } /// + /// Returns a sim profile from it's Region name string + /// + /// The region name search query + /// The sim profile + public RegionProfileData GetProfileByString(string regionName) + { + if (regionName.Length > 2) + { + + Dictionary param = new Dictionary(); + // Add % because this is a like query. + param["?regionName"] = regionName + "%"; + // Only returns one record or no record. + IDbCommand result = database.Query("SELECT * FROM regions WHERE regionName like ?regionName LIMIT 1", param); + IDataReader reader = result.ExecuteReader(); + + RegionProfileData row = database.getRow(reader); + reader.Close(); + result.Dispose(); + + return row; + + } + else + { + //m_log.Error("[DATABASE]: Searched for a Region Name shorter then 3 characters"); + return null; + } + } + + + /// /// Returns a sim profile from it's UUID /// /// The region UUID diff --git a/OpenSim/Framework/Data/GridData.cs b/OpenSim/Framework/Data/GridData.cs index 95a568a..5eaa2c4 100644 --- a/OpenSim/Framework/Data/GridData.cs +++ b/OpenSim/Framework/Data/GridData.cs @@ -69,6 +69,13 @@ namespace OpenSim.Framework.Data RegionProfileData GetProfileByLLUUID(LLUUID UUID); /// + /// Returns a sim profile from a string match + /// + /// A string for a partial region name match + /// A sim profile + RegionProfileData GetProfileByString(string regionName); + + /// /// Returns all profiles within the specified range /// /// Minimum sim coordinate (X) diff --git a/OpenSim/Framework/Data/RegionProfileData.cs b/OpenSim/Framework/Data/RegionProfileData.cs index b541116..f736571 100644 --- a/OpenSim/Framework/Data/RegionProfileData.cs +++ b/OpenSim/Framework/Data/RegionProfileData.cs @@ -216,5 +216,47 @@ namespace OpenSim.Framework.Data return simData; } + + /// + /// Request sim profile information from a grid server + /// + /// + /// + /// + /// + /// The sim profile. Null if there was a request failure + public static RegionProfileData RequestSimProfileData(string regionName, string gridserver_url, + string gridserver_sendkey, string gridserver_recvkey) + { + Hashtable requestData = new Hashtable(); + requestData["region_name_search"] = regionName; + requestData["authkey"] = gridserver_sendkey; + ArrayList SendParams = new ArrayList(); + SendParams.Add(requestData); + XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); + XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000); + + Hashtable responseData = (Hashtable)GridResp.Value; + + if (responseData.ContainsKey("error")) + { + return null; + } + + RegionProfileData simData = new RegionProfileData(); + simData.regionLocX = Convert.ToUInt32((string)responseData["region_locx"]); + simData.regionLocY = Convert.ToUInt32((string)responseData["region_locy"]); + simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * Constants.RegionSize), (simData.regionLocY * Constants.RegionSize)); + simData.serverIP = (string)responseData["sim_ip"]; + simData.serverPort = Convert.ToUInt32((string)responseData["sim_port"]); + simData.httpPort = Convert.ToUInt32((string)responseData["http_port"]); + simData.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); + simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/"; + simData.serverURI = (string)responseData["server_uri"]; + simData.UUID = new LLUUID((string)responseData["region_UUID"]); + simData.regionName = (string)responseData["region_name"]; + + return simData; + } } } diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 0f1f0d9..37ddb3e 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -597,5 +597,53 @@ namespace OpenSim.Framework return ret; } + public static string[] ParseStartLocationRequest(string startLocationRequest) + { + string[] returnstring = new string[4]; + // format uri:RegionName&X&Y&Z + returnstring[0] = "last"; + returnstring[1] = "127"; + returnstring[2] = "127"; + returnstring[3] = "0"; + // This is the crappy way of doing it. + + if (startLocationRequest.Contains(":") && startLocationRequest.Contains("&")) + { + //System.Console.WriteLine("StartLocationRequest Contains proper elements"); + + string[] splitstr = startLocationRequest.Split(':');//,2,StringSplitOptions.RemoveEmptyEntries); + + //System.Console.WriteLine("Found " + splitstr.GetLength(0) + " elements in 1st split result"); + + if (splitstr.GetLength(0) == 2) + { + + string[] splitstr2 = splitstr[1].Split('&');//, 4, StringSplitOptions.RemoveEmptyEntries); + + //System.Console.WriteLine("Found " + splitstr2.GetLength(0) + " elements in 2nd split result"); + + if (splitstr2.GetLength(0) >= 1) + { + returnstring[0] = splitstr2[0]; + } + if (splitstr2.GetLength(0) >= 2) + { + returnstring[1] = splitstr2[1]; + } + if (splitstr2.GetLength(0) >= 3) + { + returnstring[2] = splitstr2[2]; + } + if (splitstr2.GetLength(0) >= 4) + { + returnstring[3] = splitstr2[3]; + } + } + + } + return returnstring; + + + } } } -- cgit v1.1