From 7416809077227f35ab70ed44060e51f2bcf66937 Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Wed, 2 Oct 2013 16:59:37 -0700
Subject: 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).
---
OpenSim/Data/MySQL/MySQLSimulationData.cs | 47 +++++++++++--------------------
1 file changed, 17 insertions(+), 30 deletions(-)
(limited to 'OpenSim/Data/MySQL')
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
public class MySQLSimulationData : ISimulationDataStore
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+ private static string LogHeader = "[REGION DB MYSQL]";
private string m_connectionString;
private object m_dbLock = new object();
@@ -91,7 +92,7 @@ namespace OpenSim.Data.MySQL
}
catch (Exception e)
{
- m_log.Error("[REGION DB]: MySQL error in ExecuteReader: " + e.Message);
+ m_log.ErrorFormat("{0} MySQL error in ExecuteReader: {1}", LogHeader, e);
throw;
}
@@ -572,11 +573,14 @@ namespace OpenSim.Data.MySQL
}
}
+ // Legacy entry point for when terrain was always a 256x256 hieghtmap
public void StoreTerrain(double[,] ter, UUID regionID)
{
- m_log.Info("[REGION DB]: Storing terrain");
- int revision = (int)DBTerrainRevision.Legacy256;
+ StoreTerrain(new HeightmapTerrainData(ter), regionID);
+ }
+ public void StoreTerrain(TerrainData terrData, UUID regionID)
+ {
lock (m_dbLock)
{
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
@@ -590,11 +594,18 @@ namespace OpenSim.Data.MySQL
ExecuteNonQuery(cmd);
+ int terrainDBRevision;
+ Array terrainDBblob;
+ terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
+
+ m_log.InfoFormat("{0} Storing terrain. X={1}, Y={2}, rev={3}",
+ LogHeader, terrData.SizeX, terrData.SizeY, terrainDBRevision);
+
cmd.CommandText = "insert into terrain (RegionUUID, Revision, Heightfield)"
+ "values (?RegionUUID, ?Revision, ?Heightfield)";
-
- cmd.Parameters.AddWithValue("Revision", revision);
- cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter));
+
+ cmd.Parameters.AddWithValue("Revision", terrainDBRevision);
+ cmd.Parameters.AddWithValue("Heightfield", terrainDBblob);
ExecuteNonQuery(cmd);
}
@@ -1526,30 +1537,6 @@ namespace OpenSim.Data.MySQL
}
///
- ///
- ///
- ///
- ///
- private static Array SerializeTerrain(double[,] val)
- {
- MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) *sizeof (double));
- BinaryWriter bw = new BinaryWriter(str);
-
- // TODO: COMPATIBILITY - Add byte-order conversions
- for (int x = 0; x < (int)Constants.RegionSize; x++)
- for (int y = 0; y < (int)Constants.RegionSize; y++)
- {
- double height = val[x, y];
- if (height == 0.0)
- height = double.Epsilon;
-
- bw.Write(height);
- }
-
- return str.ToArray();
- }
-
- ///
/// Fill the prim command with prim values
///
///
--
cgit v1.1