aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/PGSQL
diff options
context:
space:
mode:
authorUbitUmarov2016-09-18 20:02:59 +0100
committerUbitUmarov2016-09-18 20:02:59 +0100
commit82997c5907bcb0591b815ed9343e9d2c56ba5710 (patch)
tree699c875eb48f6efa3ca2c8b5d22315df20b5130f /OpenSim/Data/PGSQL
parentMerge branch 'master' into httptests (diff)
parentfix typo in table name, thx tglion (diff)
downloadopensim-SC-82997c5907bcb0591b815ed9343e9d2c56ba5710.zip
opensim-SC-82997c5907bcb0591b815ed9343e9d2c56ba5710.tar.gz
opensim-SC-82997c5907bcb0591b815ed9343e9d2c56ba5710.tar.bz2
opensim-SC-82997c5907bcb0591b815ed9343e9d2c56ba5710.tar.xz
Merge branch 'master' into httptests
Diffstat (limited to 'OpenSim/Data/PGSQL')
-rwxr-xr-xOpenSim/Data/PGSQL/PGSQLSimulationData.cs76
-rw-r--r--OpenSim/Data/PGSQL/Resources/RegionStore.migrations13
2 files changed, 89 insertions, 0 deletions
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;
1182ALTER TABLE prims ADD "RotationAxisLocks" smallint NOT NULL DEFAULT (0); 1182ALTER TABLE prims ADD "RotationAxisLocks" smallint NOT NULL DEFAULT (0);
1183 1183
1184COMMIT; 1184COMMIT;
1185
1186:VERSION 44 #---- add baked terrain store
1187
1188BEGIN TRANSACTION;
1189
1190CREATE TABLE bakedterrain
1191 (
1192 "RegionUUID" uuid NULL,
1193 "Revision" int NULL,
1194 "Heightfield" bytea NULL
1195 );
1196
1197COMMIT;