aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
authorRobert Adams2013-10-16 08:13:06 -0700
committerRobert Adams2013-10-16 08:13:06 -0700
commitc5815060589fe733825c23a6638bbca20dd5994d (patch)
treeaf6cc7b148d81219721232fbd35b6d85665f586a /OpenSim/Data
parentMerge branch 'master' into varregion (diff)
downloadopensim-SC-c5815060589fe733825c23a6638bbca20dd5994d.zip
opensim-SC-c5815060589fe733825c23a6638bbca20dd5994d.tar.gz
opensim-SC-c5815060589fe733825c23a6638bbca20dd5994d.tar.bz2
opensim-SC-c5815060589fe733825c23a6638bbca20dd5994d.tar.xz
varregion: update PGSQL driver for storing variable terrain size blobs.
Diffstat (limited to 'OpenSim/Data')
-rw-r--r--OpenSim/Data/PGSQL/PGSQLSimulationData.cs45
1 files changed, 30 insertions, 15 deletions
diff --git a/OpenSim/Data/PGSQL/PGSQLSimulationData.cs b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs
index 69b0beb..433ffe9 100644
--- a/OpenSim/Data/PGSQL/PGSQLSimulationData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs
@@ -46,6 +46,7 @@ namespace OpenSim.Data.PGSQL
46 public class PGSQLSimulationData : ISimulationDataStore 46 public class PGSQLSimulationData : ISimulationDataStore
47 { 47 {
48 private const string _migrationStore = "RegionStore"; 48 private const string _migrationStore = "RegionStore";
49 private const string LogHeader = "[REGION DB PGSQL]";
49 50
50 // private static FileSystemDataStore Instance = new FileSystemDataStore(); 51 // private static FileSystemDataStore Instance = new FileSystemDataStore();
51 private static readonly ILog _Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 52 private static readonly ILog _Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -563,40 +564,54 @@ namespace OpenSim.Data.PGSQL
563 return terrain; 564 return terrain;
564 } 565 }
565 566
567 // Legacy entry point for when terrain was always a 256x256 heightmap
568 public void StoreTerrain(double[,] terrain, UUID regionID)
569 {
570 StoreTerrain(new HeightmapTerrainData(terrain), regionID);
571 }
572
566 /// <summary> 573 /// <summary>
567 /// Stores the terrain map to DB. 574 /// Stores the terrain map to DB.
568 /// </summary> 575 /// </summary>
569 /// <param name="terrain">terrain map data.</param> 576 /// <param name="terrain">terrain map data.</param>
570 /// <param name="regionID">regionID.</param> 577 /// <param name="regionID">regionID.</param>
571 public void StoreTerrain(double[,] terrain, UUID regionID) 578 public void StoreTerrain(TerrainData terrData, UUID regionID)
572 { 579 {
573 int revision = Util.UnixTimeSinceEpoch();
574
575 //Delete old terrain map 580 //Delete old terrain map
576 string sql = @"delete from terrain where ""RegionUUID""=:RegionUUID"; 581 string sql = @"delete from terrain where ""RegionUUID""=:RegionUUID";
577 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) 582 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
578 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
579 { 583 {
580 cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID)); 584 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
581 conn.Open(); 585 {
582 cmd.ExecuteNonQuery(); 586 cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID));
587 conn.Open();
588 cmd.ExecuteNonQuery();
589
590 _Log.InfoFormat("{0} Deleted terrain revision id = {1}", LogHeader, regionID);
591 }
583 } 592 }
584 593
585 _Log.Info("[REGION DB]: Deleted terrain revision r " + revision); 594 int terrainDBRevision;
595 Array terrainDBblob;
596 terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
586 597
587 sql = @"insert into terrain(""RegionUUID"", ""Revision"", ""Heightfield"") values(:RegionUUID, :Revision, :Heightfield)"; 598 sql = @"insert into terrain(""RegionUUID"", ""Revision"", ""Heightfield"") values(:RegionUUID, :Revision, :Heightfield)";
588 599
589 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) 600 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
590 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
591 { 601 {
592 cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID)); 602 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
593 cmd.Parameters.Add(_Database.CreateParameter("Revision", revision)); 603 {
594 cmd.Parameters.Add(_Database.CreateParameter("Heightfield", serializeTerrain(terrain))); 604 cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID));
595 conn.Open(); 605 cmd.Parameters.Add(_Database.CreateParameter("Revision", terrainDBRevision));
596 cmd.ExecuteNonQuery(); 606 cmd.Parameters.Add(_Database.CreateParameter("Heightfield", terrainDBblob));
607 conn.Open();
608 cmd.ExecuteNonQuery();
609
610 _Log.InfoFormat("{0} Stored terrain id = {1}, terrainSize = <{2},{3}>",
611 LogHeader, regionID, terrData.SizeX, terrData.SizeY);
612 }
597 } 613 }
598 614
599 _Log.Info("[REGION DB]: Stored terrain revision r " + revision);
600 } 615 }
601 616
602 /// <summary> 617 /// <summary>