diff options
Diffstat (limited to 'OpenSim/Data')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLSimulationData.cs | 82 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/Resources/RegionStore.migrations | 11 | ||||
-rw-r--r-- | OpenSim/Data/Null/NullSimulationData.cs | 17 | ||||
-rwxr-xr-x | OpenSim/Data/PGSQL/PGSQLSimulationData.cs | 76 | ||||
-rw-r--r-- | OpenSim/Data/PGSQL/Resources/RegionStore.migrations | 13 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/Resources/RegionStore.migrations | 11 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteSimulationData.cs | 74 |
7 files changed, 280 insertions, 4 deletions
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 46364a5..ab24b76 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs | |||
@@ -639,6 +639,53 @@ namespace OpenSim.Data.MySQL | |||
639 | }); | 639 | }); |
640 | } | 640 | } |
641 | 641 | ||
642 | public void StoreBakedTerrain(TerrainData terrData, UUID regionID) | ||
643 | { | ||
644 | Util.FireAndForget(delegate(object x) | ||
645 | { | ||
646 | m_log.Info("[REGION DB]: Storing Baked terrain"); | ||
647 | |||
648 | lock (m_dbLock) | ||
649 | { | ||
650 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
651 | { | ||
652 | dbcon.Open(); | ||
653 | |||
654 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
655 | { | ||
656 | cmd.CommandText = "delete from bakedterrain where RegionUUID = ?RegionUUID"; | ||
657 | cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); | ||
658 | |||
659 | using (MySqlCommand cmd2 = dbcon.CreateCommand()) | ||
660 | { | ||
661 | try | ||
662 | { | ||
663 | cmd2.CommandText = "insert into bakedterrain (RegionUUID, " + | ||
664 | "Revision, Heightfield) values (?RegionUUID, " + | ||
665 | "?Revision, ?Heightfield)"; | ||
666 | |||
667 | int terrainDBRevision; | ||
668 | Array terrainDBblob; | ||
669 | terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob); | ||
670 | |||
671 | cmd2.Parameters.AddWithValue("RegionUUID", regionID.ToString()); | ||
672 | cmd2.Parameters.AddWithValue("Revision", terrainDBRevision); | ||
673 | cmd2.Parameters.AddWithValue("Heightfield", terrainDBblob); | ||
674 | |||
675 | ExecuteNonQuery(cmd); | ||
676 | ExecuteNonQuery(cmd2); | ||
677 | } | ||
678 | catch (Exception e) | ||
679 | { | ||
680 | m_log.ErrorFormat(e.ToString()); | ||
681 | } | ||
682 | } | ||
683 | } | ||
684 | } | ||
685 | } | ||
686 | }); | ||
687 | } | ||
688 | |||
642 | // Legacy region loading | 689 | // Legacy region loading |
643 | public virtual double[,] LoadTerrain(UUID regionID) | 690 | public virtual double[,] LoadTerrain(UUID regionID) |
644 | { | 691 | { |
@@ -686,6 +733,41 @@ namespace OpenSim.Data.MySQL | |||
686 | return terrData; | 733 | return terrData; |
687 | } | 734 | } |
688 | 735 | ||
736 | public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) | ||
737 | { | ||
738 | TerrainData terrData = null; | ||
739 | |||
740 | lock (m_dbLock) | ||
741 | { | ||
742 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | ||
743 | { | ||
744 | dbcon.Open(); | ||
745 | |||
746 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
747 | { | ||
748 | cmd.CommandText = "select RegionUUID, Revision, Heightfield " + | ||
749 | "from bakedterrain where RegionUUID = ?RegionUUID "; | ||
750 | cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); | ||
751 | |||
752 | using (IDataReader reader = ExecuteReader(cmd)) | ||
753 | { | ||
754 | while (reader.Read()) | ||
755 | { | ||
756 | int rev = Convert.ToInt32(reader["Revision"]); | ||
757 | if ((reader["Heightfield"] != DBNull.Value)) | ||
758 | { | ||
759 | byte[] blob = (byte[])reader["Heightfield"]; | ||
760 | terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob); | ||
761 | } | ||
762 | } | ||
763 | } | ||
764 | } | ||
765 | } | ||
766 | } | ||
767 | |||
768 | return terrData; | ||
769 | } | ||
770 | |||
689 | public virtual void RemoveLandObject(UUID globalID) | 771 | public virtual void RemoveLandObject(UUID globalID) |
690 | { | 772 | { |
691 | lock (m_dbLock) | 773 | lock (m_dbLock) |
diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations index c32f645..1de5a01 100644 --- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations | |||
@@ -379,3 +379,14 @@ ALTER TABLE `prims` ADD COLUMN `RotationAxisLocks` tinyint(4) NOT NULL default ' | |||
379 | 379 | ||
380 | COMMIT; | 380 | COMMIT; |
381 | 381 | ||
382 | :VERSION 54 #----- add baked terrain store | ||
383 | |||
384 | BEGIN; | ||
385 | |||
386 | CREATE TABLE IF NOT EXISTS `bakedterrain` ( | ||
387 | `RegionUUID` varchar(255) DEFAULT NULL, | ||
388 | `Revision` int(11) DEFAULT NULL, | ||
389 | `Heightfield` longblob | ||
390 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
391 | |||
392 | COMMIT; | ||
diff --git a/OpenSim/Data/Null/NullSimulationData.cs b/OpenSim/Data/Null/NullSimulationData.cs index 339e7f4..7bb6da3 100644 --- a/OpenSim/Data/Null/NullSimulationData.cs +++ b/OpenSim/Data/Null/NullSimulationData.cs | |||
@@ -133,6 +133,7 @@ namespace OpenSim.Data.Null | |||
133 | } | 133 | } |
134 | 134 | ||
135 | Dictionary<UUID, TerrainData> m_terrains = new Dictionary<UUID, TerrainData>(); | 135 | Dictionary<UUID, TerrainData> m_terrains = new Dictionary<UUID, TerrainData>(); |
136 | Dictionary<UUID, TerrainData> m_bakedterrains = new Dictionary<UUID, TerrainData>(); | ||
136 | public void StoreTerrain(TerrainData ter, UUID regionID) | 137 | public void StoreTerrain(TerrainData ter, UUID regionID) |
137 | { | 138 | { |
138 | if (m_terrains.ContainsKey(regionID)) | 139 | if (m_terrains.ContainsKey(regionID)) |
@@ -140,6 +141,13 @@ namespace OpenSim.Data.Null | |||
140 | m_terrains.Add(regionID, ter); | 141 | m_terrains.Add(regionID, ter); |
141 | } | 142 | } |
142 | 143 | ||
144 | public void StoreBakedTerrain(TerrainData ter, UUID regionID) | ||
145 | { | ||
146 | if (m_bakedterrains.ContainsKey(regionID)) | ||
147 | m_bakedterrains.Remove(regionID); | ||
148 | m_bakedterrains.Add(regionID, ter); | ||
149 | } | ||
150 | |||
143 | // Legacy. Just don't do this. | 151 | // Legacy. Just don't do this. |
144 | public void StoreTerrain(double[,] ter, UUID regionID) | 152 | public void StoreTerrain(double[,] ter, UUID regionID) |
145 | { | 153 | { |
@@ -167,6 +175,15 @@ namespace OpenSim.Data.Null | |||
167 | return null; | 175 | return null; |
168 | } | 176 | } |
169 | 177 | ||
178 | public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) | ||
179 | { | ||
180 | if (m_bakedterrains.ContainsKey(regionID)) | ||
181 | { | ||
182 | return m_bakedterrains[regionID]; | ||
183 | } | ||
184 | return null; | ||
185 | } | ||
186 | |||
170 | public void RemoveLandObject(UUID globalID) | 187 | public void RemoveLandObject(UUID globalID) |
171 | { | 188 | { |
172 | } | 189 | } |
diff --git a/OpenSim/Data/PGSQL/PGSQLSimulationData.cs b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs index 25e1a7f..902aae0 100755 --- a/OpenSim/Data/PGSQL/PGSQLSimulationData.cs +++ b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs | |||
@@ -573,6 +573,39 @@ namespace OpenSim.Data.PGSQL | |||
573 | return terrData; | 573 | return terrData; |
574 | } | 574 | } |
575 | 575 | ||
576 | public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) | ||
577 | { | ||
578 | TerrainData terrData = null; | ||
579 | |||
580 | string sql = @"select ""RegionUUID"", ""Revision"", ""Heightfield"" from bakedterrain | ||
581 | where ""RegionUUID"" = :RegionUUID; "; | ||
582 | |||
583 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) | ||
584 | { | ||
585 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) | ||
586 | { | ||
587 | // PGSqlParameter param = new PGSqlParameter(); | ||
588 | cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID)); | ||
589 | conn.Open(); | ||
590 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) | ||
591 | { | ||
592 | int rev; | ||
593 | if (reader.Read()) | ||
594 | { | ||
595 | rev = Convert.ToInt32(reader["Revision"]); | ||
596 | if ((reader["Heightfield"] != DBNull.Value)) | ||
597 | { | ||
598 | byte[] blob = (byte[])reader["Heightfield"]; | ||
599 | terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob); | ||
600 | } | ||
601 | } | ||
602 | } | ||
603 | } | ||
604 | } | ||
605 | |||
606 | return terrData; | ||
607 | } | ||
608 | |||
576 | // Legacy entry point for when terrain was always a 256x256 heightmap | 609 | // Legacy entry point for when terrain was always a 256x256 heightmap |
577 | public void StoreTerrain(double[,] terrain, UUID regionID) | 610 | public void StoreTerrain(double[,] terrain, UUID regionID) |
578 | { | 611 | { |
@@ -624,6 +657,49 @@ namespace OpenSim.Data.PGSQL | |||
624 | } | 657 | } |
625 | 658 | ||
626 | /// <summary> | 659 | /// <summary> |
660 | /// Stores the baked terrain map to DB. | ||
661 | /// </summary> | ||
662 | /// <param name="terrain">terrain map data.</param> | ||
663 | /// <param name="regionID">regionID.</param> | ||
664 | public void StoreBakedTerrain(TerrainData terrData, UUID regionID) | ||
665 | { | ||
666 | //Delete old terrain map | ||
667 | string sql = @"delete from bakedterrain where ""RegionUUID""=:RegionUUID"; | ||
668 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) | ||
669 | { | ||
670 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) | ||
671 | { | ||
672 | cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID)); | ||
673 | conn.Open(); | ||
674 | cmd.ExecuteNonQuery(); | ||
675 | |||
676 | _Log.InfoFormat("{0} Deleted bakedterrain id = {1}", LogHeader, regionID); | ||
677 | } | ||
678 | } | ||
679 | |||
680 | int terrainDBRevision; | ||
681 | Array terrainDBblob; | ||
682 | terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob); | ||
683 | |||
684 | sql = @"insert into bakedterrain(""RegionUUID"", ""Revision"", ""Heightfield"") values(:RegionUUID, :Revision, :Heightfield)"; | ||
685 | |||
686 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) | ||
687 | { | ||
688 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) | ||
689 | { | ||
690 | cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID)); | ||
691 | cmd.Parameters.Add(_Database.CreateParameter("Revision", terrainDBRevision)); | ||
692 | cmd.Parameters.Add(_Database.CreateParameter("Heightfield", terrainDBblob)); | ||
693 | conn.Open(); | ||
694 | cmd.ExecuteNonQuery(); | ||
695 | |||
696 | _Log.InfoFormat("{0} Stored bakedterrain id = {1}, terrainSize = <{2},{3}>", | ||
697 | LogHeader, regionID, terrData.SizeX, terrData.SizeY); | ||
698 | } | ||
699 | } | ||
700 | } | ||
701 | |||
702 | /// <summary> | ||
627 | /// Loads all the land objects of a region. | 703 | /// Loads all the land objects of a region. |
628 | /// </summary> | 704 | /// </summary> |
629 | /// <param name="regionUUID">The region UUID.</param> | 705 | /// <param name="regionUUID">The region UUID.</param> |
diff --git a/OpenSim/Data/PGSQL/Resources/RegionStore.migrations b/OpenSim/Data/PGSQL/Resources/RegionStore.migrations index 9a2c19b..c085939 100644 --- a/OpenSim/Data/PGSQL/Resources/RegionStore.migrations +++ b/OpenSim/Data/PGSQL/Resources/RegionStore.migrations | |||
@@ -1182,3 +1182,16 @@ BEGIN TRANSACTION; | |||
1182 | ALTER TABLE prims ADD "RotationAxisLocks" smallint NOT NULL DEFAULT (0); | 1182 | ALTER TABLE prims ADD "RotationAxisLocks" smallint NOT NULL DEFAULT (0); |
1183 | 1183 | ||
1184 | COMMIT; | 1184 | COMMIT; |
1185 | |||
1186 | :VERSION 44 #---- add baked terrain store | ||
1187 | |||
1188 | BEGIN TRANSACTION; | ||
1189 | |||
1190 | CREATE TABLE bakedterrain | ||
1191 | ( | ||
1192 | "RegionUUID" uuid NULL, | ||
1193 | "Revision" int NULL, | ||
1194 | "Heightfield" bytea NULL | ||
1195 | ); | ||
1196 | |||
1197 | COMMIT; | ||
diff --git a/OpenSim/Data/SQLite/Resources/RegionStore.migrations b/OpenSim/Data/SQLite/Resources/RegionStore.migrations index 25f3ad9..64624db 100644 --- a/OpenSim/Data/SQLite/Resources/RegionStore.migrations +++ b/OpenSim/Data/SQLite/Resources/RegionStore.migrations | |||
@@ -352,3 +352,14 @@ BEGIN; | |||
352 | ALTER TABLE prims ADD COLUMN `RotationAxisLocks` tinyint(4) NOT NULL default '0'; | 352 | ALTER TABLE prims ADD COLUMN `RotationAxisLocks` tinyint(4) NOT NULL default '0'; |
353 | 353 | ||
354 | COMMIT; | 354 | COMMIT; |
355 | |||
356 | :VERSION 34 #---- add baked terrain store | ||
357 | |||
358 | BEGIN; | ||
359 | |||
360 | CREATE TABLE IF NOT EXISTS bakedterrain( | ||
361 | RegionUUID varchar(255), | ||
362 | Revision integer, | ||
363 | Heightfield blob); | ||
364 | |||
365 | COMMIT; | ||
diff --git a/OpenSim/Data/SQLite/SQLiteSimulationData.cs b/OpenSim/Data/SQLite/SQLiteSimulationData.cs index cd20c4e..c1c7b7e 100644 --- a/OpenSim/Data/SQLite/SQLiteSimulationData.cs +++ b/OpenSim/Data/SQLite/SQLiteSimulationData.cs | |||
@@ -827,7 +827,7 @@ namespace OpenSim.Data.SQLite | |||
827 | } | 827 | } |
828 | 828 | ||
829 | /// <summary> | 829 | /// <summary> |
830 | /// Store a terrain revision in region storage | 830 | /// Store a terrain in region storage |
831 | /// </summary> | 831 | /// </summary> |
832 | /// <param name="ter">terrain heightfield</param> | 832 | /// <param name="ter">terrain heightfield</param> |
833 | /// <param name="regionID">region UUID</param> | 833 | /// <param name="regionID">region UUID</param> |
@@ -851,7 +851,44 @@ namespace OpenSim.Data.SQLite | |||
851 | Array terrainDBblob; | 851 | Array terrainDBblob; |
852 | terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob); | 852 | terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob); |
853 | 853 | ||
854 | m_log.DebugFormat("{0} Storing terrain revision r {1}", LogHeader, terrainDBRevision); | 854 | m_log.DebugFormat("{0} Storing terrain format {1}", LogHeader, terrainDBRevision); |
855 | |||
856 | using (SqliteCommand cmd = new SqliteCommand(sql, m_conn)) | ||
857 | { | ||
858 | cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString())); | ||
859 | cmd.Parameters.Add(new SqliteParameter(":Revision", terrainDBRevision)); | ||
860 | cmd.Parameters.Add(new SqliteParameter(":Heightfield", terrainDBblob)); | ||
861 | cmd.ExecuteNonQuery(); | ||
862 | } | ||
863 | } | ||
864 | } | ||
865 | |||
866 | /// <summary> | ||
867 | /// Store baked terrain in region storage | ||
868 | /// </summary> | ||
869 | /// <param name="ter">terrain heightfield</param> | ||
870 | /// <param name="regionID">region UUID</param> | ||
871 | public void StoreBakedTerrain(TerrainData terrData, UUID regionID) | ||
872 | { | ||
873 | lock (ds) | ||
874 | { | ||
875 | using ( | ||
876 | SqliteCommand cmd = new SqliteCommand("delete from bakedterrain where RegionUUID=:RegionUUID", m_conn)) | ||
877 | { | ||
878 | cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString())); | ||
879 | cmd.ExecuteNonQuery(); | ||
880 | } | ||
881 | |||
882 | // the following is an work around for .NET. The perf | ||
883 | // issues associated with it aren't as bad as you think. | ||
884 | String sql = "insert into bakedterrain(RegionUUID, Revision, Heightfield)" + | ||
885 | " values(:RegionUUID, :Revision, :Heightfield)"; | ||
886 | |||
887 | int terrainDBRevision; | ||
888 | Array terrainDBblob; | ||
889 | terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob); | ||
890 | |||
891 | m_log.DebugFormat("{0} Storing bakedterrain format {1}", LogHeader, terrainDBRevision); | ||
855 | 892 | ||
856 | using (SqliteCommand cmd = new SqliteCommand(sql, m_conn)) | 893 | using (SqliteCommand cmd = new SqliteCommand(sql, m_conn)) |
857 | { | 894 | { |
@@ -913,6 +950,34 @@ namespace OpenSim.Data.SQLite | |||
913 | return terrData; | 950 | return terrData; |
914 | } | 951 | } |
915 | 952 | ||
953 | public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) | ||
954 | { | ||
955 | TerrainData terrData = null; | ||
956 | |||
957 | lock (ds) | ||
958 | { | ||
959 | String sql = "select RegionUUID, Revision, Heightfield from bakedterrain" + | ||
960 | " where RegionUUID=:RegionUUID"; | ||
961 | |||
962 | using (SqliteCommand cmd = new SqliteCommand(sql, m_conn)) | ||
963 | { | ||
964 | cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString())); | ||
965 | |||
966 | using (IDataReader row = cmd.ExecuteReader()) | ||
967 | { | ||
968 | int rev = 0; | ||
969 | if (row.Read()) | ||
970 | { | ||
971 | rev = Convert.ToInt32(row["Revision"]); | ||
972 | byte[] blob = (byte[])row["Heightfield"]; | ||
973 | terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob); | ||
974 | } | ||
975 | } | ||
976 | } | ||
977 | } | ||
978 | return terrData; | ||
979 | } | ||
980 | |||
916 | public void RemoveLandObject(UUID globalID) | 981 | public void RemoveLandObject(UUID globalID) |
917 | { | 982 | { |
918 | lock (ds) | 983 | lock (ds) |
@@ -1354,7 +1419,7 @@ namespace OpenSim.Data.SQLite | |||
1354 | createCol(land, "Name", typeof(String)); | 1419 | createCol(land, "Name", typeof(String)); |
1355 | createCol(land, "Desc", typeof(String)); | 1420 | createCol(land, "Desc", typeof(String)); |
1356 | createCol(land, "OwnerUUID", typeof(String)); | 1421 | createCol(land, "OwnerUUID", typeof(String)); |
1357 | createCol(land, "IsGroupOwned", typeof(String)); | 1422 | createCol(land, "IsGroupOwned", typeof(string)); |
1358 | createCol(land, "Area", typeof(Int32)); | 1423 | createCol(land, "Area", typeof(Int32)); |
1359 | createCol(land, "AuctionID", typeof(Int32)); //Unemplemented | 1424 | createCol(land, "AuctionID", typeof(Int32)); //Unemplemented |
1360 | createCol(land, "Category", typeof(Int32)); //Enum OpenMetaverse.Parcel.ParcelCategory | 1425 | createCol(land, "Category", typeof(Int32)); //Enum OpenMetaverse.Parcel.ParcelCategory |
@@ -2942,7 +3007,8 @@ namespace OpenSim.Data.SQLite | |||
2942 | { | 3007 | { |
2943 | return DbType.Binary; | 3008 | return DbType.Binary; |
2944 | } | 3009 | } |
2945 | else if (type == typeof(Boolean)) { | 3010 | else if (type == typeof(Boolean)) |
3011 | { | ||
2946 | return DbType.Boolean; | 3012 | return DbType.Boolean; |
2947 | } | 3013 | } |
2948 | else | 3014 | else |