diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 0bb25480ab..5a934a9170 100755 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -7408,14 +7408,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP { if (part.IsRoot) { - UUID fromID = part.ParentGroup.FromItemID; - if(fromID.IsZero()) - fromID = part.UUID; - nv = Util.StringToBytes256("AttachItemID STRING RW SV " + fromID.ToString()); + if (part.ParentGroup.FromItemID.IsZero()) + nv = Util.StringToBytes256("AttachItemID STRING RW SV " + part.UUID.ToString()); + else + nv = Util.StringToBytes256("AttachItemID STRING RW SV " + part.ParentGroup.FromItemID.ToString()); } - int st = (int)part.ParentGroup.AttachmentPoint; - state = (byte)(((st & 0xf0) >> 4) + ((st & 0x0f) << 4)); ; + int st = 0xff & (int)part.ParentGroup.AttachmentPoint; + state = (byte)((st >> 4) | (st << 4)); } // filter out mesh faces hack @@ -7658,8 +7658,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP nv = Util.StringToBytes256("AttachItemID STRING RW SV " + fromID.ToString()); } - int st = (int)part.ParentGroup.AttachmentPoint; - state = (byte)(((st & 0xf0) >> 4) + ((st & 0x0f) << 4)); ; + int st = 0xff & (int)part.ParentGroup.AttachmentPoint; + state = (byte)((st & >> 4) | (st << 4)); } bool hastext = part.Text != null && part.Text.Length > 0; @@ -7868,7 +7868,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP PrimFlags primflags = (PrimFlags)m_scene.Permissions.GenerateClientFlags(part, sp); // Don't send the CreateSelected flag to everyone primflags &= ~PrimFlags.CreateSelected; - if (sp.UUID == part.OwnerID) + if (sp.UUID.Equals(part.OwnerID)) { if (part.CreateSelected) { @@ -7925,13 +7925,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP { if (part.IsRoot) { - UUID fromID = part.ParentGroup.FromItemID; - if (fromID.IsZero()) - fromID = part.UUID; - nv = Util.StringToBytes256("AttachItemID STRING RW SV " + fromID.ToString()); + if (part.ParentGroup.FromItemID.IsZero()) + nv = Util.StringToBytes256("AttachItemID STRING RW SV " + part.UUID.ToString()); + else + nv = Util.StringToBytes256("AttachItemID STRING RW SV " + part.ParentGroup.FromItemID.ToString()); } - int st = (int)part.ParentGroup.AttachmentPoint; - state = (byte)(((st & 0xf0) >> 4) + ((st & 0x0f) << 4)); ; + int st = 0xff & (int)part.ParentGroup.AttachmentPoint; + state = (byte)((st >> 4) | (st << 4)); } bool hastext = false; @@ -8068,10 +8068,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP zc.AddByte(part.ClickAction); zc.AddVector3(part.Shape.Scale); zc.AddVector3(part.RelativePosition); - if (pcode == PCode.Grass) - zc.AddZeros(12); - else - zc.AddNormQuat(part.RotationOffset); + zc.AddNormQuat(part.RotationOffset); zc.AddUInt((uint)cflags); diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPZeroEncoder.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPZeroEncoder.cs index 7f670b9993..e82c40557f 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPZeroEncoder.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPZeroEncoder.cs @@ -26,14 +26,13 @@ */ using System; -using System.Text; +using System.Runtime.CompilerServices; using OpenSim.Framework; -using Nini.Config; using OpenMetaverse; namespace OpenSim.Region.ClientStack.LindenUDP { - public sealed class LLUDPZeroEncoder + public class LLUDPZeroEncoder { private byte[] m_tmp = new byte[16]; private byte[] m_dest; @@ -86,6 +85,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void AddZeros(int len) { zerocount += len; @@ -97,6 +97,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe int Finish() { if(zerocount > 0) @@ -114,11 +115,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (src[i] == 0x00) { zerocount++; - if (zerocount == 0) + if (zerocount == 256) { m_dest[pos++] = 0x00; m_dest[pos++] = 0xff; - zerocount++; + zerocount = 1; } } else @@ -142,11 +143,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (src[i] == 0x00) { zerocount++; - if (zerocount == 0) + if (zerocount == 256) { m_dest[pos++] = 0x00; m_dest[pos++] = 0xff; - zerocount++; + zerocount = 1; } } else @@ -168,11 +169,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (v == 0x00) { zerocount++; - if (zerocount == 0) + if (zerocount == 256) { m_dest[pos++] = 0x00; m_dest[pos++] = 0xff; - zerocount++; + zerocount = 1; } } else @@ -188,6 +189,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddInt16(short v) { if (v == 0) @@ -199,6 +201,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddUInt16(ushort v) { if (v == 0) @@ -210,6 +213,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddInt(int v) { if (v == 0) @@ -221,6 +225,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void AddUInt(uint v) { if (v == 0) @@ -232,12 +237,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddFloatToUInt16(float v, float range) { Utils.FloatToUInt16Bytes(v, range, m_tmp, 0); AddBytes(m_tmp, 2); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddFloat(float v) { if (v == 0f) @@ -249,6 +256,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddInt64(long v) { if (v == 0) @@ -260,6 +268,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddUInt64(ulong v) { if (v == 0) @@ -271,6 +280,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddVector3(Vector3 v) { if (v.IsZero()) @@ -282,6 +292,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddVector4(Vector4 v) { if (v.IsZero()) @@ -293,12 +304,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddNormQuat(Quaternion v) { v.ToBytes(m_tmp, 0); AddBytes(m_tmp, 12); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddUUID(UUID v) { v.ToBytes(m_tmp, 0); @@ -306,6 +319,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } // maxlen <= 255 and includes null termination byte + [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void AddShortString(string str, int maxlen) { if (String.IsNullOrEmpty(str)) @@ -328,6 +342,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } // maxlen <= 255 and includes null termination byte, maxchars == max len of utf16 source + [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void AddShortString(string str, int maxchars, int maxlen) { if (String.IsNullOrEmpty(str)) @@ -353,6 +368,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } // maxlen <= 254 because null termination byte + [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void AddShortLimitedUTF8(osUTF8 str) { if(str == null)