From 5225e40f9e2cfdbc5a14099f45e794ed208838f5 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Wed, 1 Apr 2009 05:58:07 +0000 Subject: * Removes some hard-coded magic numbers relating to RegionSize. We now use Constants.RegionSize as expected. (Working towards enlarged or smaller regionsizes that arent multiples of 256m) * Adds minor functionality to MRM Scripting. --- OpenSim/Data/NHibernate/Terrain.cs | 12 ++++++------ OpenSim/Data/Tests/BasicRegionTest.cs | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/NHibernate/Terrain.cs b/OpenSim/Data/NHibernate/Terrain.cs index 292b3b4..bd6f992 100644 --- a/OpenSim/Data/NHibernate/Terrain.cs +++ b/OpenSim/Data/NHibernate/Terrain.cs @@ -74,15 +74,15 @@ namespace OpenSim.Data.NHibernate private static double[,] parseTerrain(byte[] data) { - double[,] terret = new double[256,256]; + double[,] terret = new double[Constants.RegionSize, Constants.RegionSize]; terret.Initialize(); MemoryStream str = new MemoryStream(data); BinaryReader br = new BinaryReader(str); try { - for (int x = 0; x < 256; x++) + for (int x = 0; x < Constants.RegionSize; x++) { - for (int y = 0; y < 256; y++) + for (int y = 0; y < Constants.RegionSize; y++) { terret[x, y] = br.ReadDouble(); } @@ -97,13 +97,13 @@ namespace OpenSim.Data.NHibernate private static byte[] serializeTerrain(double[,] val) { - MemoryStream str = new MemoryStream((int)(65536 * sizeof (double))); + MemoryStream str = new MemoryStream((int) ((Constants.RegionSize*Constants.RegionSize)*sizeof (double))); BinaryWriter bw = new BinaryWriter(str); // TODO: COMPATIBILITY - Add byte-order conversions - for (int x = 0; x < 256; x++) + for (int x = 0; x < Constants.RegionSize; x++) { - for (int y = 0; y < 256; y++) + for (int y = 0; y < Constants.RegionSize; y++) { double height = val[x, y]; if (height <= 0.0) diff --git a/OpenSim/Data/Tests/BasicRegionTest.cs b/OpenSim/Data/Tests/BasicRegionTest.cs index 179692a..e7ce8af 100644 --- a/OpenSim/Data/Tests/BasicRegionTest.cs +++ b/OpenSim/Data/Tests/BasicRegionTest.cs @@ -882,10 +882,10 @@ namespace OpenSim.Data.Tests private double[,] GenTerrain(double value) { - double[,] terret = new double[256,256]; + double[,] terret = new double[Constants.RegionSize, Constants.RegionSize]; terret.Initialize(); - for (int x = 0; x < 256; x++) - for (int y = 0; y < 256; y++) + for (int x = 0; x < Constants.RegionSize; x++) + for (int y = 0; y < Constants.RegionSize; y++) terret[x,y] = value; return terret; @@ -893,8 +893,8 @@ namespace OpenSim.Data.Tests private bool CompareTerrain(double[,] one, double[,] two) { - for (int x = 0; x < 256; x++) - for (int y = 0; y < 256; y++) + for (int x = 0; x < Constants.RegionSize; x++) + for (int y = 0; y < Constants.RegionSize; y++) if (one[x,y] != two[x,y]) return false; -- cgit v1.1