From 16b6738cdadc70966a93b6d025ae469738955dcb Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Fri, 26 Sep 2008 17:25:22 +0000 Subject: * Patch from JHurliman * Updates to libomv r2243, * Remove lots of unnecessary typecasts * Improves SendWindData() Thanks jhurliman. * Will update OpenSim-libs in 10 minutes.. --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 110 +++++++-------------- .../ClientStack/LindenUDP/LLPacketHandler.cs | 10 +- .../Region/ClientStack/LindenUDP/LLPacketQueue.cs | 5 +- OpenSim/Region/ClientStack/LindenUDP/LLQueItem.cs | 1 + 4 files changed, 45 insertions(+), 81 deletions(-) (limited to 'OpenSim/Region/ClientStack') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 4027377..5a48c90 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -1232,43 +1232,40 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// /// Send the region heightmap to the client /// - /// heightmap - public virtual void SendWindData(float[] map) + /// 16x16 array of wind speeds + public virtual void SendWindData(Vector2[] windSpeeds) { - //ThreadPool.QueueUserWorkItem(new WaitCallback(DoSendWindData), (object)map); + ThreadPool.QueueUserWorkItem(new WaitCallback(DoSendWindData), (object)windSpeeds); } /// /// Send terrain layer information to the client. /// /// - //private void DoSendWindData(object o) - //{ - //float[] map = (float[])o; - - //try - //{ - //for (int y = 0; y < 16; y++) - //{ - // 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++) - //{ - //SendWindData(x, y, map); - //Thread.Sleep(35); - //} - //} - //} - //catch (Exception e) - //{ - // m_log.Warn("[CLIENT]: ClientView.API.cs: SendLayerData() - Failed with exception " + e.ToString()); - // } - //} + private void DoSendWindData(object o) + { + Vector2[] windSpeeds = (Vector2[])o; + + TerrainPatch[] patches = new TerrainPatch[2]; + patches[0] = new TerrainPatch(); + patches[0].Data = new float[16 * 16]; + patches[1] = new TerrainPatch(); + patches[1].Data = new float[16 * 16]; + + for (int y = 0; y < 16; y++) + { + for (int x = 0; x < 16; x++) + { + patches[0].Data[y * 16 + x] = windSpeeds[y * 16 + x].X; + patches[1].Data[y * 16 + x] = windSpeeds[y * 16 + x].Y; + } + } + + LayerDataPacket layerpack = TerrainCompressor.CreateLayerDataPacket(patches, TerrainPatch.LayerType.Wind); + layerpack.Header.Zerocoded = true; + + OutPacket(layerpack, ThrottleOutPacketType.Wind); + } /// /// Sends a set of four patches (x, x+1, ..., x+3) to the client @@ -1289,41 +1286,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP // } /// - /// Sends a specified patch to a client - /// - /// Patch coordinate (x) 0..15 - /// Patch coordinate (y) 0..15 - /// heightmap - public void SendWindData(int p1x, int p1y, int p2x, int p2y, float[] map) - { - try - { - int[] patches = new int[2]; - int patch1x, patch1y, patch2x, patch2y; - patch1x = p1x; - patch1y = p1y; - patch2x = p2x; - patch2y = p2y; - - - patches[0] = patch1x + 0 + patch1y * 16; - patches[1] = patch2x + 0 + patch2y * 16; - - LayerDataPacket layerpack = TerrainCompressor.CreateWindPacket(map, patches); - layerpack.Header.Zerocoded = true; - - OutPacket(layerpack, ThrottleOutPacketType.Wind); - - } - catch (Exception e) - { - m_log.Warn("[client]: ClientView.API.cs: SendLayerData() - Failed with exception " + e.ToString()); - } - } - - - - /// /// Tell the client that the given neighbour region is ready to receive a child agent. /// /// @@ -2940,13 +2902,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP updatePacket.ParcelData.PassPrice = landData.PassPrice; updatePacket.ParcelData.PublicCount = 0; //unemplemented - updatePacket.ParcelData.RegionDenyAnonymous = ((regionFlags & (uint)Simulator.RegionFlags.DenyAnonymous) > + updatePacket.ParcelData.RegionDenyAnonymous = ((regionFlags & (uint)RegionFlags.DenyAnonymous) > 0); - updatePacket.ParcelData.RegionDenyIdentified = ((regionFlags & (uint)Simulator.RegionFlags.DenyIdentified) > + updatePacket.ParcelData.RegionDenyIdentified = ((regionFlags & (uint)RegionFlags.DenyIdentified) > 0); - updatePacket.ParcelData.RegionDenyTransacted = ((regionFlags & (uint)Simulator.RegionFlags.DenyTransacted) > + updatePacket.ParcelData.RegionDenyTransacted = ((regionFlags & (uint)RegionFlags.DenyTransacted) > 0); - updatePacket.ParcelData.RegionPushOverride = ((regionFlags & (uint)Simulator.RegionFlags.RestrictPushObject) > + updatePacket.ParcelData.RegionPushOverride = ((regionFlags & (uint)RegionFlags.RestrictPushObject) > 0); updatePacket.ParcelData.RentPrice = 0; @@ -3586,7 +3548,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP { string name = (string)nod.Attributes["name"].Value.ToLower(); string id = (string)nod.InnerText; - m_defaultAnimations.Add(name, id); + m_defaultAnimations.Add(name, (UUID)id); } } } @@ -4936,9 +4898,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP // if (transfer.TransferInfo.SourceType == 3) { - UUID taskID = null; - UUID itemID = null; - UUID requestID = null; + UUID taskID = UUID.Zero; + UUID itemID = UUID.Zero; + UUID requestID = UUID.Zero; taskID = new UUID(transfer.TransferInfo.Params, 48); itemID = new UUID(transfer.TransferInfo.Params, 64); requestID = new UUID(transfer.TransferInfo.Params, 80); @@ -5569,7 +5531,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP { ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); entry.AgentID = block.ID; - entry.Flags = (ParcelManager.AccessList)block.Flags; + entry.Flags = (AccessList)block.Flags; entry.Time = new DateTime(); entries.Add(entry); } diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs index d885e3b..149fa9a 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs @@ -109,6 +109,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public Packet Packet; public Object Identifier; + public int TickCount; } private Dictionary m_NeedAck = @@ -293,12 +294,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP Packet packet, ThrottleOutPacketType throttlePacketType, Object id) { - packet.TickCount = System.Environment.TickCount; - LLQueItem item = new LLQueItem(); item.Packet = packet; item.Incoming = false; item.throttleType = throttlePacketType; + item.TickCount = System.Environment.TickCount; item.Identifier = id; m_PacketQueue.Enqueue(item); @@ -341,7 +341,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // Packets this old get resent // - if ((now - packet.TickCount) > m_ResendTimeout) + if ((now - data.TickCount) > m_ResendTimeout) { // Resend the packet. Set the packet's tick count to // now, and keep it marked as resent. @@ -357,7 +357,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // pipes. Most likely, the client is gone // Drop the packets // - if ((now - packet.TickCount) > m_DiscardTimeout) + if ((now - data.TickCount) > m_DiscardTimeout) { if (!m_ImportantPackets.Contains(packet.Type)) m_NeedAck.Remove(packet.Header.Sequence); @@ -729,7 +729,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP Packet packet = item.Packet; // Keep track of when this packet was sent out - packet.TickCount = System.Environment.TickCount; + item.TickCount = System.Environment.TickCount; // Assign sequence number here to prevent out of order packets if (packet.Header.Sequence == 0) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs index 32b4bc1..81c789a 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs @@ -36,6 +36,7 @@ using OpenSim.Framework.Statistics; using OpenSim.Framework.Statistics.Interfaces; using Timer=System.Timers.Timer; + namespace OpenSim.Region.ClientStack.LindenUDP { public class LLPacketQueue : IPullStatsProvider @@ -45,7 +46,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP private bool m_enabled = true; - private BlockingQueue SendQueue; + private OpenSim.Framework.BlockingQueue SendQueue; private Queue IncomingPacketQueue; private Queue OutgoingPacketQueue; @@ -91,7 +92,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // in it to process. it's an on-purpose threadlock though because // without it, the clientloop will suck up all sim resources. - SendQueue = new BlockingQueue(); + SendQueue = new OpenSim.Framework.BlockingQueue(); IncomingPacketQueue = new Queue(); OutgoingPacketQueue = new Queue(); diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLQueItem.cs b/OpenSim/Region/ClientStack/LindenUDP/LLQueItem.cs index 3bb0b7a..494d62b 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLQueItem.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLQueItem.cs @@ -40,6 +40,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public Packet Packet; public bool Incoming; public ThrottleOutPacketType throttleType; + public int TickCount; public Object Identifier; } } -- cgit v1.1