diff options
author | PixelTomsen | 2012-05-23 21:06:25 +0200 |
---|---|---|
committer | BlueWall | 2012-05-23 17:04:19 -0400 |
commit | bc543c1797c629a8584dd2e74d3c5f7a67de96c9 (patch) | |
tree | b7521f1875c349929dbfc79ef6562cf7082fd72e /OpenSim/Data/SQLite/SQLiteSimulationData.cs | |
parent | Format cleanup (diff) | |
download | opensim-SC-bc543c1797c629a8584dd2e74d3c5f7a67de96c9.zip opensim-SC-bc543c1797c629a8584dd2e74d3c5f7a67de96c9.tar.gz opensim-SC-bc543c1797c629a8584dd2e74d3c5f7a67de96c9.tar.bz2 opensim-SC-bc543c1797c629a8584dd2e74d3c5f7a67de96c9.tar.xz |
Environment Module - allows Environment settings for Viewer3 warning: includes database region store migrations for mssql, mysql, sqlite
enable/disable this module:
Cap_EnvironmentSettings = "localhost" (for enable)
Cap_EnvironmentSettings = "" (for disable) at ClientStack.LindenCaps section (OpenSimDefaults.ini file)
or owerwrite in OpenSim.ini
mantis: http://opensimulator.org/mantis/view.php?id=5860
Signed-off-by: BlueWall <jamesh@bluewallgroup.com>
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteSimulationData.cs | 101 |
1 files changed, 100 insertions, 1 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteSimulationData.cs b/OpenSim/Data/SQLite/SQLiteSimulationData.cs index 7e7c08a..f40e866 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 regionEnvironmentSelect = "select * from regionenvironment"; | ||
64 | private const string regionSpawnPointsSelect = "select * from spawn_points"; | 65 | private const string regionSpawnPointsSelect = "select * from spawn_points"; |
65 | 66 | ||
66 | private DataSet ds; | 67 | private DataSet ds; |
@@ -72,6 +73,7 @@ namespace OpenSim.Data.SQLite | |||
72 | private SqliteDataAdapter landAccessListDa; | 73 | private SqliteDataAdapter landAccessListDa; |
73 | private SqliteDataAdapter regionSettingsDa; | 74 | private SqliteDataAdapter regionSettingsDa; |
74 | private SqliteDataAdapter regionWindlightDa; | 75 | private SqliteDataAdapter regionWindlightDa; |
76 | private SqliteDataAdapter regionEnvironmentDa; | ||
75 | private SqliteDataAdapter regionSpawnPointsDa; | 77 | private SqliteDataAdapter regionSpawnPointsDa; |
76 | 78 | ||
77 | private SqliteConnection m_conn; | 79 | private SqliteConnection m_conn; |
@@ -146,6 +148,9 @@ namespace OpenSim.Data.SQLite | |||
146 | SqliteCommand regionWindlightSelectCmd = new SqliteCommand(regionWindlightSelect, m_conn); | 148 | SqliteCommand regionWindlightSelectCmd = new SqliteCommand(regionWindlightSelect, m_conn); |
147 | regionWindlightDa = new SqliteDataAdapter(regionWindlightSelectCmd); | 149 | regionWindlightDa = new SqliteDataAdapter(regionWindlightSelectCmd); |
148 | 150 | ||
151 | SqliteCommand regionEnvironmentSelectCmd = new SqliteCommand(regionEnvironmentSelect, m_conn); | ||
152 | regionEnvironmentDa = new SqliteDataAdapter(regionEnvironmentSelectCmd); | ||
153 | |||
149 | SqliteCommand regionSpawnPointsSelectCmd = new SqliteCommand(regionSpawnPointsSelect, m_conn); | 154 | SqliteCommand regionSpawnPointsSelectCmd = new SqliteCommand(regionSpawnPointsSelect, m_conn); |
150 | regionSpawnPointsDa = new SqliteDataAdapter(regionSpawnPointsSelectCmd); | 155 | regionSpawnPointsDa = new SqliteDataAdapter(regionSpawnPointsSelectCmd); |
151 | 156 | ||
@@ -179,6 +184,9 @@ namespace OpenSim.Data.SQLite | |||
179 | ds.Tables.Add(createRegionWindlightTable()); | 184 | ds.Tables.Add(createRegionWindlightTable()); |
180 | setupRegionWindlightCommands(regionWindlightDa, m_conn); | 185 | setupRegionWindlightCommands(regionWindlightDa, m_conn); |
181 | 186 | ||
187 | ds.Tables.Add(createRegionEnvironmentTable()); | ||
188 | setupRegionEnvironmentCommands(regionEnvironmentDa, m_conn); | ||
189 | |||
182 | ds.Tables.Add(createRegionSpawnPointsTable()); | 190 | ds.Tables.Add(createRegionSpawnPointsTable()); |
183 | setupRegionSpawnPointsCommands(regionSpawnPointsDa, m_conn); | 191 | setupRegionSpawnPointsCommands(regionSpawnPointsDa, m_conn); |
184 | 192 | ||
@@ -260,6 +268,15 @@ namespace OpenSim.Data.SQLite | |||
260 | 268 | ||
261 | try | 269 | try |
262 | { | 270 | { |
271 | regionEnvironmentDa.Fill(ds.Tables["regionenvironment"]); | ||
272 | } | ||
273 | catch (Exception e) | ||
274 | { | ||
275 | m_log.ErrorFormat("[SQLITE REGION DB]: Caught fill error on regionenvironment table :{0}", e.Message); | ||
276 | } | ||
277 | |||
278 | try | ||
279 | { | ||
263 | regionSpawnPointsDa.Fill(ds.Tables["spawn_points"]); | 280 | regionSpawnPointsDa.Fill(ds.Tables["spawn_points"]); |
264 | } | 281 | } |
265 | catch (Exception e) | 282 | catch (Exception e) |
@@ -278,12 +295,13 @@ namespace OpenSim.Data.SQLite | |||
278 | CreateDataSetMapping(landAccessListDa, "landaccesslist"); | 295 | CreateDataSetMapping(landAccessListDa, "landaccesslist"); |
279 | CreateDataSetMapping(regionSettingsDa, "regionsettings"); | 296 | CreateDataSetMapping(regionSettingsDa, "regionsettings"); |
280 | CreateDataSetMapping(regionWindlightDa, "regionwindlight"); | 297 | CreateDataSetMapping(regionWindlightDa, "regionwindlight"); |
298 | CreateDataSetMapping(regionEnvironmentDa, "regionenvironment"); | ||
281 | CreateDataSetMapping(regionSpawnPointsDa, "spawn_points"); | 299 | CreateDataSetMapping(regionSpawnPointsDa, "spawn_points"); |
282 | } | 300 | } |
283 | } | 301 | } |
284 | catch (Exception e) | 302 | catch (Exception e) |
285 | { | 303 | { |
286 | m_log.ErrorFormat("[SQLITE REGION DB]: ", e); | 304 | m_log.ErrorFormat("[SQLITE REGION DB]: {0} - {1}", e.Message, e.StackTrace); |
287 | Environment.Exit(23); | 305 | Environment.Exit(23); |
288 | } | 306 | } |
289 | return; | 307 | return; |
@@ -341,6 +359,11 @@ namespace OpenSim.Data.SQLite | |||
341 | regionWindlightDa.Dispose(); | 359 | regionWindlightDa.Dispose(); |
342 | regionWindlightDa = null; | 360 | regionWindlightDa = null; |
343 | } | 361 | } |
362 | if (regionEnvironmentDa != null) | ||
363 | { | ||
364 | regionEnvironmentDa.Dispose(); | ||
365 | regionEnvironmentDa = null; | ||
366 | } | ||
344 | if (regionSpawnPointsDa != null) | 367 | if (regionSpawnPointsDa != null) |
345 | { | 368 | { |
346 | regionSpawnPointsDa.Dispose(); | 369 | regionSpawnPointsDa.Dispose(); |
@@ -474,6 +497,63 @@ namespace OpenSim.Data.SQLite | |||
474 | } | 497 | } |
475 | } | 498 | } |
476 | 499 | ||
500 | #region Region Environment Settings | ||
501 | public string LoadRegionEnvironmentSettings(UUID regionUUID) | ||
502 | { | ||
503 | lock (ds) | ||
504 | { | ||
505 | DataTable environmentTable = ds.Tables["regionenvironment"]; | ||
506 | DataRow row = environmentTable.Rows.Find(regionUUID.ToString()); | ||
507 | if (row == null) | ||
508 | { | ||
509 | return String.Empty; | ||
510 | } | ||
511 | |||
512 | return (String)row["llsd_settings"]; | ||
513 | } | ||
514 | } | ||
515 | |||
516 | public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) | ||
517 | { | ||
518 | lock (ds) | ||
519 | { | ||
520 | DataTable environmentTable = ds.Tables["regionenvironment"]; | ||
521 | DataRow row = environmentTable.Rows.Find(regionUUID.ToString()); | ||
522 | |||
523 | if (row == null) | ||
524 | { | ||
525 | row = environmentTable.NewRow(); | ||
526 | row["region_id"] = regionUUID.ToString(); | ||
527 | row["llsd_settings"] = settings; | ||
528 | environmentTable.Rows.Add(row); | ||
529 | } | ||
530 | else | ||
531 | { | ||
532 | row["llsd_settings"] = settings; | ||
533 | } | ||
534 | |||
535 | regionEnvironmentDa.Update(ds, "regionenvironment"); | ||
536 | } | ||
537 | } | ||
538 | |||
539 | public void RemoveRegionEnvironmentSettings(UUID regionUUID) | ||
540 | { | ||
541 | lock (ds) | ||
542 | { | ||
543 | DataTable environmentTable = ds.Tables["regionenvironment"]; | ||
544 | DataRow row = environmentTable.Rows.Find(regionUUID.ToString()); | ||
545 | |||
546 | if (row != null) | ||
547 | { | ||
548 | row.Delete(); | ||
549 | } | ||
550 | |||
551 | regionEnvironmentDa.Update(ds, "regionenvironment"); | ||
552 | } | ||
553 | } | ||
554 | |||
555 | #endregion | ||
556 | |||
477 | public RegionSettings LoadRegionSettings(UUID regionUUID) | 557 | public RegionSettings LoadRegionSettings(UUID regionUUID) |
478 | { | 558 | { |
479 | lock (ds) | 559 | lock (ds) |
@@ -1430,6 +1510,17 @@ namespace OpenSim.Data.SQLite | |||
1430 | return regionwindlight; | 1510 | return regionwindlight; |
1431 | } | 1511 | } |
1432 | 1512 | ||
1513 | private static DataTable createRegionEnvironmentTable() | ||
1514 | { | ||
1515 | DataTable regionEnvironment = new DataTable("regionenvironment"); | ||
1516 | createCol(regionEnvironment, "region_id", typeof(String)); | ||
1517 | createCol(regionEnvironment, "llsd_settings", typeof(String)); | ||
1518 | |||
1519 | regionEnvironment.PrimaryKey = new DataColumn[] { regionEnvironment.Columns["region_id"] }; | ||
1520 | |||
1521 | return regionEnvironment; | ||
1522 | } | ||
1523 | |||
1433 | private static DataTable createRegionSpawnPointsTable() | 1524 | private static DataTable createRegionSpawnPointsTable() |
1434 | { | 1525 | { |
1435 | DataTable spawn_points = new DataTable("spawn_points"); | 1526 | DataTable spawn_points = new DataTable("spawn_points"); |
@@ -2691,6 +2782,14 @@ namespace OpenSim.Data.SQLite | |||
2691 | da.UpdateCommand.Connection = conn; | 2782 | da.UpdateCommand.Connection = conn; |
2692 | } | 2783 | } |
2693 | 2784 | ||
2785 | private void setupRegionEnvironmentCommands(SqliteDataAdapter da, SqliteConnection conn) | ||
2786 | { | ||
2787 | da.InsertCommand = createInsertCommand("regionenvironment", ds.Tables["regionenvironment"]); | ||
2788 | da.InsertCommand.Connection = conn; | ||
2789 | da.UpdateCommand = createUpdateCommand("regionenvironment", "region_id=:region_id", ds.Tables["regionenvironment"]); | ||
2790 | da.UpdateCommand.Connection = conn; | ||
2791 | } | ||
2792 | |||
2694 | private void setupRegionSpawnPointsCommands(SqliteDataAdapter da, SqliteConnection conn) | 2793 | private void setupRegionSpawnPointsCommands(SqliteDataAdapter da, SqliteConnection conn) |
2695 | { | 2794 | { |
2696 | da.InsertCommand = createInsertCommand("spawn_points", ds.Tables["spawn_points"]); | 2795 | da.InsertCommand = createInsertCommand("spawn_points", ds.Tables["spawn_points"]); |