aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World/Terrain/FileLoaders
diff options
context:
space:
mode:
authorRobert Adams2014-02-03 21:21:29 -0800
committerRobert Adams2014-02-03 21:23:32 -0800
commit1b41ec0a85443b08b9ea8a33215deb9243cd7156 (patch)
tree4f48c95019cf10b59daca9d6e87297807000adc5 /OpenSim/Region/CoreModules/World/Terrain/FileLoaders
parentAdd one check for a blank URL because the module wasn't quite sure not to wor... (diff)
downloadopensim-SC_OLD-1b41ec0a85443b08b9ea8a33215deb9243cd7156.zip
opensim-SC_OLD-1b41ec0a85443b08b9ea8a33215deb9243cd7156.tar.gz
opensim-SC_OLD-1b41ec0a85443b08b9ea8a33215deb9243cd7156.tar.bz2
opensim-SC_OLD-1b41ec0a85443b08b9ea8a33215deb9243cd7156.tar.xz
Fix raw32 terrain heightmap reader so it estimates terrain size from
the size of the input stream. This is required since the raw heightmap format (.r32) does not contain any size information. The estimation relies on terrain being square.
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Terrain/FileLoaders')
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs13
1 files changed, 12 insertions, 1 deletions
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs
index 9fb7ef7..d467abb 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/RAW32.cs
@@ -25,7 +25,10 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
28using System.IO; 29using System.IO;
30
31using OpenSim.Framework;
29using OpenSim.Region.Framework.Interfaces; 32using OpenSim.Region.Framework.Interfaces;
30using OpenSim.Region.Framework.Scenes; 33using OpenSim.Region.Framework.Scenes;
31 34
@@ -116,7 +119,15 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
116 119
117 public ITerrainChannel LoadStream(Stream s) 120 public ITerrainChannel LoadStream(Stream s)
118 { 121 {
119 TerrainChannel retval = new TerrainChannel(); 122 // The raw format doesn't contain any dimension information.
123 // Guess the square dimensions by using the length of the raw file.
124 double dimension = Math.Sqrt((double)(s.Length / 4));
125 // Regions are always multiples of 256.
126 int trimmedDimension = (int)dimension - ((int)dimension % (int)Constants.RegionSize);
127 if (trimmedDimension < Constants.RegionSize)
128 trimmedDimension = (int)Constants.RegionSize;
129
130 TerrainChannel retval = new TerrainChannel(trimmedDimension, trimmedDimension);
120 131
121 BinaryReader bs = new BinaryReader(s); 132 BinaryReader bs = new BinaryReader(s);
122 int y; 133 int y;