aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/PGSQL/PGSQLSimulationData.cs
diff options
context:
space:
mode:
authorRobert Adams2013-11-01 11:35:31 -0700
committerRobert Adams2013-11-01 11:35:31 -0700
commitff5885ab234bc9a7efda49eea0e2200711c4933c (patch)
tree21ef180072b30891700f139792d34ca9b2c7e0d6 /OpenSim/Data/PGSQL/PGSQLSimulationData.cs
parentvarregion: fix problem of X/Y dimensions swapped and incorrect terrain (diff)
downloadopensim-SC_OLD-ff5885ab234bc9a7efda49eea0e2200711c4933c.zip
opensim-SC_OLD-ff5885ab234bc9a7efda49eea0e2200711c4933c.tar.gz
opensim-SC_OLD-ff5885ab234bc9a7efda49eea0e2200711c4933c.tar.bz2
opensim-SC_OLD-ff5885ab234bc9a7efda49eea0e2200711c4933c.tar.xz
varregion: push TerrainData implementation up and down the database storage stack.
Implement both LoadTerrain and StoreTerrain for all DBs. Move all database blob serialization/deserialization into TerrainData.
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/PGSQL/PGSQLSimulationData.cs48
1 files changed, 24 insertions, 24 deletions
diff --git a/OpenSim/Data/PGSQL/PGSQLSimulationData.cs b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs
index 433ffe9..34eb038 100644
--- a/OpenSim/Data/PGSQL/PGSQLSimulationData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs
@@ -524,44 +524,44 @@ namespace OpenSim.Data.PGSQL
524 /// <returns></returns> 524 /// <returns></returns>
525 public double[,] LoadTerrain(UUID regionID) 525 public double[,] LoadTerrain(UUID regionID)
526 { 526 {
527 double[,] terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; 527 TerrainData terrData = LoadTerrain(regionID, (int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionHeight);
528 terrain.Initialize(); 528 return terrData.GetDoubles();
529 }
530
531 public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
532 {
533 TerrainData terrData = null;
529 534
530 string sql = @"select ""RegionUUID"", ""Revision"", ""Heightfield"" from terrain 535 string sql = @"select ""RegionUUID"", ""Revision"", ""Heightfield"" from terrain
531 where ""RegionUUID"" = :RegionUUID order by ""Revision"" desc limit 1; "; 536 where ""RegionUUID"" = :RegionUUID order by ""Revision"" desc limit 1; ";
532 537
533 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) 538 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
534 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
535 { 539 {
536 // PGSqlParameter param = new PGSqlParameter(); 540 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
537 cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID));
538 conn.Open();
539 using (NpgsqlDataReader reader = cmd.ExecuteReader())
540 { 541 {
541 int rev; 542 // PGSqlParameter param = new PGSqlParameter();
542 if (reader.Read()) 543 cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID));
544 conn.Open();
545 using (NpgsqlDataReader reader = cmd.ExecuteReader())
543 { 546 {
544 MemoryStream str = new MemoryStream((byte[])reader["Heightfield"]); 547 int rev;
545 BinaryReader br = new BinaryReader(str); 548 if (reader.Read())
546 for (int x = 0; x < (int)Constants.RegionSize; x++)
547 { 549 {
548 for (int y = 0; y < (int)Constants.RegionSize; y++) 550 rev = Convert.ToInt32(reader["Revision"]);
549 { 551 byte[] blob = (byte[])reader["Heightfield"];
550 terrain[x, y] = br.ReadDouble(); 552 terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob);
551 }
552 } 553 }
553 rev = (int)reader["Revision"]; 554 else
554 } 555 {
555 else 556 _Log.Info("[REGION DB]: No terrain found for region");
556 { 557 return null;
557 _Log.Info("[REGION DB]: No terrain found for region"); 558 }
558 return null; 559 _Log.Info("[REGION DB]: Loaded terrain revision r" + rev);
559 } 560 }
560 _Log.Info("[REGION DB]: Loaded terrain revision r" + rev);
561 } 561 }
562 } 562 }
563 563
564 return terrain; 564 return terrData;
565 } 565 }
566 566
567 // Legacy entry point for when terrain was always a 256x256 heightmap 567 // Legacy entry point for when terrain was always a 256x256 heightmap