aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/SQLite/SQLiteRegionData.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/SQLite/SQLiteRegionData.cs184
1 files changed, 183 insertions, 1 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs
index 5a5d835..c3ff47f 100644
--- a/OpenSim/Data/SQLite/SQLiteRegionData.cs
+++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs
@@ -55,6 +55,7 @@ namespace OpenSim.Data.SQLite
55 private const string landSelect = "select * from land"; 55 private const string landSelect = "select * from land";
56 private const string landAccessListSelect = "select distinct * from landaccesslist"; 56 private const string landAccessListSelect = "select distinct * from landaccesslist";
57 private const string regionbanListSelect = "select * from regionban"; 57 private const string regionbanListSelect = "select * from regionban";
58 private const string regionSettingsSelect = "select * from regionsettings";
58 59
59 private DataSet ds; 60 private DataSet ds;
60 private SqliteDataAdapter primDa; 61 private SqliteDataAdapter primDa;
@@ -63,6 +64,7 @@ namespace OpenSim.Data.SQLite
63 private SqliteDataAdapter terrainDa; 64 private SqliteDataAdapter terrainDa;
64 private SqliteDataAdapter landDa; 65 private SqliteDataAdapter landDa;
65 private SqliteDataAdapter landAccessListDa; 66 private SqliteDataAdapter landAccessListDa;
67 private SqliteDataAdapter regionSettingsDa;
66 68
67 private SqliteConnection m_conn; 69 private SqliteConnection m_conn;
68 70
@@ -116,6 +118,8 @@ namespace OpenSim.Data.SQLite
116 SqliteCommand landAccessListSelectCmd = new SqliteCommand(landAccessListSelect, m_conn); 118 SqliteCommand landAccessListSelectCmd = new SqliteCommand(landAccessListSelect, m_conn);
117 landAccessListDa = new SqliteDataAdapter(landAccessListSelectCmd); 119 landAccessListDa = new SqliteDataAdapter(landAccessListSelectCmd);
118 120
121 SqliteCommand regionSettingsSelectCmd = new SqliteCommand(regionSettingsSelect, m_conn);
122
119 // This actually does the roll forward assembly stuff 123 // This actually does the roll forward assembly stuff
120 Assembly assem = GetType().Assembly; 124 Assembly assem = GetType().Assembly;
121 Migration m = new Migration(m_conn, assem, "RegionStore"); 125 Migration m = new Migration(m_conn, assem, "RegionStore");
@@ -143,6 +147,9 @@ namespace OpenSim.Data.SQLite
143 ds.Tables.Add(createLandAccessListTable()); 147 ds.Tables.Add(createLandAccessListTable());
144 setupLandAccessCommands(landAccessListDa, m_conn); 148 setupLandAccessCommands(landAccessListDa, m_conn);
145 149
150 ds.Tables.Add(createRegionSettingsTable());
151 setupRegionSettingsCommands(regionSettingsDa, m_conn);
152
146 // WORKAROUND: This is a work around for sqlite on 153 // WORKAROUND: This is a work around for sqlite on
147 // windows, which gets really unhappy with blob columns 154 // windows, which gets really unhappy with blob columns
148 // that have no sample data in them. At some point we 155 // that have no sample data in them. At some point we
@@ -183,17 +190,65 @@ namespace OpenSim.Data.SQLite
183 m_log.Info("[REGION DB]: Caught fill error on landaccesslist table"); 190 m_log.Info("[REGION DB]: Caught fill error on landaccesslist table");
184 } 191 }
185 192
193 try
194 {
195 regionSettingsDa.Fill(ds.Tables["regionsettings"]);
196 }
197 catch (Exception)
198 {
199 m_log.Info("[REGION DB]: Caught fill error on regionsettings table");
200 }
186 return; 201 return;
187 } 202 }
188 } 203 }
189 204
190 public void StoreRegionSettings(RegionSettings rs) 205 public void StoreRegionSettings(RegionSettings rs)
191 { 206 {
207 lock(ds)
208 {
209 DataTable regionsettings = ds.Tables["regionsettings"];
210
211 DataRow settingsRow = regionsettings.Rows.Find(rs.RegionUUID.ToString());
212 if (settingsRow == null)
213 {
214 settingsRow = regionsettings.NewRow();
215 fillRegionSettingsRow(settingsRow, rs);
216 regionsettings.Rows.Add(settingsRow);
217 }
218 else
219 {
220 fillRegionSettingsRow(settingsRow, rs);
221 }
222
223 Commit();
224 }
192 } 225 }
193 226
194 public RegionSettings LoadRegionSettings(UUID regionUUID) 227 public RegionSettings LoadRegionSettings(UUID regionUUID)
195 { 228 {
196 return null; 229 lock (ds)
230 {
231 DataTable regionsettings = ds.Tables["regionsettings"];
232
233 string searchExp = "regionUUID = '" + regionUUID.ToString() + "'";
234 DataRow[] rawsettings = regionsettings.Select(searchExp);
235 if (rawsettings.Length == 0)
236 {
237 RegionSettings rs = new RegionSettings();
238 rs.RegionUUID = regionUUID;
239 rs.OnSave += StoreRegionSettings;
240
241 StoreRegionSettings(rs);
242
243 return rs;
244 }
245 DataRow row = rawsettings[0];
246
247 RegionSettings newSettings = buildRegionSettings(row);
248 newSettings.OnSave += StoreRegionSettings;
249
250 return newSettings;
251 }
197 } 252 }
198 253
199 /// <summary> 254 /// <summary>
@@ -871,6 +926,47 @@ namespace OpenSim.Data.SQLite
871 return landaccess; 926 return landaccess;
872 } 927 }
873 928
929 private static DataTable createRegionSettingsTable()
930 {
931 DataTable regionsettings = new DataTable("regionsettings");
932 createCol(regionsettings, "regionUUID", typeof(String));
933 createCol(regionsettings, "block_terraform", typeof (Int32));
934 createCol(regionsettings, "block_fly", typeof (Int32));
935 createCol(regionsettings, "allow_damage", typeof (Int32));
936 createCol(regionsettings, "restrict_pushing", typeof (Int32));
937 createCol(regionsettings, "allow_land_resell", typeof (Int32));
938 createCol(regionsettings, "allow_land_join_divide", typeof (Int32));
939 createCol(regionsettings, "block_show_in_search", typeof (Int32));
940 createCol(regionsettings, "agent_limit", typeof (Int32));
941 createCol(regionsettings, "object_bonus", typeof (Double));
942 createCol(regionsettings, "maturity", typeof (Int32));
943 createCol(regionsettings, "disable_scripts", typeof (Int32));
944 createCol(regionsettings, "disable_collisions", typeof (Int32));
945 createCol(regionsettings, "disable_physics", typeof (Int32));
946 createCol(regionsettings, "terrain_texture_1", typeof(String));
947 createCol(regionsettings, "terrain_texture_2", typeof(String));
948 createCol(regionsettings, "terrain_texture_3", typeof(String));
949 createCol(regionsettings, "terrain_texture_4", typeof(String));
950 createCol(regionsettings, "elevation_1_nw", typeof (Double));
951 createCol(regionsettings, "elevation_2_nw", typeof (Double));
952 createCol(regionsettings, "elevation_1_ne", typeof (Double));
953 createCol(regionsettings, "elevation_2_ne", typeof (Double));
954 createCol(regionsettings, "elevation_1_se", typeof (Double));
955 createCol(regionsettings, "elevation_2_se", typeof (Double));
956 createCol(regionsettings, "elevation_1_sw", typeof (Double));
957 createCol(regionsettings, "elevation_2_sw", typeof (Double));
958 createCol(regionsettings, "water_height", typeof (Double));
959 createCol(regionsettings, "terrain_raise_limit", typeof (Double));
960 createCol(regionsettings, "terrain_lower_limit", typeof (Double));
961 createCol(regionsettings, "use_estate_sun", typeof (Int32));
962 createCol(regionsettings, "sandbox", typeof (Int32));
963 createCol(regionsettings, "fixed_sun", typeof (Int32));
964 createCol(regionsettings, "sun_position", typeof (Double));
965 createCol(regionsettings, "covenant", typeof(String));
966
967 return regionsettings;
968 }
969
874 /*********************************************************************** 970 /***********************************************************************
875 * 971 *
876 * Convert between ADO.NET <=> OpenSim Objects 972 * Convert between ADO.NET <=> OpenSim Objects
@@ -1126,6 +1222,48 @@ namespace OpenSim.Data.SQLite
1126 return newData; 1222 return newData;
1127 } 1223 }
1128 1224
1225 private RegionSettings buildRegionSettings(DataRow row)
1226 {
1227 RegionSettings newSettings = new RegionSettings();
1228
1229 newSettings.RegionUUID = new UUID((string) row["regionUUID"]);
1230 newSettings.BlockTerraform = Convert.ToBoolean(row["block_terraform"]);
1231 newSettings.AllowDamage = Convert.ToBoolean(row["allow_damage"]);
1232 newSettings.BlockFly = Convert.ToBoolean(row["block_fly"]);
1233 newSettings.RestrictPushing = Convert.ToBoolean(row["restrict_pushing"]);
1234 newSettings.AllowLandResell = Convert.ToBoolean(row["allow_land_resell"]);
1235 newSettings.AllowLandJoinDivide = Convert.ToBoolean(row["allow_land_join_divide"]);
1236 newSettings.BlockShowInSearch = Convert.ToBoolean(row["block_show_in_search"]);
1237 newSettings.AgentLimit = Convert.ToInt32(row["agent_limit"]);
1238 newSettings.ObjectBonus = Convert.ToDouble(row["object_bonus"]);
1239 newSettings.Maturity = Convert.ToInt32(row["maturity"]);
1240 newSettings.DisableScripts = Convert.ToBoolean(row["disable_scripts"]);
1241 newSettings.DisableCollisions = Convert.ToBoolean(row["disable_collisions"]);
1242 newSettings.DisablePhysics = Convert.ToBoolean(row["disable_physics"]);
1243 newSettings.TerrainTexture1 = new UUID((String) row["terrain_texture_1"]);
1244 newSettings.TerrainTexture2 = new UUID((String) row["terrain_texture_2"]);
1245 newSettings.TerrainTexture3 = new UUID((String) row["terrain_texture_3"]);
1246 newSettings.TerrainTexture4 = new UUID((String) row["terrain_texture_4"]);
1247 newSettings.Elevation1NW = Convert.ToDouble(row["elevation_1_nw"]);
1248 newSettings.Elevation2NW = Convert.ToDouble(row["elevation_2_nw"]);
1249 newSettings.Elevation1NE = Convert.ToDouble(row["elevation_1_ne"]);
1250 newSettings.Elevation2NE = Convert.ToDouble(row["elevation_2_ne"]);
1251 newSettings.Elevation1SE = Convert.ToDouble(row["elevation_1_se"]);
1252 newSettings.Elevation2SE = Convert.ToDouble(row["elevation_2_se"]);
1253 newSettings.Elevation1SW = Convert.ToDouble(row["elevation_1_sw"]);
1254 newSettings.Elevation2SW = Convert.ToDouble(row["elevation_2_sw"]);
1255 newSettings.WaterHeight = Convert.ToDouble(row["water_height"]);
1256 newSettings.TerrainRaiseLimit = Convert.ToDouble(row["terrain_raise_limit"]);
1257 newSettings.TerrainLowerLimit = Convert.ToDouble(row["terrain_lower_limit"]);
1258 newSettings.UseEstateSun = Convert.ToBoolean(row["use_estate_sun"]);
1259 newSettings.Sandbox = Convert.ToBoolean(row["sandbox"]);
1260 newSettings.FixedSun = Convert.ToBoolean(row["fixed_sun"]);
1261 newSettings.SunPosition = Convert.ToDouble(row["sun_position"]);
1262 newSettings.Covenant = new UUID((String) row["covenant"]);
1263
1264 return newSettings;
1265 }
1266
1129 /// <summary> 1267 /// <summary>
1130 /// Build a land access entry from the persisted data. 1268 /// Build a land access entry from the persisted data.
1131 /// </summary> 1269 /// </summary>
@@ -1336,6 +1474,44 @@ namespace OpenSim.Data.SQLite
1336 row["Flags"] = entry.Flags; 1474 row["Flags"] = entry.Flags;
1337 } 1475 }
1338 1476
1477 private static void fillRegionSettingsRow(DataRow row, RegionSettings settings)
1478 {
1479 row["regionUUID"] = settings.RegionUUID.ToString();
1480 row["block_terraform"] = settings.BlockTerraform;
1481 row["block_fly"] = settings.BlockFly;
1482 row["allow_damage"] = settings.AllowDamage;
1483 row["restrict_pushing"] = settings.RestrictPushing;
1484 row["allow_land_resell"] = settings.AllowLandResell;
1485 row["allow_land_join_divide"] = settings.AllowLandJoinDivide;
1486 row["block_show_in_search"] = settings.BlockShowInSearch;
1487 row["agent_limit"] = settings.AgentLimit;
1488 row["object_bonus"] = settings.ObjectBonus;
1489 row["maturity"] = settings.Maturity;
1490 row["disable_scripts"] = settings.DisableScripts;
1491 row["disable_collisions"] = settings.DisableCollisions;
1492 row["disable_physics"] = settings.DisablePhysics;
1493 row["terrain_texture_1"] = settings.TerrainTexture1.ToString();
1494 row["terrain_texture_2"] = settings.TerrainTexture2.ToString();
1495 row["terrain_texture_3"] = settings.TerrainTexture3.ToString();
1496 row["terrain_texture_4"] = settings.TerrainTexture4.ToString();
1497 row["elevation_1_nw"] = settings.Elevation1NW;
1498 row["elevation_2_nw"] = settings.Elevation2NW;
1499 row["elevation_1_ne"] = settings.Elevation1NE;
1500 row["elevation_2_ne"] = settings.Elevation2NE;
1501 row["elevation_1_se"] = settings.Elevation1SE;
1502 row["elevation_2_se"] = settings.Elevation2SE;
1503 row["elevation_1_sw"] = settings.Elevation1SW;
1504 row["elevation_2_sw"] = settings.Elevation2SW;
1505 row["water_height"] = settings.WaterHeight;
1506 row["terrain_raise_limit"] = settings.TerrainRaiseLimit;
1507 row["terrain_lower_limit"] = settings.TerrainLowerLimit;
1508 row["use_estate_sun"] = settings.UseEstateSun;
1509 row["sandbox"] = settings.Sandbox;
1510 row["fixed_sun"] = settings.FixedSun;
1511 row["sun_position"] = settings.SunPosition;
1512 row["covenant"] = settings.Covenant.ToString();
1513 }
1514
1339 /// <summary> 1515 /// <summary>
1340 /// 1516 ///
1341 /// </summary> 1517 /// </summary>
@@ -1720,6 +1896,12 @@ namespace OpenSim.Data.SQLite
1720 da.InsertCommand.Connection = conn; 1896 da.InsertCommand.Connection = conn;
1721 } 1897 }
1722 1898
1899 private void setupRegionSettingsCommands(SqliteDataAdapter da, SqliteConnection conn)
1900 {
1901 da.InsertCommand = createInsertCommand("regionsettings", ds.Tables["regionsettings"]);
1902 da.InsertCommand.Connection = conn;
1903 }
1904
1723 /// <summary> 1905 /// <summary>
1724 /// 1906 ///
1725 /// </summary> 1907 /// </summary>