From 692e684ced49ffa59771d29819750e41ec58a2da Mon Sep 17 00:00:00 2001 From: Marck Date: Sat, 31 Jul 2010 20:16:39 +0200 Subject: Implemented console command "show hyperlinks". --- OpenSim/Data/IRegionData.cs | 7 ++-- OpenSim/Data/MSSQL/MSSQLRegionData.cs | 55 ++++++++++++++++--------------- OpenSim/Data/MySQL/MySQLRegionData.cs | 49 +++++++++++++++------------- OpenSim/Data/Null/NullRegionData.cs | 61 +++++++++++++++++------------------ 4 files changed, 87 insertions(+), 85 deletions(-) (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/IRegionData.cs b/OpenSim/Data/IRegionData.cs index 8259f9b..9f08e04 100644 --- a/OpenSim/Data/IRegionData.cs +++ b/OpenSim/Data/IRegionData.cs @@ -58,10 +58,11 @@ namespace OpenSim.Data bool SetDataItem(UUID principalID, string item, string value); - bool Delete(UUID regionID); - + bool Delete(UUID regionID); + List GetDefaultRegions(UUID scopeID); - List GetFallbackRegions(UUID scopeID, int x, int y); + List GetFallbackRegions(UUID scopeID, int x, int y); + List GetHyperlinks(UUID scopeID); } [Flags] diff --git a/OpenSim/Data/MSSQL/MSSQLRegionData.cs b/OpenSim/Data/MSSQL/MSSQLRegionData.cs index 66c3f81..73c67d4 100644 --- a/OpenSim/Data/MSSQL/MSSQLRegionData.cs +++ b/OpenSim/Data/MSSQL/MSSQLRegionData.cs @@ -306,38 +306,37 @@ namespace OpenSim.Data.MSSQL return true; } return false; - } + } public List GetDefaultRegions(UUID scopeID) - { - string sql = "SELECT * FROM [" + m_Realm + "] WHERE (flags & 1) <> 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); - } - + { + return Get((int)RegionFlags.DefaultRegion, scopeID); } public List GetFallbackRegions(UUID scopeID, int x, int y) - { - string sql = "SELECT * FROM [" + m_Realm + "] WHERE (flags & 2) <> 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(); - // TODO: distance-sort results - return RunCommand(cmd); - } - } + { + // TODO: distance-sort results + return Get((int)RegionFlags.FallbackRegion, scopeID); + } + + public List GetHyperlinks(UUID scopeID) + { + return Get((int)RegionFlags.Hyperlink, scopeID); + } + + private List Get(int regionFlags, UUID scopeID) + { + 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); + } + } } } diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index c7bddac..6dc62c6 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -280,32 +280,35 @@ namespace OpenSim.Data.MySQL } return false; - } + } + public List GetDefaultRegions(UUID scopeID) - { - string command = "select * from `"+m_Realm+"` where (flags & 1) <> 0"; - if (scopeID != UUID.Zero) - command += " and ScopeID = ?scopeID"; - - MySqlCommand cmd = new MySqlCommand(command); - - cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); - - return RunCommand(cmd); + { + return Get((int)RegionFlags.DefaultRegion, scopeID); } public List GetFallbackRegions(UUID scopeID, int x, int y) - { - string command = "select * from `"+m_Realm+"` where (flags & 2) <> 0"; - if (scopeID != UUID.Zero) - command += " and ScopeID = ?scopeID"; - - MySqlCommand cmd = new MySqlCommand(command); - - cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); - - // TODO: distance-sort results - return RunCommand(cmd); - } + { + // TODO: distance-sort results + return Get((int)RegionFlags.FallbackRegion, scopeID); + } + + public List GetHyperlinks(UUID scopeID) + { + return Get((int)RegionFlags.Hyperlink, scopeID); + } + + private List 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); + } } } diff --git a/OpenSim/Data/Null/NullRegionData.cs b/OpenSim/Data/Null/NullRegionData.cs index d596698..397b32d 100644 --- a/OpenSim/Data/Null/NullRegionData.cs +++ b/OpenSim/Data/Null/NullRegionData.cs @@ -49,8 +49,8 @@ namespace OpenSim.Data.Null if (Instance == null) Instance = this; //Console.WriteLine("[XXX] NullRegionData constructor"); - } - + } + public List Get(string regionName, UUID scopeID) { if (Instance != this) @@ -160,38 +160,37 @@ namespace OpenSim.Data.Null m_regionData.Remove(regionID); return true; - } - + } + public List GetDefaultRegions(UUID scopeID) - { - if (Instance != this) - return Instance.GetDefaultRegions(scopeID); - - List ret = new List(); - - foreach (RegionData r in m_regionData.Values) - { - if ((Convert.ToInt32(r.Data["flags"]) & 1) != 0) - ret.Add(r); - } - - return ret; + { + return Get((int)RegionFlags.DefaultRegion, scopeID); } public List GetFallbackRegions(UUID scopeID, int x, int y) - { - if (Instance != this) - return Instance.GetFallbackRegions(scopeID, x, y); - - List ret = new List(); - - foreach (RegionData r in m_regionData.Values) - { - if ((Convert.ToInt32(r.Data["flags"]) & 2) != 0) - ret.Add(r); - } - - return ret; - } + { + return Get((int)RegionFlags.FallbackRegion, scopeID); + } + + public List GetHyperlinks(UUID scopeID) + { + return Get((int)RegionFlags.Hyperlink, scopeID); + } + + private List Get(int regionFlags, UUID scopeID) + { + if (Instance != this) + return Instance.Get(regionFlags, scopeID); + + List ret = new List(); + + foreach (RegionData r in m_regionData.Values) + { + if ((Convert.ToInt32(r.Data["flags"]) & regionFlags) != 0) + ret.Add(r); + } + + return ret; + } } } \ No newline at end of file -- cgit v1.1