aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/SQLite/SQLiteSimulationData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/SQLite/SQLiteSimulationData.cs')
-rw-r--r--OpenSim/Data/SQLite/SQLiteSimulationData.cs102
1 files changed, 102 insertions, 0 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteSimulationData.cs b/OpenSim/Data/SQLite/SQLiteSimulationData.cs
index ce1b7b4..83f803b 100644
--- a/OpenSim/Data/SQLite/SQLiteSimulationData.cs
+++ b/OpenSim/Data/SQLite/SQLiteSimulationData.cs
@@ -61,6 +61,7 @@ namespace OpenSim.Data.SQLite
61 private const string regionbanListSelect = "select * from regionban"; 61 private const string regionbanListSelect = "select * from regionban";
62 private const string regionSettingsSelect = "select * from regionsettings"; 62 private const string regionSettingsSelect = "select * from regionsettings";
63 private const string regionWindlightSelect = "select * from regionwindlight"; 63 private const string regionWindlightSelect = "select * from regionwindlight";
64 private const string regionSpawnPointsSelect = "select * from spawn_points";
64 65
65 private DataSet ds; 66 private DataSet ds;
66 private SqliteDataAdapter primDa; 67 private SqliteDataAdapter primDa;
@@ -71,6 +72,7 @@ namespace OpenSim.Data.SQLite
71 private SqliteDataAdapter landAccessListDa; 72 private SqliteDataAdapter landAccessListDa;
72 private SqliteDataAdapter regionSettingsDa; 73 private SqliteDataAdapter regionSettingsDa;
73 private SqliteDataAdapter regionWindlightDa; 74 private SqliteDataAdapter regionWindlightDa;
75 private SqliteDataAdapter regionSpawnPointsDa;
74 76
75 private SqliteConnection m_conn; 77 private SqliteConnection m_conn;
76 private String m_connectionString; 78 private String m_connectionString;
@@ -140,6 +142,10 @@ namespace OpenSim.Data.SQLite
140 142
141 SqliteCommand regionWindlightSelectCmd = new SqliteCommand(regionWindlightSelect, m_conn); 143 SqliteCommand regionWindlightSelectCmd = new SqliteCommand(regionWindlightSelect, m_conn);
142 regionWindlightDa = new SqliteDataAdapter(regionWindlightSelectCmd); 144 regionWindlightDa = new SqliteDataAdapter(regionWindlightSelectCmd);
145
146 SqliteCommand regionSpawnPointsSelectCmd = new SqliteCommand(regionSpawnPointsSelect, m_conn);
147 regionSpawnPointsDa = new SqliteDataAdapter(regionSpawnPointsSelectCmd);
148
143 // This actually does the roll forward assembly stuff 149 // This actually does the roll forward assembly stuff
144 Migration m = new Migration(m_conn, Assembly, "RegionStore"); 150 Migration m = new Migration(m_conn, Assembly, "RegionStore");
145 m.Update(); 151 m.Update();
@@ -170,6 +176,9 @@ namespace OpenSim.Data.SQLite
170 ds.Tables.Add(createRegionWindlightTable()); 176 ds.Tables.Add(createRegionWindlightTable());
171 setupRegionWindlightCommands(regionWindlightDa, m_conn); 177 setupRegionWindlightCommands(regionWindlightDa, m_conn);
172 178
179 ds.Tables.Add(createRegionSpawnPointsTable());
180 setupRegionSpawnPointsCommands(regionSpawnPointsDa, m_conn);
181
173 // WORKAROUND: This is a work around for sqlite on 182 // WORKAROUND: This is a work around for sqlite on
174 // windows, which gets really unhappy with blob columns 183 // windows, which gets really unhappy with blob columns
175 // that have no sample data in them. At some point we 184 // that have no sample data in them. At some point we
@@ -246,6 +255,15 @@ namespace OpenSim.Data.SQLite
246 m_log.ErrorFormat("[SQLITE REGION DB]: Caught fill error on regionwindlight table :{0}", e.Message); 255 m_log.ErrorFormat("[SQLITE REGION DB]: Caught fill error on regionwindlight table :{0}", e.Message);
247 } 256 }
248 257
258 try
259 {
260 regionSpawnPointsDa.Fill(ds.Tables["spawn_points"]);
261 }
262 catch (Exception e)
263 {
264 m_log.ErrorFormat("[SQLITE REGION DB]: Caught fill error on spawn_points table :{0}", e.Message);
265 }
266
249 // We have to create a data set mapping for every table, otherwise the IDataAdaptor.Update() will not populate rows with values! 267 // We have to create a data set mapping for every table, otherwise the IDataAdaptor.Update() will not populate rows with values!
250 // Not sure exactly why this is - this kind of thing was not necessary before - justincc 20100409 268 // Not sure exactly why this is - this kind of thing was not necessary before - justincc 20100409
251 // Possibly because we manually set up our own DataTables before connecting to the database 269 // Possibly because we manually set up our own DataTables before connecting to the database
@@ -257,6 +275,7 @@ namespace OpenSim.Data.SQLite
257 CreateDataSetMapping(landAccessListDa, "landaccesslist"); 275 CreateDataSetMapping(landAccessListDa, "landaccesslist");
258 CreateDataSetMapping(regionSettingsDa, "regionsettings"); 276 CreateDataSetMapping(regionSettingsDa, "regionsettings");
259 CreateDataSetMapping(regionWindlightDa, "regionwindlight"); 277 CreateDataSetMapping(regionWindlightDa, "regionwindlight");
278 CreateDataSetMapping(regionSpawnPointsDa, "spawn_points");
260 } 279 }
261 } 280 }
262 catch (Exception e) 281 catch (Exception e)
@@ -319,6 +338,11 @@ namespace OpenSim.Data.SQLite
319 regionWindlightDa.Dispose(); 338 regionWindlightDa.Dispose();
320 regionWindlightDa = null; 339 regionWindlightDa = null;
321 } 340 }
341 if (regionSpawnPointsDa != null)
342 {
343 regionSpawnPointsDa.Dispose();
344 regionWindlightDa = null;
345 }
322 } 346 }
323 347
324 public void StoreRegionSettings(RegionSettings rs) 348 public void StoreRegionSettings(RegionSettings rs)
@@ -339,8 +363,43 @@ namespace OpenSim.Data.SQLite
339 fillRegionSettingsRow(settingsRow, rs); 363 fillRegionSettingsRow(settingsRow, rs);
340 } 364 }
341 365
366 StoreSpawnPoints(rs);
367
342 Commit(); 368 Commit();
343 } 369 }
370
371 }
372
373 public void StoreSpawnPoints(RegionSettings rs)
374 {
375 lock (ds)
376 {
377 // DataTable spawnpoints = ds.Tables["spawn_points"];
378
379 // remove region's spawnpoints
380 using (
381 SqliteCommand cmd =
382 new SqliteCommand("delete from spawn_points where RegionID=:RegionID",
383 m_conn))
384 {
385
386 cmd.Parameters.Add(new SqliteParameter(":RegionID", rs.RegionUUID.ToString()));
387 cmd.ExecuteNonQuery();
388 }
389 }
390
391 foreach (SpawnPoint sp in rs.SpawnPoints())
392 {
393 using (SqliteCommand cmd = new SqliteCommand("insert into spawn_points(RegionID, Yaw, Pitch, Distance)" +
394 "values ( :RegionID, :Yaw, :Pitch, :Distance)", m_conn))
395 {
396 cmd.Parameters.Add(new SqliteParameter(":RegionID", rs.RegionUUID.ToString()));
397 cmd.Parameters.Add(new SqliteParameter(":Yaw", sp.Yaw));
398 cmd.Parameters.Add(new SqliteParameter(":Pitch", sp.Pitch));
399 cmd.Parameters.Add(new SqliteParameter(":Distance", sp.Distance));
400 cmd.ExecuteNonQuery();
401 }
402 }
344 } 403 }
345 404
346 /// <summary> 405 /// <summary>
@@ -435,10 +494,31 @@ namespace OpenSim.Data.SQLite
435 RegionSettings newSettings = buildRegionSettings(row); 494 RegionSettings newSettings = buildRegionSettings(row);
436 newSettings.OnSave += StoreRegionSettings; 495 newSettings.OnSave += StoreRegionSettings;
437 496
497 LoadSpawnPoints(newSettings);
498
438 return newSettings; 499 return newSettings;
439 } 500 }
440 } 501 }
441 502
503 private void LoadSpawnPoints(RegionSettings rs)
504 {
505 rs.ClearSpawnPoints();
506
507 DataTable spawnpoints = ds.Tables["spawn_points"];
508 string byRegion = "RegionID = '" + rs.RegionUUID + "'";
509 DataRow[] spForRegion = spawnpoints.Select(byRegion);
510
511 foreach (DataRow spRow in spForRegion)
512 {
513 SpawnPoint sp = new SpawnPoint();
514 sp.Pitch = (float)spRow["Pitch"];
515 sp.Yaw = (float)spRow["Yaw"];
516 sp.Distance = (float)spRow["Distance"];
517
518 rs.AddSpawnPoint(sp);
519 }
520 }
521
442 /// <summary> 522 /// <summary>
443 /// Adds an object into region storage 523 /// Adds an object into region storage
444 /// </summary> 524 /// </summary>
@@ -1265,6 +1345,7 @@ namespace OpenSim.Data.SQLite
1265 createCol(regionsettings, "covenant", typeof(String)); 1345 createCol(regionsettings, "covenant", typeof(String));
1266 createCol(regionsettings, "covenant_datetime", typeof(Int32)); 1346 createCol(regionsettings, "covenant_datetime", typeof(Int32));
1267 createCol(regionsettings, "map_tile_ID", typeof(String)); 1347 createCol(regionsettings, "map_tile_ID", typeof(String));
1348 createCol(regionsettings, "TelehubObject", typeof(String));
1268 regionsettings.PrimaryKey = new DataColumn[] { regionsettings.Columns["regionUUID"] }; 1349 regionsettings.PrimaryKey = new DataColumn[] { regionsettings.Columns["regionUUID"] };
1269 return regionsettings; 1350 return regionsettings;
1270 } 1351 }
@@ -1345,6 +1426,17 @@ namespace OpenSim.Data.SQLite
1345 return regionwindlight; 1426 return regionwindlight;
1346 } 1427 }
1347 1428
1429 private static DataTable createRegionSpawnPointsTable()
1430 {
1431 DataTable spawn_points = new DataTable("spawn_points");
1432 createCol(spawn_points, "regionID", typeof(String));
1433 createCol(spawn_points, "Yaw", typeof(float));
1434 createCol(spawn_points, "Pitch", typeof(float));
1435 createCol(spawn_points, "Distance", typeof(float));
1436
1437 return spawn_points;
1438 }
1439
1348 /*********************************************************************** 1440 /***********************************************************************
1349 * 1441 *
1350 * Convert between ADO.NET <=> OpenSim Objects 1442 * Convert between ADO.NET <=> OpenSim Objects
@@ -1666,6 +1758,7 @@ namespace OpenSim.Data.SQLite
1666 newSettings.Covenant = new UUID((String)row["covenant"]); 1758 newSettings.Covenant = new UUID((String)row["covenant"]);
1667 newSettings.CovenantChangedDateTime = Convert.ToInt32(row["covenant_datetime"]); 1759 newSettings.CovenantChangedDateTime = Convert.ToInt32(row["covenant_datetime"]);
1668 newSettings.TerrainImageID = new UUID((String)row["map_tile_ID"]); 1760 newSettings.TerrainImageID = new UUID((String)row["map_tile_ID"]);
1761 newSettings.TelehubObject = new UUID((String)row["TelehubObject"]);
1669 1762
1670 return newSettings; 1763 return newSettings;
1671 } 1764 }
@@ -2068,6 +2161,7 @@ namespace OpenSim.Data.SQLite
2068 row["covenant"] = settings.Covenant.ToString(); 2161 row["covenant"] = settings.Covenant.ToString();
2069 row["covenant_datetime"] = settings.CovenantChangedDateTime; 2162 row["covenant_datetime"] = settings.CovenantChangedDateTime;
2070 row["map_tile_ID"] = settings.TerrainImageID.ToString(); 2163 row["map_tile_ID"] = settings.TerrainImageID.ToString();
2164 row["TelehubObject"] = settings.TelehubObject.ToString();
2071 } 2165 }
2072 2166
2073 /// <summary> 2167 /// <summary>
@@ -2591,6 +2685,14 @@ namespace OpenSim.Data.SQLite
2591 da.UpdateCommand.Connection = conn; 2685 da.UpdateCommand.Connection = conn;
2592 } 2686 }
2593 2687
2688 private void setupRegionSpawnPointsCommands(SqliteDataAdapter da, SqliteConnection conn)
2689 {
2690 da.InsertCommand = createInsertCommand("spawn_points", ds.Tables["spawn_points"]);
2691 da.InsertCommand.Connection = conn;
2692 da.UpdateCommand = createUpdateCommand("spawn_points", "RegionID=:RegionID", ds.Tables["spawn_points"]);
2693 da.UpdateCommand.Connection = conn;
2694 }
2695
2594 /// <summary> 2696 /// <summary>
2595 /// 2697 ///
2596 /// </summary> 2698 /// </summary>