diff --git a/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs b/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs index fcc7cc1838..9518724f25 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs @@ -374,12 +374,13 @@ namespace OpenSim.Framework.Data.MySQL int rev = 0; if (row.Read()) { - byte[] heightmap = (byte[]) row["Heightfield"]; + MemoryStream str = new MemoryStream((byte[]) row["Heightfield"]); + BinaryReader br = new BinaryReader(str); for (int x = 0; x < 256; x++) { for (int y = 0; y < 256; y++) { - terret[x, y] = BitConverter.ToDouble(heightmap, ((x*256) + y)*8); + terret[x, y] = br.ReadDouble(); } } rev = (int) row["Revision"]; diff --git a/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs b/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs index a724875dc9..5d9580e5e0 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs @@ -436,12 +436,13 @@ namespace OpenSim.Framework.Data.SQLite if (row.Read()) { // TODO: put this into a function - byte[] heightmap = (byte[]) row["Heightfield"]; + MemoryStream str = new MemoryStream((byte[]) row["Heightfield"]); + BinaryReader br = new BinaryReader(str); for (int x = 0; x < 256; x++) { for (int y = 0; y < 256; y++) { - terret[x, y] = BitConverter.ToDouble(heightmap, ((x*256) + y)*8); + terret[x, y] = br.ReadDouble(); } } rev = (int) row["Revision"];