aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorTeravus Ovares2007-12-27 05:37:48 +0000
committerTeravus Ovares2007-12-27 05:37:48 +0000
commitcbf5ff4a9371c067dbe36ef28487c8784b9229d2 (patch)
treea5b16f0cd840374dc475153d77671f1d20f06ac7 /OpenSim/Region
parent* Added osRegionRestart(float secs) to LSL Commands (diff)
downloadopensim-SC-cbf5ff4a9371c067dbe36ef28487c8784b9229d2.zip
opensim-SC-cbf5ff4a9371c067dbe36ef28487c8784b9229d2.tar.gz
opensim-SC-cbf5ff4a9371c067dbe36ef28487c8784b9229d2.tar.bz2
opensim-SC-cbf5ff4a9371c067dbe36ef28487c8784b9229d2.tar.xz
* Added Sit Target persistence over sim restarts for mySQL and MonoSQLite.
* SAVE YOUR PRIM DATA, THIS MAKES CHANGES TO YOUR PRIMS TABLE * The first time you run OpenSim after updating past this revision, you'll see a lot of Errors. Be calm, shutdown the simulator, and start it again and your prims table will be updated. * MSSQL added the fields to the Initial CreateTable section, however, you'll need to add the fields to your prims table if you want it to persist.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs27
-rw-r--r--OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs46
-rw-r--r--OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs48
3 files changed, 121 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index bcd31c2..973c30e 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -72,6 +72,8 @@ namespace OpenSim.Region.Environment.Scenes
72 private Quaternion m_sitTargetOrientation = new Quaternion(0, 0, 0, 1); 72 private Quaternion m_sitTargetOrientation = new Quaternion(0, 0, 0, 1);
73 private LLUUID m_SitTargetAvatar = LLUUID.Zero; 73 private LLUUID m_SitTargetAvatar = LLUUID.Zero;
74 74
75
76
75 77
76 // Main grid has default permissions as follows 78 // Main grid has default permissions as follows
77 // 79 //
@@ -345,6 +347,15 @@ namespace OpenSim.Region.Environment.Scenes
345 347
346 private string m_text = ""; 348 private string m_text = "";
347 349
350 public Vector3 SitTargetPosition
351 {
352 get { return m_sitTargetPosition; }
353 }
354 public Quaternion SitTargetOrientation
355 {
356 get { return m_sitTargetOrientation; }
357 }
358
348 public string Text 359 public string Text
349 { 360 {
350 get { return m_text; } 361 get { return m_text; }
@@ -786,6 +797,22 @@ namespace OpenSim.Region.Environment.Scenes
786 m_sitTargetPosition = offset; 797 m_sitTargetPosition = offset;
787 m_sitTargetOrientation = orientation; 798 m_sitTargetOrientation = orientation;
788 } 799 }
800 public LLVector3 GetSitTargetPositionLL()
801 {
802 return new LLVector3(m_sitTargetPosition.x, m_sitTargetPosition.y, m_sitTargetPosition.z);
803 }
804
805 public LLQuaternion GetSitTargetOrientationLL()
806 {
807 return new LLQuaternion(m_sitTargetOrientation.w, m_sitTargetOrientation.x, m_sitTargetOrientation.y, m_sitTargetOrientation.z);
808 }
809
810 // Utility function so the databases don't have to reference axiom.math
811 public void SetSitTargetLL(LLVector3 offset, LLQuaternion orientation)
812 {
813 m_sitTargetPosition = new Vector3(offset.X, offset.Y, offset.Z);
814 m_sitTargetOrientation = new Quaternion(orientation.W, orientation.X, orientation.Y, orientation.Z);
815 }
789 816
790 public Vector3 GetSitTargetPosition() 817 public Vector3 GetSitTargetPosition()
791 { 818 {
diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs
index c6210f7..91edf5e 100644
--- a/OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs
+++ b/OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs
@@ -391,6 +391,16 @@ namespace OpenSim.DataStore.MSSQL
391 createCol(prims, "RotationZ", typeof(System.Double)); 391 createCol(prims, "RotationZ", typeof(System.Double));
392 createCol(prims, "RotationW", typeof(System.Double)); 392 createCol(prims, "RotationW", typeof(System.Double));
393 393
394 // sit target
395 createCol(prims, "SitTargetOffsetX", typeof(System.Double));
396 createCol(prims, "SitTargetOffsetY", typeof(System.Double));
397 createCol(prims, "SitTargetOffsetZ", typeof(System.Double));
398
399 createCol(prims, "SitTargetOrientW", typeof(System.Double));
400 createCol(prims, "SitTargetOrientX", typeof(System.Double));
401 createCol(prims, "SitTargetOrientY", typeof(System.Double));
402 createCol(prims, "SitTargetOrientZ", typeof(System.Double));
403
394 // Add in contraints 404 // Add in contraints
395 prims.PrimaryKey = new DataColumn[] { prims.Columns["UUID"] }; 405 prims.PrimaryKey = new DataColumn[] { prims.Columns["UUID"] };
396 406
@@ -508,6 +518,22 @@ namespace OpenSim.DataStore.MSSQL
508 Convert.ToSingle(row["RotationW"]) 518 Convert.ToSingle(row["RotationW"])
509 ); 519 );
510 520
521 try
522 {
523 prim.SetSitTargetLL(new LLVector3(
524 Convert.ToSingle(row["SitTargetOffsetX"]),
525 Convert.ToSingle(row["SitTargetOffsetX"]),
526 Convert.ToSingle(row["SitTargetOffsetZ"])), new LLQuaternion(
527 Convert.ToSingle(row["SitTargetOrientW"]),
528 Convert.ToSingle(row["SitTargetOrientX"]),
529 Convert.ToSingle(row["SitTargetOrientY"]),
530 Convert.ToSingle(row["SitTargetOrientX"])));
531 }
532 catch (System.InvalidCastException)
533 {
534 // Database table was created before we got here and now has null values :P
535 }
536
511 return prim; 537 return prim;
512 } 538 }
513 539
@@ -557,6 +583,26 @@ namespace OpenSim.DataStore.MSSQL
557 row["RotationY"] = prim.RotationOffset.Y; 583 row["RotationY"] = prim.RotationOffset.Y;
558 row["RotationZ"] = prim.RotationOffset.Z; 584 row["RotationZ"] = prim.RotationOffset.Z;
559 row["RotationW"] = prim.RotationOffset.W; 585 row["RotationW"] = prim.RotationOffset.W;
586
587 try
588 {
589 // Sit target
590 LLVector3 sitTargetPos = prim.GetSitTargetPositionLL();
591 row["SitTargetOffsetX"] = sitTargetPos.X;
592 row["SitTargetOffsetY"] = sitTargetPos.Y;
593 row["SitTargetOffsetZ"] = sitTargetPos.Z;
594
595 LLQuaternion sitTargetOrient = prim.GetSitTargetOrientationLL();
596 row["SitTargetOrientW"] = sitTargetOrient.W;
597 row["SitTargetOrientX"] = sitTargetOrient.X;
598 row["SitTargetOrientY"] = sitTargetOrient.Y;
599 row["SitTargetOrientZ"] = sitTargetOrient.Z;
600 }
601 catch (System.Exception)
602 {
603 // TODO: Add Sit Target Rows!
604 }
605
560 } 606 }
561 607
562 private PrimitiveBaseShape buildShape(DataRow row) 608 private PrimitiveBaseShape buildShape(DataRow row)
diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs
index 6750e4d..5bf4551 100644
--- a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs
+++ b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs
@@ -56,6 +56,8 @@ namespace OpenSim.DataStore.MonoSqlite
56 private SqliteDataAdapter landDa; 56 private SqliteDataAdapter landDa;
57 private SqliteDataAdapter landAccessListDa; 57 private SqliteDataAdapter landAccessListDa;
58 58
59 private SqliteConnection m_conn;
60
59 private String m_connectionString; 61 private String m_connectionString;
60 62
61 private bool persistPrimInventories; 63 private bool persistPrimInventories;
@@ -77,6 +79,9 @@ namespace OpenSim.DataStore.MonoSqlite
77 MainLog.Instance.Verbose("DATASTORE", "Sqlite - connecting: " + connectionString); 79 MainLog.Instance.Verbose("DATASTORE", "Sqlite - connecting: " + connectionString);
78 SqliteConnection conn = new SqliteConnection(m_connectionString); 80 SqliteConnection conn = new SqliteConnection(m_connectionString);
79 81
82 // Arg! Hate databases..
83 m_conn = conn;
84
80 SqliteCommand primSelectCmd = new SqliteCommand(primSelect, conn); 85 SqliteCommand primSelectCmd = new SqliteCommand(primSelect, conn);
81 primDa = new SqliteDataAdapter(primSelectCmd); 86 primDa = new SqliteDataAdapter(primSelectCmd);
82 // SqliteCommandBuilder primCb = new SqliteCommandBuilder(primDa); 87 // SqliteCommandBuilder primCb = new SqliteCommandBuilder(primDa);
@@ -564,6 +569,16 @@ namespace OpenSim.DataStore.MonoSqlite
564 createCol(prims, "RotationZ", typeof (Double)); 569 createCol(prims, "RotationZ", typeof (Double));
565 createCol(prims, "RotationW", typeof (Double)); 570 createCol(prims, "RotationW", typeof (Double));
566 571
572 // sit target
573 createCol(prims, "SitTargetOffsetX", typeof(Double));
574 createCol(prims, "SitTargetOffsetY", typeof(Double));
575 createCol(prims, "SitTargetOffsetZ", typeof(Double));
576
577 createCol(prims, "SitTargetOrientW", typeof(Double));
578 createCol(prims, "SitTargetOrientX", typeof(Double));
579 createCol(prims, "SitTargetOrientY", typeof(Double));
580 createCol(prims, "SitTargetOrientZ", typeof(Double));
581
567 // Add in contraints 582 // Add in contraints
568 prims.PrimaryKey = new DataColumn[] {prims.Columns["UUID"]}; 583 prims.PrimaryKey = new DataColumn[] {prims.Columns["UUID"]};
569 584
@@ -764,6 +779,26 @@ namespace OpenSim.DataStore.MonoSqlite
764 Convert.ToSingle(row["RotationW"]) 779 Convert.ToSingle(row["RotationW"])
765 ); 780 );
766 781
782 try
783 {
784 prim.SetSitTargetLL(new LLVector3(
785 Convert.ToSingle(row["SitTargetOffsetX"]),
786 Convert.ToSingle(row["SitTargetOffsetX"]),
787 Convert.ToSingle(row["SitTargetOffsetZ"])), new LLQuaternion(
788 Convert.ToSingle(row["SitTargetOrientW"]),
789 Convert.ToSingle(row["SitTargetOrientX"]),
790 Convert.ToSingle(row["SitTargetOrientY"]),
791 Convert.ToSingle(row["SitTargetOrientX"])));
792 }
793 catch (System.InvalidCastException)
794 {
795 // Database table was created before we got here and now has null values :P
796 using (SqliteCommand cmd = new SqliteCommand("ALTER TABLE `prims` ADD COLUMN `SitTargetOffsetX` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetY` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetZ` float NOT NULL default 0, ADD COLUMN `SitTargetOrientW` float NOT NULL default 0, ADD COLUMN `SitTargetOrientX` float NOT NULL default 0, ADD COLUMN `SitTargetOrientY` float NOT NULL default 0, ADD COLUMN `SitTargetOrientZ` float NOT NULL default 0;", m_conn))
797 {
798 cmd.ExecuteNonQuery();
799 }
800 }
801
767 return prim; 802 return prim;
768 } 803 }
769 804
@@ -889,6 +924,18 @@ namespace OpenSim.DataStore.MonoSqlite
889 row["RotationY"] = prim.RotationOffset.Y; 924 row["RotationY"] = prim.RotationOffset.Y;
890 row["RotationZ"] = prim.RotationOffset.Z; 925 row["RotationZ"] = prim.RotationOffset.Z;
891 row["RotationW"] = prim.RotationOffset.W; 926 row["RotationW"] = prim.RotationOffset.W;
927
928 // Sit target
929 LLVector3 sitTargetPos = prim.GetSitTargetPositionLL();
930 row["SitTargetOffsetX"] = sitTargetPos.X;
931 row["SitTargetOffsetY"] = sitTargetPos.Y;
932 row["SitTargetOffsetZ"] = sitTargetPos.Z;
933
934 LLQuaternion sitTargetOrient = prim.GetSitTargetOrientationLL();
935 row["SitTargetOrientW"] = sitTargetOrient.W;
936 row["SitTargetOrientX"] = sitTargetOrient.X;
937 row["SitTargetOrientY"] = sitTargetOrient.Y;
938 row["SitTargetOrientZ"] = sitTargetOrient.Z;
892 } 939 }
893 940
894 private void fillLandRow(DataRow row, LandData land, LLUUID regionUUID) 941 private void fillLandRow(DataRow row, LandData land, LLUUID regionUUID)
@@ -1331,6 +1378,7 @@ namespace OpenSim.DataStore.MonoSqlite
1331 DataSet tmpDS = new DataSet(); 1378 DataSet tmpDS = new DataSet();
1332 try 1379 try
1333 { 1380 {
1381
1334 pDa.Fill(tmpDS, "prims"); 1382 pDa.Fill(tmpDS, "prims");
1335 sDa.Fill(tmpDS, "primshapes"); 1383 sDa.Fill(tmpDS, "primshapes");
1336 1384