From c654df5dfdc77dd24d52f94a154d1e5aba739aaf Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 11 Feb 2008 12:38:51 +0000 Subject: From: dirk husemann these two patches fixe the terrain load exception that occurs when restarting OpenSim on PPC32 by making terrain loading endian clean. it does NOT fix the client crash exception. need to hunt that one down. --- OpenSim/Framework/Data.MySQL/MySQLDataStore.cs | 5 +++-- OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs b/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs index fcc7cc1..9518724 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 a724875..5d9580e 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"]; -- cgit v1.1