diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index b2786d45e9..f5fd5f5f42 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -1143,6 +1143,8 @@ namespace OpenSim.Framework void SendGenericMessage(string method, UUID invoice, List message); void SendGenericMessage(string method, UUID invoice, List message); + bool CanSendLayerData(); + void SendLayerData(float[] map); void SendLayerData(int px, int py, float[] map); diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 36c37801b7..46836b1d61 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -1199,6 +1199,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP OutPacket(GATRP, ThrottleOutPacketType.Task); } + + public virtual bool CanSendLayerData() + { + int n = m_udpClient.GetCatBytesInSendQueue(ThrottleOutPacketType.Land); + if ( n > 100000) + return false; + return true; + } + /// /// Send the region heightmap to the client /// This method is only called when not doing intellegent terrain patch sending and @@ -9151,7 +9160,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if ((locX >= m_scene.RegionInfo.WorldLocX) && (locX < (m_scene.RegionInfo.WorldLocX + m_scene.RegionInfo.RegionSizeX)) && (locY >= m_scene.RegionInfo.WorldLocY) - && (locY < (m_scene.RegionInfo.WorldLocY + m_scene.RegionInfo.RegionSizeY)) ) + && (locY < (m_scene.RegionInfo.WorldLocY + m_scene.RegionInfo.RegionSizeY))) { tpLocReq.Info.RegionHandle = m_scene.RegionInfo.RegionHandle; tpLocReq.Info.Position.X += locX - m_scene.RegionInfo.WorldLocX; diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs index 0ae7617a61..4b541e66fd 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs @@ -474,6 +474,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP return data; } + + public int GetCatBytesInSendQueue(ThrottleOutPacketType cat) + { + ; + int icat = (int)cat; + if (icat > 0 && icat < THROTTLE_CATEGORY_COUNT) + { + TokenBucket bucket = m_throttleCategories[icat]; + return m_packetOutboxes[icat].Count; + } + else + return 0; + } + public int GetCatBytesCanSend(ThrottleOutPacketType cat, int timeMS) { diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index dfafcadb0e..118c8f8634 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs @@ -229,11 +229,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain } m_scene.RegisterModuleInterface(this); + m_scene.EventManager.OnFrame += EventManager_OnFrame; m_scene.EventManager.OnNewClient += EventManager_OnNewClient; m_scene.EventManager.OnClientClosed += EventManager_OnClientClosed; m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; m_scene.EventManager.OnTerrainTick += EventManager_OnTerrainTick; - m_scene.EventManager.OnFrame += EventManager_OnFrame; } InstallDefaultEffects(); @@ -767,6 +767,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain /// private void EventManager_OnFrame() { + // this needs fixing TerrainData terrData = m_channel.GetTerrainData(); bool shouldTaint = false; @@ -792,6 +793,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain m_scene.EventManager.TriggerTerrainTainted(); m_tainted = true; } + } /// @@ -993,6 +995,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain { foreach (PatchUpdates pups in m_perClientPatchUpdates.Values) { + // throught acording to land queue free to send bytes + if (!pups.Presence.ControllingClient.CanSendLayerData()) + continue; + if (pups.HasUpdates()) { // There is something that could be sent to this client. diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 51ecc8d8f3..89e18b0eb8 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -997,6 +997,11 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server } + public virtual bool CanSendLayerData() + { + return false; + } + public void SendLayerData(float[] map) { diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 0b4d03adf2..dcd2a5272d 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -671,6 +671,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC } + public virtual bool CanSendLayerData() + { + return false; + } + public virtual void SendLayerData(float[] map) { } diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index 96bccd2e47..5daca1e908 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -590,6 +590,11 @@ namespace OpenSim.Tests.Common.Mock } + public virtual bool CanSendLayerData() + { + return false; + } + public virtual void SendLayerData(float[] map) { }