mirror of
https://github.com/opensim/opensim.git
synced 2026-08-06 17:32:42 +08:00
* 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.
This commit is contained in:
@@ -36,6 +36,7 @@ namespace OpenSim.Framework.Communications
|
||||
bool DeregisterRegion(RegionInfo regionInfo);
|
||||
List<SimpleRegionInfo> RequestNeighbours(uint x, uint y);
|
||||
RegionInfo RequestNeighbourInfo(ulong regionHandle);
|
||||
RegionInfo RequestClosestRegion(string regionName);
|
||||
Dictionary<string, string> GetGridSettings();
|
||||
List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a new specified region to the database
|
||||
/// </summary>
|
||||
|
||||
@@ -180,6 +180,49 @@ namespace OpenSim.Framework.Data.MSSQL
|
||||
return row;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns a sim profile from it's Region name string
|
||||
/// </summary>
|
||||
/// <param name="uuid">The region name search query</param>
|
||||
/// <returns>The sim profile</returns>
|
||||
public RegionProfileData GetProfileByString(string regionName)
|
||||
{
|
||||
if (regionName.Length > 2)
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (database)
|
||||
{
|
||||
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new specified region to the database
|
||||
/// </summary>
|
||||
|
||||
@@ -248,6 +248,47 @@ namespace OpenSim.Framework.Data.MySQL
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a sim profile from it's Region name string
|
||||
/// </summary>
|
||||
/// <param name="uuid">The region name search query</param>
|
||||
/// <returns>The sim profile</returns>
|
||||
public RegionProfileData GetProfileByString(string regionName)
|
||||
{
|
||||
if (regionName.Length > 2)
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (database)
|
||||
{
|
||||
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new profile to the database
|
||||
/// </summary>
|
||||
|
||||
@@ -111,6 +111,38 @@ namespace OpenSim.Framework.Data.SQLite
|
||||
return row;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a sim profile from it's Region name string
|
||||
/// </summary>
|
||||
/// <param name="uuid">The region name search query</param>
|
||||
/// <returns>The sim profile</returns>
|
||||
public RegionProfileData GetProfileByString(string regionName)
|
||||
{
|
||||
if (regionName.Length > 2)
|
||||
{
|
||||
|
||||
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns a sim profile from it's UUID
|
||||
/// </summary>
|
||||
|
||||
@@ -68,6 +68,13 @@ namespace OpenSim.Framework.Data
|
||||
/// <returns>A sim profile</returns>
|
||||
RegionProfileData GetProfileByLLUUID(LLUUID UUID);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a sim profile from a string match
|
||||
/// </summary>
|
||||
/// <param name="regionName">A string for a partial region name match</param>
|
||||
/// <returns>A sim profile</returns>
|
||||
RegionProfileData GetProfileByString(string regionName);
|
||||
|
||||
/// <summary>
|
||||
/// Returns all profiles within the specified range
|
||||
/// </summary>
|
||||
|
||||
@@ -216,5 +216,47 @@ namespace OpenSim.Framework.Data
|
||||
|
||||
return simData;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Request sim profile information from a grid server
|
||||
/// </summary>
|
||||
/// <param name="region_handle"></param>
|
||||
/// <param name="gridserver_url"></param>
|
||||
/// <param name="gridserver_sendkey"></param>
|
||||
/// <param name="gridserver_recvkey"></param>
|
||||
/// <returns>The sim profile. Null if there was a request failure</returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user