aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/SQLite/SQLiteSimulationData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/SQLite/SQLiteSimulationData.cs')
-rw-r--r--OpenSim/Data/SQLite/SQLiteSimulationData.cs40
1 files changed, 16 insertions, 24 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteSimulationData.cs b/OpenSim/Data/SQLite/SQLiteSimulationData.cs
index b70af6b..cce59c1 100644
--- a/OpenSim/Data/SQLite/SQLiteSimulationData.cs
+++ b/OpenSim/Data/SQLite/SQLiteSimulationData.cs
@@ -51,6 +51,7 @@ namespace OpenSim.Data.SQLite
51 public class SQLiteSimulationData : ISimulationDataStore 51 public class SQLiteSimulationData : ISimulationDataStore
52 { 52 {
53 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 53 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
54 private static readonly string LogHeader = "[REGION DB SQLLITE]";
54 55
55 private const string primSelect = "select * from prims"; 56 private const string primSelect = "select * from prims";
56 private const string shapeSelect = "select * from primshapes"; 57 private const string shapeSelect = "select * from primshapes";
@@ -819,17 +820,21 @@ namespace OpenSim.Data.SQLite
819 prim.Inventory.RestoreInventoryItems(inventory); 820 prim.Inventory.RestoreInventoryItems(inventory);
820 } 821 }
821 822
823 // Legacy entry point for when terrain was always a 256x256 hieghtmap
824 public void StoreTerrain(double[,] ter, UUID regionID)
825 {
826 StoreTerrain(new HeightmapTerrainData(ter), regionID);
827 }
828
822 /// <summary> 829 /// <summary>
823 /// Store a terrain revision in region storage 830 /// Store a terrain revision in region storage
824 /// </summary> 831 /// </summary>
825 /// <param name="ter">terrain heightfield</param> 832 /// <param name="ter">terrain heightfield</param>
826 /// <param name="regionID">region UUID</param> 833 /// <param name="regionID">region UUID</param>
827 public void StoreTerrain(double[,] ter, UUID regionID) 834 public void StoreTerrain(TerrainData terrData, UUID regionID)
828 { 835 {
829 lock (ds) 836 lock (ds)
830 { 837 {
831 int revision = (int)DBTerrainRevision.Legacy256;
832
833 using ( 838 using (
834 SqliteCommand cmd = new SqliteCommand("delete from terrain where RegionUUID=:RegionUUID", m_conn)) 839 SqliteCommand cmd = new SqliteCommand("delete from terrain where RegionUUID=:RegionUUID", m_conn))
835 { 840 {
@@ -839,15 +844,20 @@ namespace OpenSim.Data.SQLite
839 844
840 // the following is an work around for .NET. The perf 845 // the following is an work around for .NET. The perf
841 // issues associated with it aren't as bad as you think. 846 // issues associated with it aren't as bad as you think.
842 m_log.Debug("[SQLITE REGION DB]: Storing terrain revision r" + revision.ToString());
843 String sql = "insert into terrain(RegionUUID, Revision, Heightfield)" + 847 String sql = "insert into terrain(RegionUUID, Revision, Heightfield)" +
844 " values(:RegionUUID, :Revision, :Heightfield)"; 848 " values(:RegionUUID, :Revision, :Heightfield)";
845 849
850 int terrainDBRevision;
851 Array terrainDBblob;
852 terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
853
854 m_log.DebugFormat("{0} Storing terrain revision r {1}", LogHeader, terrainDBRevision);
855
846 using (SqliteCommand cmd = new SqliteCommand(sql, m_conn)) 856 using (SqliteCommand cmd = new SqliteCommand(sql, m_conn))
847 { 857 {
848 cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString())); 858 cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString()));
849 cmd.Parameters.Add(new SqliteParameter(":Revision", revision)); 859 cmd.Parameters.Add(new SqliteParameter(":Revision", terrainDBRevision));
850 cmd.Parameters.Add(new SqliteParameter(":Heightfield", serializeTerrain(ter))); 860 cmd.Parameters.Add(new SqliteParameter(":Heightfield", terrainDBblob));
851 cmd.ExecuteNonQuery(); 861 cmd.ExecuteNonQuery();
852 } 862 }
853 } 863 }
@@ -2006,24 +2016,6 @@ namespace OpenSim.Data.SQLite
2006 return entry; 2016 return entry;
2007 } 2017 }
2008 2018
2009 /// <summary>
2010 ///
2011 /// </summary>
2012 /// <param name="val"></param>
2013 /// <returns></returns>
2014 private static Array serializeTerrain(double[,] val)
2015 {
2016 MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) * sizeof(double));
2017 BinaryWriter bw = new BinaryWriter(str);
2018
2019 // TODO: COMPATIBILITY - Add byte-order conversions
2020 for (int x = 0; x < (int)Constants.RegionSize; x++)
2021 for (int y = 0; y < (int)Constants.RegionSize; y++)
2022 bw.Write(val[x, y]);
2023
2024 return str.ToArray();
2025 }
2026
2027 // private void fillTerrainRow(DataRow row, UUID regionUUID, int rev, double[,] val) 2019 // private void fillTerrainRow(DataRow row, UUID regionUUID, int rev, double[,] val)
2028 // { 2020 // {
2029 // row["RegionUUID"] = regionUUID; 2021 // row["RegionUUID"] = regionUUID;