diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs index 62d232e833..ce93a18001 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/LLRAW.cs @@ -147,7 +147,15 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders public ITerrainChannel LoadStream(Stream s) { - TerrainChannel retval = new TerrainChannel(); + // The raw format doesn't contain any dimension information. + // Guess the square dimensions by using the length of the raw file. + double dimension = Math.Sqrt((double)(s.Length / 13)); + // Regions are always multiples of 256. + int trimmedDimension = (int)dimension - ((int)dimension % (int)Constants.RegionSize); + if (trimmedDimension < Constants.RegionSize) + trimmedDimension = (int)Constants.RegionSize; + + TerrainChannel retval = new TerrainChannel(trimmedDimension, trimmedDimension); BinaryReader bs = new BinaryReader(s); int y;