Skip to content

Commit

Permalink
[Core] Fixed that newFace would not be parsed correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Linwenxuan authored and Linwenxuan committed Dec 16, 2023
1 parent fea9bea commit 06f5137
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using ProtoBuf;


#pragma warning disable CS8618
namespace Lagrange.Core.Internal.Packets.Message.Element.Implementation.Extra;

[ProtoContract]
internal class QSmallFaceExtra
{
[ProtoMember(1)] public uint FaceId { get; set; }

[ProtoMember(2)] public string Preview { get; set; }

[ProtoMember(3)] public string Preview2 { get; set; }
}
8 changes: 7 additions & 1 deletion Lagrange.Core/Message/Entity/FaceEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,19 @@ IEnumerable<Elem> IMessageEntity.PackElement()
if (faceId != null) return new FaceEntity((ushort)faceId, false);
}

if (elems.CommonElem is { PbElem: not null } common)
if (elems.CommonElem is { ServiceType:37, PbElem: not null } common)
{
var qFace = Serializer.Deserialize<QFaceExtra>(common.PbElem.AsSpan());

ushort? faceId = (ushort?)qFace.FaceId;
if (faceId != null) return new FaceEntity((ushort)faceId, true);
}

if (elems.CommonElem is { ServiceType: 33, PbElem: not null } append)
{
var qSmallFace = Serializer.Deserialize<QSmallFaceExtra>(append.PbElem.AsSpan());
return new FaceEntity((ushort)qSmallFace.FaceId, false);
}

return null;
}
Expand Down

0 comments on commit 06f5137

Please sign in to comment.