From 87b313792821cb842fd54b568302b6877c4e53f8 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 3 May 2008 20:00:35 +0000 Subject: * Cleaned up code in Terrain, Tree and Map modules. * Fixed a bug with Terragen loader where it would do bad things on a non 256x256 sized terrain. Now loads the array correctly. * Moved MapImageModule.cs to Modules/World/WorldMap * Changed Location.RegionHandle to use Helpers.GetUlong instead of doing it ourselves. --- .../Modules/World/Terrain/FileLoaders/Terragen.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs') diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs index 7cb4b00..fe36cf7 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/Terragen.cs @@ -50,14 +50,15 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders BinaryReader bs = new BinaryReader(s); bool eof = false; - if (ASCIIEncoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ") + if (Encoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ") { + int w = 256; + int h = 256; + // Terragen file while (eof == false) { - int w = 256; - int h = 256; - string tmp = ASCIIEncoding.ASCII.GetString(bs.ReadBytes(4)); + string tmp = Encoding.ASCII.GetString(bs.ReadBytes(4)); switch (tmp) { case "SIZE": @@ -79,12 +80,13 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders Int16 heightScale = bs.ReadInt16(); Int16 baseHeight = bs.ReadInt16(); retval = new TerrainChannel(w, h); - int x, y; + int x; for (x = 0; x < w; x++) { + int y; for (y = 0; y < h; y++) { - retval[x, y] = (double) baseHeight + (double) bs.ReadInt16() * (double) heightScale / 65536.0; + retval[x, y] = baseHeight + bs.ReadInt16() * (double) heightScale / 65536.0; } } break; @@ -103,7 +105,6 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders public void SaveFile(string filename, ITerrainChannel map) { - char[] header = "TERRAGENTERRAIN".ToCharArray(); throw new NotImplementedException(); } -- cgit v1.1