From bff26ccdbb94fbdf9623b0b00a16ef88549e648e Mon Sep 17 00:00:00 2001
From: Teravus Ovares (Dan Olivares)
Date: Sat, 8 Aug 2009 00:10:19 -0400
Subject: * More tweaking of the various services to work with nonstandard
region sizes. * Now, what's available of the terrain will show and it'll be
truncated if it's larger on Linden Clients. Parcel minimum is 64 (256/4)
for the client to accept it.
---
.../Region/ClientStack/LindenUDP/LLClientView.cs | 37 ++++++++++++++++++++--
.../CoreModules/World/Land/LandManagementModule.cs | 24 ++++++++++----
.../Region/CoreModules/World/Land/LandObject.cs | 5 +--
OpenSim/Region/Framework/Scenes/Scene.cs | 6 ++++
4 files changed, 62 insertions(+), 10 deletions(-)
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 9142b36..d8f786b 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -1457,7 +1457,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
//}
for (int x = 0; x < 16; x++)
{
- SendLayerData(x, y, map);
+ SendLayerData(x, y, LLHeightFieldMoronize(map));
Thread.Sleep(35);
}
}
@@ -1503,7 +1503,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
patches[0] = patchx + 0 + patchy * 16;
- LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(map, patches);
+ LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(((map.Length==65536)? map : LLHeightFieldMoronize(map)), patches);
layerpack.Header.Zerocoded = true;
OutPacket(layerpack, ThrottleOutPacketType.Land);
@@ -1516,6 +1516,39 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
///
+ /// Munges heightfield into the LLUDP backed in restricted heightfield.
+ ///
+ /// float array in the base; Constants.RegionSize
+ /// float array in the base 256
+ internal float[] LLHeightFieldMoronize(float[] map)
+ {
+ if (map.Length == 65536)
+ return map;
+ else
+ {
+ float[] returnmap = new float[65536];
+
+ if (map.Length < 65535)
+ {
+ // rebase the vector stride to 256
+ for (int i = 0; i < Constants.RegionSize; i++)
+ Array.Copy(map, i * (int)Constants.RegionSize, returnmap, i * 256, (int)Constants.RegionSize);
+ }
+ else
+ {
+ for (int i = 0; i < 256; i++)
+ Array.Copy(map, i * (int)Constants.RegionSize, returnmap, i * 256, 256);
+ }
+
+
+ //Array.Copy(map,0,returnmap,0,(map.Length < 65536)? map.Length : 65536);
+
+ return returnmap;
+ }
+
+ }
+
+ ///
/// Send the wind matrix to the client
///
/// 16x16 array of wind speeds
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 097a62d..c917840 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -60,7 +60,10 @@ namespace OpenSim.Region.CoreModules.World.Land
private LandChannel landChannel;
private Scene m_scene;
- private readonly int[,] m_landIDList = new int[64, 64];
+ // Minimum for parcels to work is 64m even if we don't actually use them.
+ private const int landArrayMax = ((int)((int)Constants.RegionSize / 4) >= 64) ? (int)((int)Constants.RegionSize / 4) : 64;
+
+ private readonly int[,] m_landIDList = new int[landArrayMax, landArrayMax];
private readonly Dictionary m_landList = new Dictionary();
private bool m_landPrimCountTainted;
@@ -456,9 +459,9 @@ namespace OpenSim.Region.CoreModules.World.Land
new_land.landData.LocalID = newLandLocalID;
bool[,] landBitmap = new_land.getLandBitmap();
- for (int x = 0; x < 64; x++)
+ for (int x = 0; x < landArrayMax; x++)
{
- for (int y = 0; y < 64; y++)
+ for (int y = 0; y < landArrayMax; y++)
{
if (landBitmap[x, y])
{
@@ -581,10 +584,17 @@ namespace OpenSim.Region.CoreModules.World.Land
}
lock (m_landIDList)
{
- if (m_landList.ContainsKey(m_landIDList[x / 4, y / 4]))
- return m_landList[m_landIDList[x / 4, y / 4]];
- else
+ try
+ {
+ if (m_landList.ContainsKey(m_landIDList[x / 4, y / 4]))
+ return m_landList[m_landIDList[x / 4, y / 4]];
+ else
+ return null;
+ }
+ catch (IndexOutOfRangeException)
+ {
return null;
+ }
}
}
@@ -941,6 +951,7 @@ namespace OpenSim.Region.CoreModules.World.Land
{
for (int y = 0; y < inc_y; y++)
{
+
ILandObject currentParcel = GetLandObject(start_x + x, start_y + y);
if (currentParcel != null)
@@ -951,6 +962,7 @@ namespace OpenSim.Region.CoreModules.World.Land
temp.Add(currentParcel);
}
}
+
}
}
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index f41bdac..bb06996 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -44,7 +44,8 @@ namespace OpenSim.Region.CoreModules.World.Land
#region Member Variables
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
- private bool[,] m_landBitmap = new bool[64,64];
+ private const int landArrayMax = ((int)((int)Constants.RegionSize / 4) >= 64) ? (int)((int)Constants.RegionSize / 4) : 64;
+ private bool[,] m_landBitmap = new bool[landArrayMax,landArrayMax];
protected LandData m_landData = new LandData();
protected Scene m_scene;
@@ -630,7 +631,7 @@ namespace OpenSim.Region.CoreModules.World.Land
private bool[,] convertBytesToLandBitmap()
{
- bool[,] tempConvertMap = new bool[64,64];
+ bool[,] tempConvertMap = new bool[landArrayMax, landArrayMax];
tempConvertMap.Initialize();
byte tempByte = 0;
int x = 0, y = 0, i = 0, bitNum = 0;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index e344da3..7f1936e 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2494,6 +2494,12 @@ namespace OpenSim.Region.Framework.Scenes
if (!agent.child)
{
+ if (agent.startpos.X > (int)Constants.RegionSize - 1)
+ agent.startpos.X = (int)Constants.RegionSize - 1;
+
+ if (agent.startpos.Y > (int)Constants.RegionSize - 1)
+ agent.startpos.Y = (int)Constants.RegionSize - 1;
+
// Honor parcel landing type and position.
ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
if (land != null)
--
cgit v1.1