diff options
author | Sean Dague | 2007-11-14 21:00:19 +0000 |
---|---|---|
committer | Sean Dague | 2007-11-14 21:00:19 +0000 |
commit | c7e125033cb1b717949db9d83d1a7007c3c56db9 (patch) | |
tree | 9fee41e2207d94c87be718a202d16df52664ce8d /OpenSim | |
parent | managed to produce and kill the same exception on mono as on .net. Hopefully (diff) | |
download | opensim-SC_OLD-c7e125033cb1b717949db9d83d1a7007c3c56db9.zip opensim-SC_OLD-c7e125033cb1b717949db9d83d1a7007c3c56db9.tar.gz opensim-SC_OLD-c7e125033cb1b717949db9d83d1a7007c3c56db9.tar.bz2 opensim-SC_OLD-c7e125033cb1b717949db9d83d1a7007c3c56db9.tar.xz |
clean up most of my mess on terrain. Someone on .NET please test and make
sure this remains working for you.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs index 6540b6d..582bdfc 100644 --- a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs +++ b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs | |||
@@ -246,49 +246,47 @@ namespace OpenSim.DataStore.MonoSqlite | |||
246 | public void StoreTerrain(double[,] ter, LLUUID regionID) | 246 | public void StoreTerrain(double[,] ter, LLUUID regionID) |
247 | { | 247 | { |
248 | int revision = Util.UnixTimeSinceEpoch(); | 248 | int revision = Util.UnixTimeSinceEpoch(); |
249 | |||
250 | // the following is an work around for .NET. The perf | ||
251 | // issues associated with it aren't as bad as you think. | ||
249 | SqliteConnection conn = new SqliteConnection(connectionString); | 252 | SqliteConnection conn = new SqliteConnection(connectionString); |
250 | conn.Open(); | 253 | conn.Open(); |
251 | MainLog.Instance.Verbose("DATASTORE", "Storing terrain revision r" + revision.ToString()); | 254 | MainLog.Instance.Verbose("DATASTORE", "Storing terrain revision r" + revision.ToString()); |
255 | String sql = "insert into terrain(RegionUUID, Revision, Heightfield)" + | ||
256 | " values(:RegionUUID, :Revision, :Heightfield)"; | ||
252 | 257 | ||
253 | DataTable terrain = ds.Tables["terrain"]; | 258 | using(SqliteCommand cmd = new SqliteCommand(sql, conn)) |
254 | lock (ds) | ||
255 | { | 259 | { |
256 | SqliteCommand cmd = new SqliteCommand("insert into terrain(RegionUUID, Revision, Heightfield)" + | 260 | cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString())); |
257 | " values(:RegionUUID, :Revision, :Heightfield)", conn); | 261 | cmd.Parameters.Add(new SqliteParameter(":Revision", revision)); |
258 | using(cmd) | 262 | cmd.Parameters.Add(new SqliteParameter(":Heightfield", serializeTerrain(ter))); |
259 | { | 263 | cmd.ExecuteNonQuery(); |
260 | |||
261 | cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString())); | ||
262 | cmd.Parameters.Add(new SqliteParameter(":Revision", revision)); | ||
263 | cmd.Parameters.Add(new SqliteParameter(":Heightfield", serializeTerrain(ter))); | ||
264 | cmd.ExecuteNonQuery(); | ||
265 | } | ||
266 | } | 264 | } |
267 | conn.Close(); | 265 | conn.Close(); |
268 | } | 266 | } |
269 | 267 | ||
270 | public double[,] LoadTerrain(LLUUID regionID) | 268 | public double[,] LoadTerrain(LLUUID regionID) |
271 | { | 269 | { |
272 | SqliteConnection conn = new SqliteConnection(connectionString); | ||
273 | conn.Open(); | ||
274 | double[,] terret = new double[256,256]; | 270 | double[,] terret = new double[256,256]; |
275 | terret.Initialize(); | 271 | terret.Initialize(); |
272 | // the following is an work around for .NET. The perf | ||
273 | // issues associated with it aren't as bad as you think. | ||
274 | SqliteConnection conn = new SqliteConnection(connectionString); | ||
275 | conn.Open(); | ||
276 | String sql = "select RegionUUID, Revision, Heightfield from terrain" + | 276 | String sql = "select RegionUUID, Revision, Heightfield from terrain" + |
277 | " where RegionUUID='" + regionID.ToString() + "' order by Revision desc"; | 277 | " where RegionUUID=:RegionUUID order by Revision desc"; |
278 | 278 | ||
279 | using (IDbCommand cmd = conn.CreateCommand()) | 279 | |
280 | using (SqliteCommand cmd = new SqliteCommand(sql, conn)) | ||
280 | { | 281 | { |
281 | cmd.CommandText = sql; | 282 | cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString())); |
282 | // SqliteParameter param = new SqliteParameter(":RegionUUID", regionID.ToString()); | ||
283 | // param.SourceColumn = "RegionUUID"; | ||
284 | // param.SourceVersion = DataRowVersion.Current; | ||
285 | // cmd.Parameters.Add(param); | ||
286 | 283 | ||
287 | using (IDataReader row = cmd.ExecuteReader()) | 284 | using (IDataReader row = cmd.ExecuteReader()) |
288 | { | 285 | { |
289 | int rev = 0; | 286 | int rev = 0; |
290 | if (row.Read()) | 287 | if (row.Read()) |
291 | { | 288 | { |
289 | // TODO: put this into a function | ||
292 | byte[] heightmap = (byte[]) row["Heightfield"]; | 290 | byte[] heightmap = (byte[]) row["Heightfield"]; |
293 | for (int x = 0; x < 256; x++) | 291 | for (int x = 0; x < 256; x++) |
294 | { | 292 | { |