Implemented console command "show hyperlinks".

0.7.0.1-release
Marck 2010-07-31 20:16:39 +02:00 committed by Diva Canto
parent 875a623654
commit 692e684ced
5 changed files with 111 additions and 110 deletions

View File

@ -58,10 +58,11 @@ namespace OpenSim.Data
bool SetDataItem(UUID principalID, string item, string value); bool SetDataItem(UUID principalID, string item, string value);
bool Delete(UUID regionID); bool Delete(UUID regionID);
List<RegionData> GetDefaultRegions(UUID scopeID); List<RegionData> GetDefaultRegions(UUID scopeID);
List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y); List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y);
List<RegionData> GetHyperlinks(UUID scopeID);
} }
[Flags] [Flags]

View File

@ -306,38 +306,37 @@ namespace OpenSim.Data.MSSQL
return true; return true;
} }
return false; return false;
} }
public List<RegionData> GetDefaultRegions(UUID scopeID) public List<RegionData> GetDefaultRegions(UUID scopeID)
{ {
string sql = "SELECT * FROM [" + m_Realm + "] WHERE (flags & 1) <> 0"; return Get((int)RegionFlags.DefaultRegion, scopeID);
if (scopeID != UUID.Zero)
sql += " AND ScopeID = @scopeID";
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
using (SqlCommand cmd = new SqlCommand(sql, conn))
{
cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID));
conn.Open();
return RunCommand(cmd);
}
} }
public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y) public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y)
{ {
string sql = "SELECT * FROM [" + m_Realm + "] WHERE (flags & 2) <> 0"; // TODO: distance-sort results
if (scopeID != UUID.Zero) return Get((int)RegionFlags.FallbackRegion, scopeID);
sql += " AND ScopeID = @scopeID"; }
using (SqlConnection conn = new SqlConnection(m_ConnectionString)) public List<RegionData> GetHyperlinks(UUID scopeID)
using (SqlCommand cmd = new SqlCommand(sql, conn)) {
{ return Get((int)RegionFlags.Hyperlink, scopeID);
cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID)); }
conn.Open();
// TODO: distance-sort results private List<RegionData> Get(int regionFlags, UUID scopeID)
return RunCommand(cmd); {
} string sql = "SELECT * FROM [" + m_Realm + "] WHERE (flags & " + regionFlags.ToString() + ") <> 0";
} if (scopeID != UUID.Zero)
sql += " AND ScopeID = @scopeID";
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
using (SqlCommand cmd = new SqlCommand(sql, conn))
{
cmd.Parameters.Add(m_database.CreateParameter("@scopeID", scopeID));
conn.Open();
return RunCommand(cmd);
}
}
} }
} }

View File

@ -280,32 +280,35 @@ namespace OpenSim.Data.MySQL
} }
return false; return false;
} }
public List<RegionData> GetDefaultRegions(UUID scopeID) public List<RegionData> GetDefaultRegions(UUID scopeID)
{ {
string command = "select * from `"+m_Realm+"` where (flags & 1) <> 0"; return Get((int)RegionFlags.DefaultRegion, scopeID);
if (scopeID != UUID.Zero)
command += " and ScopeID = ?scopeID";
MySqlCommand cmd = new MySqlCommand(command);
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
return RunCommand(cmd);
} }
public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y) public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y)
{ {
string command = "select * from `"+m_Realm+"` where (flags & 2) <> 0"; // TODO: distance-sort results
if (scopeID != UUID.Zero) return Get((int)RegionFlags.FallbackRegion, scopeID);
command += " and ScopeID = ?scopeID"; }
MySqlCommand cmd = new MySqlCommand(command); public List<RegionData> GetHyperlinks(UUID scopeID)
{
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); return Get((int)RegionFlags.Hyperlink, scopeID);
}
// TODO: distance-sort results
return RunCommand(cmd); private List<RegionData> Get(int regionFlags, UUID scopeID)
} {
string command = "select * from `" + m_Realm + "` where (flags & " + regionFlags.ToString() + ") <> 0";
if (scopeID != UUID.Zero)
command += " and ScopeID = ?scopeID";
MySqlCommand cmd = new MySqlCommand(command);
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
return RunCommand(cmd);
}
} }
} }

View File

@ -49,8 +49,8 @@ namespace OpenSim.Data.Null
if (Instance == null) if (Instance == null)
Instance = this; Instance = this;
//Console.WriteLine("[XXX] NullRegionData constructor"); //Console.WriteLine("[XXX] NullRegionData constructor");
} }
public List<RegionData> Get(string regionName, UUID scopeID) public List<RegionData> Get(string regionName, UUID scopeID)
{ {
if (Instance != this) if (Instance != this)
@ -160,38 +160,37 @@ namespace OpenSim.Data.Null
m_regionData.Remove(regionID); m_regionData.Remove(regionID);
return true; return true;
} }
public List<RegionData> GetDefaultRegions(UUID scopeID) public List<RegionData> GetDefaultRegions(UUID scopeID)
{ {
if (Instance != this) return Get((int)RegionFlags.DefaultRegion, scopeID);
return Instance.GetDefaultRegions(scopeID);
List<RegionData> ret = new List<RegionData>();
foreach (RegionData r in m_regionData.Values)
{
if ((Convert.ToInt32(r.Data["flags"]) & 1) != 0)
ret.Add(r);
}
return ret;
} }
public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y) public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y)
{ {
if (Instance != this) return Get((int)RegionFlags.FallbackRegion, scopeID);
return Instance.GetFallbackRegions(scopeID, x, y); }
List<RegionData> ret = new List<RegionData>(); public List<RegionData> GetHyperlinks(UUID scopeID)
{
foreach (RegionData r in m_regionData.Values) return Get((int)RegionFlags.Hyperlink, scopeID);
{ }
if ((Convert.ToInt32(r.Data["flags"]) & 2) != 0)
ret.Add(r); private List<RegionData> Get(int regionFlags, UUID scopeID)
} {
if (Instance != this)
return ret; return Instance.Get(regionFlags, scopeID);
}
List<RegionData> ret = new List<RegionData>();
foreach (RegionData r in m_regionData.Values)
{
if ((Convert.ToInt32(r.Data["flags"]) & regionFlags) != 0)
ret.Add(r);
}
return ret;
}
} }
} }

View File

@ -378,32 +378,31 @@ namespace OpenSim.Services.GridService
public void HandleShow(string module, string[] cmd) public void HandleShow(string module, string[] cmd)
{ {
MainConsole.Instance.Output("Not Implemented Yet"); if (cmd.Length != 2)
//if (cmd.Length != 2) {
//{ MainConsole.Instance.Output("Syntax: show hyperlinks");
// MainConsole.Instance.Output("Syntax: show hyperlinks"); return;
// return; }
//} List<RegionData> regions = m_Database.GetHyperlinks(UUID.Zero);
//List<GridRegion> regions = new List<GridRegion>(m_HypergridService.m_HyperlinkRegions.Values); if (regions == null || regions.Count < 1)
//if (regions == null || regions.Count < 1) {
//{ MainConsole.Instance.Output("No hyperlinks");
// MainConsole.Instance.Output("No hyperlinks"); return;
// return; }
//}
MainConsole.Instance.Output("Region Name Region UUID");
//MainConsole.Instance.Output("Region Name Region UUID"); MainConsole.Instance.Output("Location URI");
//MainConsole.Instance.Output("Location URI"); MainConsole.Instance.Output("-------------------------------------------------------------------------------");
//MainConsole.Instance.Output("Owner ID "); foreach (RegionData r in regions)
//MainConsole.Instance.Output("-------------------------------------------------------------------------------"); {
//foreach (GridRegion r in regions) MainConsole.Instance.Output(String.Format("{0,-39} {1}\n{2,-39} {3}\n",
//{ r.RegionName, r.RegionID,
// MainConsole.Instance.Output(String.Format("{0,-20} {1}\n{2,-20} {3}\n{4,-39} \n\n", String.Format("{0},{1} ({2},{3})", r.posX, r.posY, r.posX / 256, r.posY / 256),
// r.RegionName, r.RegionID, "http://" + r.Data["serverIP"].ToString() + ":" + r.Data["serverHttpPort"].ToString()));
// String.Format("{0},{1}", r.RegionLocX, r.RegionLocY), "http://" + r.ExternalHostName + ":" + r.HttpPort.ToString(), }
// r.EstateOwner.ToString())); return;
//}
//return;
} }
public void RunCommand(string module, string[] cmdparams) public void RunCommand(string module, string[] cmdparams)
{ {
List<string> args = new List<string>(cmdparams); List<string> args = new List<string>(cmdparams);