From f3f31744abaf8a9df952a0d547faa59035b46ff3 Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 29 Jun 2008 11:48:58 +0000 Subject: patch and files from mantis #1630, Thanks Melanie --- OpenSim/Data/MySQL/MySQLDataStore.cs | 183 +++++++++++++++++++++++ OpenSim/Data/MySQL/Resources/005_RegionStore.sql | 40 +++++ 2 files changed, 223 insertions(+) create mode 100644 OpenSim/Data/MySQL/Resources/005_RegionStore.sql (limited to 'OpenSim/Data/MySQL') diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs index 87bce10..35e0ab7 100644 --- a/OpenSim/Data/MySQL/MySQLDataStore.cs +++ b/OpenSim/Data/MySQL/MySQLDataStore.cs @@ -54,6 +54,7 @@ namespace OpenSim.Data.MySQL 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"; /// @@ -70,6 +71,7 @@ namespace OpenSim.Data.MySQL private MySqlDataAdapter m_landDataAdapter; private MySqlDataAdapter m_landAccessListDataAdapter; private MySqlDataAdapter m_regionBanListDataAdapter; + private MySqlDataAdapter m_regionSettingsDataAdapter; private DataTable m_primTable; private DataTable m_shapeTable; @@ -78,6 +80,7 @@ namespace OpenSim.Data.MySQL private DataTable m_landTable; private DataTable m_landAccessListTable; private DataTable m_regionBanListTable; + private DataTable m_regionSettingsTable; /// Temporary attribute while this is experimental private bool persistPrimInventories; @@ -134,6 +137,8 @@ namespace OpenSim.Data.MySQL 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); lock (m_dataSet) { @@ -175,6 +180,11 @@ namespace OpenSim.Data.MySQL 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); + m_regionSettingsDataAdapter.Fill(m_regionSettingsTable); } } /// @@ -640,6 +650,41 @@ namespace OpenSim.Data.MySQL } } + public RegionSettings LoadRegionSettings(LLUUID regionUUID) + { + lock(m_dataSet) + { + DataTable regionsettings = m_regionSettingsTable; + string searchExp = "regionUUID = '" + regionUUID.ToString() + "'"; + DataRow[] rawsettings = regionsettings.Select(searchExp); + if(rawsettings.Length == 0) + return null; + DataRow row = rawsettings[0]; + + return buildRegionSettings(row); + } + } + + public void StoreRegionSettings(RegionSettings rs) + { + lock (m_dataSet) + { + DataTable regionsettings = m_dataSet.Tables["regionsettings"]; + + DataRow settingsRow = regionsettings.Rows.Find(rs.RegionUUID.ToString()); + if (settingsRow == null) + { + settingsRow = regionsettings.NewRow(); + fillRegionSettingsRow(settingsRow, rs); + regionsettings.Rows.Add(settingsRow); + } + else + { + fillRegionSettingsRow(settingsRow, rs); + } + } + } + /// /// Load (fetch?) a region banlist /// @@ -839,6 +884,49 @@ namespace OpenSim.Data.MySQL } /// + /// Create the "regionsettings" table + /// + /// + private static DataTable createRegionSettingsTable() + { + DataTable regionsettings = new DataTable("regionsettings"); + createCol(regionsettings, "regionUUID", typeof(String)); + createCol(regionsettings, "block_terraform", typeof (Int32)); + createCol(regionsettings, "block_fly", typeof (Int32)); + createCol(regionsettings, "allow_damage", typeof (Int32)); + createCol(regionsettings, "restrict_pushing", typeof (Int32)); + createCol(regionsettings, "allow_land_resell", typeof (Int32)); + createCol(regionsettings, "allow_land_join_divide", typeof (Int32)); + createCol(regionsettings, "block_show_in_search", typeof (Int32)); + createCol(regionsettings, "agent_limit", typeof (Int32)); + createCol(regionsettings, "object_bonus", typeof (Double)); + createCol(regionsettings, "maturity", typeof (Int32)); + createCol(regionsettings, "disable_scripts", typeof (Int32)); + createCol(regionsettings, "disable_collisions", typeof (Int32)); + createCol(regionsettings, "disable_physics", typeof (Int32)); + createCol(regionsettings, "terrain_texture_1", typeof(String)); + createCol(regionsettings, "terrain_texture_2", typeof(String)); + createCol(regionsettings, "terrain_texture_3", typeof(String)); + createCol(regionsettings, "terrain_texture_4", typeof(String)); + createCol(regionsettings, "elevation_1_nw", typeof (Double)); + createCol(regionsettings, "elevation_2_nw", typeof (Double)); + createCol(regionsettings, "elevation_1_ne", typeof (Double)); + createCol(regionsettings, "elevation_2_ne", typeof (Double)); + createCol(regionsettings, "elevation_1_se", typeof (Double)); + createCol(regionsettings, "elevation_2_se", typeof (Double)); + createCol(regionsettings, "elevation_1_sw", typeof (Double)); + createCol(regionsettings, "elevation_2_sw", typeof (Double)); + createCol(regionsettings, "water_height", typeof (Double)); + createCol(regionsettings, "terrain_raise_limit", typeof (Double)); + createCol(regionsettings, "terrain_lower_limit", typeof (Double)); + createCol(regionsettings, "use_estate_sun", typeof (Int32)); + createCol(regionsettings, "fixed_sun", typeof (Int32)); + createCol(regionsettings, "sun_position", typeof (Double)); + createCol(regionsettings, "covenant", typeof(String)); + return regionsettings; + } + + /// /// Create the "regionban" table /// /// @@ -1205,6 +1293,47 @@ namespace OpenSim.Data.MySQL return taskItem; } + private static RegionSettings buildRegionSettings(DataRow row) + { + RegionSettings newSettings = new RegionSettings(); + + newSettings.RegionUUID = new LLUUID((string) row["regionUUID"]); + newSettings.BlockTerraform = Convert.ToBoolean(row["block_terraform"]); + newSettings.AllowDamage = Convert.ToBoolean(row["allow_damage"]); + newSettings.BlockFly = Convert.ToBoolean(row["block_fly"]); + newSettings.RestrictPushing = Convert.ToBoolean(row["restrict_pushing"]); + newSettings.AllowLandResell = Convert.ToBoolean(row["allow_land_resell"]); + newSettings.AllowLandJoinDivide = Convert.ToBoolean(row["allow_land_join_divide"]); + newSettings.BlockShowInSearch = Convert.ToBoolean(row["block_show_in_search"]); + newSettings.AgentLimit = Convert.ToInt32(row["agent_limit"]); + newSettings.ObjectBonus = Convert.ToDouble(row["object_bonus"]); + newSettings.Maturity = Convert.ToInt32(row["maturity"]); + newSettings.DisableScripts = Convert.ToBoolean(row["disable_scripts"]); + newSettings.DisableCollisions = Convert.ToBoolean(row["disable_collisions"]); + newSettings.DisablePhysics = Convert.ToBoolean(row["disable_physics"]); + newSettings.TerrainTexture1 = new LLUUID((String) row["terrain_texture_1"]); + newSettings.TerrainTexture2 = new LLUUID((String) row["terrain_texture_2"]); + newSettings.TerrainTexture3 = new LLUUID((String) row["terrain_texture_3"]); + newSettings.TerrainTexture4 = new LLUUID((String) row["terrain_texture_4"]); + newSettings.Elevation1NW = Convert.ToDouble(row["elevation_1_nw"]); + newSettings.Elevation2NW = Convert.ToDouble(row["elevation_2_nw"]); + newSettings.Elevation1NE = Convert.ToDouble(row["elevation_1_ne"]); + newSettings.Elevation2NE = Convert.ToDouble(row["elevation_2_ne"]); + newSettings.Elevation1SE = Convert.ToDouble(row["elevation_1_se"]); + newSettings.Elevation2SE = Convert.ToDouble(row["elevation_2_se"]); + newSettings.Elevation1SW = Convert.ToDouble(row["elevation_1_sw"]); + newSettings.Elevation2SW = Convert.ToDouble(row["elevation_2_sw"]); + newSettings.WaterHeight = Convert.ToDouble(row["water_height"]); + 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.FixedSun = Convert.ToBoolean(row["fixed_sun"]); + newSettings.SunPosition = Convert.ToDouble(row["sun_position"]); + newSettings.Covenant = new LLUUID((String) row["covenant"]); + + return newSettings; + } + /// /// /// @@ -1425,6 +1554,46 @@ namespace OpenSim.Data.MySQL /// /// /// + private static void fillRegionSettingsRow(DataRow row, RegionSettings settings) + { + row["regionUUID"] = settings.RegionUUID.ToString(); + row["block_terraform"] = settings.BlockTerraform; + row["block_fly"] = settings.BlockFly; + row["allow_damage"] = settings.AllowDamage; + row["restrict_pushing"] = settings.RestrictPushing; + row["allow_land_resell"] = settings.AllowLandResell; + row["allow_land_join_divide"] = settings.AllowLandJoinDivide; + row["block_show_in_search"] = settings.BlockShowInSearch; + row["agent_limit"] = settings.AgentLimit; + row["object_bonus"] = settings.ObjectBonus; + row["maturity"] = settings.Maturity; + row["disable_scripts"] = settings.DisableScripts; + row["disable_collisions"] = settings.DisableCollisions; + row["disable_physics"] = settings.DisablePhysics; + row["terrain_texture_1"] = settings.TerrainTexture1.ToString(); + row["terrain_texture_2"] = settings.TerrainTexture2.ToString(); + row["terrain_texture_3"] = settings.TerrainTexture3.ToString(); + row["terrain_texture_4"] = settings.TerrainTexture4.ToString(); + row["elevation_1_nw"] = settings.Elevation1NW; + row["elevation_2_nw"] = settings.Elevation2NW; + row["elevation_1_ne"] = settings.Elevation1NE; + row["elevation_2_ne"] = settings.Elevation2NE; + row["elevation_1_se"] = settings.Elevation1SE; + row["elevation_2_se"] = settings.Elevation2SE; + row["elevation_1_sw"] = settings.Elevation1SW; + row["elevation_2_sw"] = settings.Elevation2SW; + row["water_height"] = settings.WaterHeight; + row["terrain_raise_limit"] = settings.TerrainRaiseLimit; + row["terrain_lower_limit"] = settings.TerrainLowerLimit; + row["use_estate_sun"] = settings.UseEstateSun; + row["fixed_sun"] = settings.FixedSun; + row["sun_position"] = settings.SunPosition; + row["covenant"] = settings.Covenant.ToString(); + } + + /// + /// + /// /// /// /// @@ -1865,6 +2034,20 @@ namespace OpenSim.Data.MySQL da.DeleteCommand = delete; } + private void SetupRegionSettingsCommands(MySqlDataAdapter da, MySqlConnection conn) + { + da.InsertCommand = createInsertCommand("regionsettings", m_regionSettingsTable); + da.InsertCommand.Connection = conn; + + da.UpdateCommand = createUpdateCommand("regionsettings", "regionUUID = ?regionUUID", m_regionSettingsTable); + da.UpdateCommand.Connection = conn; + + MySqlCommand delete = new MySqlCommand("delete from regionsettings where regionUUID = ?regionUUID"); + delete.Parameters.Add(createMySqlParameter("regionUUID", typeof(String))); + delete.Connection = conn; + da.DeleteCommand = delete; + } + /// /// /// diff --git a/OpenSim/Data/MySQL/Resources/005_RegionStore.sql b/OpenSim/Data/MySQL/Resources/005_RegionStore.sql new file mode 100644 index 0000000..c4a9527 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/005_RegionStore.sql @@ -0,0 +1,40 @@ +BEGIN; + +create table regionsettings ( + regionUUID char(36) not null, + block_terraform integer not null, + block_fly integer not null, + allow_damage integer not null, + restrict_pushing integer not null, + allow_land_resell integer not null, + allow_land_join_divide integer not null, + block_show_in_search integer not null, + agent_limit integer not null, + object_bonus float not null, + maturity integer not null, + disable_scripts integer not null, + disable_collisions integer not null, + disable_physics integer 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 integer not null, + fixed_sun integer not null, + sun_position float not null, + covenant char(36), + primary key(regionUUID) +); + +COMMIT; -- cgit v1.1