From 71bd3ce49f1159251ec4339d098d93c2119729f0 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 17 Sep 2016 16:42:40 +0100 Subject: add load baked terrain methods --- OpenSim/Data/PGSQL/PGSQLSimulationData.cs | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'OpenSim/Data/PGSQL') diff --git a/OpenSim/Data/PGSQL/PGSQLSimulationData.cs b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs index e6161a2..902aae0 100755 --- a/OpenSim/Data/PGSQL/PGSQLSimulationData.cs +++ b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs @@ -573,6 +573,39 @@ namespace OpenSim.Data.PGSQL return terrData; } + public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) + { + TerrainData terrData = null; + + string sql = @"select ""RegionUUID"", ""Revision"", ""Heightfield"" from bakedterrain + where ""RegionUUID"" = :RegionUUID; "; + + using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) + { + using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) + { + // PGSqlParameter param = new PGSqlParameter(); + cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID)); + conn.Open(); + using (NpgsqlDataReader reader = cmd.ExecuteReader()) + { + int rev; + if (reader.Read()) + { + rev = Convert.ToInt32(reader["Revision"]); + if ((reader["Heightfield"] != DBNull.Value)) + { + byte[] blob = (byte[])reader["Heightfield"]; + terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob); + } + } + } + } + } + + return terrData; + } + // Legacy entry point for when terrain was always a 256x256 heightmap public void StoreTerrain(double[,] terrain, UUID regionID) { -- cgit v1.1