Permit loading of LLRAW files bigger than 256x256 by calculating size based on file size rather than assuming 256x256, same as for RAW32.

inv-download
Magnuz Binder 2015-01-28 11:32:43 +01:00 committed by Justin Clark-Casey (justincc)
parent 59d6d03909
commit fad4d4dc55
1 changed files with 9 additions and 1 deletions

View File

@ -147,7 +147,15 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
public ITerrainChannel LoadStream(Stream s) 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); BinaryReader bs = new BinaryReader(s);
int y; int y;