lludp: direct encode AvatarAppearance

0.9.1.0-post-fixes
UbitUmarov 2019-03-17 02:02:40 +00:00
parent 2ff5b322be
commit ee8ad3e69d
1 changed files with 39 additions and 22 deletions

View File

@ -3995,36 +3995,53 @@ namespace OpenSim.Region.ClientStack.LindenUDP
OutPacket(aw, ThrottleOutPacketType.Task | ThrottleOutPacketType.HighPriority); OutPacket(aw, ThrottleOutPacketType.Task | ThrottleOutPacketType.HighPriority);
} }
public void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry) static private readonly byte[] AvatarAppearanceHeader = new byte[] {
Helpers.MSG_RELIABLE | Helpers.MSG_ZEROCODED,
0, 0, 0, 0, // sequence number
0, // extra
0xff, 0xff, 0, 158 // ID 158 (low frequency bigendian) not zeroencoded
//0xff, 0xff, 0, 1, 158 // ID 158 (low frequency bigendian) zeroencoded
};
public void SendAppearance(UUID targetID, byte[] visualParams, byte[] textureEntry)
{ {
// m_log.DebugFormat( // doing post zero encode, because odds of beeing bad are not that low
// "[LLCLIENTVIEW]: Sending avatar appearance for {0} with {1} bytes to {2} {3}", UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint);
// agentID, textureEntry.Length, Name, AgentId); Buffer.BlockCopy(AvatarAppearanceHeader, 0, buf.Data, 0, 10);
byte[] data = buf.Data;
int pos = 10;
AvatarAppearancePacket avp = (AvatarAppearancePacket)PacketPool.Instance.GetPacket(PacketType.AvatarAppearance); //sender block
// TODO: don't create new blocks if recycling an old packet targetID.ToBytes(data, pos); pos += 16;
avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[visualParams.Length]; data[pos++] = 0;// is trial = false
avp.ObjectData.TextureEntry = textureEntry;
AvatarAppearancePacket.VisualParamBlock avblock = null; // objectdata block ie texture
for (int i = 0; i < visualParams.Length; i++) int len = textureEntry.Length;
if (len == 0)
{ {
avblock = new AvatarAppearancePacket.VisualParamBlock(); data[pos++] = 0;
avblock.ParamValue = visualParams[i]; data[pos++] = 0;
avp.VisualParam[i] = avblock; }
else
{
data[pos++] = (byte)len;
data[pos++] = (byte)(len >> 8);
Buffer.BlockCopy(textureEntry, 0, data, pos, len); pos += len;
} }
avp.Sender.IsTrial = false; // visual parameters
avp.Sender.ID = agentID; len = visualParams.Length;
avp.AppearanceData = new AvatarAppearancePacket.AppearanceDataBlock[0]; data[pos++] = (byte)len;
avp.AppearanceHover = new AvatarAppearancePacket.AppearanceHoverBlock[0]; if(len > 0)
Buffer.BlockCopy(visualParams, 0, data, pos, len); pos += len;
// this need be use in future ? // no AppearanceData
// avp.AppearanceData[0].AppearanceVersion = 0; data[pos++] = 0;
// avp.AppearanceData[0].CofVersion = 0; // no AppearanceHover
data[pos++] = 0;
//m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString()); buf.DataLength = pos;
OutPacket(avp, ThrottleOutPacketType.Task | ThrottleOutPacketType.HighPriority); m_udpServer.SendUDPPacket(m_udpClient, buf, ThrottleOutPacketType.Task | ThrottleOutPacketType.HighPriority, null, false, true);
} }
static private readonly byte[] AvatarAnimationHeader = new byte[] { static private readonly byte[] AvatarAnimationHeader = new byte[] {