diff options
author | Robert Adams | 2013-10-02 16:59:37 -0700 |
---|---|---|
committer | Robert Adams | 2013-10-07 13:57:40 -0700 |
commit | 7416809077227f35ab70ed44060e51f2bcf66937 (patch) | |
tree | 7578cbfed07777d5c60af986791dc7d8b09b2cd5 /OpenSim/Data/MySQL | |
parent | varregion: remove scattered use of Constants.RegionSize by having routines re... (diff) | |
download | opensim-SC_OLD-7416809077227f35ab70ed44060e51f2bcf66937.zip opensim-SC_OLD-7416809077227f35ab70ed44060e51f2bcf66937.tar.gz opensim-SC_OLD-7416809077227f35ab70ed44060e51f2bcf66937.tar.bz2 opensim-SC_OLD-7416809077227f35ab70ed44060e51f2bcf66937.tar.xz |
varregion: plug in TerrainData class and modify TerrainModule and LLClientView to use same. This passes a terrain info class around rather than passing a one dimensional array thus allowing variable regions. Update the database storage for variable region sizes. This should be downward compatible (same format for 256x256 regions).
Diffstat (limited to 'OpenSim/Data/MySQL')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLSimulationData.cs | 47 |
1 files changed, 17 insertions, 30 deletions
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 5751dc8..4bd8617 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs | |||
@@ -48,6 +48,7 @@ namespace OpenSim.Data.MySQL | |||
48 | public class MySQLSimulationData : ISimulationDataStore | 48 | public class MySQLSimulationData : ISimulationDataStore |
49 | { | 49 | { |
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
51 | private static string LogHeader = "[REGION DB MYSQL]"; | ||
51 | 52 | ||
52 | private string m_connectionString; | 53 | private string m_connectionString; |
53 | private object m_dbLock = new object(); | 54 | private object m_dbLock = new object(); |
@@ -91,7 +92,7 @@ namespace OpenSim.Data.MySQL | |||
91 | } | 92 | } |
92 | catch (Exception e) | 93 | catch (Exception e) |
93 | { | 94 | { |
94 | m_log.Error("[REGION DB]: MySQL error in ExecuteReader: " + e.Message); | 95 | m_log.ErrorFormat("{0} MySQL error in ExecuteReader: {1}", LogHeader, e); |
95 | throw; | 96 | throw; |
96 | } | 97 | } |
97 | 98 | ||
@@ -572,11 +573,14 @@ namespace OpenSim.Data.MySQL | |||
572 | } | 573 | } |
573 | } | 574 | } |
574 | 575 | ||
576 | // Legacy entry point for when terrain was always a 256x256 hieghtmap | ||
575 | public void StoreTerrain(double[,] ter, UUID regionID) | 577 | public void StoreTerrain(double[,] ter, UUID regionID) |
576 | { | 578 | { |
577 | m_log.Info("[REGION DB]: Storing terrain"); | 579 | StoreTerrain(new HeightmapTerrainData(ter), regionID); |
578 | int revision = (int)DBTerrainRevision.Legacy256; | 580 | } |
579 | 581 | ||
582 | public void StoreTerrain(TerrainData terrData, UUID regionID) | ||
583 | { | ||
580 | lock (m_dbLock) | 584 | lock (m_dbLock) |
581 | { | 585 | { |
582 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 586 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
@@ -590,11 +594,18 @@ namespace OpenSim.Data.MySQL | |||
590 | 594 | ||
591 | ExecuteNonQuery(cmd); | 595 | ExecuteNonQuery(cmd); |
592 | 596 | ||
597 | int terrainDBRevision; | ||
598 | Array terrainDBblob; | ||
599 | terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob); | ||
600 | |||
601 | m_log.InfoFormat("{0} Storing terrain. X={1}, Y={2}, rev={3}", | ||
602 | LogHeader, terrData.SizeX, terrData.SizeY, terrainDBRevision); | ||
603 | |||
593 | cmd.CommandText = "insert into terrain (RegionUUID, Revision, Heightfield)" | 604 | cmd.CommandText = "insert into terrain (RegionUUID, Revision, Heightfield)" |
594 | + "values (?RegionUUID, ?Revision, ?Heightfield)"; | 605 | + "values (?RegionUUID, ?Revision, ?Heightfield)"; |
595 | 606 | ||
596 | cmd.Parameters.AddWithValue("Revision", revision); | 607 | cmd.Parameters.AddWithValue("Revision", terrainDBRevision); |
597 | cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter)); | 608 | cmd.Parameters.AddWithValue("Heightfield", terrainDBblob); |
598 | 609 | ||
599 | ExecuteNonQuery(cmd); | 610 | ExecuteNonQuery(cmd); |
600 | } | 611 | } |
@@ -1526,30 +1537,6 @@ namespace OpenSim.Data.MySQL | |||
1526 | } | 1537 | } |
1527 | 1538 | ||
1528 | /// <summary> | 1539 | /// <summary> |
1529 | /// | ||
1530 | /// </summary> | ||
1531 | /// <param name="val"></param> | ||
1532 | /// <returns></returns> | ||
1533 | private static Array SerializeTerrain(double[,] val) | ||
1534 | { | ||
1535 | MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) *sizeof (double)); | ||
1536 | BinaryWriter bw = new BinaryWriter(str); | ||
1537 | |||
1538 | // TODO: COMPATIBILITY - Add byte-order conversions | ||
1539 | for (int x = 0; x < (int)Constants.RegionSize; x++) | ||
1540 | for (int y = 0; y < (int)Constants.RegionSize; y++) | ||
1541 | { | ||
1542 | double height = val[x, y]; | ||
1543 | if (height == 0.0) | ||
1544 | height = double.Epsilon; | ||
1545 | |||
1546 | bw.Write(height); | ||
1547 | } | ||
1548 | |||
1549 | return str.ToArray(); | ||
1550 | } | ||
1551 | |||
1552 | /// <summary> | ||
1553 | /// Fill the prim command with prim values | 1540 | /// Fill the prim command with prim values |
1554 | /// </summary> | 1541 | /// </summary> |
1555 | /// <param name="row"></param> | 1542 | /// <param name="row"></param> |