From 22f573a0bed4c7b0d9aa84ba38e966f0be802f5d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 25 Aug 2015 20:00:31 +0100 Subject: [PATCH] update raw32 file reader to core one. Warning only suports square regions --- .../CoreModules/World/Terrain/FileLoaders/RAW32.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs index 9fb7ef796e..1bbef40f3a 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,6 +119,14 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders public ITerrainChannel LoadStream(Stream s) { + // 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(); BinaryReader bs = new BinaryReader(s);