aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL/MySQLDataStore.cs
diff options
context:
space:
mode:
authorMW2008-06-29 11:48:58 +0000
committerMW2008-06-29 11:48:58 +0000
commitf3f31744abaf8a9df952a0d547faa59035b46ff3 (patch)
treed400f1ef6854d9f7b57007f92e774b5c7b1a1c81 /OpenSim/Data/MySQL/MySQLDataStore.cs
parentcouple of small fixes to try to fix support for multiple inventory servers in... (diff)
downloadopensim-SC_OLD-f3f31744abaf8a9df952a0d547faa59035b46ff3.zip
opensim-SC_OLD-f3f31744abaf8a9df952a0d547faa59035b46ff3.tar.gz
opensim-SC_OLD-f3f31744abaf8a9df952a0d547faa59035b46ff3.tar.bz2
opensim-SC_OLD-f3f31744abaf8a9df952a0d547faa59035b46ff3.tar.xz
patch and files from mantis #1630, Thanks Melanie
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLDataStore.cs')
-rw-r--r--OpenSim/Data/MySQL/MySQLDataStore.cs183
1 files changed, 183 insertions, 0 deletions
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
54 private const string m_landSelect = "select * from land"; 54 private const string m_landSelect = "select * from land";
55 private const string m_landAccessListSelect = "select * from landaccesslist"; 55 private const string m_landAccessListSelect = "select * from landaccesslist";
56 private const string m_regionBanListSelect = "select * from regionban"; 56 private const string m_regionBanListSelect = "select * from regionban";
57 private const string m_regionSettingsSelect = "select * from regionsettings";
57 58
58 59
59 /// <summary> 60 /// <summary>
@@ -70,6 +71,7 @@ namespace OpenSim.Data.MySQL
70 private MySqlDataAdapter m_landDataAdapter; 71 private MySqlDataAdapter m_landDataAdapter;
71 private MySqlDataAdapter m_landAccessListDataAdapter; 72 private MySqlDataAdapter m_landAccessListDataAdapter;
72 private MySqlDataAdapter m_regionBanListDataAdapter; 73 private MySqlDataAdapter m_regionBanListDataAdapter;
74 private MySqlDataAdapter m_regionSettingsDataAdapter;
73 75
74 private DataTable m_primTable; 76 private DataTable m_primTable;
75 private DataTable m_shapeTable; 77 private DataTable m_shapeTable;
@@ -78,6 +80,7 @@ namespace OpenSim.Data.MySQL
78 private DataTable m_landTable; 80 private DataTable m_landTable;
79 private DataTable m_landAccessListTable; 81 private DataTable m_landAccessListTable;
80 private DataTable m_regionBanListTable; 82 private DataTable m_regionBanListTable;
83 private DataTable m_regionSettingsTable;
81 84
82 /// <value>Temporary attribute while this is experimental</value> 85 /// <value>Temporary attribute while this is experimental</value>
83 private bool persistPrimInventories; 86 private bool persistPrimInventories;
@@ -134,6 +137,8 @@ namespace OpenSim.Data.MySQL
134 MySqlCommand regionBanListSelectCmd = new MySqlCommand(m_regionBanListSelect, m_connection); 137 MySqlCommand regionBanListSelectCmd = new MySqlCommand(m_regionBanListSelect, m_connection);
135 m_regionBanListDataAdapter = new MySqlDataAdapter(regionBanListSelectCmd); 138 m_regionBanListDataAdapter = new MySqlDataAdapter(regionBanListSelectCmd);
136 139
140 MySqlCommand regionSettingsSelectCmd = new MySqlCommand(m_regionSettingsSelect, m_connection);
141 m_regionSettingsDataAdapter = new MySqlDataAdapter(regionSettingsSelectCmd);
137 142
138 lock (m_dataSet) 143 lock (m_dataSet)
139 { 144 {
@@ -175,6 +180,11 @@ namespace OpenSim.Data.MySQL
175 m_dataSet.Tables.Add(m_regionBanListTable); 180 m_dataSet.Tables.Add(m_regionBanListTable);
176 SetupRegionBanCommands(m_regionBanListDataAdapter, m_connection); 181 SetupRegionBanCommands(m_regionBanListDataAdapter, m_connection);
177 m_regionBanListDataAdapter.Fill(m_regionBanListTable); 182 m_regionBanListDataAdapter.Fill(m_regionBanListTable);
183
184 m_regionSettingsTable = createRegionSettingsTable();
185 m_dataSet.Tables.Add(m_regionSettingsTable);
186 SetupRegionSettingsCommands(m_regionSettingsDataAdapter, m_connection);
187 m_regionSettingsDataAdapter.Fill(m_regionSettingsTable);
178 } 188 }
179 } 189 }
180 /// <summary> 190 /// <summary>
@@ -640,6 +650,41 @@ namespace OpenSim.Data.MySQL
640 } 650 }
641 } 651 }
642 652
653 public RegionSettings LoadRegionSettings(LLUUID regionUUID)
654 {
655 lock(m_dataSet)
656 {
657 DataTable regionsettings = m_regionSettingsTable;
658 string searchExp = "regionUUID = '" + regionUUID.ToString() + "'";
659 DataRow[] rawsettings = regionsettings.Select(searchExp);
660 if(rawsettings.Length == 0)
661 return null;
662 DataRow row = rawsettings[0];
663
664 return buildRegionSettings(row);
665 }
666 }
667
668 public void StoreRegionSettings(RegionSettings rs)
669 {
670 lock (m_dataSet)
671 {
672 DataTable regionsettings = m_dataSet.Tables["regionsettings"];
673
674 DataRow settingsRow = regionsettings.Rows.Find(rs.RegionUUID.ToString());
675 if (settingsRow == null)
676 {
677 settingsRow = regionsettings.NewRow();
678 fillRegionSettingsRow(settingsRow, rs);
679 regionsettings.Rows.Add(settingsRow);
680 }
681 else
682 {
683 fillRegionSettingsRow(settingsRow, rs);
684 }
685 }
686 }
687
643 /// <summary> 688 /// <summary>
644 /// Load (fetch?) a region banlist 689 /// Load (fetch?) a region banlist
645 /// </summary> 690 /// </summary>
@@ -839,6 +884,49 @@ namespace OpenSim.Data.MySQL
839 } 884 }
840 885
841 /// <summary> 886 /// <summary>
887 /// Create the "regionsettings" table
888 /// </summary>
889 /// <returns></returns>
890 private static DataTable createRegionSettingsTable()
891 {
892 DataTable regionsettings = new DataTable("regionsettings");
893 createCol(regionsettings, "regionUUID", typeof(String));
894 createCol(regionsettings, "block_terraform", typeof (Int32));
895 createCol(regionsettings, "block_fly", typeof (Int32));
896 createCol(regionsettings, "allow_damage", typeof (Int32));
897 createCol(regionsettings, "restrict_pushing", typeof (Int32));
898 createCol(regionsettings, "allow_land_resell", typeof (Int32));
899 createCol(regionsettings, "allow_land_join_divide", typeof (Int32));
900 createCol(regionsettings, "block_show_in_search", typeof (Int32));
901 createCol(regionsettings, "agent_limit", typeof (Int32));
902 createCol(regionsettings, "object_bonus", typeof (Double));
903 createCol(regionsettings, "maturity", typeof (Int32));
904 createCol(regionsettings, "disable_scripts", typeof (Int32));
905 createCol(regionsettings, "disable_collisions", typeof (Int32));
906 createCol(regionsettings, "disable_physics", typeof (Int32));
907 createCol(regionsettings, "terrain_texture_1", typeof(String));
908 createCol(regionsettings, "terrain_texture_2", typeof(String));
909 createCol(regionsettings, "terrain_texture_3", typeof(String));
910 createCol(regionsettings, "terrain_texture_4", typeof(String));
911 createCol(regionsettings, "elevation_1_nw", typeof (Double));
912 createCol(regionsettings, "elevation_2_nw", typeof (Double));
913 createCol(regionsettings, "elevation_1_ne", typeof (Double));
914 createCol(regionsettings, "elevation_2_ne", typeof (Double));
915 createCol(regionsettings, "elevation_1_se", typeof (Double));
916 createCol(regionsettings, "elevation_2_se", typeof (Double));
917 createCol(regionsettings, "elevation_1_sw", typeof (Double));
918 createCol(regionsettings, "elevation_2_sw", typeof (Double));
919 createCol(regionsettings, "water_height", typeof (Double));
920 createCol(regionsettings, "terrain_raise_limit", typeof (Double));
921 createCol(regionsettings, "terrain_lower_limit", typeof (Double));
922 createCol(regionsettings, "use_estate_sun", typeof (Int32));
923 createCol(regionsettings, "fixed_sun", typeof (Int32));
924 createCol(regionsettings, "sun_position", typeof (Double));
925 createCol(regionsettings, "covenant", typeof(String));
926 return regionsettings;
927 }
928
929 /// <summary>
842 /// Create the "regionban" table 930 /// Create the "regionban" table
843 /// </summary> 931 /// </summary>
844 /// <returns></returns> 932 /// <returns></returns>
@@ -1205,6 +1293,47 @@ namespace OpenSim.Data.MySQL
1205 return taskItem; 1293 return taskItem;
1206 } 1294 }
1207 1295
1296 private static RegionSettings buildRegionSettings(DataRow row)
1297 {
1298 RegionSettings newSettings = new RegionSettings();
1299
1300 newSettings.RegionUUID = new LLUUID((string) row["regionUUID"]);
1301 newSettings.BlockTerraform = Convert.ToBoolean(row["block_terraform"]);
1302 newSettings.AllowDamage = Convert.ToBoolean(row["allow_damage"]);
1303 newSettings.BlockFly = Convert.ToBoolean(row["block_fly"]);
1304 newSettings.RestrictPushing = Convert.ToBoolean(row["restrict_pushing"]);
1305 newSettings.AllowLandResell = Convert.ToBoolean(row["allow_land_resell"]);
1306 newSettings.AllowLandJoinDivide = Convert.ToBoolean(row["allow_land_join_divide"]);
1307 newSettings.BlockShowInSearch = Convert.ToBoolean(row["block_show_in_search"]);
1308 newSettings.AgentLimit = Convert.ToInt32(row["agent_limit"]);
1309 newSettings.ObjectBonus = Convert.ToDouble(row["object_bonus"]);
1310 newSettings.Maturity = Convert.ToInt32(row["maturity"]);
1311 newSettings.DisableScripts = Convert.ToBoolean(row["disable_scripts"]);
1312 newSettings.DisableCollisions = Convert.ToBoolean(row["disable_collisions"]);
1313 newSettings.DisablePhysics = Convert.ToBoolean(row["disable_physics"]);
1314 newSettings.TerrainTexture1 = new LLUUID((String) row["terrain_texture_1"]);
1315 newSettings.TerrainTexture2 = new LLUUID((String) row["terrain_texture_2"]);
1316 newSettings.TerrainTexture3 = new LLUUID((String) row["terrain_texture_3"]);
1317 newSettings.TerrainTexture4 = new LLUUID((String) row["terrain_texture_4"]);
1318 newSettings.Elevation1NW = Convert.ToDouble(row["elevation_1_nw"]);
1319 newSettings.Elevation2NW = Convert.ToDouble(row["elevation_2_nw"]);
1320 newSettings.Elevation1NE = Convert.ToDouble(row["elevation_1_ne"]);
1321 newSettings.Elevation2NE = Convert.ToDouble(row["elevation_2_ne"]);
1322 newSettings.Elevation1SE = Convert.ToDouble(row["elevation_1_se"]);
1323 newSettings.Elevation2SE = Convert.ToDouble(row["elevation_2_se"]);
1324 newSettings.Elevation1SW = Convert.ToDouble(row["elevation_1_sw"]);
1325 newSettings.Elevation2SW = Convert.ToDouble(row["elevation_2_sw"]);
1326 newSettings.WaterHeight = Convert.ToDouble(row["water_height"]);
1327 newSettings.TerrainRaiseLimit = Convert.ToDouble(row["terrain_raise_limit"]);
1328 newSettings.TerrainLowerLimit = Convert.ToDouble(row["terrain_lower_limit"]);
1329 newSettings.UseEstateSun = Convert.ToBoolean(row["use_estate_sun"]);
1330 newSettings.FixedSun = Convert.ToBoolean(row["fixed_sun"]);
1331 newSettings.SunPosition = Convert.ToDouble(row["sun_position"]);
1332 newSettings.Covenant = new LLUUID((String) row["covenant"]);
1333
1334 return newSettings;
1335 }
1336
1208 /// <summary> 1337 /// <summary>
1209 /// 1338 ///
1210 /// </summary> 1339 /// </summary>
@@ -1425,6 +1554,46 @@ namespace OpenSim.Data.MySQL
1425 /// <summary> 1554 /// <summary>
1426 /// 1555 ///
1427 /// </summary> 1556 /// </summary>
1557 private static void fillRegionSettingsRow(DataRow row, RegionSettings settings)
1558 {
1559 row["regionUUID"] = settings.RegionUUID.ToString();
1560 row["block_terraform"] = settings.BlockTerraform;
1561 row["block_fly"] = settings.BlockFly;
1562 row["allow_damage"] = settings.AllowDamage;
1563 row["restrict_pushing"] = settings.RestrictPushing;
1564 row["allow_land_resell"] = settings.AllowLandResell;
1565 row["allow_land_join_divide"] = settings.AllowLandJoinDivide;
1566 row["block_show_in_search"] = settings.BlockShowInSearch;
1567 row["agent_limit"] = settings.AgentLimit;
1568 row["object_bonus"] = settings.ObjectBonus;
1569 row["maturity"] = settings.Maturity;
1570 row["disable_scripts"] = settings.DisableScripts;
1571 row["disable_collisions"] = settings.DisableCollisions;
1572 row["disable_physics"] = settings.DisablePhysics;
1573 row["terrain_texture_1"] = settings.TerrainTexture1.ToString();
1574 row["terrain_texture_2"] = settings.TerrainTexture2.ToString();
1575 row["terrain_texture_3"] = settings.TerrainTexture3.ToString();
1576 row["terrain_texture_4"] = settings.TerrainTexture4.ToString();
1577 row["elevation_1_nw"] = settings.Elevation1NW;
1578 row["elevation_2_nw"] = settings.Elevation2NW;
1579 row["elevation_1_ne"] = settings.Elevation1NE;
1580 row["elevation_2_ne"] = settings.Elevation2NE;
1581 row["elevation_1_se"] = settings.Elevation1SE;
1582 row["elevation_2_se"] = settings.Elevation2SE;
1583 row["elevation_1_sw"] = settings.Elevation1SW;
1584 row["elevation_2_sw"] = settings.Elevation2SW;
1585 row["water_height"] = settings.WaterHeight;
1586 row["terrain_raise_limit"] = settings.TerrainRaiseLimit;
1587 row["terrain_lower_limit"] = settings.TerrainLowerLimit;
1588 row["use_estate_sun"] = settings.UseEstateSun;
1589 row["fixed_sun"] = settings.FixedSun;
1590 row["sun_position"] = settings.SunPosition;
1591 row["covenant"] = settings.Covenant.ToString();
1592 }
1593
1594 /// <summary>
1595 ///
1596 /// </summary>
1428 /// <param name="row"></param> 1597 /// <param name="row"></param>
1429 /// <param name="land"></param> 1598 /// <param name="land"></param>
1430 /// <param name="regionUUID"></param> 1599 /// <param name="regionUUID"></param>
@@ -1865,6 +2034,20 @@ namespace OpenSim.Data.MySQL
1865 da.DeleteCommand = delete; 2034 da.DeleteCommand = delete;
1866 } 2035 }
1867 2036
2037 private void SetupRegionSettingsCommands(MySqlDataAdapter da, MySqlConnection conn)
2038 {
2039 da.InsertCommand = createInsertCommand("regionsettings", m_regionSettingsTable);
2040 da.InsertCommand.Connection = conn;
2041
2042 da.UpdateCommand = createUpdateCommand("regionsettings", "regionUUID = ?regionUUID", m_regionSettingsTable);
2043 da.UpdateCommand.Connection = conn;
2044
2045 MySqlCommand delete = new MySqlCommand("delete from regionsettings where regionUUID = ?regionUUID");
2046 delete.Parameters.Add(createMySqlParameter("regionUUID", typeof(String)));
2047 delete.Connection = conn;
2048 da.DeleteCommand = delete;
2049 }
2050
1868 /// <summary> 2051 /// <summary>
1869 /// 2052 ///
1870 /// </summary> 2053 /// </summary>