add to databases a table to store baked terrain.

This commit is contained in:
UbitUmarov
2016-09-17 15:45:11 +01:00
parent 0cdad0faf4
commit 3f9f105295
11 changed files with 208 additions and 13 deletions

View File

@@ -623,6 +623,49 @@ namespace OpenSim.Data.PGSQL
}
/// <summary>
/// Stores the baked terrain map to DB.
/// </summary>
/// <param name="terrain">terrain map data.</param>
/// <param name="regionID">regionID.</param>
public void StoreBakedTerrain(TerrainData terrData, UUID regionID)
{
//Delete old terrain map
string sql = @"delete from bakedterrain where ""RegionUUID""=:RegionUUID";
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
{
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
{
cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID));
conn.Open();
cmd.ExecuteNonQuery();
_Log.InfoFormat("{0} Deleted bakedterrain id = {1}", LogHeader, regionID);
}
}
int terrainDBRevision;
Array terrainDBblob;
terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
sql = @"insert into bakedterrain(""RegionUUID"", ""Revision"", ""Heightfield"") values(:RegionUUID, :Revision, :Heightfield)";
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
{
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
{
cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID));
cmd.Parameters.Add(_Database.CreateParameter("Revision", terrainDBRevision));
cmd.Parameters.Add(_Database.CreateParameter("Heightfield", terrainDBblob));
conn.Open();
cmd.ExecuteNonQuery();
_Log.InfoFormat("{0} Stored bakedterrain id = {1}, terrainSize = <{2},{3}>",
LogHeader, regionID, terrData.SizeX, terrData.SizeY);
}
}
}
/// <summary>
/// Loads all the land objects of a region.
/// </summary>