diff options
Diffstat (limited to 'OpenSim/Data/PGSQL/PGSQLSimulationData.cs')
-rw-r--r-- | OpenSim/Data/PGSQL/PGSQLSimulationData.cs | 72 |
1 files changed, 24 insertions, 48 deletions
diff --git a/OpenSim/Data/PGSQL/PGSQLSimulationData.cs b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs index cd02e05..77d87d4 100644 --- a/OpenSim/Data/PGSQL/PGSQLSimulationData.cs +++ b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs | |||
@@ -540,26 +540,28 @@ namespace OpenSim.Data.PGSQL | |||
540 | where ""RegionUUID"" = :RegionUUID order by ""Revision"" desc limit 1; "; | 540 | where ""RegionUUID"" = :RegionUUID order by ""Revision"" desc limit 1; "; |
541 | 541 | ||
542 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) | 542 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
543 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) | ||
544 | { | 543 | { |
545 | // PGSqlParameter param = new PGSqlParameter(); | 544 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
546 | cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID)); | ||
547 | conn.Open(); | ||
548 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) | ||
549 | { | 545 | { |
550 | int rev; | 546 | // PGSqlParameter param = new PGSqlParameter(); |
551 | if (reader.Read()) | 547 | cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID)); |
552 | { | 548 | conn.Open(); |
553 | rev = Convert.ToInt32(reader["Revision"]); | 549 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) |
554 | byte[] blob = (byte[])reader["Heightfield"]; | ||
555 | terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob); | ||
556 | } | ||
557 | else | ||
558 | { | 550 | { |
559 | _Log.Info("[REGION DB]: No terrain found for region"); | 551 | int rev; |
560 | return null; | 552 | if (reader.Read()) |
553 | { | ||
554 | rev = Convert.ToInt32(reader["Revision"]); | ||
555 | byte[] blob = (byte[])reader["Heightfield"]; | ||
556 | terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob); | ||
557 | } | ||
558 | else | ||
559 | { | ||
560 | _Log.Info("[REGION DB]: No terrain found for region"); | ||
561 | return null; | ||
562 | } | ||
563 | _Log.Info("[REGION DB]: Loaded terrain revision r" + rev); | ||
561 | } | 564 | } |
562 | _Log.Info("[REGION DB]: Loaded terrain revision r" + rev); | ||
563 | } | 565 | } |
564 | } | 566 | } |
565 | 567 | ||
@@ -588,8 +590,11 @@ namespace OpenSim.Data.PGSQL | |||
588 | cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID)); | 590 | cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID)); |
589 | conn.Open(); | 591 | conn.Open(); |
590 | cmd.ExecuteNonQuery(); | 592 | cmd.ExecuteNonQuery(); |
593 | |||
594 | _Log.InfoFormat("{0} Deleted terrain revision id = {1}", LogHeader, regionID); | ||
591 | } | 595 | } |
592 | } | 596 | } |
597 | |||
593 | int terrainDBRevision; | 598 | int terrainDBRevision; |
594 | Array terrainDBblob; | 599 | Array terrainDBblob; |
595 | terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob); | 600 | terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob); |
@@ -605,10 +610,12 @@ namespace OpenSim.Data.PGSQL | |||
605 | cmd.Parameters.Add(_Database.CreateParameter("Heightfield", terrainDBblob)); | 610 | cmd.Parameters.Add(_Database.CreateParameter("Heightfield", terrainDBblob)); |
606 | conn.Open(); | 611 | conn.Open(); |
607 | cmd.ExecuteNonQuery(); | 612 | cmd.ExecuteNonQuery(); |
613 | |||
614 | _Log.InfoFormat("{0} Stored terrain id = {1}, terrainSize = <{2},{3}>", | ||
615 | LogHeader, regionID, terrData.SizeX, terrData.SizeY); | ||
608 | } | 616 | } |
609 | } | 617 | } |
610 | 618 | ||
611 | _Log.Info("[REGION DB]: Stored terrain revision r " + terrainDBRevision); | ||
612 | } | 619 | } |
613 | 620 | ||
614 | /// <summary> | 621 | /// <summary> |
@@ -1361,32 +1368,6 @@ namespace OpenSim.Data.PGSQL | |||
1361 | 1368 | ||
1362 | #region Private Methods | 1369 | #region Private Methods |
1363 | 1370 | ||
1364 | /* | ||
1365 | /// <summary> | ||
1366 | /// Serializes the terrain data for storage in DB. | ||
1367 | /// </summary> | ||
1368 | /// <param name="val">terrain data</param> | ||
1369 | /// <returns></returns> | ||
1370 | private static Array serializeTerrain(double[,] val) | ||
1371 | { | ||
1372 | MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) * sizeof(double)); | ||
1373 | BinaryWriter bw = new BinaryWriter(str); | ||
1374 | |||
1375 | // TODO: COMPATIBILITY - Add byte-order conversions | ||
1376 | for (int x = 0; x < (int)Constants.RegionSize; x++) | ||
1377 | for (int y = 0; y < (int)Constants.RegionSize; y++) | ||
1378 | { | ||
1379 | double height = val[x, y]; | ||
1380 | if (height == 0.0) | ||
1381 | height = double.Epsilon; | ||
1382 | |||
1383 | bw.Write(height); | ||
1384 | } | ||
1385 | |||
1386 | return str.ToArray(); | ||
1387 | } | ||
1388 | */ | ||
1389 | |||
1390 | /// <summary> | 1371 | /// <summary> |
1391 | /// Stores new regionsettings. | 1372 | /// Stores new regionsettings. |
1392 | /// </summary> | 1373 | /// </summary> |
@@ -2246,11 +2227,6 @@ namespace OpenSim.Data.PGSQL | |||
2246 | } | 2227 | } |
2247 | } | 2228 | } |
2248 | 2229 | ||
2249 | public UUID[] GetObjectIDs(UUID regionID) | ||
2250 | { | ||
2251 | return new UUID[0]; | ||
2252 | } | ||
2253 | |||
2254 | public void SaveExtra(UUID regionID, string name, string value) | 2230 | public void SaveExtra(UUID regionID, string name, string value) |
2255 | { | 2231 | { |
2256 | } | 2232 | } |