diff options
author | lbsa71 | 2007-12-27 21:41:48 +0000 |
---|---|---|
committer | lbsa71 | 2007-12-27 21:41:48 +0000 |
commit | efd90b56b761219af6425b1c7a2cdd3b6ffb4de2 (patch) | |
tree | bf5b897e1e3c13211e3e2fc61d30508b94c928c0 /OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite | |
parent | * removed always true if (diff) | |
download | opensim-SC_OLD-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.zip opensim-SC_OLD-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.tar.gz opensim-SC_OLD-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.tar.bz2 opensim-SC_OLD-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.tar.xz |
* Optimized usings
* shortened references
* Removed redundant 'this'
* Normalized EOF
Diffstat (limited to 'OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite')
-rw-r--r-- | OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs | 306 |
1 files changed, 163 insertions, 143 deletions
diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs index c885310..065d37d 100644 --- a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs +++ b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs | |||
@@ -59,7 +59,7 @@ namespace OpenSim.DataStore.MonoSqlite | |||
59 | private SqliteConnection m_conn; | 59 | private SqliteConnection m_conn; |
60 | 60 | ||
61 | private String m_connectionString; | 61 | private String m_connectionString; |
62 | 62 | ||
63 | private bool persistPrimInventories; | 63 | private bool persistPrimInventories; |
64 | 64 | ||
65 | /*********************************************************************** | 65 | /*********************************************************************** |
@@ -71,7 +71,7 @@ namespace OpenSim.DataStore.MonoSqlite | |||
71 | // see IRegionDataStore | 71 | // see IRegionDataStore |
72 | public void Initialise(string connectionString, bool persistPrimInventories) | 72 | public void Initialise(string connectionString, bool persistPrimInventories) |
73 | { | 73 | { |
74 | m_connectionString = connectionString; | 74 | m_connectionString = connectionString; |
75 | this.persistPrimInventories = persistPrimInventories; | 75 | this.persistPrimInventories = persistPrimInventories; |
76 | 76 | ||
77 | ds = new DataSet(); | 77 | ds = new DataSet(); |
@@ -182,20 +182,20 @@ namespace OpenSim.DataStore.MonoSqlite | |||
182 | { | 182 | { |
183 | foreach (SceneObjectPart prim in obj.Children.Values) | 183 | foreach (SceneObjectPart prim in obj.Children.Values) |
184 | { | 184 | { |
185 | if ((prim.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) == 0) | 185 | if ((prim.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0) |
186 | { | 186 | { |
187 | MainLog.Instance.Verbose("DATASTORE", "Adding obj: " + obj.UUID + " to region: " + regionUUID); | 187 | MainLog.Instance.Verbose("DATASTORE", "Adding obj: " + obj.UUID + " to region: " + regionUUID); |
188 | addPrim(prim, Util.ToRawUuidString(obj.UUID), Util.ToRawUuidString(regionUUID)); | 188 | addPrim(prim, Util.ToRawUuidString(obj.UUID), Util.ToRawUuidString(regionUUID)); |
189 | } | 189 | } |
190 | else if (Stopped(prim)) | 190 | else if (Stopped(prim)) |
191 | { | 191 | { |
192 | MainLog.Instance.Verbose("DATASTORE", "Adding stopped obj: " + obj.UUID + " to region: " + regionUUID); | 192 | MainLog.Instance.Verbose("DATASTORE", |
193 | "Adding stopped obj: " + obj.UUID + " to region: " + regionUUID); | ||
193 | addPrim(prim, Util.ToRawUuidString(obj.UUID), Util.ToRawUuidString(regionUUID)); | 194 | addPrim(prim, Util.ToRawUuidString(obj.UUID), Util.ToRawUuidString(regionUUID)); |
194 | } | 195 | } |
195 | else | 196 | else |
196 | { | 197 | { |
197 | // MainLog.Instance.Verbose("DATASTORE", "Ignoring Physical obj: " + obj.UUID + " in region: " + regionUUID); | 198 | // MainLog.Instance.Verbose("DATASTORE", "Ignoring Physical obj: " + obj.UUID + " in region: " + regionUUID); |
198 | |||
199 | } | 199 | } |
200 | } | 200 | } |
201 | } | 201 | } |
@@ -307,18 +307,19 @@ namespace OpenSim.DataStore.MonoSqlite | |||
307 | 307 | ||
308 | public void StoreTerrain(double[,] ter, LLUUID regionID) | 308 | public void StoreTerrain(double[,] ter, LLUUID regionID) |
309 | { | 309 | { |
310 | lock (ds) { | 310 | lock (ds) |
311 | { | ||
311 | int revision = Util.UnixTimeSinceEpoch(); | 312 | int revision = Util.UnixTimeSinceEpoch(); |
312 | 313 | ||
313 | // the following is an work around for .NET. The perf | 314 | // the following is an work around for .NET. The perf |
314 | // issues associated with it aren't as bad as you think. | 315 | // issues associated with it aren't as bad as you think. |
315 | SqliteConnection conn = new SqliteConnection(m_connectionString); | 316 | SqliteConnection conn = new SqliteConnection(m_connectionString); |
316 | conn.Open(); | 317 | conn.Open(); |
317 | MainLog.Instance.Verbose("DATASTORE", "Storing terrain revision r" + revision.ToString()); | 318 | MainLog.Instance.Verbose("DATASTORE", "Storing terrain revision r" + revision.ToString()); |
318 | String sql = "insert into terrain(RegionUUID, Revision, Heightfield)" + | 319 | String sql = "insert into terrain(RegionUUID, Revision, Heightfield)" + |
319 | " values(:RegionUUID, :Revision, :Heightfield)"; | 320 | " values(:RegionUUID, :Revision, :Heightfield)"; |
320 | 321 | ||
321 | using(SqliteCommand cmd = new SqliteCommand(sql, conn)) | 322 | using (SqliteCommand cmd = new SqliteCommand(sql, conn)) |
322 | { | 323 | { |
323 | cmd.Parameters.Add(new SqliteParameter(":RegionUUID", Util.ToRawUuidString(regionID))); | 324 | cmd.Parameters.Add(new SqliteParameter(":RegionUUID", Util.ToRawUuidString(regionID))); |
324 | cmd.Parameters.Add(new SqliteParameter(":Revision", revision)); | 325 | cmd.Parameters.Add(new SqliteParameter(":Revision", revision)); |
@@ -333,7 +334,10 @@ namespace OpenSim.DataStore.MonoSqlite | |||
333 | // revisions in the database, as this old | 334 | // revisions in the database, as this old |
334 | // implementation is a DOS attack waiting to happen. | 335 | // implementation is a DOS attack waiting to happen. |
335 | 336 | ||
336 | using(SqliteCommand cmd = new SqliteCommand("delete from terrain where RegionUUID=:RegionUUID and Revision < :Revision", conn)) | 337 | using ( |
338 | SqliteCommand cmd = | ||
339 | new SqliteCommand("delete from terrain where RegionUUID=:RegionUUID and Revision < :Revision", | ||
340 | conn)) | ||
337 | { | 341 | { |
338 | cmd.Parameters.Add(new SqliteParameter(":RegionUUID", Util.ToRawUuidString(regionID))); | 342 | cmd.Parameters.Add(new SqliteParameter(":RegionUUID", Util.ToRawUuidString(regionID))); |
339 | cmd.Parameters.Add(new SqliteParameter(":Revision", revision)); | 343 | cmd.Parameters.Add(new SqliteParameter(":Revision", revision)); |
@@ -345,21 +349,22 @@ namespace OpenSim.DataStore.MonoSqlite | |||
345 | 349 | ||
346 | public double[,] LoadTerrain(LLUUID regionID) | 350 | public double[,] LoadTerrain(LLUUID regionID) |
347 | { | 351 | { |
348 | lock (ds) { | 352 | lock (ds) |
353 | { | ||
349 | double[,] terret = new double[256,256]; | 354 | double[,] terret = new double[256,256]; |
350 | terret.Initialize(); | 355 | terret.Initialize(); |
351 | // the following is an work around for .NET. The perf | 356 | // the following is an work around for .NET. The perf |
352 | // issues associated with it aren't as bad as you think. | 357 | // issues associated with it aren't as bad as you think. |
353 | SqliteConnection conn = new SqliteConnection(m_connectionString); | 358 | SqliteConnection conn = new SqliteConnection(m_connectionString); |
354 | conn.Open(); | 359 | conn.Open(); |
355 | String sql = "select RegionUUID, Revision, Heightfield from terrain" + | 360 | String sql = "select RegionUUID, Revision, Heightfield from terrain" + |
356 | " where RegionUUID=:RegionUUID order by Revision desc"; | 361 | " where RegionUUID=:RegionUUID order by Revision desc"; |
357 | 362 | ||
358 | 363 | ||
359 | using (SqliteCommand cmd = new SqliteCommand(sql, conn)) | 364 | using (SqliteCommand cmd = new SqliteCommand(sql, conn)) |
360 | { | 365 | { |
361 | cmd.Parameters.Add(new SqliteParameter(":RegionUUID", Util.ToRawUuidString(regionID))); | 366 | cmd.Parameters.Add(new SqliteParameter(":RegionUUID", Util.ToRawUuidString(regionID))); |
362 | 367 | ||
363 | using (IDataReader row = cmd.ExecuteReader()) | 368 | using (IDataReader row = cmd.ExecuteReader()) |
364 | { | 369 | { |
365 | int rev = 0; | 370 | int rev = 0; |
@@ -374,7 +379,7 @@ namespace OpenSim.DataStore.MonoSqlite | |||
374 | terret[x, y] = BitConverter.ToDouble(heightmap, ((x*256) + y)*8); | 379 | terret[x, y] = BitConverter.ToDouble(heightmap, ((x*256) + y)*8); |
375 | } | 380 | } |
376 | } | 381 | } |
377 | rev = (int)row["Revision"]; | 382 | rev = (int) row["Revision"]; |
378 | } | 383 | } |
379 | else | 384 | else |
380 | { | 385 | { |
@@ -382,7 +387,7 @@ namespace OpenSim.DataStore.MonoSqlite | |||
382 | conn.Close(); | 387 | conn.Close(); |
383 | return null; | 388 | return null; |
384 | } | 389 | } |
385 | 390 | ||
386 | MainLog.Instance.Verbose("DATASTORE", "Loaded terrain revision r" + rev.ToString()); | 391 | MainLog.Instance.Verbose("DATASTORE", "Loaded terrain revision r" + rev.ToString()); |
387 | } | 392 | } |
388 | } | 393 | } |
@@ -434,7 +439,8 @@ namespace OpenSim.DataStore.MonoSqlite | |||
434 | fillLandRow(landRow, parcel.landData, regionUUID); | 439 | fillLandRow(landRow, parcel.landData, regionUUID); |
435 | } | 440 | } |
436 | 441 | ||
437 | using (SqliteCommand cmd = new SqliteCommand("delete from landaccesslist where LandUUID=:LandUUID", conn)) | 442 | using ( |
443 | SqliteCommand cmd = new SqliteCommand("delete from landaccesslist where LandUUID=:LandUUID", conn)) | ||
438 | { | 444 | { |
439 | cmd.Parameters.Add(new SqliteParameter(":LandUUID", Util.ToRawUuidString(parcel.landData.globalID))); | 445 | cmd.Parameters.Add(new SqliteParameter(":LandUUID", Util.ToRawUuidString(parcel.landData.globalID))); |
440 | cmd.ExecuteNonQuery(); | 446 | cmd.ExecuteNonQuery(); |
@@ -447,16 +453,15 @@ namespace OpenSim.DataStore.MonoSqlite | |||
447 | landaccesslist.Rows.Add(newAccessRow); | 453 | landaccesslist.Rows.Add(newAccessRow); |
448 | } | 454 | } |
449 | conn.Close(); | 455 | conn.Close(); |
450 | |||
451 | } | 456 | } |
452 | 457 | ||
453 | Commit(); | 458 | Commit(); |
454 | } | 459 | } |
455 | 460 | ||
456 | public List<Framework.LandData> LoadLandObjects(LLUUID regionUUID) | 461 | public List<LandData> LoadLandObjects(LLUUID regionUUID) |
457 | { | 462 | { |
458 | List<LandData> landDataForRegion = new List<LandData>(); | 463 | List<LandData> landDataForRegion = new List<LandData>(); |
459 | lock(ds) | 464 | lock (ds) |
460 | { | 465 | { |
461 | DataTable land = ds.Tables["land"]; | 466 | DataTable land = ds.Tables["land"]; |
462 | DataTable landaccesslist = ds.Tables["landaccesslist"]; | 467 | DataTable landaccesslist = ds.Tables["landaccesslist"]; |
@@ -570,14 +575,14 @@ namespace OpenSim.DataStore.MonoSqlite | |||
570 | createCol(prims, "RotationW", typeof (Double)); | 575 | createCol(prims, "RotationW", typeof (Double)); |
571 | 576 | ||
572 | // sit target | 577 | // sit target |
573 | createCol(prims, "SitTargetOffsetX", typeof(Double)); | 578 | createCol(prims, "SitTargetOffsetX", typeof (Double)); |
574 | createCol(prims, "SitTargetOffsetY", typeof(Double)); | 579 | createCol(prims, "SitTargetOffsetY", typeof (Double)); |
575 | createCol(prims, "SitTargetOffsetZ", typeof(Double)); | 580 | createCol(prims, "SitTargetOffsetZ", typeof (Double)); |
576 | 581 | ||
577 | createCol(prims, "SitTargetOrientW", typeof(Double)); | 582 | createCol(prims, "SitTargetOrientW", typeof (Double)); |
578 | createCol(prims, "SitTargetOrientX", typeof(Double)); | 583 | createCol(prims, "SitTargetOrientX", typeof (Double)); |
579 | createCol(prims, "SitTargetOrientY", typeof(Double)); | 584 | createCol(prims, "SitTargetOrientY", typeof (Double)); |
580 | createCol(prims, "SitTargetOrientZ", typeof(Double)); | 585 | createCol(prims, "SitTargetOrientZ", typeof (Double)); |
581 | 586 | ||
582 | // Add in contraints | 587 | // Add in contraints |
583 | prims.PrimaryKey = new DataColumn[] {prims.Columns["UUID"]}; | 588 | prims.PrimaryKey = new DataColumn[] {prims.Columns["UUID"]}; |
@@ -621,11 +626,11 @@ namespace OpenSim.DataStore.MonoSqlite | |||
621 | createCol(shapes, "Texture", typeof (Byte[])); | 626 | createCol(shapes, "Texture", typeof (Byte[])); |
622 | createCol(shapes, "ExtraParams", typeof (Byte[])); | 627 | createCol(shapes, "ExtraParams", typeof (Byte[])); |
623 | 628 | ||
624 | shapes.PrimaryKey = new DataColumn[] { shapes.Columns["UUID"] }; | 629 | shapes.PrimaryKey = new DataColumn[] {shapes.Columns["UUID"]}; |
625 | 630 | ||
626 | return shapes; | 631 | return shapes; |
627 | } | 632 | } |
628 | 633 | ||
629 | private DataTable createItemsTable() | 634 | private DataTable createItemsTable() |
630 | { | 635 | { |
631 | DataTable items = new DataTable("primitems"); | 636 | DataTable items = new DataTable("primitems"); |
@@ -635,10 +640,10 @@ namespace OpenSim.DataStore.MonoSqlite | |||
635 | createCol(items, "assetID", typeof (String)); | 640 | createCol(items, "assetID", typeof (String)); |
636 | createCol(items, "assetType", typeof (Int32)); | 641 | createCol(items, "assetType", typeof (Int32)); |
637 | createCol(items, "parentFolderID", typeof (String)); | 642 | createCol(items, "parentFolderID", typeof (String)); |
638 | 643 | ||
639 | createCol(items, "name", typeof (String)); | 644 | createCol(items, "name", typeof (String)); |
640 | createCol(items, "description", typeof (String)); | 645 | createCol(items, "description", typeof (String)); |
641 | 646 | ||
642 | createCol(items, "creationDate", typeof (Int64)); | 647 | createCol(items, "creationDate", typeof (Int64)); |
643 | createCol(items, "creatorID", typeof (String)); | 648 | createCol(items, "creatorID", typeof (String)); |
644 | createCol(items, "ownerID", typeof (String)); | 649 | createCol(items, "ownerID", typeof (String)); |
@@ -651,50 +656,50 @@ namespace OpenSim.DataStore.MonoSqlite | |||
651 | createCol(items, "everyonePermissions", typeof (Int32)); | 656 | createCol(items, "everyonePermissions", typeof (Int32)); |
652 | createCol(items, "groupPermissions", typeof (Int32)); | 657 | createCol(items, "groupPermissions", typeof (Int32)); |
653 | 658 | ||
654 | items.PrimaryKey = new DataColumn[] { items.Columns["UUID"] }; | 659 | items.PrimaryKey = new DataColumn[] {items.Columns["UUID"]}; |
655 | 660 | ||
656 | return items; | 661 | return items; |
657 | } | 662 | } |
658 | 663 | ||
659 | private DataTable createLandTable() | 664 | private DataTable createLandTable() |
660 | { | 665 | { |
661 | DataTable land = new DataTable("land"); | 666 | DataTable land = new DataTable("land"); |
662 | createCol(land, "UUID", typeof(String)); | 667 | createCol(land, "UUID", typeof (String)); |
663 | createCol(land, "RegionUUID", typeof(String)); | 668 | createCol(land, "RegionUUID", typeof (String)); |
664 | createCol(land, "LocalLandID", typeof(UInt32)); | 669 | createCol(land, "LocalLandID", typeof (UInt32)); |
665 | 670 | ||
666 | // Bitmap is a byte[512] | 671 | // Bitmap is a byte[512] |
667 | createCol(land, "Bitmap", typeof(Byte[])); | 672 | createCol(land, "Bitmap", typeof (Byte[])); |
668 | 673 | ||
669 | createCol(land, "Name", typeof(String)); | 674 | createCol(land, "Name", typeof (String)); |
670 | createCol(land, "Desc", typeof(String)); | 675 | createCol(land, "Desc", typeof (String)); |
671 | createCol(land, "OwnerUUID", typeof(String)); | 676 | createCol(land, "OwnerUUID", typeof (String)); |
672 | createCol(land, "IsGroupOwned", typeof(Boolean)); | 677 | createCol(land, "IsGroupOwned", typeof (Boolean)); |
673 | createCol(land, "Area", typeof(Int32)); | 678 | createCol(land, "Area", typeof (Int32)); |
674 | createCol(land, "AuctionID", typeof(Int32)); //Unemplemented | 679 | createCol(land, "AuctionID", typeof (Int32)); //Unemplemented |
675 | createCol(land, "Category", typeof(Int32)); //Enum libsecondlife.Parcel.ParcelCategory | 680 | createCol(land, "Category", typeof (Int32)); //Enum libsecondlife.Parcel.ParcelCategory |
676 | createCol(land, "ClaimDate", typeof(Int32)); | 681 | createCol(land, "ClaimDate", typeof (Int32)); |
677 | createCol(land, "ClaimPrice", typeof(Int32)); | 682 | createCol(land, "ClaimPrice", typeof (Int32)); |
678 | createCol(land, "GroupUUID", typeof(string)); | 683 | createCol(land, "GroupUUID", typeof (string)); |
679 | createCol(land, "SalePrice", typeof(Int32)); | 684 | createCol(land, "SalePrice", typeof (Int32)); |
680 | createCol(land, "LandStatus", typeof(Int32)); //Enum. libsecondlife.Parcel.ParcelStatus | 685 | createCol(land, "LandStatus", typeof (Int32)); //Enum. libsecondlife.Parcel.ParcelStatus |
681 | createCol(land, "LandFlags", typeof(UInt32)); | 686 | createCol(land, "LandFlags", typeof (UInt32)); |
682 | createCol(land, "LandingType", typeof(Byte)); | 687 | createCol(land, "LandingType", typeof (Byte)); |
683 | createCol(land, "MediaAutoScale", typeof(Byte)); | 688 | createCol(land, "MediaAutoScale", typeof (Byte)); |
684 | createCol(land, "MediaTextureUUID", typeof(String)); | 689 | createCol(land, "MediaTextureUUID", typeof (String)); |
685 | createCol(land, "MediaURL", typeof(String)); | 690 | createCol(land, "MediaURL", typeof (String)); |
686 | createCol(land, "MusicURL", typeof(String)); | 691 | createCol(land, "MusicURL", typeof (String)); |
687 | createCol(land, "PassHours", typeof(Double)); | 692 | createCol(land, "PassHours", typeof (Double)); |
688 | createCol(land, "PassPrice", typeof(UInt32)); | 693 | createCol(land, "PassPrice", typeof (UInt32)); |
689 | createCol(land, "SnapshotUUID", typeof(String)); | 694 | createCol(land, "SnapshotUUID", typeof (String)); |
690 | createCol(land, "UserLocationX", typeof(Double)); | 695 | createCol(land, "UserLocationX", typeof (Double)); |
691 | createCol(land, "UserLocationY", typeof(Double)); | 696 | createCol(land, "UserLocationY", typeof (Double)); |
692 | createCol(land, "UserLocationZ", typeof(Double)); | 697 | createCol(land, "UserLocationZ", typeof (Double)); |
693 | createCol(land, "UserLookAtX", typeof(Double)); | 698 | createCol(land, "UserLookAtX", typeof (Double)); |
694 | createCol(land, "UserLookAtY", typeof(Double)); | 699 | createCol(land, "UserLookAtY", typeof (Double)); |
695 | createCol(land, "UserLookAtZ", typeof(Double)); | 700 | createCol(land, "UserLookAtZ", typeof (Double)); |
696 | 701 | ||
697 | land.PrimaryKey = new DataColumn[] { land.Columns["UUID"] }; | 702 | land.PrimaryKey = new DataColumn[] {land.Columns["UUID"]}; |
698 | 703 | ||
699 | return land; | 704 | return land; |
700 | } | 705 | } |
@@ -702,9 +707,9 @@ namespace OpenSim.DataStore.MonoSqlite | |||
702 | private DataTable createLandAccessListTable() | 707 | private DataTable createLandAccessListTable() |
703 | { | 708 | { |
704 | DataTable landaccess = new DataTable("landaccesslist"); | 709 | DataTable landaccess = new DataTable("landaccesslist"); |
705 | createCol(landaccess, "LandUUID", typeof(String)); | 710 | createCol(landaccess, "LandUUID", typeof (String)); |
706 | createCol(landaccess, "AccessUUID", typeof(String)); | 711 | createCol(landaccess, "AccessUUID", typeof (String)); |
707 | createCol(landaccess, "Flags", typeof(UInt32)); | 712 | createCol(landaccess, "Flags", typeof (UInt32)); |
708 | 713 | ||
709 | return landaccess; | 714 | return landaccess; |
710 | } | 715 | } |
@@ -782,35 +787,43 @@ namespace OpenSim.DataStore.MonoSqlite | |||
782 | try | 787 | try |
783 | { | 788 | { |
784 | prim.SetSitTargetLL(new LLVector3( | 789 | prim.SetSitTargetLL(new LLVector3( |
785 | Convert.ToSingle(row["SitTargetOffsetX"]), | 790 | Convert.ToSingle(row["SitTargetOffsetX"]), |
786 | Convert.ToSingle(row["SitTargetOffsetY"]), | 791 | Convert.ToSingle(row["SitTargetOffsetY"]), |
787 | Convert.ToSingle(row["SitTargetOffsetZ"])), new LLQuaternion( | 792 | Convert.ToSingle(row["SitTargetOffsetZ"])), new LLQuaternion( |
788 | Convert.ToSingle(row["SitTargetOrientX"]), | 793 | Convert.ToSingle( |
789 | Convert.ToSingle(row["SitTargetOrientY"]), | 794 | row["SitTargetOrientX"]), |
790 | Convert.ToSingle(row["SitTargetOrientZ"]), | 795 | Convert.ToSingle( |
791 | Convert.ToSingle(row["SitTargetOrientW"]))); | 796 | row["SitTargetOrientY"]), |
797 | Convert.ToSingle( | ||
798 | row["SitTargetOrientZ"]), | ||
799 | Convert.ToSingle( | ||
800 | row["SitTargetOrientW"]))); | ||
792 | } | 801 | } |
793 | catch (System.InvalidCastException) | 802 | catch (InvalidCastException) |
794 | { | 803 | { |
795 | // Database table was created before we got here and now has null values :P | 804 | // Database table was created before we got here and now has null values :P |
796 | m_conn.Open(); | 805 | m_conn.Open(); |
797 | SqliteCommand cmd = new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOffsetX float NOT NULL default 0;", m_conn); | 806 | SqliteCommand cmd = |
807 | new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOffsetX float NOT NULL default 0;", m_conn); | ||
798 | cmd.ExecuteNonQuery(); | 808 | cmd.ExecuteNonQuery(); |
799 | cmd = new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOffsetY float NOT NULL default 0;", m_conn); | 809 | cmd = |
810 | new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOffsetY float NOT NULL default 0;", m_conn); | ||
800 | cmd.ExecuteNonQuery(); | 811 | cmd.ExecuteNonQuery(); |
801 | cmd = new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOffsetZ float NOT NULL default 0;", m_conn); | 812 | cmd = |
813 | new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOffsetZ float NOT NULL default 0;", m_conn); | ||
802 | cmd.ExecuteNonQuery(); | 814 | cmd.ExecuteNonQuery(); |
803 | cmd = new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOrientW float NOT NULL default 0;", m_conn); | 815 | cmd = |
816 | new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOrientW float NOT NULL default 0;", m_conn); | ||
804 | cmd.ExecuteNonQuery(); | 817 | cmd.ExecuteNonQuery(); |
805 | cmd = new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOrientX float NOT NULL default 0;", m_conn); | 818 | cmd = |
819 | new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOrientX float NOT NULL default 0;", m_conn); | ||
806 | cmd.ExecuteNonQuery(); | 820 | cmd.ExecuteNonQuery(); |
807 | cmd = new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOrientY float NOT NULL default 0;", m_conn); | 821 | cmd = |
822 | new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOrientY float NOT NULL default 0;", m_conn); | ||
808 | cmd.ExecuteNonQuery(); | 823 | cmd.ExecuteNonQuery(); |
809 | cmd = new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOrientZ float NOT NULL default 0;", m_conn); | 824 | cmd = |
825 | new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOrientZ float NOT NULL default 0;", m_conn); | ||
810 | cmd.ExecuteNonQuery(); | 826 | cmd.ExecuteNonQuery(); |
811 | |||
812 | |||
813 | |||
814 | } | 827 | } |
815 | 828 | ||
816 | return prim; | 829 | return prim; |
@@ -820,36 +833,42 @@ namespace OpenSim.DataStore.MonoSqlite | |||
820 | { | 833 | { |
821 | LandData newData = new LandData(); | 834 | LandData newData = new LandData(); |
822 | 835 | ||
823 | newData.globalID = new LLUUID((String)row["UUID"]); | 836 | newData.globalID = new LLUUID((String) row["UUID"]); |
824 | newData.localID= Convert.ToInt32(row["LocalLandID"]); | 837 | newData.localID = Convert.ToInt32(row["LocalLandID"]); |
825 | 838 | ||
826 | // Bitmap is a byte[512] | 839 | // Bitmap is a byte[512] |
827 | newData.landBitmapByteArray = (Byte[]) row["Bitmap"]; | 840 | newData.landBitmapByteArray = (Byte[]) row["Bitmap"]; |
828 | 841 | ||
829 | newData.landName= (String) row["Name"]; | 842 | newData.landName = (String) row["Name"]; |
830 | newData.landDesc= (String) row["Desc"]; | 843 | newData.landDesc = (String) row["Desc"]; |
831 | newData.ownerID= (String) row["OwnerUUID"]; | 844 | newData.ownerID = (String) row["OwnerUUID"]; |
832 | newData.isGroupOwned= (Boolean) row["IsGroupOwned"]; | 845 | newData.isGroupOwned = (Boolean) row["IsGroupOwned"]; |
833 | newData.area= Convert.ToInt32(row["Area"]); | 846 | newData.area = Convert.ToInt32(row["Area"]); |
834 | newData.auctionID = Convert.ToUInt32(row["AuctionID"]); //Unemplemented | 847 | newData.auctionID = Convert.ToUInt32(row["AuctionID"]); //Unemplemented |
835 | newData.category= (Parcel.ParcelCategory) Convert.ToInt32(row["Category"]); //Enum libsecondlife.Parcel.ParcelCategory | 848 | newData.category = (Parcel.ParcelCategory) Convert.ToInt32(row["Category"]); |
836 | newData.claimDate= Convert.ToInt32(row["ClaimDate"]); | 849 | //Enum libsecondlife.Parcel.ParcelCategory |
837 | newData.claimPrice= Convert.ToInt32(row["ClaimPrice"]); | 850 | newData.claimDate = Convert.ToInt32(row["ClaimDate"]); |
838 | newData.groupID= new LLUUID((String)row["GroupUUID"]); | 851 | newData.claimPrice = Convert.ToInt32(row["ClaimPrice"]); |
852 | newData.groupID = new LLUUID((String) row["GroupUUID"]); | ||
839 | newData.salePrice = Convert.ToInt32(row["SalePrice"]); | 853 | newData.salePrice = Convert.ToInt32(row["SalePrice"]); |
840 | newData.landStatus= (Parcel.ParcelStatus) Convert.ToInt32(row["LandStatus"]); //Enum. libsecondlife.Parcel.ParcelStatus | 854 | newData.landStatus = (Parcel.ParcelStatus) Convert.ToInt32(row["LandStatus"]); |
841 | newData.landFlags= Convert.ToUInt32(row["LandFlags"]); | 855 | //Enum. libsecondlife.Parcel.ParcelStatus |
842 | newData.landingType= (Byte) row["LandingType"]; | 856 | newData.landFlags = Convert.ToUInt32(row["LandFlags"]); |
843 | newData.mediaAutoScale= (Byte) row["MediaAutoScale"]; | 857 | newData.landingType = (Byte) row["LandingType"]; |
844 | newData.mediaID= new LLUUID((String)row["MediaTextureUUID"]); | 858 | newData.mediaAutoScale = (Byte) row["MediaAutoScale"]; |
845 | newData.mediaURL= (String) row["MediaURL"]; | 859 | newData.mediaID = new LLUUID((String) row["MediaTextureUUID"]); |
846 | newData.musicURL= (String) row["MusicURL"]; | 860 | newData.mediaURL = (String) row["MediaURL"]; |
847 | newData.passHours= Convert.ToSingle(row["PassHours"]); | 861 | newData.musicURL = (String) row["MusicURL"]; |
848 | newData.passPrice= Convert.ToInt32(row["PassPrice"]); | 862 | newData.passHours = Convert.ToSingle(row["PassHours"]); |
849 | newData.snapshotID= (String) row["SnapshotUUID"]; | 863 | newData.passPrice = Convert.ToInt32(row["PassPrice"]); |
850 | 864 | newData.snapshotID = (String) row["SnapshotUUID"]; | |
851 | newData.userLocation = new LLVector3(Convert.ToSingle(row["UserLocationX"]),Convert.ToSingle(row["UserLocationY"]), Convert.ToSingle(row["UserLocationZ"])); | 865 | |
852 | newData.userLookAt = new LLVector3(Convert.ToSingle(row["UserLookAtX"]),Convert.ToSingle(row["UserLookAtY"]), Convert.ToSingle(row["UserLookAtZ"])); | 866 | newData.userLocation = |
867 | new LLVector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]), | ||
868 | Convert.ToSingle(row["UserLocationZ"])); | ||
869 | newData.userLookAt = | ||
870 | new LLVector3(Convert.ToSingle(row["UserLookAtX"]), Convert.ToSingle(row["UserLookAtY"]), | ||
871 | Convert.ToSingle(row["UserLookAtZ"])); | ||
853 | newData.parcelAccessList = new List<ParcelManager.ParcelAccessEntry>(); | 872 | newData.parcelAccessList = new List<ParcelManager.ParcelAccessEntry>(); |
854 | 873 | ||
855 | return newData; | 874 | return newData; |
@@ -858,13 +877,13 @@ namespace OpenSim.DataStore.MonoSqlite | |||
858 | private ParcelManager.ParcelAccessEntry buildLandAccessData(DataRow row) | 877 | private ParcelManager.ParcelAccessEntry buildLandAccessData(DataRow row) |
859 | { | 878 | { |
860 | ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); | 879 | ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); |
861 | entry.AgentID = new LLUUID((string)row["AccessUUID"]); | 880 | entry.AgentID = new LLUUID((string) row["AccessUUID"]); |
862 | entry.Flags = (ParcelManager.AccessList)row["Flags"]; | 881 | entry.Flags = (ParcelManager.AccessList) row["Flags"]; |
863 | entry.Time = new DateTime(); | 882 | entry.Time = new DateTime(); |
864 | return entry; | 883 | return entry; |
865 | } | 884 | } |
866 | 885 | ||
867 | private Array serializeTerrain(double[,] val) | 886 | private Array serializeTerrain(double[,] val) |
868 | { | 887 | { |
869 | MemoryStream str = new MemoryStream(65536*sizeof (double)); | 888 | MemoryStream str = new MemoryStream(65536*sizeof (double)); |
870 | BinaryWriter bw = new BinaryWriter(str); | 889 | BinaryWriter bw = new BinaryWriter(str); |
@@ -900,7 +919,8 @@ namespace OpenSim.DataStore.MonoSqlite | |||
900 | row["ParentID"] = prim.ParentID; | 919 | row["ParentID"] = prim.ParentID; |
901 | row["CreationDate"] = prim.CreationDate; | 920 | row["CreationDate"] = prim.CreationDate; |
902 | row["Name"] = prim.Name; | 921 | row["Name"] = prim.Name; |
903 | row["SceneGroupID"] = Util.ToRawUuidString(sceneGroupID); // the UUID of the root part for this SceneObjectGroup | 922 | row["SceneGroupID"] = Util.ToRawUuidString(sceneGroupID); |
923 | // the UUID of the root part for this SceneObjectGroup | ||
904 | // various text fields | 924 | // various text fields |
905 | row["Text"] = prim.Text; | 925 | row["Text"] = prim.Text; |
906 | row["Description"] = prim.Description; | 926 | row["Description"] = prim.Description; |
@@ -1028,10 +1048,10 @@ namespace OpenSim.DataStore.MonoSqlite | |||
1028 | s.ProfileHollow = Convert.ToUInt16(row["ProfileHollow"]); | 1048 | s.ProfileHollow = Convert.ToUInt16(row["ProfileHollow"]); |
1029 | // text TODO: this isn't right] = but I'm not sure the right | 1049 | // text TODO: this isn't right] = but I'm not sure the right |
1030 | // way to specify this as a blob atm | 1050 | // way to specify this as a blob atm |
1031 | 1051 | ||
1032 | byte[] textureEntry = (byte[])row["Texture"]; | 1052 | byte[] textureEntry = (byte[]) row["Texture"]; |
1033 | s.TextureEntry = textureEntry; | 1053 | s.TextureEntry = textureEntry; |
1034 | 1054 | ||
1035 | 1055 | ||
1036 | s.ExtraParams = (byte[]) row["ExtraParams"]; | 1056 | s.ExtraParams = (byte[]) row["ExtraParams"]; |
1037 | // System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); | 1057 | // System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); |
@@ -1278,6 +1298,7 @@ namespace OpenSim.DataStore.MonoSqlite | |||
1278 | da.InsertCommand = createInsertCommand("landaccesslist", ds.Tables["landaccesslist"]); | 1298 | da.InsertCommand = createInsertCommand("landaccesslist", ds.Tables["landaccesslist"]); |
1279 | da.InsertCommand.Connection = conn; | 1299 | da.InsertCommand.Connection = conn; |
1280 | } | 1300 | } |
1301 | |||
1281 | private void setupShapeCommands(SqliteDataAdapter da, SqliteConnection conn) | 1302 | private void setupShapeCommands(SqliteDataAdapter da, SqliteConnection conn) |
1282 | { | 1303 | { |
1283 | da.InsertCommand = createInsertCommand("primshapes", ds.Tables["primshapes"]); | 1304 | da.InsertCommand = createInsertCommand("primshapes", ds.Tables["primshapes"]); |
@@ -1331,7 +1352,7 @@ namespace OpenSim.DataStore.MonoSqlite | |||
1331 | { | 1352 | { |
1332 | MainLog.Instance.Warn("SQLITE", "Shapes Table Already Exists"); | 1353 | MainLog.Instance.Warn("SQLITE", "Shapes Table Already Exists"); |
1333 | } | 1354 | } |
1334 | 1355 | ||
1335 | if (persistPrimInventories) | 1356 | if (persistPrimInventories) |
1336 | { | 1357 | { |
1337 | try | 1358 | try |
@@ -1341,7 +1362,7 @@ namespace OpenSim.DataStore.MonoSqlite | |||
1341 | catch (SqliteSyntaxException) | 1362 | catch (SqliteSyntaxException) |
1342 | { | 1363 | { |
1343 | MainLog.Instance.Warn("SQLITE", "Primitives Inventory Table Already Exists"); | 1364 | MainLog.Instance.Warn("SQLITE", "Primitives Inventory Table Already Exists"); |
1344 | } | 1365 | } |
1345 | } | 1366 | } |
1346 | 1367 | ||
1347 | try | 1368 | try |
@@ -1377,32 +1398,31 @@ namespace OpenSim.DataStore.MonoSqlite | |||
1377 | { | 1398 | { |
1378 | SqliteCommand primSelectCmd = new SqliteCommand(primSelect, conn); | 1399 | SqliteCommand primSelectCmd = new SqliteCommand(primSelect, conn); |
1379 | SqliteDataAdapter pDa = new SqliteDataAdapter(primSelectCmd); | 1400 | SqliteDataAdapter pDa = new SqliteDataAdapter(primSelectCmd); |
1380 | 1401 | ||
1381 | SqliteCommand shapeSelectCmd = new SqliteCommand(shapeSelect, conn); | 1402 | SqliteCommand shapeSelectCmd = new SqliteCommand(shapeSelect, conn); |
1382 | SqliteDataAdapter sDa = new SqliteDataAdapter(shapeSelectCmd); | 1403 | SqliteDataAdapter sDa = new SqliteDataAdapter(shapeSelectCmd); |
1383 | 1404 | ||
1384 | SqliteCommand itemsSelectCmd = new SqliteCommand(itemsSelect, conn); | 1405 | SqliteCommand itemsSelectCmd = new SqliteCommand(itemsSelect, conn); |
1385 | SqliteDataAdapter iDa = new SqliteDataAdapter(itemsSelectCmd); | 1406 | SqliteDataAdapter iDa = new SqliteDataAdapter(itemsSelectCmd); |
1386 | 1407 | ||
1387 | SqliteCommand terrainSelectCmd = new SqliteCommand(terrainSelect, conn); | 1408 | SqliteCommand terrainSelectCmd = new SqliteCommand(terrainSelect, conn); |
1388 | SqliteDataAdapter tDa = new SqliteDataAdapter(terrainSelectCmd); | 1409 | SqliteDataAdapter tDa = new SqliteDataAdapter(terrainSelectCmd); |
1389 | 1410 | ||
1390 | SqliteCommand landSelectCmd = new SqliteCommand(landSelect, conn); | 1411 | SqliteCommand landSelectCmd = new SqliteCommand(landSelect, conn); |
1391 | SqliteDataAdapter lDa = new SqliteDataAdapter(landSelectCmd); | 1412 | SqliteDataAdapter lDa = new SqliteDataAdapter(landSelectCmd); |
1392 | 1413 | ||
1393 | SqliteCommand landAccessListSelectCmd = new SqliteCommand(landAccessListSelect, conn); | 1414 | SqliteCommand landAccessListSelectCmd = new SqliteCommand(landAccessListSelect, conn); |
1394 | SqliteDataAdapter lalDa = new SqliteDataAdapter(landAccessListSelectCmd); | 1415 | SqliteDataAdapter lalDa = new SqliteDataAdapter(landAccessListSelectCmd); |
1395 | 1416 | ||
1396 | DataSet tmpDS = new DataSet(); | 1417 | DataSet tmpDS = new DataSet(); |
1397 | try | 1418 | try |
1398 | { | 1419 | { |
1399 | |||
1400 | pDa.Fill(tmpDS, "prims"); | 1420 | pDa.Fill(tmpDS, "prims"); |
1401 | sDa.Fill(tmpDS, "primshapes"); | 1421 | sDa.Fill(tmpDS, "primshapes"); |
1402 | 1422 | ||
1403 | if (persistPrimInventories) | 1423 | if (persistPrimInventories) |
1404 | iDa.Fill(tmpDS, "primitems"); | 1424 | iDa.Fill(tmpDS, "primitems"); |
1405 | 1425 | ||
1406 | tDa.Fill(tmpDS, "terrain"); | 1426 | tDa.Fill(tmpDS, "terrain"); |
1407 | lDa.Fill(tmpDS, "land"); | 1427 | lDa.Fill(tmpDS, "land"); |
1408 | lalDa.Fill(tmpDS, "landaccesslist"); | 1428 | lalDa.Fill(tmpDS, "landaccesslist"); |
@@ -1415,13 +1435,13 @@ namespace OpenSim.DataStore.MonoSqlite | |||
1415 | 1435 | ||
1416 | pDa.Fill(tmpDS, "prims"); | 1436 | pDa.Fill(tmpDS, "prims"); |
1417 | sDa.Fill(tmpDS, "primshapes"); | 1437 | sDa.Fill(tmpDS, "primshapes"); |
1418 | 1438 | ||
1419 | if (persistPrimInventories) | 1439 | if (persistPrimInventories) |
1420 | iDa.Fill(tmpDS, "primitems"); | 1440 | iDa.Fill(tmpDS, "primitems"); |
1421 | 1441 | ||
1422 | tDa.Fill(tmpDS, "terrain"); | 1442 | tDa.Fill(tmpDS, "terrain"); |
1423 | lDa.Fill(tmpDS, "land"); | 1443 | lDa.Fill(tmpDS, "land"); |
1424 | lalDa.Fill(tmpDS,"landaccesslist"); | 1444 | lalDa.Fill(tmpDS, "landaccesslist"); |
1425 | 1445 | ||
1426 | foreach (DataColumn col in createPrimTable().Columns) | 1446 | foreach (DataColumn col in createPrimTable().Columns) |
1427 | { | 1447 | { |
@@ -1431,7 +1451,7 @@ namespace OpenSim.DataStore.MonoSqlite | |||
1431 | return false; | 1451 | return false; |
1432 | } | 1452 | } |
1433 | } | 1453 | } |
1434 | 1454 | ||
1435 | foreach (DataColumn col in createShapeTable().Columns) | 1455 | foreach (DataColumn col in createShapeTable().Columns) |
1436 | { | 1456 | { |
1437 | if (!tmpDS.Tables["primshapes"].Columns.Contains(col.ColumnName)) | 1457 | if (!tmpDS.Tables["primshapes"].Columns.Contains(col.ColumnName)) |
@@ -1440,9 +1460,9 @@ namespace OpenSim.DataStore.MonoSqlite | |||
1440 | return false; | 1460 | return false; |
1441 | } | 1461 | } |
1442 | } | 1462 | } |
1443 | 1463 | ||
1444 | // TODO Not restoring prim inventories quite yet | 1464 | // TODO Not restoring prim inventories quite yet |
1445 | 1465 | ||
1446 | foreach (DataColumn col in createTerrainTable().Columns) | 1466 | foreach (DataColumn col in createTerrainTable().Columns) |
1447 | { | 1467 | { |
1448 | if (!tmpDS.Tables["terrain"].Columns.Contains(col.ColumnName)) | 1468 | if (!tmpDS.Tables["terrain"].Columns.Contains(col.ColumnName)) |
@@ -1451,7 +1471,7 @@ namespace OpenSim.DataStore.MonoSqlite | |||
1451 | return false; | 1471 | return false; |
1452 | } | 1472 | } |
1453 | } | 1473 | } |
1454 | 1474 | ||
1455 | foreach (DataColumn col in createLandTable().Columns) | 1475 | foreach (DataColumn col in createLandTable().Columns) |
1456 | { | 1476 | { |
1457 | if (!tmpDS.Tables["land"].Columns.Contains(col.ColumnName)) | 1477 | if (!tmpDS.Tables["land"].Columns.Contains(col.ColumnName)) |
@@ -1460,7 +1480,7 @@ namespace OpenSim.DataStore.MonoSqlite | |||
1460 | return false; | 1480 | return false; |
1461 | } | 1481 | } |
1462 | } | 1482 | } |
1463 | 1483 | ||
1464 | foreach (DataColumn col in createLandAccessListTable().Columns) | 1484 | foreach (DataColumn col in createLandAccessListTable().Columns) |
1465 | { | 1485 | { |
1466 | if (!tmpDS.Tables["landaccesslist"].Columns.Contains(col.ColumnName)) | 1486 | if (!tmpDS.Tables["landaccesslist"].Columns.Contains(col.ColumnName)) |
@@ -1469,7 +1489,7 @@ namespace OpenSim.DataStore.MonoSqlite | |||
1469 | return false; | 1489 | return false; |
1470 | } | 1490 | } |
1471 | } | 1491 | } |
1472 | 1492 | ||
1473 | return true; | 1493 | return true; |
1474 | } | 1494 | } |
1475 | 1495 | ||
@@ -1526,7 +1546,7 @@ namespace OpenSim.DataStore.MonoSqlite | |||
1526 | else if (type == typeof (Int64)) | 1546 | else if (type == typeof (Int64)) |
1527 | { | 1547 | { |
1528 | return "integer"; | 1548 | return "integer"; |
1529 | } | 1549 | } |
1530 | else if (type == typeof (Double)) | 1550 | else if (type == typeof (Double)) |
1531 | { | 1551 | { |
1532 | return "float"; | 1552 | return "float"; |
@@ -1541,4 +1561,4 @@ namespace OpenSim.DataStore.MonoSqlite | |||
1541 | } | 1561 | } |
1542 | } | 1562 | } |
1543 | } | 1563 | } |
1544 | } | 1564 | } \ No newline at end of file |