From 1453a192f49b6f617236def66faa103eda4e4572 Mon Sep 17 00:00:00 2001 From: Gremlin13 Date: Mon, 10 Oct 2011 06:11:18 +0700 Subject: [PATCH] * Fixed AddObjectVehicle packet --- Chraft/Net/Packets/Packet.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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