Pull some PacketDecoder changes from Ubit OMV
This commit is contained in:
@@ -335,7 +335,11 @@ namespace OpenMetaverse.Packets
|
||||
"(" + point + ")",
|
||||
"AttachmentPoint");
|
||||
|
||||
// TODO: CRC
|
||||
//CRC
|
||||
result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
|
||||
"CRC",
|
||||
Utils.BytesToUInt(block, i),
|
||||
"UInt");
|
||||
|
||||
i += 4;
|
||||
// Material
|
||||
@@ -483,7 +487,12 @@ namespace OpenMetaverse.Packets
|
||||
|
||||
// Extra parameters TODO:
|
||||
Primitive prim = new Primitive();
|
||||
i += prim.SetExtraParamsFromBytes(block, i);
|
||||
int extrapLen = prim.SetExtraParamsFromBytes(block, i);
|
||||
i += extrapLen;
|
||||
result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
|
||||
"ExtraParams[]",
|
||||
extrapLen,
|
||||
"byte[]");
|
||||
|
||||
//Sound data
|
||||
if ((flags & CompressedFlags.HasSound) != 0)
|
||||
@@ -538,7 +547,7 @@ namespace OpenMetaverse.Packets
|
||||
nameValues[j] = nv;
|
||||
}
|
||||
}
|
||||
DecodeNameValue("NameValues", nameValues);
|
||||
result.AppendLine(DecodeNameValue("NameValues", nameValues));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -658,6 +667,17 @@ namespace OpenMetaverse.Packets
|
||||
result.AppendLine(a);
|
||||
}
|
||||
|
||||
if ((flags & CompressedFlags.HasParticlesNew) != 0)
|
||||
{
|
||||
Primitive.ParticleSystem p = new Primitive.ParticleSystem(block, i);
|
||||
result.AppendLine(DecodeObjectParticleSystem("ParticleSystemNEW", p));
|
||||
i += 94;
|
||||
if ((p.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.DataGlow) != 0)
|
||||
i += 2;
|
||||
if ((p.PartDataFlags & Primitive.ParticleSystem.ParticleDataFlags.DataBlend) != 0)
|
||||
i += 2;
|
||||
}
|
||||
|
||||
return result.ToString();
|
||||
}
|
||||
|
||||
@@ -669,18 +689,96 @@ namespace OpenMetaverse.Packets
|
||||
return String.Format("{0,30}: {1,2} {2,-38} [{3}]",
|
||||
fieldName + " (Tree Species)",
|
||||
fieldData,
|
||||
"(" + (Tree)(byte)fieldData + ")",
|
||||
//"(" + (Tree)(byte)fieldData + ")",
|
||||
"(" + (Tree)data[0] + ")",
|
||||
fieldData.GetType().Name);
|
||||
}
|
||||
else if (data.Length == 60)
|
||||
else if (data.Length == 76)
|
||||
{
|
||||
/* TODO: these are likely useful packed fields,
|
||||
* need to unpack them */
|
||||
return Utils.BytesToHexString((byte[])fieldData, String.Format("{0,30}", fieldName));
|
||||
Vector4 col = Vector4.Zero;
|
||||
Vector3 offset = Vector3.Zero;
|
||||
Vector3 vel = Vector3.Zero;
|
||||
Vector3 acc = Vector3.Zero;
|
||||
Quaternion q = Quaternion.Identity;
|
||||
Vector3 angvel = Vector3.Zero;
|
||||
|
||||
col.FromBytes(data, 0);
|
||||
offset.FromBytes(data, 16);
|
||||
vel.FromBytes(data, 28);
|
||||
acc.FromBytes(data, 40);
|
||||
q.FromBytes(data, 52, true);
|
||||
angvel.FromBytes(data, 64);
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
|
||||
"ColisionPlane",
|
||||
col,
|
||||
"Vector4");
|
||||
result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
|
||||
"Offset",
|
||||
offset,
|
||||
"Vector3");
|
||||
result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
|
||||
"Velocity",
|
||||
vel,
|
||||
"Vector3");
|
||||
result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
|
||||
"Acceleration",
|
||||
acc,
|
||||
"Vector3");
|
||||
result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
|
||||
"rotation",
|
||||
q,
|
||||
"Quaternion");
|
||||
result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
|
||||
"Omega",
|
||||
angvel,
|
||||
"Vector3");
|
||||
return result.ToString();
|
||||
}
|
||||
else if (data.Length == 60)
|
||||
{
|
||||
/* TODO: these are likely useful packed fields, need to unpack them */
|
||||
Vector3 offset = Vector3.Zero;
|
||||
Vector3 vel = Vector3.Zero;
|
||||
Vector3 acc = Vector3.Zero;
|
||||
Quaternion q = Quaternion.Identity;
|
||||
Vector3 angvel = Vector3.Zero;
|
||||
|
||||
offset.FromBytes(data, 0);
|
||||
vel.FromBytes(data, 12);
|
||||
acc.FromBytes(data, 24);
|
||||
q.FromBytes(data, 36, true);
|
||||
angvel.FromBytes(data, 48);
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
|
||||
"Offset",
|
||||
offset,
|
||||
"Vector3");
|
||||
result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
|
||||
"Velocity",
|
||||
vel,
|
||||
"Vector3");
|
||||
result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
|
||||
"Acceleration",
|
||||
acc,
|
||||
"Vector3");
|
||||
result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
|
||||
"rotation",
|
||||
q,
|
||||
"Quaternion");
|
||||
result.AppendFormat("{0,30}: {1,-40} [{2}]" + Environment.NewLine,
|
||||
"Omega",
|
||||
angvel,
|
||||
"Vector3");
|
||||
return result.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return Utils.BytesToHexString((byte[])fieldData, String.Format("{0,30}", fieldName));
|
||||
return Utils.BytesToHexString((byte[])fieldData, $"{fieldName, 30}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -688,8 +786,8 @@ namespace OpenMetaverse.Packets
|
||||
{
|
||||
StringBuilder result = new StringBuilder();
|
||||
Primitive.TextureAnimation TextureAnim;
|
||||
if (fieldData is Primitive.TextureAnimation)
|
||||
TextureAnim = (Primitive.TextureAnimation)fieldData;
|
||||
if (fieldData is Primitive.TextureAnimation data)
|
||||
TextureAnim = data;
|
||||
else
|
||||
TextureAnim = new Primitive.TextureAnimation((byte[])fieldData, 0);
|
||||
|
||||
@@ -716,23 +814,27 @@ namespace OpenMetaverse.Packets
|
||||
|
||||
private static string DecodeNameValue(string fieldName, object fieldData)
|
||||
{
|
||||
string nameValue = Utils.BytesToString((byte[])fieldData);
|
||||
NameValue[] nameValues = null;
|
||||
if (nameValue.Length > 0)
|
||||
if (fieldData is NameValue[])
|
||||
nameValues = fieldData as NameValue[];
|
||||
else
|
||||
{
|
||||
string[] lines = nameValue.Split('\n');
|
||||
nameValues = new NameValue[lines.Length];
|
||||
|
||||
for (int i = 0; i < lines.Length; i++)
|
||||
string nameValue = Utils.BytesToString((byte[])fieldData);
|
||||
if (nameValue.Length > 0)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(lines[i]))
|
||||
string[] lines = nameValue.Split('\n');
|
||||
nameValues = new NameValue[lines.Length];
|
||||
|
||||
for (int i = 0; i < lines.Length; i++)
|
||||
{
|
||||
NameValue nv = new NameValue(lines[i]);
|
||||
nameValues[i] = nv;
|
||||
if (!String.IsNullOrEmpty(lines[i]))
|
||||
{
|
||||
NameValue nv = new NameValue(lines[i]);
|
||||
nameValues[i] = nv;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.AppendFormat("{0,30}", " <NameValues>" + Environment.NewLine);
|
||||
if (nameValues != null)
|
||||
@@ -759,6 +861,9 @@ namespace OpenMetaverse.Packets
|
||||
Primitive.FlexibleData Flexible = null;
|
||||
Primitive.LightData Light = null;
|
||||
Primitive.SculptData Sculpt = null;
|
||||
Primitive.SculptData Mesh = null;
|
||||
uint meshFlags = 0;
|
||||
bool hasmeshFlags = false;
|
||||
|
||||
byte extraParamCount = data[i++];
|
||||
|
||||
@@ -776,7 +881,13 @@ namespace OpenMetaverse.Packets
|
||||
Light = new Primitive.LightData(data, i);
|
||||
else if (type == ExtraParamType.Sculpt)
|
||||
Sculpt = new Primitive.SculptData(data, i);
|
||||
|
||||
else if (type == ExtraParamType.Mesh)
|
||||
Mesh = new Primitive.SculptData(data, i);
|
||||
else if ((byte)type == 0x70)
|
||||
{
|
||||
hasmeshFlags = true;
|
||||
meshFlags = Utils.BytesToUInt(data, i);
|
||||
}
|
||||
i += (int)paramLength;
|
||||
//totalLength += (int)paramLength + 6;
|
||||
}
|
||||
@@ -797,6 +908,13 @@ namespace OpenMetaverse.Packets
|
||||
result.AppendFormat("{0,30}", "</Sculpt>" + Environment.NewLine);
|
||||
}
|
||||
|
||||
if (Mesh != null)
|
||||
{
|
||||
result.AppendFormat("{0,30}", "<Mesh>" + Environment.NewLine);
|
||||
GenericTypeDecoder(Mesh, ref result);
|
||||
result.AppendFormat("{0,30}", "</Mesh>" + Environment.NewLine);
|
||||
}
|
||||
|
||||
if (Light != null)
|
||||
{
|
||||
result.AppendFormat("{0,30}", "<Light>" + Environment.NewLine);
|
||||
@@ -804,6 +922,13 @@ namespace OpenMetaverse.Packets
|
||||
result.AppendFormat("{0,30}", "</Light>" + Environment.NewLine);
|
||||
}
|
||||
|
||||
if (hasmeshFlags)
|
||||
{
|
||||
result.AppendFormat("{0,30}", "<MeshFlags>" + Environment.NewLine);
|
||||
result.AppendFormat("{0,30}", meshFlags.ToString() + Environment.NewLine);
|
||||
result.AppendFormat("{0,30}", "</MeshFlags>" + Environment.NewLine);
|
||||
}
|
||||
|
||||
result.AppendFormat("{0,30}", "</ExtraParams>");
|
||||
return result.ToString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user