clean up most of my mess on terrain. Someone on .NET please test and make
sure this remains working for you.afrisby
parent
ec48b67276
commit
c7e125033c
|
@ -246,49 +246,47 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||||
public void StoreTerrain(double[,] ter, LLUUID regionID)
|
public void StoreTerrain(double[,] ter, LLUUID regionID)
|
||||||
{
|
{
|
||||||
int revision = Util.UnixTimeSinceEpoch();
|
int revision = Util.UnixTimeSinceEpoch();
|
||||||
|
|
||||||
|
// the following is an work around for .NET. The perf
|
||||||
|
// issues associated with it aren't as bad as you think.
|
||||||
SqliteConnection conn = new SqliteConnection(connectionString);
|
SqliteConnection conn = new SqliteConnection(connectionString);
|
||||||
conn.Open();
|
conn.Open();
|
||||||
MainLog.Instance.Verbose("DATASTORE", "Storing terrain revision r" + revision.ToString());
|
MainLog.Instance.Verbose("DATASTORE", "Storing terrain revision r" + revision.ToString());
|
||||||
|
String sql = "insert into terrain(RegionUUID, Revision, Heightfield)" +
|
||||||
|
" values(:RegionUUID, :Revision, :Heightfield)";
|
||||||
|
|
||||||
DataTable terrain = ds.Tables["terrain"];
|
using(SqliteCommand cmd = new SqliteCommand(sql, conn))
|
||||||
lock (ds)
|
|
||||||
{
|
{
|
||||||
SqliteCommand cmd = new SqliteCommand("insert into terrain(RegionUUID, Revision, Heightfield)" +
|
|
||||||
" values(:RegionUUID, :Revision, :Heightfield)", conn);
|
|
||||||
using(cmd)
|
|
||||||
{
|
|
||||||
|
|
||||||
cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString()));
|
cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString()));
|
||||||
cmd.Parameters.Add(new SqliteParameter(":Revision", revision));
|
cmd.Parameters.Add(new SqliteParameter(":Revision", revision));
|
||||||
cmd.Parameters.Add(new SqliteParameter(":Heightfield", serializeTerrain(ter)));
|
cmd.Parameters.Add(new SqliteParameter(":Heightfield", serializeTerrain(ter)));
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
conn.Close();
|
conn.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double[,] LoadTerrain(LLUUID regionID)
|
public double[,] LoadTerrain(LLUUID regionID)
|
||||||
{
|
{
|
||||||
SqliteConnection conn = new SqliteConnection(connectionString);
|
|
||||||
conn.Open();
|
|
||||||
double[,] terret = new double[256,256];
|
double[,] terret = new double[256,256];
|
||||||
terret.Initialize();
|
terret.Initialize();
|
||||||
|
// the following is an work around for .NET. The perf
|
||||||
|
// issues associated with it aren't as bad as you think.
|
||||||
|
SqliteConnection conn = new SqliteConnection(connectionString);
|
||||||
|
conn.Open();
|
||||||
String sql = "select RegionUUID, Revision, Heightfield from terrain" +
|
String sql = "select RegionUUID, Revision, Heightfield from terrain" +
|
||||||
" where RegionUUID='" + regionID.ToString() + "' order by Revision desc";
|
" where RegionUUID=:RegionUUID order by Revision desc";
|
||||||
|
|
||||||
using (IDbCommand cmd = conn.CreateCommand())
|
|
||||||
|
using (SqliteCommand cmd = new SqliteCommand(sql, conn))
|
||||||
{
|
{
|
||||||
cmd.CommandText = sql;
|
cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString()));
|
||||||
// SqliteParameter param = new SqliteParameter(":RegionUUID", regionID.ToString());
|
|
||||||
// param.SourceColumn = "RegionUUID";
|
|
||||||
// param.SourceVersion = DataRowVersion.Current;
|
|
||||||
// cmd.Parameters.Add(param);
|
|
||||||
|
|
||||||
using (IDataReader row = cmd.ExecuteReader())
|
using (IDataReader row = cmd.ExecuteReader())
|
||||||
{
|
{
|
||||||
int rev = 0;
|
int rev = 0;
|
||||||
if (row.Read())
|
if (row.Read())
|
||||||
{
|
{
|
||||||
|
// TODO: put this into a function
|
||||||
byte[] heightmap = (byte[]) row["Heightfield"];
|
byte[] heightmap = (byte[]) row["Heightfield"];
|
||||||
for (int x = 0; x < 256; x++)
|
for (int x = 0; x < 256; x++)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue