diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index cd3efe381d..949aa279f6 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -1101,27 +1101,44 @@ namespace OpenSim.Region.ClientStack.LindenUDP //} } + /// + /// Send terrain layer information to the client. + /// + /// private void DoSendLayerData(object o) { float[] map = (float[])o; + try { for (int y = 0; y < 16; y++) { - for (int x = 0; x < 16; x += 4) + // For some terrains, sending more than one terrain patch at once results in a libsecondlife exception + // see http://opensimulator.org/mantis/view.php?id=1662 + //for (int x = 0; x < 16; x += 4) + //{ + // SendLayerPacket(map, y, x); + // Thread.Sleep(150); + //} + for (int x= 0; x < 16; x++) { - SendLayerPacket(map, y, x); - Thread.Sleep(150); + SendLayerData(x, y, map); + Thread.Sleep(35); } } } catch (Exception e) { - m_log.Warn("[client]: " + - "ClientView.API.cs: SendLayerData() - Failed with exception " + e.ToString()); + m_log.Warn("[CLIENT]: ClientView.API.cs: SendLayerData() - Failed with exception " + e.ToString()); } } + /// + /// Sends a set of four patches (x, x+1, ..., x+3) to the client + /// + /// heightmap + /// X coordinate for patches 0..12 + /// Y coordinate for patches 0..15 private void SendLayerPacket(float[] map, int y, int x) { int[] patches = new int[4]; @@ -1137,8 +1154,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// /// Sends a specified patch to a client /// - /// Patch coordinate (x) 0..16 - /// Patch coordinate (y) 0..16 + /// Patch coordinate (x) 0..15 + /// Patch coordinate (y) 0..15 /// heightmap public void SendLayerData(int px, int py, float[] map) { @@ -1157,8 +1174,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } catch (Exception e) { - m_log.Warn("[client]: " + - "ClientView.API.cs: SendLayerData() - Failed with exception " + e.ToString()); + m_log.Warn("[client]: ClientView.API.cs: SendLayerData() - Failed with exception " + e.ToString()); } } diff --git a/OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs b/OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs index 952ca0a483..aa34c45f94 100644 --- a/OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs +++ b/OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs @@ -32,7 +32,13 @@ namespace OpenSim.Region.Environment.Interfaces int Height { get; } double this[int x, int y] { get; set; } int Width { get; } + + /// + /// Squash the entire heightmap into a single dimensioned array + /// + /// float[] GetFloatsSerialised(); + double[,] GetDoubles(); bool Tainted(int x, int y); ITerrainChannel MakeCopy(); diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainChannel.cs b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainChannel.cs index 53d03fc177..24a76f719c 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainChannel.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainChannel.cs @@ -45,7 +45,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain public TerrainChannel() { - map = new double[Constants.RegionSize,Constants.RegionSize]; + map = new double[Constants.RegionSize, Constants.RegionSize]; taint = new bool[Constants.RegionSize / 16,Constants.RegionSize / 16]; int x; diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs index fb81abcf65..f47e6c04db 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs @@ -494,8 +494,9 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain } /// - /// Checks to see if the terrain has been modified since last check - /// if the call is asked to respect the estate settings for terrain_raise_limit and + /// Checks to see if the terrain has been modified since last check. + /// If it has been modified, every all the terrain patches are sent to the client. + /// If the call is asked to respect the estate settings for terrain_raise_limit and /// terrain_lower_limit, it will clamp terrain updates between these values /// currently invoked by client_OnModifyTerrain only and not the Commander interfaces /// should height map deltas be limited to the estate settings limits @@ -520,6 +521,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain // what we are going to send to the client serialised = m_channel.GetFloatsSerialised(); } + SendToClients(serialised, x, y); shouldTaint = true; } @@ -578,7 +580,11 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain private void SendToClients(float[] serialised, int x, int y) { m_scene.ForEachClient( - delegate(IClientAPI controller) { controller.SendLayerData(x / Constants.TerrainPatchSize, y / Constants.TerrainPatchSize, serialised); }); + delegate(IClientAPI controller) + { controller.SendLayerData( + x / Constants.TerrainPatchSize, y / Constants.TerrainPatchSize, serialised); + } + ); } private void client_OnModifyTerrain(float height, float seconds, byte size, byte action, float north, float west,