diff --git a/OpenSim/Data/MSSQL/MSSQLDataStore.cs b/OpenSim/Data/MSSQL/MSSQLDataStore.cs index 46e410765d..c7d034f721 100644 --- a/OpenSim/Data/MSSQL/MSSQLDataStore.cs +++ b/OpenSim/Data/MSSQL/MSSQLDataStore.cs @@ -548,9 +548,9 @@ namespace OpenSim.Data.MSSQL /// /// the region UUID /// the banlist list - public List LoadRegionBanList(LLUUID regionUUID) + public List LoadRegionBanList(LLUUID regionUUID) { - List regionbanlist = new List(); + List regionbanlist = new List(); return regionbanlist; } @@ -558,7 +558,7 @@ namespace OpenSim.Data.MSSQL /// STUB, add an item into region banlist /// /// the item - public void AddToRegionBanlist(RegionBanListItem item) + public void AddToRegionBanlist(EstateBan item) { } @@ -567,7 +567,7 @@ namespace OpenSim.Data.MSSQL /// STUB, remove an item from region banlist /// /// - public void RemoveFromRegionBanlist(RegionBanListItem item) + public void RemoveFromRegionBanlist(EstateBan item) { } diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index 254e526ceb..25956d5b09 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -53,7 +53,6 @@ namespace OpenSim.Data.MySQL private const string m_terrainSelect = "select * from terrain limit 1"; private const string m_landSelect = "select * from land"; private const string m_landAccessListSelect = "select * from landaccesslist"; - private const string m_regionBanListSelect = "select * from regionban"; private const string m_regionSettingsSelect = "select * from regionsettings"; private const string m_waitTimeoutSelect = "select @@wait_timeout"; @@ -83,7 +82,6 @@ namespace OpenSim.Data.MySQL private MySqlDataAdapter m_terrainDataAdapter; private MySqlDataAdapter m_landDataAdapter; private MySqlDataAdapter m_landAccessListDataAdapter; - private MySqlDataAdapter m_regionBanListDataAdapter; private MySqlDataAdapter m_regionSettingsDataAdapter; private DataTable m_primTable; @@ -92,7 +90,6 @@ namespace OpenSim.Data.MySQL private DataTable m_terrainTable; private DataTable m_landTable; private DataTable m_landAccessListTable; - private DataTable m_regionBanListTable; private DataTable m_regionSettingsTable; /// Temporary attribute while this is experimental @@ -150,9 +147,6 @@ namespace OpenSim.Data.MySQL MySqlCommand landAccessListSelectCmd = new MySqlCommand(m_landAccessListSelect, m_connection); m_landAccessListDataAdapter = new MySqlDataAdapter(landAccessListSelectCmd); - MySqlCommand regionBanListSelectCmd = new MySqlCommand(m_regionBanListSelect, m_connection); - m_regionBanListDataAdapter = new MySqlDataAdapter(regionBanListSelectCmd); - MySqlCommand regionSettingsSelectCmd = new MySqlCommand(m_regionSettingsSelect, m_connection); m_regionSettingsDataAdapter = new MySqlDataAdapter(regionSettingsSelectCmd); @@ -192,11 +186,6 @@ namespace OpenSim.Data.MySQL setupLandAccessCommands(m_landAccessListDataAdapter, m_connection); m_landAccessListDataAdapter.Fill(m_landAccessListTable); - m_regionBanListTable = createRegionBanTable(); - m_dataSet.Tables.Add(m_regionBanListTable); - SetupRegionBanCommands(m_regionBanListDataAdapter, m_connection); - m_regionBanListDataAdapter.Fill(m_regionBanListTable); - m_regionSettingsTable = createRegionSettingsTable(); m_dataSet.Tables.Add(m_regionSettingsTable); SetupRegionSettingsCommands(m_regionSettingsDataAdapter, m_connection); @@ -773,99 +762,6 @@ namespace OpenSim.Data.MySQL } } - /// - /// Load (fetch?) a region banlist - /// - /// The region UUID - /// The Region banlist - public List LoadRegionBanList(LLUUID regionUUID) - { - List regionbanlist = new List(); - lock (m_dataSet) - { - CheckConnection(); - DataTable regionban = m_regionBanListTable; - string searchExp = "regionUUID = '" + regionUUID.ToString() + "'"; - DataRow[] rawbanlist = regionban.Select(searchExp); - foreach (DataRow rawbanrow in rawbanlist) - { - RegionBanListItem rbli = new RegionBanListItem(); - LLUUID tmpvalue = LLUUID.Zero; - - rbli.regionUUID = regionUUID; - - if (Helpers.TryParse((string)rawbanrow["bannedUUID"], out tmpvalue)) - rbli.bannedUUID = tmpvalue; - - rbli.bannedIP = (string)rawbanrow["bannedIp"]; - rbli.bannedIPHostMask = (string)rawbanrow["bannedIpHostMask"]; - regionbanlist.Add(rbli); - } - return regionbanlist; - } - } - - /// - /// Add an item to region banlist - /// - /// The item - public void AddToRegionBanlist(RegionBanListItem item) - { - lock (m_dataSet) - { - CheckConnection(); - DataTable regionban = m_regionBanListTable; - string searchExp = "regionUUID = '" + item.regionUUID.ToString() + "' AND bannedUUID = '" + item.bannedUUID.ToString() + "'"; - DataRow[] rawbanlist = regionban.Select(searchExp); - if (rawbanlist.Length == 0) - { - DataRow regionbanrow = regionban.NewRow(); - regionbanrow["regionUUID"] = item.regionUUID.ToString(); - regionbanrow["bannedUUID"] = item.bannedUUID.ToString(); - regionbanrow["bannedIp"] = item.bannedIP.ToString(); - regionbanrow["bannedIpHostMask"] = item.bannedIPHostMask.ToString(); - regionban.Rows.Add(regionbanrow); - } - Commit(); - } - } - - /// - /// Remove an item from region banlist - /// - /// The item - public void RemoveFromRegionBanlist(RegionBanListItem item) - { - lock (m_dataSet) - { - CheckConnection(); - DataTable regionban = m_regionBanListTable; - string searchExp = "regionUUID = '" + item.regionUUID.ToString() + "' AND bannedUUID = '" + item.bannedUUID.ToString() + "'"; - DataRow[] rawbanlist = regionban.Select(searchExp); - if (rawbanlist.Length > 0) - { - foreach (DataRow rbli in rawbanlist) - { - regionban.Rows.Remove(rbli); - } - } - Commit(); - } - - using - ( - MySqlCommand cmd = - new MySqlCommand("delete from regionban where regionUUID = ?regionUUID AND bannedUUID = ?bannedUUID", m_connection) - ) - { - cmd.Parameters.Add(new MySqlParameter("?regionUUID", item.regionUUID.ToString())); - cmd.Parameters.Add(new MySqlParameter("?bannedUUID", item.bannedUUID.ToString())); - CheckConnection(); - cmd.ExecuteNonQuery(); - } - - } - /// /// /// @@ -918,7 +814,6 @@ namespace OpenSim.Data.MySQL m_terrainDataAdapter.Update(m_terrainTable); m_landDataAdapter.Update(m_landTable); m_landAccessListDataAdapter.Update(m_landAccessListTable); - m_regionBanListDataAdapter.Update(m_regionBanListTable); m_regionSettingsDataAdapter.Update(m_regionSettingsTable); m_dataSet.AcceptChanges(); @@ -1006,6 +901,7 @@ namespace OpenSim.Data.MySQL createCol(regionsettings, "terrain_raise_limit", typeof (Double)); createCol(regionsettings, "terrain_lower_limit", typeof (Double)); createCol(regionsettings, "use_estate_sun", typeof (Int32)); + createCol(regionsettings, "sandbox", typeof (Int32)); createCol(regionsettings, "fixed_sun", typeof (Int32)); createCol(regionsettings, "sun_position", typeof (Double)); createCol(regionsettings, "covenant", typeof(String)); @@ -1015,21 +911,6 @@ namespace OpenSim.Data.MySQL return regionsettings; } - /// - /// Create the "regionban" table - /// - /// - private static DataTable createRegionBanTable() - { - DataTable regionban = new DataTable("regionban"); - createCol(regionban, "regionUUID", typeof(String)); - createCol(regionban, "bannedUUID", typeof(String)); - createCol(regionban, "bannedIp", typeof(String)); - createCol(regionban, "bannedIpHostMask", typeof(String)); - return regionban; - - } - /// /// Create the "prims" table /// @@ -1417,6 +1298,7 @@ namespace OpenSim.Data.MySQL newSettings.TerrainRaiseLimit = Convert.ToDouble(row["terrain_raise_limit"]); newSettings.TerrainLowerLimit = Convert.ToDouble(row["terrain_lower_limit"]); newSettings.UseEstateSun = Convert.ToBoolean(row["use_estate_sun"]); + newSettings.Sandbox = Convert.ToBoolean(row["sandbox"]); newSettings.FixedSun = Convert.ToBoolean(row["fixed_sun"]); newSettings.SunPosition = Convert.ToDouble(row["sun_position"]); newSettings.Covenant = new LLUUID((String) row["covenant"]); @@ -1676,6 +1558,7 @@ namespace OpenSim.Data.MySQL row["terrain_raise_limit"] = settings.TerrainRaiseLimit; row["terrain_lower_limit"] = settings.TerrainLowerLimit; row["use_estate_sun"] = settings.UseEstateSun; + row["sandbox"] = settings.Sandbox; row["fixed_sun"] = settings.FixedSun; row["sun_position"] = settings.SunPosition; row["covenant"] = settings.Covenant.ToString(); @@ -2138,26 +2021,6 @@ namespace OpenSim.Data.MySQL da.DeleteCommand = delete; } - /// - /// - /// - /// - /// - private void SetupRegionBanCommands(MySqlDataAdapter da, MySqlConnection conn) - { - da.InsertCommand = createInsertCommand("regionban", m_regionBanListTable); - da.InsertCommand.Connection = conn; - - da.UpdateCommand = createUpdateCommand("regionban", "regionUUID = ?regionUUID AND bannedUUID = ?bannedUUID", m_regionBanListTable); - da.UpdateCommand.Connection = conn; - - MySqlCommand delete = new MySqlCommand("delete from regionban where regionUUID = ?regionUUID AND bannedUUID = ?bannedUUID"); - delete.Parameters.Add(createMySqlParameter("regionUUID", typeof(String))); - delete.Parameters.Add(createMySqlParameter("bannedUUID", typeof(String))); - delete.Connection = conn; - da.DeleteCommand = delete; - } - /// /// /// diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs new file mode 100644 index 0000000000..eeff31b21c --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -0,0 +1,386 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Data; +using System.IO; +using System.Reflection; +using System.Threading; +using libsecondlife; +using log4net; +using MySql.Data.MySqlClient; +using OpenSim.Framework; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; + +namespace OpenSim.Data.MySQL +{ + public class MySQLEstateStore : IEstateDataStore + { + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private const string m_waitTimeoutSelect = "select @@wait_timeout"; + + private MySqlConnection m_connection; + private string m_connectionString; + private long m_waitTimeout; + private long m_waitTimeoutLeeway = 60 * TimeSpan.TicksPerSecond; + private long m_lastConnectionUse; + + private FieldInfo[] m_Fields; + private Dictionary m_FieldMap = + new Dictionary(); + + public void Initialise(string connectionString) + { + m_connectionString = connectionString; + + m_log.Info("[ESTATE DB]: MySql - connecting: "+m_connectionString); + + m_connection = new MySqlConnection(m_connectionString); + m_connection.Open(); + + GetWaitTimeout(); + + Assembly assem = GetType().Assembly; + Migration m = new Migration(m_connection, assem, "EstateStore"); + m.Update(); + + Type t = typeof(EstateSettings); + m_Fields = t.GetFields(BindingFlags.NonPublic | + BindingFlags.Instance | + BindingFlags.DeclaredOnly); + + foreach (FieldInfo f in m_Fields) + if(f.Name.Substring(0, 2) == "m_") + m_FieldMap[f.Name.Substring(2)] = f; + } + + private string[] FieldList + { + get { return new List(m_FieldMap.Keys).ToArray(); } + } + + protected void GetWaitTimeout() + { + MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, + m_connection); + + using (MySqlDataReader dbReader = + cmd.ExecuteReader(CommandBehavior.SingleRow)) + { + if (dbReader.Read()) + { + m_waitTimeout + = Convert.ToInt32(dbReader["@@wait_timeout"]) * + TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; + } + + dbReader.Close(); + cmd.Dispose(); + } + + m_lastConnectionUse = System.DateTime.Now.Ticks; + + m_log.DebugFormat( + "[REGION DB]: Connection wait timeout {0} seconds", + m_waitTimeout / TimeSpan.TicksPerSecond); + } + + protected void CheckConnection() + { + long timeNow = System.DateTime.Now.Ticks; + if (timeNow - m_lastConnectionUse > m_waitTimeout || + m_connection.State != ConnectionState.Open) + { + m_log.DebugFormat("[REGION DB]: Database connection has gone away - reconnecting"); + + lock (m_connection) + { + m_connection.Close(); + m_connection = new MySqlConnection(m_connectionString); + m_connection.Open(); + } + } + + m_lastConnectionUse = timeNow; + } + + public EstateSettings LoadEstateSettings(LLUUID regionID) + { + EstateSettings es = new EstateSettings(); + + string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = ?RegionID"; + + CheckConnection(); + + MySqlCommand cmd = m_connection.CreateCommand(); + + cmd.CommandText = sql; + cmd.Parameters.Add("?RegionID", regionID.ToString()); + + IDataReader r = cmd.ExecuteReader(); + + if(r.Read()) + { + foreach (string name in FieldList) + { + if(m_FieldMap[name].GetValue(es) is bool) + { + int v = Convert.ToInt32(r[name]); + if(v != 0) + m_FieldMap[name].SetValue(es, true); + else + m_FieldMap[name].SetValue(es, false); + } + else + { + m_FieldMap[name].SetValue(es, r[name]); + } + } + r.Close(); + } + else + { + // Migration case + // + r.Close(); + + List names = new List(FieldList); + + names.Remove("EstateID"); + + sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( ?"+String.Join(", ?", names.ToArray())+")"; + + cmd.CommandText = sql; + cmd.Parameters.Clear(); + + foreach (string name in FieldList) + { + if(m_FieldMap[name].GetValue(es) is bool) + { + if((bool)m_FieldMap[name].GetValue(es)) + cmd.Parameters.Add("?"+name, "1"); + else + cmd.Parameters.Add("?"+name, "0"); + } + else + { + cmd.Parameters.Add("?"+name, m_FieldMap[name].GetValue(es).ToString()); + } + } + + cmd.ExecuteNonQuery(); + + cmd.CommandText = "select LAST_INSERT_ID() as id"; + cmd.Parameters.Clear(); + + r = cmd.ExecuteReader(); + + r.Read(); + + es.EstateID = Convert.ToUInt32(r["id"]); + + r.Close(); + + cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; + cmd.Parameters.Add("?RegionID", regionID.ToString()); + cmd.Parameters.Add("?EstateID", es.EstateID.ToString()); + + // This will throw on dupe key + try + { + cmd.ExecuteNonQuery(); + } + catch (Exception) + { + } + + // Munge and transfer the ban list + // + cmd.Parameters.Clear(); + cmd.CommandText = "insert into estateban select "+es.EstateID.ToString()+", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID"; + cmd.Parameters.Add("?UUID", regionID.ToString()); + + try + { + cmd.ExecuteNonQuery(); + } + catch (Exception) + { + } + } + + LoadBanList(es); + + es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers"); + es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users"); + es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups"); + return es; + } + + public void StoreEstateSettings(EstateSettings es) + { + string sql = "replace into estate_settings ("+String.Join(",", FieldList)+") values ( ?"+String.Join(", ?", FieldList)+")"; + + CheckConnection(); + + MySqlCommand cmd = m_connection.CreateCommand(); + + cmd.CommandText = sql; + + foreach (string name in FieldList) + { + if(m_FieldMap[name].GetValue(es) is bool) + { + if((bool)m_FieldMap[name].GetValue(es)) + cmd.Parameters.Add("?"+name, "1"); + else + cmd.Parameters.Add("?"+name, "0"); + } + else + { + cmd.Parameters.Add("?"+name, m_FieldMap[name].GetValue(es).ToString()); + } + } + + cmd.ExecuteNonQuery(); + + SaveBanList(es); + SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers); + SaveUUIDList(es.EstateID, "estate_users", es.EstateAccess); + SaveUUIDList(es.EstateID, "estate_groups", es.EstateGroups); + } + + private void LoadBanList(EstateSettings es) + { + es.ClearBans(); + + CheckConnection(); + + MySqlCommand cmd = m_connection.CreateCommand(); + + cmd.CommandText = "select bannedUUID from estateban where EstateID = ?EstateID"; + cmd.Parameters.Add("?EstateID", es.EstateID); + + IDataReader r = cmd.ExecuteReader(); + + while(r.Read()) + { + EstateBan eb = new EstateBan(); + + LLUUID uuid = new LLUUID(); + LLUUID.TryParse(r["bannedUUID"].ToString(), out uuid); + + eb.bannedUUID = uuid; + eb.bannedIP = "0.0.0.0"; + eb.bannedIPHostMask = "0.0.0.0"; + es.AddBan(eb); + } + r.Close(); + } + + private void SaveBanList(EstateSettings es) + { + CheckConnection(); + + MySqlCommand cmd = m_connection.CreateCommand(); + + cmd.CommandText = "delete from estateban where EstateID = ?EstateID"; + cmd.Parameters.Add("?EstateID", es.EstateID.ToString()); + + cmd.ExecuteNonQuery(); + + cmd.Parameters.Clear(); + + cmd.CommandText = "insert into estateban (EstateID, bannedUUID) values ( ?EstateID, ?bannedUUID )"; + + foreach(EstateBan b in es.EstateBans) + { + cmd.Parameters.Add("?EstateID", es.EstateID.ToString()); + cmd.Parameters.Add("?bannedUUID", b.bannedUUID.ToString()); + + cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + } + } + + void SaveUUIDList(uint EstateID, string table, LLUUID[] data) + { + CheckConnection(); + + MySqlCommand cmd = m_connection.CreateCommand(); + + cmd.CommandText = "delete from "+table+" where EstateID = ?EstateID"; + cmd.Parameters.Add("?EstateID", EstateID.ToString()); + + cmd.ExecuteNonQuery(); + + cmd.Parameters.Clear(); + + cmd.CommandText = "insert into "+table+" (EstateID, uuid) values ( ?EstateID, ?uuid )"; + + foreach(LLUUID uuid in data) + { + cmd.Parameters.Add("?EstateID", EstateID.ToString()); + cmd.Parameters.Add("?uuid", uuid.ToString()); + + cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + } + } + + LLUUID[] LoadUUIDList(uint EstateID, string table) + { + List uuids = new List(); + + CheckConnection(); + + MySqlCommand cmd = m_connection.CreateCommand(); + + cmd.CommandText = "select uuid from "+table+" where EstateID = ?EstateID"; + cmd.Parameters.Add("?EstateID", EstateID); + + IDataReader r = cmd.ExecuteReader(); + + while(r.Read()) + { + EstateBan eb = new EstateBan(); + + LLUUID uuid = new LLUUID(); + LLUUID.TryParse(r["uuid"].ToString(), out uuid); + + uuids.Add(uuid); + } + r.Close(); + + return uuids.ToArray(); + } + } +} diff --git a/OpenSim/Data/MySQL/Resources/013_RegionStore.sql b/OpenSim/Data/MySQL/Resources/013_RegionStore.sql new file mode 100644 index 0000000000..a6bd30da50 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/013_RegionStore.sql @@ -0,0 +1,103 @@ +begin; + +drop table regionsettings; + +CREATE TABLE `regionsettings` ( + `regionUUID` char(36) NOT NULL, + `block_terraform` int(11) NOT NULL, + `block_fly` int(11) NOT NULL, + `allow_damage` int(11) NOT NULL, + `restrict_pushing` int(11) NOT NULL, + `allow_land_resell` int(11) NOT NULL, + `allow_land_join_divide` int(11) NOT NULL, + `block_show_in_search` int(11) NOT NULL, + `agent_limit` int(11) NOT NULL, + `object_bonus` float NOT NULL, + `maturity` int(11) NOT NULL, + `disable_scripts` int(11) NOT NULL, + `disable_collisions` int(11) NOT NULL, + `disable_physics` int(11) NOT NULL, + `terrain_texture_1` char(36) NOT NULL, + `terrain_texture_2` char(36) NOT NULL, + `terrain_texture_3` char(36) NOT NULL, + `terrain_texture_4` char(36) NOT NULL, + `elevation_1_nw` float NOT NULL, + `elevation_2_nw` float NOT NULL, + `elevation_1_ne` float NOT NULL, + `elevation_2_ne` float NOT NULL, + `elevation_1_se` float NOT NULL, + `elevation_2_se` float NOT NULL, + `elevation_1_sw` float NOT NULL, + `elevation_2_sw` float NOT NULL, + `water_height` float NOT NULL, + `terrain_raise_limit` float NOT NULL, + `terrain_lower_limit` float NOT NULL, + `use_estate_sun` int(11) NOT NULL, + `fixed_sun` int(11) NOT NULL, + `sun_position` float NOT NULL, + `covenant` char(36) default NULL, + `Sandbox` tinyint(4) NOT NULL, + PRIMARY KEY (`regionUUID`) +) ENGINE=InnoDB; + +CREATE TABLE `estate_managers` ( + `EstateID` int(10) unsigned NOT NULL, + `uuid` char(36) NOT NULL, + KEY `EstateID` (`EstateID`) +) ENGINE=InnoDB; + +CREATE TABLE `estate_groups` ( + `EstateID` int(10) unsigned NOT NULL, + `uuid` char(36) NOT NULL, + KEY `EstateID` (`EstateID`) +) ENGINE=InnoDB; + +CREATE TABLE `estate_users` ( + `EstateID` int(10) unsigned NOT NULL, + `uuid` char(36) NOT NULL, + KEY `EstateID` (`EstateID`) +) ENGINE=InnoDB; + +CREATE TABLE `estateban` ( + `EstateID` int(10) unsigned NOT NULL, + `bannedUUID` varchar(36) NOT NULL, + `bannedIp` varchar(16) NOT NULL, + `bannedIpHostMask` varchar(16) NOT NULL, + `bannedNameMask` varchar(64) default NULL, + KEY `estateban_EstateID` (`EstateID`) +) ENGINE=InnoDB; + +CREATE TABLE `estate_settings` ( + `EstateID` int(10) unsigned NOT NULL auto_increment, + `EstateName` varchar(64) default NULL, + `AbuseEmailToEstateOwner` tinyint(4) NOT NULL, + `DenyAnonymous` tinyint(4) NOT NULL, + `ResetHomeOnTeleport` tinyint(4) NOT NULL, + `FixedSun` tinyint(4) NOT NULL, + `DenyTransacted` tinyint(4) NOT NULL, + `BlockDwell` tinyint(4) NOT NULL, + `DenyIdentified` tinyint(4) NOT NULL, + `AllowVoice` tinyint(4) NOT NULL, + `UseGlobalTime` tinyint(4) NOT NULL, + `PricePerMeter` int(11) NOT NULL, + `TaxFree` tinyint(4) NOT NULL, + `AllowDirectTeleport` tinyint(4) NOT NULL, + `RedirectGridX` int(11) NOT NULL, + `RedirectGridY` int(11) NOT NULL, + `ParentEstateID` int(10) unsigned NOT NULL, + `SunPosition` double NOT NULL, + `EstateSkipScripts` tinyint(4) NOT NULL, + `BillableFactor` float NOT NULL, + `PublicAccess` tinyint(4) NOT NULL, + PRIMARY KEY (`EstateID`) +) ENGINE=InnoDB AUTO_INCREMENT=100; + +CREATE TABLE `estate_map` ( + `RegionID` char(36) NOT NULL default '00000000-0000-0000-0000-000000000000', + `EstateID` int(11) NOT NULL, + PRIMARY KEY (`RegionID`), + KEY `EstateID` (`EstateID`) +) ENGINE=InnoDB; + +commit; + diff --git a/OpenSim/Data/NHibernate/NHibernateRegionData.cs b/OpenSim/Data/NHibernate/NHibernateRegionData.cs index 9dee95cee5..2014e24c12 100644 --- a/OpenSim/Data/NHibernate/NHibernateRegionData.cs +++ b/OpenSim/Data/NHibernate/NHibernateRegionData.cs @@ -349,9 +349,9 @@ namespace OpenSim.Data.NHibernate /// /// the region UUID /// The banlist - public List LoadRegionBanList(LLUUID regionUUID) + public List LoadRegionBanList(LLUUID regionUUID) { - List regionbanlist = new List(); + List regionbanlist = new List(); return regionbanlist; } @@ -360,7 +360,7 @@ namespace OpenSim.Data.NHibernate /// Add en entry into region banlist /// /// - public void AddToRegionBanlist(RegionBanListItem item) + public void AddToRegionBanlist(EstateBan item) { } @@ -369,7 +369,7 @@ namespace OpenSim.Data.NHibernate /// remove an entry from the region banlist /// /// - public void RemoveFromRegionBanlist(RegionBanListItem item) + public void RemoveFromRegionBanlist(EstateBan item) { } diff --git a/OpenSim/Data/Null/NullDataStore.cs b/OpenSim/Data/Null/NullDataStore.cs index 422c0c615f..e244a5e24f 100644 --- a/OpenSim/Data/Null/NullDataStore.cs +++ b/OpenSim/Data/Null/NullDataStore.cs @@ -92,22 +92,6 @@ namespace OpenSim.Data.Null return new List(); } - public List LoadRegionBanList(LLUUID regionUUID) - { - List regionbanlist = new List(); - return regionbanlist; - } - - public void AddToRegionBanlist(RegionBanListItem item) - { - - } - - public void RemoveFromRegionBanlist(RegionBanListItem item) - { - - } - public void Shutdown() { } diff --git a/OpenSim/Data/SQLite/Resources/006_RegionStore.sql b/OpenSim/Data/SQLite/Resources/006_RegionStore.sql new file mode 100644 index 0000000000..025f1a9e77 --- /dev/null +++ b/OpenSim/Data/SQLite/Resources/006_RegionStore.sql @@ -0,0 +1,92 @@ +CREATE TABLE `estate_groups` ( + `EstateID` int(10) NOT NULL, + `uuid` char(36) NOT NULL +); +CREATE TABLE `estate_managers` ( + `EstateID` int(10) NOT NULL, + `uuid` char(36) NOT NULL +); +CREATE TABLE `estate_map` ( + `RegionID` char(36) NOT NULL default '00000000-0000-0000-0000-000000000000', + `EstateID` int(11) NOT NULL +); +CREATE TABLE `estate_settings` ( + `EstateID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + `EstateName` varchar(64) default NULL, + `AbuseEmailToEstateOwner` tinyint(4) NOT NULL, + `DenyAnonymous` tinyint(4) NOT NULL, + `ResetHomeOnTeleport` tinyint(4) NOT NULL, + `FixedSun` tinyint(4) NOT NULL, + `DenyTransacted` tinyint(4) NOT NULL, + `BlockDwell` tinyint(4) NOT NULL, + `DenyIdentified` tinyint(4) NOT NULL, + `AllowVoice` tinyint(4) NOT NULL, + `UseGlobalTime` tinyint(4) NOT NULL, + `PricePerMeter` int(11) NOT NULL, + `TaxFree` tinyint(4) NOT NULL, + `AllowDirectTeleport` tinyint(4) NOT NULL, + `RedirectGridX` int(11) NOT NULL, + `RedirectGridY` int(11) NOT NULL, + `ParentEstateID` int(10) NOT NULL, + `SunPosition` double NOT NULL, + `EstateSkipScripts` tinyint(4) NOT NULL, + `BillableFactor` float NOT NULL, + `PublicAccess` tinyint(4) NOT NULL +); +insert into `estate_settings` (`EstateID`,`EstateName`,`AbuseEmailToEstateOwner`,`DenyAnonymous`,`ResetHomeOnTeleport`,`FixedSun`,`DenyTransacted`,`BlockDwell`,`DenyIdentified`,`AllowVoice`,`UseGlobalTime`,`PricePerMeter`,`TaxFree`,`AllowDirectTeleport`,`RedirectGridX`,`RedirectGridY`,`ParentEstateID`,`SunPosition`,`PublicAccess`,`EstateSkipScripts`,`BillableFactor`) values ( 99, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); +delete from `estate_settings`; +CREATE TABLE `estate_users` ( + `EstateID` int(10) NOT NULL, + `uuid` char(36) NOT NULL +); +CREATE TABLE `estateban` ( + `EstateID` int(10) NOT NULL, + `bannedUUID` varchar(36) NOT NULL, + `bannedIp` varchar(16) NOT NULL, + `bannedIpHostMask` varchar(16) NOT NULL, + `bannedNameMask` varchar(64) default NULL +); +drop table if exists `regionsettings`; +CREATE TABLE `regionsettings` ( + `regionUUID` char(36) NOT NULL, + `block_terraform` int(11) NOT NULL, + `block_fly` int(11) NOT NULL, + `allow_damage` int(11) NOT NULL, + `restrict_pushing` int(11) NOT NULL, + `allow_land_resell` int(11) NOT NULL, + `allow_land_join_divide` int(11) NOT NULL, + `block_show_in_search` int(11) NOT NULL, + `agent_limit` int(11) NOT NULL, + `object_bonus` float NOT NULL, + `maturity` int(11) NOT NULL, + `disable_scripts` int(11) NOT NULL, + `disable_collisions` int(11) NOT NULL, + `disable_physics` int(11) NOT NULL, + `terrain_texture_1` char(36) NOT NULL, + `terrain_texture_2` char(36) NOT NULL, + `terrain_texture_3` char(36) NOT NULL, + `terrain_texture_4` char(36) NOT NULL, + `elevation_1_nw` float NOT NULL, + `elevation_2_nw` float NOT NULL, + `elevation_1_ne` float NOT NULL, + `elevation_2_ne` float NOT NULL, + `elevation_1_se` float NOT NULL, + `elevation_2_se` float NOT NULL, + `elevation_1_sw` float NOT NULL, + `elevation_2_sw` float NOT NULL, + `water_height` float NOT NULL, + `terrain_raise_limit` float NOT NULL, + `terrain_lower_limit` float NOT NULL, + `use_estate_sun` int(11) NOT NULL, + `fixed_sun` int(11) NOT NULL, + `sun_position` float NOT NULL, + `covenant` char(36) default NULL, + `Sandbox` tinyint(4) NOT NULL, + PRIMARY KEY (`regionUUID`) +); +CREATE INDEX `estate_ban_estate_id` on `estateban`(`EstateID`); +CREATE INDEX `estate_groups_estate_id` on `estate_groups`(`EstateID`); +CREATE INDEX `estate_managers_estate_id` on `estate_managers`(`EstateID`); +CREATE INDEX `estate_map_estate_id` on `estate_map`(`EstateID`); +CREATE UNIQUE INDEX `estate_map_region)id` on `estate_map`(`RegionID`); +CREATE INDEX `estate_users_estate_id` on `estate_users`(`EstateID`); diff --git a/OpenSim/Data/SQLite/SQLiteEstateData.cs b/OpenSim/Data/SQLite/SQLiteEstateData.cs new file mode 100644 index 0000000000..2d046f2560 --- /dev/null +++ b/OpenSim/Data/SQLite/SQLiteEstateData.cs @@ -0,0 +1,333 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Data; +using System.IO; +using System.Reflection; +using System.Threading; +using libsecondlife; +using Mono.Data.SqliteClient; +using log4net; +using OpenSim.Framework; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; + +namespace OpenSim.Data.MySQL +{ + public class MySQLEstateStore : IEstateDataStore + { + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private SqliteConnection m_connection; + private string m_connectionString; + + private FieldInfo[] m_Fields; + private Dictionary m_FieldMap = + new Dictionary(); + + public void Initialise(string connectionString) + { + m_connectionString = connectionString; + + m_log.Info("[ESTATE DB]: Sqlite - connecting: "+m_connectionString); + + m_connection = new SqliteConnection(m_connectionString); + m_connection.Open(); + + Assembly assem = GetType().Assembly; + Migration m = new Migration(m_connection, assem, "EstateStore"); + m.Update(); + + m_connection.Close(); + m_connection.Open(); + + Type t = typeof(EstateSettings); + m_Fields = t.GetFields(BindingFlags.NonPublic | + BindingFlags.Instance | + BindingFlags.DeclaredOnly); + + foreach (FieldInfo f in m_Fields) + if(f.Name.Substring(0, 2) == "m_") + m_FieldMap[f.Name.Substring(2)] = f; + } + + private string[] FieldList + { + get { return new List(m_FieldMap.Keys).ToArray(); } + } + + public EstateSettings LoadEstateSettings(LLUUID regionID) + { + EstateSettings es = new EstateSettings(); + + string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = @RegionID"; + + SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); + + cmd.CommandText = sql; + cmd.Parameters.Add("@RegionID", regionID.ToString()); + + IDataReader r = cmd.ExecuteReader(); + + if(r.Read()) + { + foreach (string name in FieldList) + { + if(m_FieldMap[name].GetValue(es) is bool) + { + int v = Convert.ToInt32(r[name]); + if(v != 0) + m_FieldMap[name].SetValue(es, true); + else + m_FieldMap[name].SetValue(es, false); + } + else + { + m_FieldMap[name].SetValue(es, Convert.ChangeType(r[name], m_FieldMap[name].FieldType)); + } + } + r.Close(); + } + else + { + // Migration case + // + r.Close(); + + List names = new List(FieldList); + + names.Remove("EstateID"); + + sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( @"+String.Join(", @", names.ToArray())+")"; + + cmd.CommandText = sql; + cmd.Parameters.Clear(); + + foreach (string name in FieldList) + { + if(m_FieldMap[name].GetValue(es) is bool) + { + if((bool)m_FieldMap[name].GetValue(es)) + cmd.Parameters.Add("@"+name, "1"); + else + cmd.Parameters.Add("@"+name, "0"); + } + else + { + cmd.Parameters.Add("@"+name, m_FieldMap[name].GetValue(es).ToString()); + } + } + + cmd.ExecuteNonQuery(); + + cmd.CommandText = "select LAST_INSERT_ROWID() as id"; + cmd.Parameters.Clear(); + + r = cmd.ExecuteReader(); + + r.Read(); + + es.EstateID = Convert.ToUInt32(r["id"]); + + r.Close(); + + cmd.CommandText = "insert into estate_map values (@RegionID, @EstateID)"; + cmd.Parameters.Add("@RegionID", regionID.ToString()); + cmd.Parameters.Add("@EstateID", es.EstateID.ToString()); + + // This will throw on dupe key + try + { + cmd.ExecuteNonQuery(); + } + catch (Exception) + { + } + + // Munge and transfer the ban list + // + cmd.Parameters.Clear(); + cmd.CommandText = "insert into estateban select "+es.EstateID.ToString()+", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = @UUID"; + cmd.Parameters.Add("@UUID", regionID.ToString()); + + try + { + cmd.ExecuteNonQuery(); + } + catch (Exception) + { + } + } + + LoadBanList(es); + + es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers"); + es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users"); + es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups"); + return es; + } + + public void StoreEstateSettings(EstateSettings es) + { + List fields = new List(FieldList); + fields.Remove("EstateID"); + + List terms = new List(); + + foreach (string f in fields) + terms.Add(f+" = @"+f); + + string sql = "update estate_settings set "+String.Join(", ", terms.ToArray())+" where EstateID = @EstateID"; + + SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); + + cmd.CommandText = sql; + + foreach (string name in FieldList) + { + if(m_FieldMap[name].GetValue(es) is bool) + { + if((bool)m_FieldMap[name].GetValue(es)) + cmd.Parameters.Add("@"+name, "1"); + else + cmd.Parameters.Add("@"+name, "0"); + } + else + { + cmd.Parameters.Add("@"+name, m_FieldMap[name].GetValue(es).ToString()); + } + } + + cmd.ExecuteNonQuery(); + + SaveBanList(es); + SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers); + SaveUUIDList(es.EstateID, "estate_users", es.EstateAccess); + SaveUUIDList(es.EstateID, "estate_groups", es.EstateGroups); + } + + private void LoadBanList(EstateSettings es) + { + es.ClearBans(); + + SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); + + cmd.CommandText = "select bannedUUID from estateban where EstateID = @EstateID"; + cmd.Parameters.Add("@EstateID", es.EstateID); + + IDataReader r = cmd.ExecuteReader(); + + while(r.Read()) + { + EstateBan eb = new EstateBan(); + + LLUUID uuid = new LLUUID(); + LLUUID.TryParse(r["bannedUUID"].ToString(), out uuid); + + eb.bannedUUID = uuid; + eb.bannedIP = "0.0.0.0"; + eb.bannedIPHostMask = "0.0.0.0"; + es.AddBan(eb); + } + r.Close(); + } + + private void SaveBanList(EstateSettings es) + { + SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); + + cmd.CommandText = "delete from estateban where EstateID = @EstateID"; + cmd.Parameters.Add("@EstateID", es.EstateID.ToString()); + + cmd.ExecuteNonQuery(); + + cmd.Parameters.Clear(); + + cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( @EstateID, @bannedUUID, '', '', '' )"; + + foreach(EstateBan b in es.EstateBans) + { + cmd.Parameters.Add("@EstateID", es.EstateID.ToString()); + cmd.Parameters.Add("@bannedUUID", b.bannedUUID.ToString()); + + cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + } + } + + void SaveUUIDList(uint EstateID, string table, LLUUID[] data) + { + SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); + + cmd.CommandText = "delete from "+table+" where EstateID = @EstateID"; + cmd.Parameters.Add("@EstateID", EstateID.ToString()); + + cmd.ExecuteNonQuery(); + + cmd.Parameters.Clear(); + + cmd.CommandText = "insert into "+table+" (EstateID, uuid) values ( @EstateID, @uuid )"; + + foreach(LLUUID uuid in data) + { + cmd.Parameters.Add("@EstateID", EstateID.ToString()); + cmd.Parameters.Add("@uuid", uuid.ToString()); + + cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + } + } + + LLUUID[] LoadUUIDList(uint EstateID, string table) + { + List uuids = new List(); + + SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); + + cmd.CommandText = "select uuid from "+table+" where EstateID = @EstateID"; + cmd.Parameters.Add("@EstateID", EstateID); + + IDataReader r = cmd.ExecuteReader(); + + while(r.Read()) + { + EstateBan eb = new EstateBan(); + + LLUUID uuid = new LLUUID(); + LLUUID.TryParse(r["uuid"].ToString(), out uuid); + + uuids.Add(uuid); + } + r.Close(); + + return uuids.ToArray(); + } + } +} diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs index 0e67fb9104..4e87e0d47b 100644 --- a/OpenSim/Data/SQLite/SQLiteRegionData.cs +++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs @@ -62,7 +62,6 @@ namespace OpenSim.Data.SQLite private SqliteDataAdapter terrainDa; private SqliteDataAdapter landDa; private SqliteDataAdapter landAccessListDa; - private SqliteDataAdapter regionBanListDa; private SqliteConnection m_conn; @@ -119,9 +118,6 @@ namespace OpenSim.Data.SQLite SqliteCommand landAccessListSelectCmd = new SqliteCommand(landAccessListSelect, m_conn); landAccessListDa = new SqliteDataAdapter(landAccessListSelectCmd); - SqliteCommand regionBanListSelectCmd = new SqliteCommand(regionbanListSelect, m_conn); - regionBanListDa = new SqliteDataAdapter(regionBanListSelectCmd); - // This actually does the roll forward assembly stuff Assembly assem = GetType().Assembly; Migration m = new Migration(m_conn, assem, "RegionStore"); @@ -157,10 +153,6 @@ namespace OpenSim.Data.SQLite ds.Tables.Add(createLandAccessListTable()); setupLandAccessCommands(landAccessListDa, m_conn); - ds.Tables.Add(createRegionBanListTable()); - setupRegionBanCommands(regionBanListDa, m_conn); - - // WORKAROUND: This is a work around for sqlite on // windows, which gets really unhappy with blob columns // that have no sample data in them. At some point we @@ -201,15 +193,6 @@ namespace OpenSim.Data.SQLite m_log.Info("[REGION DB]: Caught fill error on landaccesslist table"); } - try - { - regionBanListDa.Fill(ds.Tables["regionban"]); - } - catch (Exception) - { - m_log.Info("[REGION DB]: Caught fill error on regionban table"); - } - return; } } @@ -900,21 +883,6 @@ namespace OpenSim.Data.SQLite return landaccess; } - /// - /// create "regionban" table - /// - /// regionban datatable - private static DataTable createRegionBanListTable() - { - DataTable regionbanlist = new DataTable("regionban"); - createCol(regionbanlist, "regionUUID", typeof(String)); - createCol(regionbanlist, "bannedUUID", typeof(String)); - createCol(regionbanlist, "bannedIp", typeof(String)); - createCol(regionbanlist, "bannedIpHostMask", typeof(String)); - - return regionbanlist; - } - /*********************************************************************** * * Convert between ADO.NET <=> OpenSim Objects @@ -1178,74 +1146,6 @@ namespace OpenSim.Data.SQLite return entry; } - - /// - /// Load a region banlist - /// - /// the region UUID - /// The banlist - public List LoadRegionBanList(LLUUID regionUUID) - { - List regionbanlist = new List(); - lock (ds) - { - DataTable regionban = ds.Tables["regionban"]; - string searchExp = "regionUUID = '" + regionUUID.ToString() + "'"; - DataRow[] rawbanlist = regionban.Select(searchExp); - foreach (DataRow rawbanrow in rawbanlist) - { - RegionBanListItem rbli = new RegionBanListItem(); - LLUUID tmpvalue = LLUUID.Zero; - - rbli.regionUUID = regionUUID; - - if (Helpers.TryParse((string)rawbanrow["bannedUUID"], out tmpvalue)) - rbli.bannedUUID = tmpvalue; - - rbli.bannedIP = (string)rawbanrow["bannedIp"]; - rbli.bannedIPHostMask = (string)rawbanrow["bannedIpHostMask"]; - regionbanlist.Add(rbli); - } - } - return regionbanlist; - } - - /// - /// Add en entry into region banlist - /// - /// - public void AddToRegionBanlist(RegionBanListItem item) - { - lock (ds) - { - using (SqliteCommand cmd = new SqliteCommand("insert into regionban (regionUUID, bannedUUID, bannedIp, bannedIpHostMask) values (:regionUUID,:bannedUUID,:bannedIp,:bannedIpHostMask)", m_conn)) - { - cmd.Parameters.Add(new SqliteParameter(":regionUUID", item.regionUUID.ToString())); - cmd.Parameters.Add(new SqliteParameter(":bannedUUID", item.bannedUUID.ToString())); - cmd.Parameters.Add(new SqliteParameter(":bannedIp", item.bannedIP)); - cmd.Parameters.Add(new SqliteParameter(":bannedIpHostMask", item.bannedIPHostMask)); - cmd.ExecuteNonQuery(); - } - } - } - - /// - /// remove an entry from the region banlist - /// - /// - public void RemoveFromRegionBanlist(RegionBanListItem item) - { - lock (ds) - { - using (SqliteCommand cmd = new SqliteCommand("delete from regionban where regionUUID=:regionUUID AND bannedUUID=:bannedUUID", m_conn)) - { - cmd.Parameters.Add(new SqliteParameter(":regionUUID", item.regionUUID.ToString())); - cmd.Parameters.Add(new SqliteParameter(":bannedUUID", item.bannedUUID.ToString())); - cmd.ExecuteNonQuery(); - } - } - } - /// /// /// @@ -1822,20 +1722,6 @@ namespace OpenSim.Data.SQLite da.InsertCommand.Connection = conn; } - /// - /// - /// - /// - /// - private void setupRegionBanCommands(SqliteDataAdapter da, SqliteConnection conn) - { - da.InsertCommand = createInsertCommand("regionban", ds.Tables["regionban"]); - da.InsertCommand.Connection = conn; - - da.UpdateCommand = createUpdateCommand("regionban", "regionUUID=:regionUUID AND bannedUUID=:bannedUUID", ds.Tables["regionban"]); - da.UpdateCommand.Connection = conn; - } - /// /// /// diff --git a/OpenSim/Framework/RegionBanListItem.cs b/OpenSim/Framework/EstateBan.cs similarity index 93% rename from OpenSim/Framework/RegionBanListItem.cs rename to OpenSim/Framework/EstateBan.cs index edf6a224df..c213344440 100644 --- a/OpenSim/Framework/RegionBanListItem.cs +++ b/OpenSim/Framework/EstateBan.cs @@ -32,16 +32,12 @@ using System.Text; namespace OpenSim.Framework { - public class RegionBanListItem + public class EstateBan { - public LLUUID regionUUID = LLUUID.Zero; + public uint estateID = 1; public LLUUID bannedUUID = LLUUID.Zero; public string bannedIP = string.Empty; public string bannedIPHostMask = string.Empty; - - public RegionBanListItem() - { - - } + public string bannedNameMask = string.Empty; } } diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs index 2865844591..b48a1dbae1 100644 --- a/OpenSim/Framework/EstateSettings.cs +++ b/OpenSim/Framework/EstateSettings.cs @@ -28,6 +28,7 @@ using System; using System.IO; using System.Reflection; +using System.Collections.Generic; using libsecondlife; using log4net; @@ -38,451 +39,440 @@ namespace OpenSim.Framework private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private ConfigurationMember configMember; - //Settings to this island - private float m_billableFactor; + public delegate void SaveDelegate(EstateSettings rs); - private uint m_estateID; - private LLUUID m_estateManager0; - private LLUUID m_estateManager1; - private LLUUID m_estateManager2; - private LLUUID m_estateManager3; - private LLUUID m_estateManager4; - private LLUUID m_estateManager5; - private LLUUID m_estateManager6; - private LLUUID m_estateManager7; - private LLUUID m_estateManager8; - private LLUUID m_estateManager9; - private string m_estateName; + public event SaveDelegate OnSave; - private uint m_parentEstateID; - private int m_pricePerMeter; - private int m_redirectGridX; - private int m_redirectGridY; + // Only the client uses these + // + private uint m_EstateID = 100; + + public uint EstateID + { + get { return m_EstateID; } + set { m_EstateID = value; } + } + + private string m_EstateName; + + public string EstateName + { + get { return m_EstateName; } + set { m_EstateName = value; } + } + + private uint m_ParentEstateID = 100; + + public uint ParentEstateID + { + get { return m_ParentEstateID; } + set { m_ParentEstateID = value; } + } + + private float m_BillableFactor; + + public float BillableFactor + { + get { return m_BillableFactor; } + set { m_BillableFactor = value; } + } + + private int m_PricePerMeter; + + public int PricePerMeter + { + get { return m_PricePerMeter; } + set { m_PricePerMeter = value; } + } + + private int m_RedirectGridX; + + public int RedirectGridX + { + get { return m_RedirectGridX; } + set { m_RedirectGridX = value; } + } + + private int m_RedirectGridY; + + public int RedirectGridY + { + get { return m_RedirectGridY; } + set { m_RedirectGridY = value; } + } + + // Used by the sim + // + private bool m_UseGlobalTime = true; + + public bool UseGlobalTime + { + get { return m_UseGlobalTime; } + set { m_UseGlobalTime = value; } + } + + private bool m_FixedSun = false; + + public bool FixedSun + { + get { return m_FixedSun; } + set { m_FixedSun = value; } + } + + private double m_SunPosition = 0.0; + + public double SunPosition + { + get { return m_SunPosition; } + set { m_SunPosition = value; } + } + + private bool m_AllowVoice = true; + + public bool AllowVoice + { + get { return m_AllowVoice; } + set { m_AllowVoice = value; } + } + + private bool m_AllowDirectTeleport = true; + + public bool AllowDirectTeleport + { + get { return m_AllowDirectTeleport; } + set { m_AllowDirectTeleport = value; } + } + + private bool m_DenyAnonymous = false; + + public bool DenyAnonymous + { + get { return m_DenyAnonymous; } + set { m_DenyAnonymous = value; } + } + + private bool m_DenyIdentified = false; + + public bool DenyIdentified + { + get { return m_DenyIdentified; } + set { m_DenyIdentified = value; } + } + + private bool m_DenyTransacted = false; + + public bool DenyTransacted + { + get { return m_DenyTransacted; } + set { m_DenyTransacted = value; } + } + + private bool m_AbuseEmailToEstateOwner = false; + + public bool AbuseEmailToEstateOwner + { + get { return m_AbuseEmailToEstateOwner; } + set { m_AbuseEmailToEstateOwner = value; } + } + + private bool m_BlockDwell = false; + + public bool BlockDwell + { + get { return m_BlockDwell; } + set { m_BlockDwell = value; } + } + + private bool m_EstateSkipScripts = false; + + public bool EstateSkipScripts + { + get { return m_EstateSkipScripts; } + set { m_EstateSkipScripts = value; } + } + + private bool m_ResetHomeOnTeleport = false; + + public bool ResetHomeOnTeleport + { + get { return m_ResetHomeOnTeleport; } + set { m_ResetHomeOnTeleport = value; } + } + + private bool m_TaxFree = false; + + public bool TaxFree + { + get { return m_TaxFree; } + set { m_TaxFree = value; } + } + + private bool m_PublicAccess = true; + + public bool PublicAccess + { + get { return m_PublicAccess; } + set { m_PublicAccess = value; } + } + + // All those lists... + // + private List l_EstateManagers = new List(); + + public LLUUID[] EstateManagers + { + get { return l_EstateManagers.ToArray(); } + set { l_EstateManagers = new List(value); } + } + + private List l_EstateBans = new List(); + + public EstateBan[] EstateBans + { + get { return l_EstateBans.ToArray(); } + set { l_EstateBans = new List(value); } + } + + private List l_EstateAccess = new List(); + + public LLUUID[] EstateAccess + { + get { return l_EstateAccess.ToArray(); } + set { l_EstateAccess = new List(value); } + } + + private List l_EstateGroups = new List(); + + public LLUUID[] EstateGroups + { + get { return l_EstateGroups.ToArray(); } + set { l_EstateGroups = new List(value); } + } public EstateSettings() { - // Temporary hack to prevent multiple loadings. if (configMember == null) { + // Load legacy defaults + // configMember = - new ConfigurationMember(Path.Combine(Util.configDir(), "estate_settings.xml"), "ESTATE SETTINGS", - loadConfigurationOptions, handleIncomingConfiguration, true); + new ConfigurationMember(Path.Combine(Util.configDir(), + "estate_settings.xml"), "ESTATE SETTINGS", + loadConfigurationOptions, + handleIncomingConfiguration, true); + + l_EstateManagers.Clear(); configMember.performConfigurationRetrieve(); } } - public float billableFactor + public void Save() { - get { return m_billableFactor; } - set - { - m_billableFactor = value; - configMember.forceSetConfigurationOption("billable_factor", m_billableFactor.ToString()); - } - } - - public uint estateID - { - get { return m_estateID; } - set - { - m_estateID = value; - configMember.forceSetConfigurationOption("estate_id", m_estateID.ToString()); - } - } - - public uint parentEstateID - { - get { return m_parentEstateID; } - set - { - m_parentEstateID = value; - configMember.forceSetConfigurationOption("parent_estate_id", m_parentEstateID.ToString()); - } - } - - public int redirectGridX - { - get { return m_redirectGridX; } - set - { - m_redirectGridX = value; - configMember.forceSetConfigurationOption("redirect_grid_x", m_redirectGridX.ToString()); - } - } - - public int redirectGridY - { - get { return m_redirectGridY; } - set - { - m_redirectGridY = value; - configMember.forceSetConfigurationOption("redirect_grid_y", m_redirectGridY.ToString()); - } - } - - public int pricePerMeter - { - get { return m_pricePerMeter; } - set - { - m_pricePerMeter = value; - configMember.forceSetConfigurationOption("price_per_meter", m_pricePerMeter.ToString()); - } - } - - // Estate name - - public string estateName - { - get { return m_estateName; } - set - { - m_estateName = value; - configMember.forceSetConfigurationOption("estate_name", m_estateName.ToString()); - } - } - - public LLUUID[] estateManagers - { - get - { - // returns a condensed array of LLUUIDs - return GetEstateManagers(); - } - set - { - // Sets a Condensed array of LLUUIDS - int i = 0; - for (i = 0; i < value.Length; i++) - { - switch (i) - { - case 0: - m_estateManager0 = value[i]; - break; - case 1: - m_estateManager1 = value[i]; - break; - case 2: - m_estateManager2 = value[i]; - break; - case 3: - m_estateManager3 = value[i]; - break; - case 4: - m_estateManager4 = value[i]; - break; - case 5: - m_estateManager5 = value[i]; - break; - case 6: - m_estateManager6 = value[i]; - break; - case 7: - m_estateManager7 = value[i]; - break; - case 8: - m_estateManager8 = value[i]; - break; - case 9: - m_estateManager9 = value[i]; - break; - } - } - - // Clear the rest of them.. as they're no longer valid - for (int j = i; j < 10; j++) - { - switch (j) - { - case 0: - m_estateManager0 = LLUUID.Zero; - break; - case 1: - m_estateManager1 = LLUUID.Zero; - break; - case 2: - m_estateManager2 = LLUUID.Zero; - break; - case 3: - m_estateManager3 = LLUUID.Zero; - break; - case 4: - m_estateManager4 = LLUUID.Zero; - break; - case 5: - m_estateManager5 = LLUUID.Zero; - break; - case 6: - m_estateManager6 = LLUUID.Zero; - break; - case 7: - m_estateManager7 = LLUUID.Zero; - break; - case 8: - m_estateManager8 = LLUUID.Zero; - break; - case 9: - m_estateManager9 = LLUUID.Zero; - break; - } - } - - for (i = 0; i < 10; i++) - { - // Writes out the Estate managers to the XML file. - configMember.forceSetConfigurationOption("estate_manager_" + i, (GetEstateManagerAtPos(i)).ToString()); - } - } - } - - #region EstateManager Get Methods to sort out skipped spots in the XML (suser error) - - private LLUUID GetEstateManagerAtPos(int pos) - { - // This is a helper for writing them out to the xml file - switch (pos) - { - case 0: - return m_estateManager0; - - case 1: - return m_estateManager1; - - case 2: - return m_estateManager2; - - case 3: - return m_estateManager3; - - case 4: - return m_estateManager4; - - case 5: - return m_estateManager5; - - case 6: - return m_estateManager6; - - case 7: - return m_estateManager7; - - case 8: - return m_estateManager8; - - case 9: - return m_estateManager9; - - default: - return LLUUID.Zero; - } - } - - private LLUUID[] GetEstateManagers() - { - int numEstateManagers = GetNumberOfEstateManagers(); - LLUUID[] rEstateManagers = new LLUUID[numEstateManagers]; - - int pos = 0; - - for (int i = 0; i < numEstateManagers; i++) - { - pos = GetNextEstateManager(pos); - - rEstateManagers[i] = GetEstateManagerAtPos(pos); - pos++; - } - return rEstateManagers; - } - - private int GetNextEstateManager(int startpos) - { - // This is a utility function that skips over estate managers set to LLUUID.Zero - int i = startpos; - for (i = startpos; i < 10; i++) - { - if (GetEstateManagerAtPos(i) != LLUUID.Zero) return i; - } - return i; - } - - private int GetNumberOfEstateManagers() - { - // This function returns the number of estate managers set - // Regardless of whether there is a skipped spot - int numEstateManagers = 0; - if (m_estateManager0 != LLUUID.Zero) numEstateManagers++; - if (m_estateManager1 != LLUUID.Zero) numEstateManagers++; - if (m_estateManager2 != LLUUID.Zero) numEstateManagers++; - if (m_estateManager3 != LLUUID.Zero) numEstateManagers++; - if (m_estateManager4 != LLUUID.Zero) numEstateManagers++; - if (m_estateManager5 != LLUUID.Zero) numEstateManagers++; - if (m_estateManager6 != LLUUID.Zero) numEstateManagers++; - if (m_estateManager7 != LLUUID.Zero) numEstateManagers++; - if (m_estateManager8 != LLUUID.Zero) numEstateManagers++; - if (m_estateManager9 != LLUUID.Zero) numEstateManagers++; - - return numEstateManagers; + if(OnSave != null) + OnSave(this); } public void AddEstateManager(LLUUID avatarID) { - LLUUID[] testateManagers = GetEstateManagers(); - LLUUID[] nestateManagers = new LLUUID[testateManagers.Length + 1]; - - int i = 0; - for (i = 0; i < testateManagers.Length; i++) - { - nestateManagers[i] = testateManagers[i]; - } - - nestateManagers[i] = avatarID; - - //Saves it to the estate settings file - estateManagers = nestateManagers; + if(avatarID == null || avatarID == LLUUID.Zero) + return; + if(!l_EstateManagers.Contains(avatarID)) + l_EstateManagers.Add(avatarID); } public void RemoveEstateManager(LLUUID avatarID) { - int notfoundparam = 11; // starting high so the condense routine (max ten) doesn't run if we don't find it. - LLUUID[] testateManagers = GetEstateManagers(); // temporary estate managers list - - - int i = 0; - int foundpos = notfoundparam; - - // search for estate manager. - for (i = 0; i < testateManagers.Length; i++) - { - if (testateManagers[i] == avatarID) - { - foundpos = i; - break; - } - } - if (foundpos < notfoundparam) - { - LLUUID[] restateManagers = new LLUUID[testateManagers.Length - 1]; - - // fill new estate managers array up to the found spot - for (int j = 0; j < foundpos; j++) - restateManagers[j] = testateManagers[j]; - - // skip over the estate manager we're removing and compress - for (int j = foundpos + 1; j < testateManagers.Length; j++) - restateManagers[j - 1] = testateManagers[j]; - - estateManagers = restateManagers; - } - else - { - m_log.Error("[ESTATESETTINGS]: Unable to locate estate manager : " + avatarID.ToString() + " for removal"); - } + if(l_EstateManagers.Contains(avatarID)) + l_EstateManagers.Remove(avatarID); } - #endregion + public bool IsEstateManager(LLUUID avatarID) + { + return l_EstateManagers.Contains(avatarID); + } + + public bool IsBanned(LLUUID avatarID) + { + foreach (EstateBan ban in l_EstateBans) + if(ban.bannedUUID == avatarID) + return true; + return false; + } + + public void AddBan(EstateBan ban) + { + if(ban == null) + return; + if(!IsBanned(ban.bannedUUID)) + l_EstateBans.Add(ban); + } + + public void ClearBans() + { + l_EstateBans.Clear(); + } + + public void RemoveBan(LLUUID avatarID) + { + foreach (EstateBan ban in new List(l_EstateBans)) + if(ban.bannedUUID == avatarID) + l_EstateBans.Remove(ban); + } public void loadConfigurationOptions() { - configMember.addConfigurationOption("billable_factor", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, String.Empty, - "0.0", true); - configMember.addConfigurationOption("estate_id", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, String.Empty, "100", - true); - configMember.addConfigurationOption("parent_estate_id", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, - String.Empty, "1", true); - configMember.addConfigurationOption("max_agents", ConfigurationOption.ConfigurationTypes.TYPE_BYTE, String.Empty, "40", - true); + configMember.addConfigurationOption("billable_factor", + ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, + String.Empty, "0.0", true); - configMember.addConfigurationOption("redirect_grid_x", ConfigurationOption.ConfigurationTypes.TYPE_INT32, String.Empty, - "0", true); - configMember.addConfigurationOption("redirect_grid_y", ConfigurationOption.ConfigurationTypes.TYPE_INT32, String.Empty, - "0", true); - configMember.addConfigurationOption("price_per_meter", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, - String.Empty, "1", true); +// configMember.addConfigurationOption("estate_id", +// ConfigurationOption.ConfigurationTypes.TYPE_UINT32, +// String.Empty, "100", true); - configMember.addConfigurationOption("water_height", ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE, String.Empty, - "20.0", true); +// configMember.addConfigurationOption("parent_estate_id", +// ConfigurationOption.ConfigurationTypes.TYPE_UINT32, +// String.Empty, "1", true); - configMember.addConfigurationOption("estate_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING, - String.Empty, "TestEstate", true); - configMember.addConfigurationOption("estate_manager_0", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, - String.Empty, "00000000-0000-0000-0000-000000000000", true); - configMember.addConfigurationOption("estate_manager_1", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, - String.Empty, "00000000-0000-0000-0000-000000000000", true); - configMember.addConfigurationOption("estate_manager_2", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, - String.Empty, "00000000-0000-0000-0000-000000000000", true); - configMember.addConfigurationOption("estate_manager_3", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, - String.Empty, "00000000-0000-0000-0000-000000000000", true); - configMember.addConfigurationOption("estate_manager_4", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, - String.Empty, "00000000-0000-0000-0000-000000000000", true); - configMember.addConfigurationOption("estate_manager_5", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, - String.Empty, "00000000-0000-0000-0000-000000000000", true); - configMember.addConfigurationOption("estate_manager_6", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, - String.Empty, "00000000-0000-0000-0000-000000000000", true); - configMember.addConfigurationOption("estate_manager_7", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, - String.Empty, "00000000-0000-0000-0000-000000000000", true); - configMember.addConfigurationOption("estate_manager_8", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, - String.Empty, "00000000-0000-0000-0000-000000000000", true); - configMember.addConfigurationOption("estate_manager_9", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, - String.Empty, "00000000-0000-0000-0000-000000000000", true); + configMember.addConfigurationOption("redirect_grid_x", + ConfigurationOption.ConfigurationTypes.TYPE_INT32, + String.Empty, "0", true); + + configMember.addConfigurationOption("redirect_grid_y", + ConfigurationOption.ConfigurationTypes.TYPE_INT32, + String.Empty, "0", true); + + configMember.addConfigurationOption("price_per_meter", + ConfigurationOption.ConfigurationTypes.TYPE_UINT32, + String.Empty, "1", true); + + configMember.addConfigurationOption("estate_name", + ConfigurationOption.ConfigurationTypes.TYPE_STRING, + String.Empty, "My Estate", true); + + configMember.addConfigurationOption("estate_manager_0", + ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, + String.Empty, "00000000-0000-0000-0000-000000000000", true); + + configMember.addConfigurationOption("estate_manager_1", + ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, + String.Empty, "00000000-0000-0000-0000-000000000000", true); + + configMember.addConfigurationOption("estate_manager_2", + ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, + String.Empty, "00000000-0000-0000-0000-000000000000", true); + + configMember.addConfigurationOption("estate_manager_3", + ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, + String.Empty, "00000000-0000-0000-0000-000000000000", true); + + configMember.addConfigurationOption("estate_manager_4", + ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, + String.Empty, "00000000-0000-0000-0000-000000000000", true); + + configMember.addConfigurationOption("estate_manager_5", + ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, + String.Empty, "00000000-0000-0000-0000-000000000000", true); + + configMember.addConfigurationOption("estate_manager_6", + ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, + String.Empty, "00000000-0000-0000-0000-000000000000", true); + + configMember.addConfigurationOption("estate_manager_7", + ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, + String.Empty, "00000000-0000-0000-0000-000000000000", true); + + configMember.addConfigurationOption("estate_manager_8", + ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, + String.Empty, "00000000-0000-0000-0000-000000000000", true); + + configMember.addConfigurationOption("estate_manager_9", + ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, + String.Empty, "00000000-0000-0000-0000-000000000000", true); + + configMember.addConfigurationOption("region_flags", + ConfigurationOption.ConfigurationTypes.TYPE_UINT32, + String.Empty, "336723974", true); } public bool handleIncomingConfiguration(string configuration_key, object configuration_result) { switch (configuration_key) { + case "region_flags": + Simulator.RegionFlags flags = (Simulator.RegionFlags)(uint)configuration_result; + if((flags & (Simulator.RegionFlags)(1<<29)) != 0) + m_AllowVoice = true; + if((flags & Simulator.RegionFlags.AllowDirectTeleport) != 0) + m_AllowDirectTeleport = true; + if((flags & Simulator.RegionFlags.DenyAnonymous) != 0) + m_DenyAnonymous = true; + if((flags & Simulator.RegionFlags.DenyIdentified) != 0) + m_DenyIdentified = true; + if((flags & Simulator.RegionFlags.DenyTransacted) != 0) + m_DenyTransacted = true; + if((flags & Simulator.RegionFlags.AbuseEmailToEstateOwner) != 0) + m_AbuseEmailToEstateOwner = true; + if((flags & Simulator.RegionFlags.BlockDwell) != 0) + m_BlockDwell = true; + if((flags & Simulator.RegionFlags.EstateSkipScripts) != 0) + m_EstateSkipScripts = true; + if((flags & Simulator.RegionFlags.ResetHomeOnTeleport) != 0) + m_ResetHomeOnTeleport = true; + if((flags & Simulator.RegionFlags.TaxFree) != 0) + m_TaxFree = true; + if((flags & Simulator.RegionFlags.PublicAllowed) != 0) + m_PublicAccess = true; + break; case "billable_factor": - m_billableFactor = (float) configuration_result; - break; - case "estate_id": - m_estateID = (uint) configuration_result; - break; - case "parent_estate_id": - m_parentEstateID = (uint) configuration_result; + m_BillableFactor = (float) configuration_result; break; +// case "estate_id": +// m_EstateID = (uint) configuration_result; +// break; +// case "parent_estate_id": +// m_ParentEstateID = (uint) configuration_result; +// break; case "redirect_grid_x": - m_redirectGridX = (int) configuration_result; + m_RedirectGridX = (int) configuration_result; break; case "redirect_grid_y": - m_redirectGridY = (int) configuration_result; + m_RedirectGridY = (int) configuration_result; break; case "price_per_meter": - m_pricePerMeter = Convert.ToInt32(configuration_result); + m_PricePerMeter = Convert.ToInt32(configuration_result); break; - case "estate_name": - m_estateName = (string) configuration_result; + m_EstateName = (string) configuration_result; break; case "estate_manager_0": - m_estateManager0 = (LLUUID) configuration_result; + AddEstateManager((LLUUID)configuration_result); break; case "estate_manager_1": - m_estateManager1 = (LLUUID) configuration_result; + AddEstateManager((LLUUID)configuration_result); break; case "estate_manager_2": - m_estateManager2 = (LLUUID) configuration_result; + AddEstateManager((LLUUID)configuration_result); break; case "estate_manager_3": - m_estateManager3 = (LLUUID) configuration_result; + AddEstateManager((LLUUID)configuration_result); break; case "estate_manager_4": - m_estateManager4 = (LLUUID) configuration_result; + AddEstateManager((LLUUID)configuration_result); break; case "estate_manager_5": - m_estateManager5 = (LLUUID) configuration_result; + AddEstateManager((LLUUID)configuration_result); break; case "estate_manager_6": - m_estateManager6 = (LLUUID) configuration_result; + AddEstateManager((LLUUID)configuration_result); break; case "estate_manager_7": - m_estateManager7 = (LLUUID) configuration_result; + AddEstateManager((LLUUID)configuration_result); break; case "estate_manager_8": - m_estateManager8 = (LLUUID) configuration_result; + AddEstateManager((LLUUID)configuration_result); break; case "estate_manager_9": - m_estateManager9 = (LLUUID) configuration_result; + AddEstateManager((LLUUID)configuration_result); break; } diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index f34b9c40f7..bb44eb99aa 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -285,7 +285,8 @@ namespace OpenSim.Framework public delegate void SetEstateTerrainDetailTexture(IClientAPI remoteClient, int corner, LLUUID side); public delegate void SetEstateTerrainTextureHeights(IClientAPI remoteClient, int corner, float lowVal, float highVal); public delegate void CommitEstateTerrainTextureRequest(IClientAPI remoteClient); - public delegate void SetRegionTerrainSettings(float waterHeight, float terrainRaiseLimit, float terrainLowerLimit, bool fixedSun, float sunHour); + public delegate void SetRegionTerrainSettings(float waterHeight, float terrainRaiseLimit, float terrainLowerLimit, bool estateSun, bool fixedSun, float sunHour, bool globalSun, bool estateFixed, float estateSunHour); + public delegate void EstateChangeInfo(IClientAPI client, LLUUID invoice, LLUUID senderID, UInt32 param1, UInt32 param2); public delegate void BakeTerrain(IClientAPI remoteClient ); public delegate void EstateRestartSimRequest(IClientAPI remoteClient, int secondsTilReboot); public delegate void EstateChangeCovenantRequest(IClientAPI remoteClient, LLUUID newCovenantID); @@ -349,6 +350,7 @@ namespace OpenSim.Framework // [Obsolete("LLClientView Specific - Replace with more suitable arguments.")] event ModifyTerrain OnModifyTerrain; event BakeTerrain OnBakeTerrain; + event EstateChangeInfo OnEstateChangeInfo; // [Obsolete("LLClientView Specific.")] event SetAppearance OnSetAppearance; // [Obsolete("LLClientView Specific - Replace and rename OnAvatarUpdate. Difference from SetAppearance?")] @@ -628,11 +630,11 @@ namespace OpenSim.Framework void SendEstateManagersList(LLUUID invoice, LLUUID[] EstateManagers, uint estateID); - void SendBannedUserList(LLUUID invoice, List banlist, uint estateID); + void SendBannedUserList(LLUUID invoice, EstateBan[] banlist, uint estateID); void SendRegionInfoToEstateMenu(RegionInfoForEstateMenuArgs args); - void SendEstateCovenantInformation(); - void SendDetailedEstateData(LLUUID invoice,string estateName, uint estateID); + void SendEstateCovenantInformation(LLUUID covenant); + void SendDetailedEstateData(LLUUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition, LLUUID covenant); void SendLandProperties(IClientAPI remote_client, int sequence_id, bool snap_selection, int request_result, LandData landData, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags); void SendLandAccessListData(List avatars, uint accessFlag, int localLandID); diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index e8999475d0..ee64bf2037 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -193,7 +193,6 @@ namespace OpenSim.Framework public bool commFailTF = false; public ConfigurationMember configMember; - public LLUUID CovenantID = LLUUID.Zero; public string DataStore = String.Empty; public bool isSandbox = false; private EstateSettings m_estateSettings; @@ -212,7 +211,6 @@ namespace OpenSim.Framework public LLUUID lastMapUUID = LLUUID.Zero; public string lastMapRefresh = "0"; - public List regionBanlist = new List(); // Apparently, we're applying the same estatesettings regardless of whether it's local or remote. @@ -279,6 +277,8 @@ namespace OpenSim.Framework return m_estateSettings; } + + set { m_estateSettings = value; } } public RegionSettings RegionSettings @@ -364,28 +364,6 @@ namespace OpenSim.Framework configMember.performConfigurationRetrieve(); } - public bool CheckIfUserBanned(LLUUID user) - { - - RegionBanListItem[] bl = regionBanlist.ToArray(); - - bool banned = false; - - for (int i = 0; i < bl.Length; i++) - { - if (bl[i] == null) - continue; - - if (bl[i].bannedUUID == user) - { - banned = true; - break; - } - } - - return banned; - } - public void loadConfigurationOptionsFromMe() { configMember.addConfigurationOption("sim_UUID", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID_NULL_FREE, @@ -415,9 +393,6 @@ namespace OpenSim.Framework "External Host Name", m_externalHostName, true); configMember.addConfigurationOption("master_avatar_uuid", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "Master Avatar UUID", MasterAvatarAssignedUUID.ToString(), true); - configMember.addConfigurationOption("estate_covanant_uuid", - ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "Estate Covenant", - CovenantID.ToString(), true); configMember.addConfigurationOption("master_avatar_first", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "First Name of Master Avatar", MasterAvatarFirstName, true); @@ -461,9 +436,6 @@ namespace OpenSim.Framework "External Host Name", "127.0.0.1", false); configMember.addConfigurationOption("master_avatar_uuid", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "Master Avatar UUID", LLUUID.Zero.ToString(), true); - configMember.addConfigurationOption("estate_covanant_uuid", - ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "Estate Covenant", - LLUUID.Zero.ToString(), true); configMember.addConfigurationOption("master_avatar_first", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "First Name of Master Avatar", "Test", false, @@ -538,10 +510,6 @@ namespace OpenSim.Framework case "master_avatar_uuid": MasterAvatarAssignedUUID = (LLUUID) configuration_result; break; - case "estate_covanant_uuid": - CovenantID = (LLUUID) configuration_result; - break; - case "master_avatar_first": MasterAvatarFirstName = (string) configuration_result; break; @@ -563,11 +531,6 @@ namespace OpenSim.Framework return true; } - public void SaveEstatecovenantUUID(LLUUID notecard) - { - if (null == configMember) return; - configMember.forceSetConfigurationOption("estate_covanant_uuid", notecard.ToString()); - } public void SaveLastMapUUID(LLUUID mapUUID) { if (null == configMember) return; diff --git a/OpenSim/Framework/RegionSettings.cs b/OpenSim/Framework/RegionSettings.cs index be57c1bd00..13fabaf8d8 100644 --- a/OpenSim/Framework/RegionSettings.cs +++ b/OpenSim/Framework/RegionSettings.cs @@ -162,6 +162,8 @@ namespace OpenSim.Framework (flags & Simulator.RegionFlags.SkipPhysics) != 0; m_FixedSun = (flags & Simulator.RegionFlags.SunFixed) != 0; + m_Sandbox = + (flags & Simulator.RegionFlags.Sandbox) != 0; break; case "max_agents": m_AgentLimit = (int)value; @@ -231,7 +233,8 @@ namespace OpenSim.Framework public void Save() { - OnSave(this); + if(OnSave != null) + OnSave(this); } private LLUUID m_RegionUUID = LLUUID.Zero; @@ -474,6 +477,14 @@ namespace OpenSim.Framework set { m_UseEstateSun = value; } } + private bool m_Sandbox = false; + + public bool Sandbox + { + get { return m_Sandbox; } + set { m_Sandbox = value; } + } + private LLVector3 m_SunVector; public LLVector3 SunVector diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index c9cc062308..380df73a3b 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -520,7 +520,6 @@ namespace OpenSim //moved these here as the terrain texture has to be created after the modules are initialized // and has to happen before the region is registered with the grid. scene.CreateTerrainTexture(false); - scene.LoadRegionBanlist(); try { diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index b170f28c26..2c05097e44 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -166,6 +166,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP private GenericCall4 handlerDeRezObject = null; //OnDeRezObject; private ModifyTerrain handlerModifyTerrain = null; private BakeTerrain handlerBakeTerrain = null; + private EstateChangeInfo handlerEstateChangeInfo = null; private Action handlerRegionHandShakeReply = null; //OnRegionHandShakeReply; private GenericCall2 handlerRequestWearables = null; //OnRequestWearables; private Action handlerRequestAvatarsData = null; //OnRequestAvatarsData; @@ -920,6 +921,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest; public event SetRegionTerrainSettings OnSetRegionTerrainSettings; public event BakeTerrain OnBakeTerrain; + public event EstateChangeInfo OnEstateChangeInfo; public event EstateRestartSimRequest OnEstateRestartSimRequest; public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest; public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest; @@ -2614,18 +2616,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP this.OutPacket(packet, ThrottleOutPacketType.Task); } - public void SendBannedUserList(LLUUID invoice, List banlist, uint estateID) + public void SendBannedUserList(LLUUID invoice, EstateBan[] bl, uint estateID) { - RegionBanListItem[] bl = banlist.ToArray(); - - LLUUID[] BannedUsers = new LLUUID[bl.Length]; - + ListBannedUsers = new List(); for (int i = 0; i < bl.Length; i++) { if (bl[i] == null) continue; - BannedUsers[i] = bl[i].bannedUUID; + if (bl[i].bannedUUID == LLUUID.Zero) + continue; + BannedUsers.Add(bl[i].bannedUUID); } EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket(); @@ -2635,9 +2636,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP packet.MethodData.Invoice = invoice; packet.MethodData.Method = Helpers.StringToField("setaccess"); - EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + BannedUsers.Length]; + EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + BannedUsers.Count]; - for (int i = 0; i < (6 + BannedUsers.Length); i++) + for (int i = 0; i < (6 + BannedUsers.Count); i++) { returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock(); } @@ -2647,12 +2648,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP returnblock[j].Parameter = Helpers.StringToField(((int)Constants.EstateAccessCodex.EstateBans).ToString()); j++; returnblock[j].Parameter = Helpers.StringToField("0"); j++; returnblock[j].Parameter = Helpers.StringToField("0"); j++; - returnblock[j].Parameter = Helpers.StringToField(BannedUsers.Length.ToString()); j++; + returnblock[j].Parameter = Helpers.StringToField(BannedUsers.Count.ToString()); j++; returnblock[j].Parameter = Helpers.StringToField("0"); j++; - for (int i = 0; i < BannedUsers.Length; i++) + foreach (LLUUID banned in BannedUsers) { - returnblock[j].Parameter = BannedUsers[i].GetBytes(); j++; + returnblock[j].Parameter = banned.GetBytes(); j++; } packet.ParamList = returnblock; packet.Header.Reliable = false; @@ -2687,11 +2688,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP this.OutPacket(rinfopack, ThrottleOutPacketType.Task); } - public void SendEstateCovenantInformation() + public void SendEstateCovenantInformation(LLUUID covenant) { EstateCovenantReplyPacket einfopack = new EstateCovenantReplyPacket(); EstateCovenantReplyPacket.DataBlock edata = new EstateCovenantReplyPacket.DataBlock(); - edata.CovenantID = m_scene.RegionInfo.CovenantID; + edata.CovenantID = covenant; edata.CovenantTimestamp = 0; edata.EstateOwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID; edata.EstateName = @@ -2700,7 +2701,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP this.OutPacket(einfopack, ThrottleOutPacketType.Task); } - public void SendDetailedEstateData(LLUUID invoice, string estateName, uint estateID) + public void SendDetailedEstateData(LLUUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition, LLUUID covenant) { EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket(); packet.MethodData.Invoice = invoice; @@ -2718,13 +2719,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP returnblock[1].Parameter = Helpers.StringToField(m_scene.RegionInfo.MasterAvatarAssignedUUID.ToString()); returnblock[2].Parameter = Helpers.StringToField(estateID.ToString()); - // TODO: Resolve Magic numbers here - returnblock[3].Parameter = Helpers.StringToField("269516800"); - returnblock[4].Parameter = Helpers.StringToField("0"); - returnblock[5].Parameter = Helpers.StringToField("1"); - returnblock[6].Parameter = Helpers.StringToField(m_scene.RegionInfo.RegionID.ToString()); - returnblock[7].Parameter = Helpers.StringToField("1160895077"); - returnblock[8].Parameter = Helpers.StringToField("1"); + returnblock[3].Parameter = Helpers.StringToField(estateFlags.ToString()); + returnblock[4].Parameter = Helpers.StringToField(sunPosition.ToString()); + returnblock[5].Parameter = Helpers.StringToField(parentEstate.ToString()); + returnblock[6].Parameter = Helpers.StringToField(covenant.ToString()); + returnblock[7].Parameter = Helpers.StringToField("1160895077"); // what is this? + returnblock[8].Parameter = Helpers.StringToField("1"); // what is this? packet.ParamList = returnblock; packet.Header.Reliable = false; @@ -5959,10 +5959,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP tmp = Helpers.FieldToUTF8String(messagePacket.ParamList[2].Parameter); if (!tmp.Contains(".")) tmp += ".00"; float TerrainLowerLimit = (float)Convert.ToDecimal(tmp); + bool UseEstateSun = convertParamStringToBool(messagePacket.ParamList[3].Parameter); bool UseFixedSun = convertParamStringToBool(messagePacket.ParamList[4].Parameter); float SunHour = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(messagePacket.ParamList[5].Parameter)); + bool UseGlobal = convertParamStringToBool(messagePacket.ParamList[6].Parameter); + bool EstateFixedSun = convertParamStringToBool(messagePacket.ParamList[7].Parameter); + float EstateSunHour = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(messagePacket.ParamList[8].Parameter)); - OnSetRegionTerrainSettings(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseFixedSun, SunHour); + OnSetRegionTerrainSettings(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseEstateSun, UseFixedSun, SunHour, UseGlobal, EstateFixedSun, EstateSunHour); } catch (Exception ex) @@ -6076,6 +6080,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; + case "estatechangeinfo": + if (((Scene)m_scene).ExternalChecks.ExternalChecksCanIssueEstateCommand(this.AgentId)) + { + LLUUID invoice = messagePacket.MethodData.Invoice; + LLUUID SenderID = messagePacket.AgentData.AgentID; + UInt32 param1 = Convert.ToUInt32(Helpers.FieldToUTF8String(messagePacket.ParamList[1].Parameter)); + UInt32 param2 = Convert.ToUInt32(Helpers.FieldToUTF8String(messagePacket.ParamList[2].Parameter)); + + handlerEstateChangeInfo = OnEstateChangeInfo; + if (handlerEstateChangeInfo != null) + { + handlerEstateChangeInfo(this, invoice, SenderID, param1, param2); + } + } + break; + default: m_log.Error("EstateOwnerMessage: Unknown method requested\n" + messagePacket.ToString()); break; diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index 6f4a563b0d..d8a6dafdc1 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs @@ -623,7 +623,7 @@ namespace OpenSim.Region.Communications.OGS1 { if (regions[i].RegionHandle == regionHandle) { - if (regions[i].CheckIfUserBanned(agentData.AgentID)) + if (regions[i].EstateSettings.IsBanned(agentData.AgentID)) { banned = true; break; @@ -1158,7 +1158,7 @@ namespace OpenSim.Region.Communications.OGS1 { if (regions[i].RegionHandle == regionHandle) { - if (regions[i].CheckIfUserBanned(agentID)) + if (regions[i].EstateSettings.IsBanned(agentID)) { banned = true; break; diff --git a/OpenSim/Region/Environment/Interfaces/IEstateDataStore.cs b/OpenSim/Region/Environment/Interfaces/IEstateDataStore.cs new file mode 100644 index 0000000000..ecac2ca4a8 --- /dev/null +++ b/OpenSim/Region/Environment/Interfaces/IEstateDataStore.cs @@ -0,0 +1,41 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using OpenSim.Framework; +using libsecondlife; + +namespace OpenSim.Region.Environment.Interfaces +{ + public interface IEstateDataStore + { + void Initialise(string connectstring); + + EstateSettings LoadEstateSettings(LLUUID regionID); + void StoreEstateSettings(EstateSettings es); + } +} diff --git a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs index c189f953b8..0316f203d6 100644 --- a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs +++ b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs @@ -72,10 +72,6 @@ namespace OpenSim.Region.Environment.Interfaces void RemoveLandObject(LLUUID globalID); List LoadLandObjects(LLUUID regionUUID); - List LoadRegionBanList(LLUUID regionUUID); - void AddToRegionBanlist(RegionBanListItem item); - void RemoveFromRegionBanlist(RegionBanListItem item); - void StoreRegionSettings(RegionSettings rs); RegionSettings LoadRegionSettings(LLUUID regionUUID); diff --git a/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs index ac6a075ddf..c5c0370e58 100644 --- a/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Estate/EstateManagementModule.cs @@ -49,9 +49,26 @@ namespace OpenSim.Region.Environment.Modules.World.Estate private void sendDetailedEstateData(IClientAPI remote_client, LLUUID invoice) { - remote_client.SendDetailedEstateData(invoice,m_scene.RegionInfo.EstateSettings.estateName,m_scene.RegionInfo.EstateSettings.estateID); - remote_client.SendEstateManagersList(invoice,m_scene.RegionInfo.EstateSettings.estateManagers,m_scene.RegionInfo.EstateSettings.estateID); - remote_client.SendBannedUserList(invoice, m_scene.RegionInfo.regionBanlist, m_scene.RegionInfo.EstateSettings.estateID); + //SendDetailedEstateData(LLUUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition, LLUUID covenant) + + uint sun = 0; + if(!m_scene.RegionInfo.EstateSettings.UseGlobalTime) + sun=(uint)(m_scene.RegionInfo.EstateSettings.SunPosition*1024.0) + 0x1800; + remote_client.SendDetailedEstateData(invoice, + m_scene.RegionInfo.EstateSettings.EstateName, + m_scene.RegionInfo.EstateSettings.EstateID, + m_scene.RegionInfo.EstateSettings.ParentEstateID, + GetEstateFlags(), + sun, + m_scene.RegionInfo.RegionSettings.Covenant); + + remote_client.SendEstateManagersList(invoice, + m_scene.RegionInfo.EstateSettings.EstateManagers, + m_scene.RegionInfo.EstateSettings.EstateID); + + remote_client.SendBannedUserList(invoice, + m_scene.RegionInfo.EstateSettings.EstateBans, + m_scene.RegionInfo.EstateSettings.EstateID); } private void estateSetRegionInfoHandler(bool blockTerraform, bool noFly, bool allowDamage, bool blockLandResell, int maxAgents, float objectBonusFactor, @@ -150,8 +167,10 @@ namespace OpenSim.Region.Environment.Modules.World.Estate sendRegionHandshakeToAll(); } - public void setRegionTerrainSettings(float WaterHeight, float TerrainRaiseLimit, float TerrainLowerLimit, - bool UseFixedSun, float SunHour) + public void setRegionTerrainSettings(float WaterHeight, + float TerrainRaiseLimit, float TerrainLowerLimit, + bool UseEstateSun, bool UseFixedSun, float SunHour, + bool UseGlobal, bool EstateFixedSun, float EstateSunHour) { // Water Height m_scene.RegionInfo.RegionSettings.WaterHeight = WaterHeight; @@ -161,10 +180,11 @@ namespace OpenSim.Region.Environment.Modules.World.Estate m_scene.RegionInfo.RegionSettings.TerrainLowerLimit = TerrainLowerLimit; // Time of day / fixed sun + m_scene.RegionInfo.RegionSettings.UseEstateSun = UseEstateSun; m_scene.RegionInfo.RegionSettings.FixedSun = UseFixedSun; m_scene.RegionInfo.RegionSettings.SunPosition = SunHour; - m_scene.EventManager.TriggerEstateToolsTimeUpdate(m_scene.RegionInfo.RegionHandle, UseFixedSun, UseFixedSun, SunHour); + m_scene.EventManager.TriggerEstateToolsTimeUpdate(m_scene.RegionInfo.RegionHandle, UseFixedSun, UseEstateSun, SunHour); //m_log.Debug("[ESTATE]: UFS: " + UseFixedSun.ToString()); //m_log.Debug("[ESTATE]: SunHour: " + SunHour.ToString()); @@ -180,20 +200,23 @@ namespace OpenSim.Region.Environment.Modules.World.Estate private void handleChangeEstateCovenantRequest(IClientAPI remoteClient, LLUUID estateCovenantID) { - m_scene.RegionInfo.CovenantID = estateCovenantID; - m_scene.RegionInfo.SaveEstatecovenantUUID(estateCovenantID); + m_scene.RegionInfo.RegionSettings.Covenant = estateCovenantID; + m_scene.RegionInfo.RegionSettings.Save(); } private void handleEstateAccessDeltaRequest(IClientAPI remote_client, LLUUID invoice, int estateAccessType, LLUUID user) { // EstateAccessDelta handles Estate Managers, Sim Access, Sim Banlist, allowed Groups.. etc. + if (user == m_scene.RegionInfo.MasterAvatarAssignedUUID) + return; // never process owner + switch (estateAccessType) { case 64: if (m_scene.ExternalChecks.ExternalChecksCanIssueEstateCommand(remote_client.AgentId) || m_scene.ExternalChecks.ExternalChecksBypassPermissions()) { - RegionBanListItem[] banlistcheck = m_scene.RegionInfo.regionBanlist.ToArray(); + EstateBan[] banlistcheck = m_scene.RegionInfo.EstateSettings.EstateBans; bool alreadyInList = false; @@ -209,15 +232,15 @@ namespace OpenSim.Region.Environment.Modules.World.Estate if (!alreadyInList) { - RegionBanListItem item = new RegionBanListItem(); + EstateBan item = new EstateBan(); item.bannedUUID = user; - item.regionUUID = m_scene.RegionInfo.RegionID; + item.estateID = m_scene.RegionInfo.EstateSettings.EstateID; item.bannedIP = "0.0.0.0"; item.bannedIPHostMask = "0.0.0.0"; - m_scene.RegionInfo.regionBanlist.Add(item); - m_scene.AddToRegionBanlist(item); + m_scene.RegionInfo.EstateSettings.AddBan(item); + m_scene.RegionInfo.EstateSettings.Save(); ScenePresence s = m_scene.GetScenePresence(user); if (s != null) @@ -231,7 +254,7 @@ namespace OpenSim.Region.Environment.Modules.World.Estate remote_client.SendAlertMessage("User is already on the region ban list"); } //m_scene.RegionInfo.regionBanlist.Add(Manager(user); - remote_client.SendBannedUserList(invoice, m_scene.RegionInfo.regionBanlist, m_scene.RegionInfo.EstateSettings.estateID); + remote_client.SendBannedUserList(invoice, m_scene.RegionInfo.EstateSettings.EstateBans, m_scene.RegionInfo.EstateSettings.EstateID); } else { @@ -241,10 +264,10 @@ namespace OpenSim.Region.Environment.Modules.World.Estate case 128: if (m_scene.ExternalChecks.ExternalChecksCanIssueEstateCommand(remote_client.AgentId) || m_scene.ExternalChecks.ExternalChecksBypassPermissions()) { - RegionBanListItem[] banlistcheck = m_scene.RegionInfo.regionBanlist.ToArray(); + EstateBan[] banlistcheck = m_scene.RegionInfo.EstateSettings.EstateBans; bool alreadyInList = false; - RegionBanListItem listitem = null; + EstateBan listitem = null; for (int i = 0; i < banlistcheck.Length; i++) { @@ -258,15 +281,15 @@ namespace OpenSim.Region.Environment.Modules.World.Estate } if (alreadyInList && listitem != null) { - m_scene.RegionInfo.regionBanlist.Remove(listitem); - m_scene.RemoveFromRegionBanlist(listitem); + m_scene.RegionInfo.EstateSettings.RemoveBan(listitem.bannedUUID); + m_scene.RegionInfo.EstateSettings.Save(); } else { remote_client.SendAlertMessage("User is not on the region ban list"); } //m_scene.RegionInfo.regionBanlist.Add(Manager(user); - remote_client.SendBannedUserList(invoice, m_scene.RegionInfo.regionBanlist, m_scene.RegionInfo.EstateSettings.estateID); + remote_client.SendBannedUserList(invoice, m_scene.RegionInfo.EstateSettings.EstateBans, m_scene.RegionInfo.EstateSettings.EstateID); } else { @@ -280,7 +303,8 @@ namespace OpenSim.Region.Environment.Modules.World.Estate if (remote_client.AgentId == m_scene.RegionInfo.MasterAvatarAssignedUUID || m_scene.ExternalChecks.ExternalChecksBypassPermissions()) { m_scene.RegionInfo.EstateSettings.AddEstateManager(user); - remote_client.SendEstateManagersList(invoice, m_scene.RegionInfo.EstateSettings.estateManagers, m_scene.RegionInfo.EstateSettings.estateID); + m_scene.RegionInfo.EstateSettings.Save(); + remote_client.SendEstateManagersList(invoice, m_scene.RegionInfo.EstateSettings.EstateManagers, m_scene.RegionInfo.EstateSettings.EstateID); } else { @@ -294,7 +318,9 @@ namespace OpenSim.Region.Environment.Modules.World.Estate if (remote_client.AgentId == m_scene.RegionInfo.MasterAvatarAssignedUUID || m_scene.ExternalChecks.ExternalChecksBypassPermissions()) { m_scene.RegionInfo.EstateSettings.RemoveEstateManager(user); - remote_client.SendEstateManagersList(invoice, m_scene.RegionInfo.EstateSettings.estateManagers, m_scene.RegionInfo.EstateSettings.estateID); + m_scene.RegionInfo.EstateSettings.Save(); + + remote_client.SendEstateManagersList(invoice, m_scene.RegionInfo.EstateSettings.EstateManagers, m_scene.RegionInfo.EstateSettings.EstateID); } else { @@ -358,28 +384,24 @@ namespace OpenSim.Region.Environment.Modules.World.Estate { RegionInfoForEstateMenuArgs args = new RegionInfoForEstateMenuArgs(); - args.billableFactor = m_scene.RegionInfo.EstateSettings.billableFactor; - args.estateID = m_scene.RegionInfo.EstateSettings.estateID; + args.billableFactor = m_scene.RegionInfo.EstateSettings.BillableFactor; + args.estateID = m_scene.RegionInfo.EstateSettings.EstateID; args.maxAgents = (byte)m_scene.RegionInfo.RegionSettings.AgentLimit; args.objectBonusFactor = (float)m_scene.RegionInfo.RegionSettings.ObjectBonus; - args.parentEstateID = m_scene.RegionInfo.EstateSettings.parentEstateID; - args.pricePerMeter = m_scene.RegionInfo.EstateSettings.pricePerMeter; - args.redirectGridX = m_scene.RegionInfo.EstateSettings.redirectGridX; - args.redirectGridY = m_scene.RegionInfo.EstateSettings.redirectGridY; + args.parentEstateID = m_scene.RegionInfo.EstateSettings.ParentEstateID; + args.pricePerMeter = m_scene.RegionInfo.EstateSettings.PricePerMeter; + args.redirectGridX = m_scene.RegionInfo.EstateSettings.RedirectGridX; + args.redirectGridY = m_scene.RegionInfo.EstateSettings.RedirectGridY; args.regionFlags = GetRegionFlags(); byte mature = 13; if(m_scene.RegionInfo.RegionSettings.Maturity == 1) mature = 21; args.simAccess = mature; - if (m_scene.RegionInfo.RegionSettings.FixedSun) - args.sunHour = (float)m_scene.RegionInfo.RegionSettings.SunPosition; - else - args.sunHour = m_scene.EventManager.GetSunLindenHour(); - + args.sunHour = (float)m_scene.RegionInfo.RegionSettings.SunPosition; args.terrainLowerLimit = (float)m_scene.RegionInfo.RegionSettings.TerrainLowerLimit; args.terrainRaiseLimit = (float)m_scene.RegionInfo.RegionSettings.TerrainRaiseLimit; - args.useEstateSun = !m_scene.RegionInfo.RegionSettings.FixedSun; + args.useEstateSun = m_scene.RegionInfo.RegionSettings.UseEstateSun; args.waterHeight = (float)m_scene.RegionInfo.RegionSettings.WaterHeight; args.simName = m_scene.RegionInfo.RegionName; @@ -387,9 +409,9 @@ namespace OpenSim.Region.Environment.Modules.World.Estate remote_client.SendRegionInfoToEstateMenu(args); } - private static void HandleEstateCovenantRequest(IClientAPI remote_client) + private void HandleEstateCovenantRequest(IClientAPI remote_client) { - remote_client.SendEstateCovenantInformation(); + remote_client.SendEstateCovenantInformation(m_scene.RegionInfo.RegionSettings.Covenant); } private void HandleLandStatRequest(int parcelID, uint reportType, uint requestFlags, string filter, IClientAPI remoteClient) { @@ -508,7 +530,7 @@ namespace OpenSim.Region.Environment.Modules.World.Estate { RegionHandshakeArgs args = new RegionHandshakeArgs(); bool estatemanager = false; - LLUUID[] EstateManagers = m_scene.RegionInfo.EstateSettings.estateManagers; + LLUUID[] EstateManagers = m_scene.RegionInfo.EstateSettings.EstateManagers; for (int i = 0; i < EstateManagers.Length; i++) { if (EstateManagers[i] == remoteClient.AgentId) @@ -517,7 +539,7 @@ namespace OpenSim.Region.Environment.Modules.World.Estate args.isEstateManager = estatemanager; - args.billableFactor = m_scene.RegionInfo.EstateSettings.billableFactor; + args.billableFactor = m_scene.RegionInfo.EstateSettings.BillableFactor; args.terrainStartHeight0 = (float)m_scene.RegionInfo.RegionSettings.Elevation1SW; args.terrainHeightRange0 = (float)m_scene.RegionInfo.RegionSettings.Elevation2SW; args.terrainStartHeight1 = (float)m_scene.RegionInfo.RegionSettings.Elevation1NW; @@ -554,6 +576,73 @@ namespace OpenSim.Region.Environment.Modules.World.Estate ); } + public void handleEstateChangeInfo(IClientAPI remoteClient, LLUUID invoice, LLUUID senderID, UInt32 parms1, UInt32 parms2) + { + if(parms2 == 0) + { + m_scene.RegionInfo.EstateSettings.UseGlobalTime = true; + m_scene.RegionInfo.EstateSettings.SunPosition = 0.0; + } + else + { + m_scene.RegionInfo.EstateSettings.UseGlobalTime = false; + m_scene.RegionInfo.EstateSettings.SunPosition = (double)(parms2 - 0x1800)/1024.0; + } + + if((parms1 & 0x00000010) != 0) + m_scene.RegionInfo.EstateSettings.FixedSun = true; + else + m_scene.RegionInfo.EstateSettings.FixedSun = false; + + if((parms1 & 0x00008000) != 0) + m_scene.RegionInfo.EstateSettings.PublicAccess = true; + else + m_scene.RegionInfo.EstateSettings.PublicAccess = false; + + if((parms1 & 0x10000000) != 0) + m_scene.RegionInfo.EstateSettings.AllowVoice = true; + else + m_scene.RegionInfo.EstateSettings.AllowVoice = false; + + if((parms1 & 0x00100000) != 0) + m_scene.RegionInfo.EstateSettings.AllowDirectTeleport = true; + else + m_scene.RegionInfo.EstateSettings.AllowDirectTeleport = false; + + if((parms1 & 0x00800000) != 0) + m_scene.RegionInfo.EstateSettings.DenyAnonymous = true; + else + m_scene.RegionInfo.EstateSettings.DenyAnonymous = false; + + if((parms1 & 0x01000000) != 0) + m_scene.RegionInfo.EstateSettings.DenyIdentified = true; + else + m_scene.RegionInfo.EstateSettings.DenyIdentified = false; + + if((parms1 & 0x02000000) != 0) + m_scene.RegionInfo.EstateSettings.DenyTransacted = true; + else + m_scene.RegionInfo.EstateSettings.DenyTransacted = false; + + m_scene.RegionInfo.EstateSettings.Save(); + + float sun = (float)m_scene.RegionInfo.RegionSettings.SunPosition; + if(m_scene.RegionInfo.RegionSettings.UseEstateSun) + { + sun = (float)m_scene.RegionInfo.EstateSettings.SunPosition; + if(m_scene.RegionInfo.EstateSettings.UseGlobalTime) + sun = m_scene.EventManager.GetSunLindenHour(); + } + + m_scene.EventManager.TriggerEstateToolsTimeUpdate( + m_scene.RegionInfo.RegionHandle, + m_scene.RegionInfo.EstateSettings.FixedSun || + m_scene.RegionInfo.RegionSettings.FixedSun, + m_scene.RegionInfo.RegionSettings.UseEstateSun, sun); + + sendDetailedEstateData(remoteClient, invoice); + } + #endregion #region IRegionModule Members @@ -594,8 +683,12 @@ namespace OpenSim.Region.Environment.Modules.World.Estate setRegionTerrainSettings(height, (float)m_scene.RegionInfo.RegionSettings.TerrainRaiseLimit, (float)m_scene.RegionInfo.RegionSettings.TerrainLowerLimit, + m_scene.RegionInfo.RegionSettings.UseEstateSun, m_scene.RegionInfo.RegionSettings.FixedSun, - (float)m_scene.RegionInfo.RegionSettings.SunPosition); + (float)m_scene.RegionInfo.RegionSettings.SunPosition, + m_scene.RegionInfo.EstateSettings.UseGlobalTime, + m_scene.RegionInfo.EstateSettings.FixedSun, + (float)m_scene.RegionInfo.EstateSettings.SunPosition); sendRegionInfoPacketToAll(); } @@ -613,6 +706,7 @@ namespace OpenSim.Region.Environment.Modules.World.Estate client.OnSetRegionTerrainSettings += setRegionTerrainSettings; client.OnEstateRestartSimRequest += handleEstateRestartSimRequest; client.OnEstateChangeCovenantRequest += handleChangeEstateCovenantRequest; + client.OnEstateChangeInfo += handleEstateChangeInfo; client.OnUpdateEstateAccessDeltaRequest += handleEstateAccessDeltaRequest; client.OnSimulatorBlueBoxMessageRequest += SendSimulatorBlueBoxMessage; client.OnEstateBlueBoxMessageRequest += SendEstateBlueBoxMessage; @@ -652,41 +746,53 @@ namespace OpenSim.Region.Environment.Modules.World.Estate if(m_scene.RegionInfo.RegionSettings.BlockShowInSearch) flags |= (Simulator.RegionFlags)(1 << 29); - // Partially implemented - // if(m_scene.RegionInfo.RegionSettings.FixedSun) flags |= Simulator.RegionFlags.SunFixed; + if(m_scene.RegionInfo.RegionSettings.Sandbox) + flags |= Simulator.RegionFlags.Sandbox; - // Not implemented - // - // TODO: ExternallyVisible - flags |= Simulator.RegionFlags.ExternallyVisible; - // TODO: PublicAllowed - flags |= Simulator.RegionFlags.PublicAllowed; - // TODO: AllowDirectTeleport - flags |= Simulator.RegionFlags.AllowDirectTeleport; - // TODO: AllowVoice - flags |= Simulator.RegionFlags.AllowVoice; + // Handled in LandObject.cs: AllowLandmark + // Handled in LandObject.cs: AllowSetHome - // TDOD: AllowLandmark - // TDOD: AllowSetHome - // TODO: ResetHomeOnTeleport - // TODO: TaxFree ? (Linden-ism) - // TODO: Sandbox ? // TODO: SkipUpdateInterestList - // TODO: ExternallyVisible - // TODO: DenyAnonymous - // TODO: DenyIdentified - // TODO: DenyTransacted - // TODO: AbuseEmailToEstateOwner - // TODO: BlockDwell - // TODO: EstateSkipScripts // Omitted // // Omitted: NullLayer (what is that?) // Omitted: SkipAgentAction (what does it do?) - // Omitted: MainlandVisible (Do we need it) + + return (uint)flags; + } + + public uint GetEstateFlags() + { + Simulator.RegionFlags flags = Simulator.RegionFlags.None; + + if(m_scene.RegionInfo.EstateSettings.FixedSun) + flags |= Simulator.RegionFlags.SunFixed; + if(m_scene.RegionInfo.EstateSettings.PublicAccess) + flags |= (Simulator.RegionFlags.PublicAllowed | + Simulator.RegionFlags.ExternallyVisible); + if(m_scene.RegionInfo.EstateSettings.AllowVoice) + flags |= Simulator.RegionFlags.AllowVoice; + if(m_scene.RegionInfo.EstateSettings.AllowDirectTeleport) + flags |= Simulator.RegionFlags.AllowDirectTeleport; + if(m_scene.RegionInfo.EstateSettings.DenyAnonymous) + flags |= Simulator.RegionFlags.DenyAnonymous; + if(m_scene.RegionInfo.EstateSettings.DenyIdentified) + flags |= Simulator.RegionFlags.DenyIdentified; + if(m_scene.RegionInfo.EstateSettings.DenyTransacted) + flags |= Simulator.RegionFlags.DenyTransacted; + if(m_scene.RegionInfo.EstateSettings.AbuseEmailToEstateOwner) + flags |= Simulator.RegionFlags.AbuseEmailToEstateOwner; + if(m_scene.RegionInfo.EstateSettings.BlockDwell) + flags |= Simulator.RegionFlags.BlockDwell; + if(m_scene.RegionInfo.EstateSettings.EstateSkipScripts) + flags |= Simulator.RegionFlags.EstateSkipScripts; + if(m_scene.RegionInfo.EstateSettings.ResetHomeOnTeleport) + flags |= Simulator.RegionFlags.ResetHomeOnTeleport; + if(m_scene.RegionInfo.EstateSettings.TaxFree) + flags |= Simulator.RegionFlags.TaxFree; return (uint)flags; } diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs b/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs index e52896ac8a..5aed2a7087 100644 --- a/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs +++ b/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs @@ -162,9 +162,13 @@ namespace OpenSim.Region.Environment.Modules.World.Land public void sendLandProperties(int sequence_id, bool snap_selection, int request_result, IClientAPI remote_client) { IEstateModule estateModule = m_scene.RequestModuleInterface(); - uint regionFlags = 67108864; + uint regionFlags = 336723974 & ~((uint)(Simulator.RegionFlags.AllowLandmark | Simulator.RegionFlags.AllowSetHome)); if(estateModule != null) regionFlags = estateModule.GetRegionFlags(); + if((landData.landFlags & (uint)Parcel.ParcelFlags.AllowLandmark) != 0) + regionFlags |= (uint)Simulator.RegionFlags.AllowLandmark; + if(landData.ownerID == remote_client.AgentId) + regionFlags |= (uint)Simulator.RegionFlags.AllowSetHome; remote_client.SendLandProperties(remote_client, sequence_id, snap_selection, request_result, landData, (float)m_scene.RegionInfo.RegionSettings.ObjectBonus, diff --git a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs index 10971db7ba..040b9b7bf4 100644 --- a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs @@ -291,6 +291,7 @@ namespace OpenSim.Region.Environment.Modules.World.NPC public event EstateBlueBoxMessageRequest OnEstateBlueBoxMessageRequest; public event EstateDebugRegionRequest OnEstateDebugRegionRequest; public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest; + public event EstateChangeInfo OnEstateChangeInfo; public event ScriptReset OnScriptReset; public event GetScriptRunning OnGetScriptRunning; public event SetScriptRunning OnSetScriptRunning; @@ -752,17 +753,17 @@ namespace OpenSim.Region.Environment.Modules.World.NPC { } - public void SendBannedUserList(LLUUID invoice, List banlist, uint estateID) + public void SendBannedUserList(LLUUID invoice, EstateBan[] banlist, uint estateID) { } public void SendRegionInfoToEstateMenu(RegionInfoForEstateMenuArgs args) { } - public void SendEstateCovenantInformation() + public void SendEstateCovenantInformation(LLUUID covenant) { } - public void SendDetailedEstateData(LLUUID invoice, string estateName, uint estateID) + public void SendDetailedEstateData(LLUUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition, LLUUID covenant) { } diff --git a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs index 41bb61051f..b0d9a26ece 100644 --- a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs @@ -246,17 +246,7 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions protected bool IsEstateManager(LLUUID user) { - if (user != LLUUID.Zero) - { - LLUUID[] estatemanagers = m_scene.RegionInfo.EstateSettings.estateManagers; - foreach (LLUUID estatemanager in estatemanagers) - { - if (estatemanager == user) - return true; - } - } - - return false; + return m_scene.RegionInfo.EstateSettings.IsEstateManager(user); } #endregion diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index ad9646f04c..4aa9cf954d 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -271,9 +271,14 @@ namespace OpenSim.Region.Environment.Scenes // Load region settings // First try database m_regInfo.RegionSettings = m_storageManager.DataStore.LoadRegionSettings(m_regInfo.RegionID); - // Hook up save event m_regInfo.RegionSettings.OnSave += m_storageManager.DataStore.StoreRegionSettings; + if(m_storageManager.EstateDataStore != null) + { + m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID); + m_regInfo.EstateSettings.OnSave += m_storageManager.EstateDataStore.StoreEstateSettings; + } + //Bind Storage Manager functions to some land manager functions for this scene @@ -1445,20 +1450,6 @@ namespace OpenSim.Region.Environment.Scenes } } - public void LoadRegionBanlist() - { - List regionbanlist = m_storageManager.DataStore.LoadRegionBanList(m_regInfo.RegionID); - m_regInfo.regionBanlist = regionbanlist; - } - public void AddToRegionBanlist(RegionBanListItem item) - { - m_storageManager.DataStore.AddToRegionBanlist(item); - } - - public void RemoveFromRegionBanlist(RegionBanListItem item) - { - m_storageManager.DataStore.RemoveFromRegionBanlist(item); - } #endregion #region Primitives Methods @@ -1916,7 +1907,7 @@ namespace OpenSim.Region.Environment.Scenes SceneObjectPart RootPrim = GetSceneObjectPart(primID); if (RootPrim != null) { - if (m_regInfo.CheckIfUserBanned(RootPrim.OwnerID)) + if (m_regInfo.EstateSettings.IsBanned(RootPrim.OwnerID)) { SceneObjectGroup grp = RootPrim.ParentGroup; if (grp != null) @@ -2410,7 +2401,7 @@ namespace OpenSim.Region.Environment.Scenes { if (regionHandle == m_regInfo.RegionHandle) { - if (m_regInfo.CheckIfUserBanned(agent.AgentID)) + if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) { m_log.WarnFormat( "[CONNECTION DEBUGGING]: Denied access to: {0} [{1}] at {2} because the user is on the region banlist", diff --git a/OpenSim/Region/Environment/StorageManager.cs b/OpenSim/Region/Environment/StorageManager.cs index b9a42a2f39..768e12cbfb 100644 --- a/OpenSim/Region/Environment/StorageManager.cs +++ b/OpenSim/Region/Environment/StorageManager.cs @@ -43,6 +43,13 @@ namespace OpenSim.Region.Environment get { return m_dataStore; } } + private IEstateDataStore m_estateDataStore; + + public IEstateDataStore EstateDataStore + { + get { return m_estateDataStore; } + } + public StorageManager(IRegionDataStore storage) { m_dataStore = storage; @@ -69,6 +76,17 @@ namespace OpenSim.Region.Environment m_log.Info("[DATASTORE]: Added IRegionDataStore Interface"); } + + typeInterface = pluginType.GetInterface("IEstateDataStore", true); + + if(typeInterface != null) + { + IEstateDataStore estPlug = + (IEstateDataStore) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + estPlug.Initialise(connectionstring); + + m_estateDataStore = estPlug; + } } } diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index 94983ee4c9..6179ccf373 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -158,6 +158,7 @@ namespace OpenSim.Region.Examples.SimpleModule public event ObjectDeselect OnObjectDeselect; public event RegionInfoRequest OnRegionInfoRequest; public event EstateCovenantRequest OnEstateCovenantRequest; + public event EstateChangeInfo OnEstateChangeInfo; public event ObjectDuplicateOnRay OnObjectDuplicateOnRay; @@ -741,17 +742,17 @@ namespace OpenSim.Region.Examples.SimpleModule { } - public void SendBannedUserList(LLUUID invoice, List banlist, uint estateID) + public void SendBannedUserList(LLUUID invoice, EstateBan[] banlist, uint estateID) { } public void SendRegionInfoToEstateMenu(RegionInfoForEstateMenuArgs args) { } - public void SendEstateCovenantInformation() + public void SendEstateCovenantInformation(LLUUID covenant) { } - public void SendDetailedEstateData(LLUUID invoice, string estateName, uint estateID) + public void SendDetailedEstateData(LLUUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition, LLUUID covenant) { } diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs index 6dfcb3c966..edbb1b779f 100644 --- a/OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs +++ b/OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs @@ -322,23 +322,6 @@ namespace OpenSim.DataStore.MSSQL return new List(); } - public List LoadRegionBanList(LLUUID regionUUID) - { - List regionbanlist = new List(); - return regionbanlist; - } - - public void AddToRegionBanlist(RegionBanListItem item) - { - - } - - public void RemoveFromRegionBanlist(RegionBanListItem item) - { - - } - - public void Commit() { lock (ds)