aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Storage
diff options
context:
space:
mode:
authorSean Dague2007-11-19 15:07:04 +0000
committerSean Dague2007-11-19 15:07:04 +0000
commit2fdca28dd4311dc4cb55dfd2bce10b4fe92aa66d (patch)
tree12c93e5ba02ef3d4d4128ec4407151ae25d96118 /OpenSim/Region/Storage
parent* added ttensy but important piece of knowledge to MySQL provider in OpenSim.... (diff)
downloadopensim-SC_OLD-2fdca28dd4311dc4cb55dfd2bce10b4fe92aa66d.zip
opensim-SC_OLD-2fdca28dd4311dc4cb55dfd2bce10b4fe92aa66d.tar.gz
opensim-SC_OLD-2fdca28dd4311dc4cb55dfd2bce10b4fe92aa66d.tar.bz2
opensim-SC_OLD-2fdca28dd4311dc4cb55dfd2bce10b4fe92aa66d.tar.xz
hopefully resolve mantis issue #10 by locking correcty around terrain methods
Diffstat (limited to 'OpenSim/Region/Storage')
-rw-r--r--OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs104
1 files changed, 54 insertions, 50 deletions
diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs
index a9fb869..fc6f59c 100644
--- a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs
+++ b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs
@@ -262,70 +262,74 @@ namespace OpenSim.DataStore.MonoSqlite
262 262
263 public void StoreTerrain(double[,] ter, LLUUID regionID) 263 public void StoreTerrain(double[,] ter, LLUUID regionID)
264 { 264 {
265 int revision = Util.UnixTimeSinceEpoch(); 265 lock (ds) {
266 266 int revision = Util.UnixTimeSinceEpoch();
267 // the following is an work around for .NET. The perf 267
268 // issues associated with it aren't as bad as you think. 268 // the following is an work around for .NET. The perf
269 SqliteConnection conn = new SqliteConnection(m_connectionString); 269 // issues associated with it aren't as bad as you think.
270 conn.Open(); 270 SqliteConnection conn = new SqliteConnection(m_connectionString);
271 MainLog.Instance.Verbose("DATASTORE", "Storing terrain revision r" + revision.ToString()); 271 conn.Open();
272 String sql = "insert into terrain(RegionUUID, Revision, Heightfield)" + 272 MainLog.Instance.Verbose("DATASTORE", "Storing terrain revision r" + revision.ToString());
273 " values(:RegionUUID, :Revision, :Heightfield)"; 273 String sql = "insert into terrain(RegionUUID, Revision, Heightfield)" +
274 274 " values(:RegionUUID, :Revision, :Heightfield)";
275 using(SqliteCommand cmd = new SqliteCommand(sql, conn)) 275
276 { 276 using(SqliteCommand cmd = new SqliteCommand(sql, conn))
277 cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString())); 277 {
278 cmd.Parameters.Add(new SqliteParameter(":Revision", revision)); 278 cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString()));
279 cmd.Parameters.Add(new SqliteParameter(":Heightfield", serializeTerrain(ter))); 279 cmd.Parameters.Add(new SqliteParameter(":Revision", revision));
280 cmd.ExecuteNonQuery(); 280 cmd.Parameters.Add(new SqliteParameter(":Heightfield", serializeTerrain(ter)));
281 cmd.ExecuteNonQuery();
282 }
283 conn.Close();
281 } 284 }
282 conn.Close();
283 } 285 }
284 286
285 public double[,] LoadTerrain(LLUUID regionID) 287 public double[,] LoadTerrain(LLUUID regionID)
286 { 288 {
287 double[,] terret = new double[256,256]; 289 lock (ds) {
288 terret.Initialize(); 290 double[,] terret = new double[256,256];
289 // the following is an work around for .NET. The perf 291 terret.Initialize();
290 // issues associated with it aren't as bad as you think. 292 // the following is an work around for .NET. The perf
291 SqliteConnection conn = new SqliteConnection(m_connectionString); 293 // issues associated with it aren't as bad as you think.
292 conn.Open(); 294 SqliteConnection conn = new SqliteConnection(m_connectionString);
293 String sql = "select RegionUUID, Revision, Heightfield from terrain" + 295 conn.Open();
294 " where RegionUUID=:RegionUUID order by Revision desc"; 296 String sql = "select RegionUUID, Revision, Heightfield from terrain" +
295 297 " where RegionUUID=:RegionUUID order by Revision desc";
296 298
297 using (SqliteCommand cmd = new SqliteCommand(sql, conn)) 299
298 { 300 using (SqliteCommand cmd = new SqliteCommand(sql, conn))
299 cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString()));
300
301 using (IDataReader row = cmd.ExecuteReader())
302 { 301 {
303 int rev = 0; 302 cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString()));
304 if (row.Read()) 303
304 using (IDataReader row = cmd.ExecuteReader())
305 { 305 {
306 // TODO: put this into a function 306 int rev = 0;
307 byte[] heightmap = (byte[]) row["Heightfield"]; 307 if (row.Read())
308 for (int x = 0; x < 256; x++)
309 { 308 {
310 for (int y = 0; y < 256; y++) 309 // TODO: put this into a function
310 byte[] heightmap = (byte[]) row["Heightfield"];
311 for (int x = 0; x < 256; x++)
311 { 312 {
312 terret[x, y] = BitConverter.ToDouble(heightmap, ((x*256) + y)*8); 313 for (int y = 0; y < 256; y++)
314 {
315 terret[x, y] = BitConverter.ToDouble(heightmap, ((x*256) + y)*8);
316 }
313 } 317 }
318 rev = (int)row["Revision"];
314 } 319 }
315 rev = (int)row["Revision"]; 320 else
316 } 321 {
317 else 322 MainLog.Instance.Verbose("DATASTORE", "No terrain found for region");
318 { 323 conn.Close();
319 MainLog.Instance.Verbose("DATASTORE", "No terrain found for region"); 324 return null;
320 conn.Close(); 325 }
321 return null; 326
327 MainLog.Instance.Verbose("DATASTORE", "Loaded terrain revision r" + rev.ToString());
322 } 328 }
323
324 MainLog.Instance.Verbose("DATASTORE", "Loaded terrain revision r" + rev.ToString());
325 } 329 }
330 conn.Close();
331 return terret;
326 } 332 }
327 conn.Close();
328 return terret;
329 } 333 }
330 334
331 public void RemoveLandObject(uint id) 335 public void RemoveLandObject(uint id)