diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs index 9fb7ef796e..d467abb80a 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs @@ -25,7 +25,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; using System.IO; + +using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -116,7 +119,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 / 4)); + // 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; diff --git a/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs b/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs index 96c16a9a8e..29e80efcd0 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs @@ -80,7 +80,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests effect = new LowerSphere(); effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0); - Assert.That(map[127, midRegion] >= 0.0, "Lower should not lowering value below 0.0 at this point (127,128)."); + Assert.That(map[127, midRegion] >= 0.0, "Lower should not lowering value below 0.0 at this point (127,128)."); Assert.That(map[127, midRegion] == 0.0, "Lower brush should lowering value to 0.0 at this point (127,128)."); Assert.That(map[125, midRegion] < 1.0, "Lower brush should lowering value at this point (124,128)."); Assert.That(map[120, midRegion] == 1.0, "Lower brush should not change value at this point (120,128)."); diff --git a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs index 24709dcf74..60dc6c9676 100644 --- a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs +++ b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs @@ -217,6 +217,10 @@ namespace OpenSim.Region.Framework.Scenes // ITerrainChannel.Merge public void Merge(ITerrainChannel newTerrain, Vector3 displacement, float radianRotation, Vector2 rotationDisplacement) { + m_log.DebugFormat("{0} Merge. inSize=<{1},{2}>, disp={3}, rot={4}, rotDisp={5}, outSize=<{6},{7}>", LogHeader, + newTerrain.Width, newTerrain.Height, + displacement, radianRotation, rotationDisplacement, + m_terrainData.SizeX, m_terrainData.SizeY); for (int xx = 0; xx < newTerrain.Width; xx++) { for (int yy = 0; yy < newTerrain.Height; yy++)