diff --git a/Chraft/Net/Packets/Packet.cs b/Chraft/Net/Packets/Packet.cs index 54172384..73188922 100644 --- a/Chraft/Net/Packets/Packet.cs +++ b/Chraft/Net/Packets/Packet.cs @@ -718,8 +718,7 @@ public class AddObjectVehiclePacket : Packet public short UnknownB { get; set; } public short UnknownC { get; set; } - // TODO: length here isn't fixed, it can be 22 or 28, must understand what UnknownFlag is. - protected override int Length { get { return 28; } } + protected override int Length { get { return UnknownFlag > 0 ? 28 : 22; } } public override void Read(PacketReader stream) { @@ -743,9 +742,12 @@ public override void Write() Writer.Write((int)(Y * 32)); Writer.Write((int)(Z * 32)); Writer.Write(UnknownFlag); - Writer.Write(UnknownA); - Writer.Write(UnknownB); - Writer.Write(UnknownC); + if (UnknownFlag != 0) + { + Writer.Write(UnknownA); + Writer.Write(UnknownB); + Writer.Write(UnknownC); + } } public enum ObjectType : sbyte