diff options
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs index dcd6609..5e39bee 100644 --- a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs +++ b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs | |||
@@ -268,36 +268,39 @@ namespace OpenSim.DataStore.MonoSqlite | |||
268 | { | 268 | { |
269 | double[,] terret = new double[256,256]; | 269 | double[,] terret = new double[256,256]; |
270 | terret.Initialize(); | 270 | terret.Initialize(); |
271 | String sql = "select RegionUUID, Revision, Heightfield from terrain" + | ||
272 | " where RegionUUID=:RegionUUID order by Revision desc limit 1"; | ||
271 | 273 | ||
272 | SqliteCommand cmd = new SqliteCommand("select RegionUUID, Revision, Heightfield from terrain" + | 274 | using (SqliteCommand cmd = new SqliteCommand(sql)) |
273 | " where RegionUUID=:RegionUUID order by Revision desc limit 1", conn); | ||
274 | SqliteParameter param = new SqliteParameter(); | ||
275 | cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString())); | ||
276 | |||
277 | using (SqliteDataReader row = cmd.ExecuteReader()) | ||
278 | { | 275 | { |
279 | int rev = 0; | 276 | cmd.Connection = conn; |
280 | if (row.Read()) | 277 | SqliteParameter param = new SqliteParameter(); |
278 | cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString())); | ||
279 | |||
280 | using (SqliteDataReader row = cmd.ExecuteReader()) | ||
281 | { | 281 | { |
282 | byte[] heightmap = (byte[]) row["Heightfield"]; | 282 | int rev = 0; |
283 | for (int x = 0; x < 256; x++) | 283 | if (row.Read()) |
284 | { | 284 | { |
285 | for (int y = 0; y < 256; y++) | 285 | byte[] heightmap = (byte[]) row["Heightfield"]; |
286 | for (int x = 0; x < 256; x++) | ||
286 | { | 287 | { |
287 | terret[x, y] = BitConverter.ToDouble(heightmap, ((x*256) + y)*8); | 288 | for (int y = 0; y < 256; y++) |
289 | { | ||
290 | terret[x, y] = BitConverter.ToDouble(heightmap, ((x*256) + y)*8); | ||
291 | } | ||
288 | } | 292 | } |
293 | rev = (int)row["Revision"]; | ||
289 | } | 294 | } |
290 | rev = (int)row["Revision"]; | 295 | else |
291 | } | 296 | { |
292 | else | 297 | MainLog.Instance.Verbose("DATASTORE", "No terrain found for region"); |
293 | { | 298 | return null; |
294 | MainLog.Instance.Verbose("DATASTORE", "No terrain found for region"); | 299 | } |
295 | return null; | 300 | |
301 | MainLog.Instance.Verbose("DATASTORE", "Loaded terrain revision r" + rev.ToString()); | ||
296 | } | 302 | } |
297 | |||
298 | MainLog.Instance.Verbose("DATASTORE", "Loaded terrain revision r" + rev.ToString()); | ||
299 | } | 303 | } |
300 | |||
301 | return terret; | 304 | return terret; |
302 | } | 305 | } |
303 | 306 | ||