public static void HandlePlayerLogin(Packet packet) { var guid = packet.ReadGuid(); packet.Writer.WriteLine("GUID: " + guid); LoginGuid = guid; }
public static void HandleClientCharDelete(Packet packet) { var playerGuid = new byte[8]; playerGuid[2] = packet.ReadBit(); playerGuid[1] = packet.ReadBit(); playerGuid[5] = packet.ReadBit(); playerGuid[7] = packet.ReadBit(); playerGuid[6] = packet.ReadBit(); var unknown = packet.ReadBit(); playerGuid[3] = packet.ReadBit(); playerGuid[0] = packet.ReadBit(); playerGuid[4] = packet.ReadBit(); packet.ReadXORByte(playerGuid, 1); packet.ReadXORByte(playerGuid, 3); packet.ReadXORByte(playerGuid, 4); packet.ReadXORByte(playerGuid, 0); packet.ReadXORByte(playerGuid, 7); packet.ReadXORByte(playerGuid, 2); packet.ReadXORByte(playerGuid, 5); packet.ReadXORByte(playerGuid, 6); var guid = new Guid(BitConverter.ToUInt64(playerGuid, 0)); packet.WriteGuid("GUID", playerGuid); }
public static void HandleMovementMessages(Packet packet) { Guid guid; if ((ClientVersion.AddedInVersion(ClientVersionBuild.V3_2_0_10192) || packet.Direction == Direction.ServerToClient) && ClientVersion.Build != ClientVersionBuild.V4_2_2_14545) { guid = packet.ReadPackedGuid("GUID"); } else { guid = new Guid(); } ReadMovementInfo(ref packet, guid); if (packet.Opcode != Opcodes.GetOpcode(Opcode.MSG_MOVE_KNOCK_BACK)) { return; } packet.ReadSingle("Sin Angle"); packet.ReadSingle("Cos Angle"); packet.ReadSingle("Speed"); packet.ReadSingle("Velocity"); }
public static void HandleNullMail(Packet packet) { if (packet.Direction == Direction.ClientToServer) { return; } // Math.Abs(this float) > 0.0f returns whether the player has received a new mail since last visiting a mailbox packet.ReadSingle("Time since last time visiting a mailbox (can be < 0.0)"); var count = packet.ReadUInt32("Count"); for (var i = 0; i < count; ++i) { var data = packet.ReadUInt64(); if (data == 0 || ((data & 0xFFFFFFFF00000000) >> 32) == 0) { packet.Writer.WriteLine("Entry: " + ((data & 0x00000000FFFFFFFF) >> 32)); } else { var guid = new Guid(data); packet.Writer.WriteLine("[" + i + "] GUID: " + guid); } packet.ReadUInt32("COD", i); packet.ReadUInt32("Unk uint32", i); packet.ReadUInt32("Stationery", i); packet.ReadSingle("Time?", i); } }
public static void HandlePlayerLogin422(Packet packet) { var guid = packet.StartBitStream(0, 4, 7, 1, 3, 2, 5, 6); packet.ParseBitStream(guid, 5, 0, 3, 4, 7, 2, 6, 1); packet.WriteGuid("Guid", guid); LoginGuid = new Guid(BitConverter.ToUInt64(guid, 0)); }
public static void HandlePlayerLogin433(Packet packet) { var guid = packet.StartBitStream(6, 7, 4, 5, 0, 1, 3, 2); packet.ParseBitStream(guid, 1, 4, 7, 2, 3, 6, 0, 5); packet.WriteGuid("Guid", guid); LoginGuid = new Guid(BitConverter.ToUInt64(guid, 0)); }
public static void HandlePlayerLogin434(Packet packet) { var guid = packet.StartBitStream(2, 3, 0, 6, 4, 5, 1, 7); packet.ParseBitStream(guid, 2, 7, 0, 3, 5, 6, 1, 4); packet.WriteGuid("Guid", guid); LoginGuid = new Guid(BitConverter.ToUInt64(guid, 0)); }
public static void HandleServerTrainerList(Packet packet) { var guid = new byte[8]; var npcTrainer = new NpcTrainer(); guid[0] = packet.ReadBit(); var titleLen = packet.ReadBits(11); packet.StartBitStream(guid, 5, 6, 1, 2, 7, 4, 3); var count = (int)packet.ReadBits("Count", 19); packet.ResetBitReader(); npcTrainer.TrainerSpells = new List <TrainerSpell>(count); for (var i = 0; i < count; ++i) { var trainerSpell = new TrainerSpell(); trainerSpell.RequiredSkillLevel = packet.ReadUInt32("Required Skill Level", i); trainerSpell.Cost = packet.ReadUInt32("Cost", i); trainerSpell.RequiredLevel = packet.ReadByte("Required Level", i); packet.ReadEntryWithName <Int32>(StoreNameType.Spell, "Required Spell ID", i); packet.ReadUInt32("Unk UInt32", i); // 0 packet.ReadUInt32("Unk UInt32", i); // 0 trainerSpell.Spell = (uint)packet.ReadEntryWithName <Int32>(StoreNameType.Spell, "Spell ID", i); packet.ReadEnum <TrainerSpellState>("State", TypeCode.Byte, i); trainerSpell.RequiredSkill = packet.ReadUInt32("Required Skill", i); npcTrainer.TrainerSpells.Add(trainerSpell); /*var trainerSpell = new TrainerSpell(); * trainerSpell.RequiredSkill = packet.ReadUInt32("Required Skill", i); * trainerSpell.RequiredSkillLevel = packet.ReadUInt32("Required Skill Level", i); * trainerSpell.Cost = packet.ReadUInt32("Cost", i); * * trainerSpell.RequiredLevel = packet.ReadByte("Required Level", i); * packet.ReadEntryWithName<Int32>(StoreNameType.Spell, "Required Spell ID", i); * packet.ReadInt32("Profession Dialog", i); * packet.ReadInt32("Profession Button", i); * * trainerSpell.Spell = (uint)packet.ReadEntryWithName<Int32>(StoreNameType.Spell, "Spell ID", i); * packet.ReadEnum<TrainerSpellState>("State", TypeCode.Byte, i); * * npcTrainer.TrainerSpells.Add(trainerSpell);*/ } packet.ReadXORBytes(guid, 5, 7, 6); npcTrainer.Title = packet.ReadWoWString("Title", titleLen); packet.ReadInt32("Unk Int32"); // 373 packet.ReadXORBytes(guid, 2, 3, 1, 0, 4); npcTrainer.Type = packet.ReadEnum <TrainerType>("Type", TypeCode.Int32); packet.WriteGuid("GUID", guid); var GUID = new Guid(BitConverter.ToUInt64(guid, 0)); Storage.NpcTrainers.Add(GUID.GetEntry(), npcTrainer, packet.TimeSpan); }
public static MovementInfo ReadMovementInfo(ref Packet packet, Guid guid) { if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_2_0_14333)) { return(ReadMovementInfo420(ref packet, guid, -1)); } return(ReadMovementInfo(ref packet, guid, -1)); }
public static void HandlePlayerLogin510(Packet packet) { var guid = packet.StartBitStream(1, 5, 0, 2, 7, 6, 3, 4); packet.ParseBitStream(guid, 6, 4, 3, 5, 0, 2, 7, 1); packet.WriteGuid("Guid", guid); packet.ReadSingle("Unk Float"); LoginGuid = new Guid(BitConverter.ToUInt64(guid, 0)); }
public static void HandlePlayerLogin(Packet packet) { packet.ReadSingle("Unk Float"); var guid = packet.StartBitStream(3, 4, 0, 6, 7, 1, 2, 5); packet.ParseBitStream(guid, 0, 3, 7, 6, 1, 2, 4, 5); LoginGuid = new Guid(BitConverter.ToUInt64(guid, 0)); packet.WriteGuid("Guid", guid); }
private static void ReadCreateObjectBlock(ref Packet packet, Guid guid, uint map, int index) { var objType = packet.ReadEnum <ObjectType>("Object Type", TypeCode.Byte, index); var moves = ReadMovementUpdateBlock(ref packet, guid, index); var updates = CoreParsers.UpdateHandler.ReadValuesUpdateBlock(ref packet, objType, index, true); WoWObject obj; switch (objType) { case ObjectType.Unit: obj = new Unit(); break; case ObjectType.GameObject: obj = new GameObject(); break; case ObjectType.Item: obj = new Item(); break; case ObjectType.Player: obj = new Player(); break; default: obj = new WoWObject(); break; } obj.Type = objType; obj.Movement = moves; obj.UpdateFields = updates; obj.Map = map; obj.Area = CoreParsers.WorldStateHandler.CurrentAreaId; obj.PhaseMask = (uint)CoreParsers.MovementHandler.CurrentPhaseMask; obj.Phases = new HashSet <ushort>(CoreParsers.MovementHandler.ActivePhases); // If this is the second time we see the same object (same guid, // same position) update its phasemask if (Storage.Objects.ContainsKey(guid)) { var existObj = Storage.Objects[guid].Item1; CoreParsers.UpdateHandler.ProcessExistingObject(ref existObj, obj, guid); // can't do "ref Storage.Objects[guid].Item1 directly } else { Storage.Objects.Add(guid, obj, packet.TimeSpan); } if (guid.HasEntry() && (objType == ObjectType.Unit || objType == ObjectType.GameObject)) { packet.AddSniffData(Utilities.ObjectTypeToStore(objType), (int)guid.GetEntry(), "SPAWN"); } }
public static void HandleLogoutComplete(Packet packet) { packet.ReadBit("Unk 1"); var guid = packet.StartBitStream(7, 3, 1, 5, 0, 6, 4, 2); packet.ParseBitStream(guid, 0, 5, 1, 2, 6, 3, 4, 7); packet.WriteGuid("Guid", guid); LoginGuid = new Guid(0); }
public static void HandlePetNameQuery(Packet packet) { var number = new byte[8]; var guid = new byte[8]; guid[6] = packet.ReadBit(); number[4] = packet.ReadBit(); number[6] = packet.ReadBit(); number[5] = packet.ReadBit(); guid[4] = packet.ReadBit(); number[7] = packet.ReadBit(); guid[5] = packet.ReadBit(); guid[3] = packet.ReadBit(); guid[2] = packet.ReadBit(); guid[7] = packet.ReadBit(); number[1] = packet.ReadBit(); number[0] = packet.ReadBit(); number[2] = packet.ReadBit(); number[3] = packet.ReadBit(); guid[1] = packet.ReadBit(); guid[0] = packet.ReadBit(); packet.ReadXORByte(guid, 7); packet.ReadXORByte(number, 2); packet.ReadXORByte(guid, 4); packet.ReadXORByte(guid, 6); packet.ReadXORByte(guid, 5); packet.ReadXORByte(number, 5); packet.ReadXORByte(guid, 3); packet.ReadXORByte(number, 0); packet.ReadXORByte(number, 6); packet.ReadXORByte(guid, 1); packet.ReadXORByte(number, 4); packet.ReadXORByte(guid, 0); packet.ReadXORByte(number, 7); packet.ReadXORByte(number, 1); packet.ReadXORByte(guid, 2); packet.ReadXORByte(number, 3); packet.WriteGuid("Guid2", number); packet.WriteGuid("Guid3", guid); var GUID = new Guid(BitConverter.ToUInt64(guid, 0)); var Number = BitConverter.ToUInt64(number, 0); packet.WriteGuid("Guid", guid); packet.WriteLine("Pet Number: {0}", Number); // Store temporary name (will be replaced in SMSG_PET_NAME_QUERY_RESPONSE) StoreGetters.AddName(GUID, Number.ToString(CultureInfo.InvariantCulture)); }
public static void ReadCreateObjectBlock(ref Packet packet, Guid guid, uint map, int index) { var objType = packet.ReadEnum <ObjectType>("Object Type", TypeCode.Byte, index); var moves = ReadMovementUpdateBlock(ref packet, guid, index); var updates = ReadValuesUpdateBlock(ref packet, objType, index); var obj = new WoWObject { Type = objType, Movement = moves, UpdateFields = updates, Map = map }; Stuffing.Objects.TryAdd(guid, obj); HandleUpdateFieldChangedValues(guid, objType, updates, moves, true); }
public static void HandlePetNameQuery(Packet packet) { var guid1 = new byte[8]; var guid2 = new byte[8]; guid2[1] = packet.ReadBit(); guid1[5] = packet.ReadBit(); guid2[3] = packet.ReadBit(); guid1[0] = packet.ReadBit(); guid1[3] = packet.ReadBit(); guid2[4] = packet.ReadBit(); guid1[1] = packet.ReadBit(); guid1[4] = packet.ReadBit(); guid2[0] = packet.ReadBit(); guid2[7] = packet.ReadBit(); guid1[6] = packet.ReadBit(); guid1[7] = packet.ReadBit(); guid1[2] = packet.ReadBit(); guid2[5] = packet.ReadBit(); guid2[2] = packet.ReadBit(); guid2[6] = packet.ReadBit(); packet.ReadXORByte(guid1, 1); packet.ReadXORByte(guid2, 5); packet.ReadXORByte(guid1, 5); packet.ReadXORByte(guid1, 4); packet.ReadXORByte(guid2, 1); packet.ReadXORByte(guid2, 7); packet.ReadXORByte(guid1, 7); packet.ReadXORByte(guid2, 4); packet.ReadXORByte(guid2, 2); packet.ReadXORByte(guid2, 0); packet.ReadXORByte(guid2, 6); packet.ReadXORByte(guid1, 6); packet.ReadXORByte(guid1, 0); packet.ReadXORByte(guid1, 3); packet.ReadXORByte(guid1, 2); packet.ReadXORByte(guid2, 3); packet.WriteGuid("Pet Guid", guid1); packet.WriteGuid("Pet Number", guid2); var PetGuid = new Guid(BitConverter.ToUInt64(guid1, 0)); var PetNumberGuid = new Guid(BitConverter.ToUInt64(guid2, 0)); var PetNumber = PetNumberGuid.GetEntry().ToString(CultureInfo.InvariantCulture); // Not sure about this. // Store temporary name from Pet Number GUID (will be retrieved as uint64 in SMSG_PET_NAME_QUERY_RESPONSE) StoreGetters.AddName(PetGuid, PetNumber); }
public static void HandlePlayerLogin430(Packet packet) { var bits = new bool[8]; for (var i = 0; i < 8; ++i) { bits[i] = packet.ReadBit(); } var bytes = new byte[8]; if (bits[3]) { bytes[4] = (byte)(packet.ReadByte() ^ 1); } if (bits[7]) { bytes[1] = (byte)(packet.ReadByte() ^ 1); } if (bits[4]) { bytes[7] = (byte)(packet.ReadByte() ^ 1); } if (bits[6]) { bytes[2] = (byte)(packet.ReadByte() ^ 1); } if (bits[5]) { bytes[6] = (byte)(packet.ReadByte() ^ 1); } if (bits[1]) { bytes[5] = (byte)(packet.ReadByte() ^ 1); } if (bits[2]) { bytes[3] = (byte)(packet.ReadByte() ^ 1); } if (bits[0]) { bytes[0] = (byte)(packet.ReadByte() ^ 1); } var guid = new Guid(BitConverter.ToUInt64(bytes, 0)); packet.WriteLine("GUID: {0}", guid); LoginGuid = guid; }
public static void HandleVendorInventoryList422(Packet packet) { var npcVendor = new NpcVendor(); var guidBytes = packet.StartBitStream(5, 6, 1, 2, 3, 0, 7, 4); packet.ReadXORByte(guidBytes, 2); packet.ReadXORByte(guidBytes, 3); var itemCount = packet.ReadUInt32("Item Count"); packet.ReadXORByte(guidBytes, 5); packet.ReadXORByte(guidBytes, 0); packet.ReadXORByte(guidBytes, 1); packet.ReadByte("Unk Byte"); packet.ReadXORByte(guidBytes, 4); packet.ReadXORByte(guidBytes, 7); packet.ReadXORByte(guidBytes, 6); var guid = new Guid(BitConverter.ToUInt64(guidBytes, 0)); packet.WriteLine("GUID: {0}", guid); npcVendor.VendorItems = new List <VendorItem>((int)itemCount); for (var i = 0; i < itemCount; i++) { var vendorItem = new VendorItem(); packet.ReadInt32("Max Durability", i); vendorItem.Slot = packet.ReadUInt32("Item Position", i); vendorItem.ItemId = (uint)packet.ReadEntryWithName <Int32>(StoreNameType.Item, "Item ID", i); packet.ReadInt32("Unk Int32 1", i); packet.ReadInt32("Display ID", i); var maxCount = packet.ReadInt32("Max Count", i); vendorItem.MaxCount = maxCount == -1 ? 0 : maxCount; // TDB packet.ReadUInt32("Buy Count", i); vendorItem.ExtendedCostId = packet.ReadUInt32("Extended Cost", i); packet.ReadInt32("Unk Int32 2", i); packet.ReadInt32("Price", i); // where's the vendorItem.Type (1/2)? npcVendor.VendorItems.Add(vendorItem); } Storage.NpcVendors.Add(guid.GetEntry(), npcVendor, packet.TimeSpan); }
private static void ReadCreateObjectBlock(ref Packet packet, Guid guid, uint map, int index) { var objType = packet.ReadEnum<ObjectType>("Object Type", TypeCode.Byte, index); var moves = ReadMovementUpdateBlock(ref packet, guid, index); var updates = CoreParsers.UpdateHandler.ReadValuesUpdateBlock(ref packet, objType, index, true); WoWObject obj; switch (objType) { case ObjectType.Unit: obj = new Unit(); break; case ObjectType.GameObject: obj = new GameObject(); break; case ObjectType.Item: obj = new Item(); break; case ObjectType.Player: obj = new Player(); break; default: obj = new WoWObject(); break; } obj.Type = objType; obj.Movement = moves; obj.UpdateFields = updates; obj.Map = map; obj.Area = CoreParsers.WorldStateHandler.CurrentAreaId; obj.PhaseMask = (uint)CoreParsers.MovementHandler.CurrentPhaseMask; obj.Phases = new HashSet<ushort>(CoreParsers.MovementHandler.ActivePhases); // If this is the second time we see the same object (same guid, // same position) update its phasemask if (Storage.Objects.ContainsKey(guid)) { var existObj = Storage.Objects[guid].Item1; CoreParsers.UpdateHandler.ProcessExistingObject(ref existObj, obj, guid); // can't do "ref Storage.Objects[guid].Item1 directly } else Storage.Objects.Add(guid, obj, packet.TimeSpan); if (guid.HasEntry() && (objType == ObjectType.Unit || objType == ObjectType.GameObject)) packet.AddSniffData(Utilities.ObjectTypeToStore(objType), (int)guid.GetEntry(), "SPAWN"); }
public static void HandleClientCharDelete(Packet packet) { var playerGuid = new byte[8]; playerGuid[1] = packet.ReadBit(); playerGuid[4] = packet.ReadBit(); playerGuid[7] = packet.ReadBit(); playerGuid[5] = packet.ReadBit(); playerGuid[3] = packet.ReadBit(); playerGuid[2] = packet.ReadBit(); playerGuid[0] = packet.ReadBit(); playerGuid[6] = packet.ReadBit(); packet.ParseBitStream(playerGuid, 2, 0, 4, 1, 5, 3, 7, 6); var guid = new Guid(BitConverter.ToUInt64(playerGuid, 0)); packet.WriteGuid("GUID", playerGuid); }
public static void HandlePetNameQuery(Packet packet) { var guid = new byte[8]; var number = new byte[8]; guid[5] = packet.ReadBit(); number[3] = packet.ReadBit(); guid[6] = packet.ReadBit(); packet.StartBitStream(number, 5, 7); packet.StartBitStream(guid, 2, 4); number[2] = packet.ReadBit(); guid[3] = packet.ReadBit(); number[1] = packet.ReadBit(); guid[7] = packet.ReadBit(); number[6] = packet.ReadBit(); packet.StartBitStream(guid, 1, 0); packet.StartBitStream(number, 4, 0); packet.ResetBitReader(); packet.ReadXORByte(number, 5); packet.ReadXORBytes(guid, 4, 3); packet.ReadXORBytes(number, 7, 4); packet.ReadXORBytes(guid, 5, 2, 0, 6); packet.ReadXORBytes(number, 2, 0, 6); packet.ReadXORByte(guid, 1); packet.ReadXORByte(number, 3); packet.ReadXORByte(guid, 7); packet.ReadXORByte(number, 1); var GUID = new Guid(BitConverter.ToUInt64(guid, 0)); var Number = BitConverter.ToUInt64(number, 0); packet.WriteGuid("Guid", guid); packet.WriteLine("Pet Number: {0}", Number); // Store temporary name (will be replaced in SMSG_PET_NAME_QUERY_RESPONSE) StoreGetters.AddName(GUID, Number.ToString(CultureInfo.InvariantCulture)); }
private static MovementInfo ReadMovementUpdateBlock433(ref Packet packet, Guid guid, int index) { var moveInfo = new MovementInfo(); bool living = packet.ReadBit("Living", index); bool hasAttackingTarget = packet.ReadBit("Has Attacking Target", index); bool hasVehicleData = packet.ReadBit("Has Vehicle Data", index); uint unkLoopCounter = packet.ReadBits(24); bool hasStationaryPosition = packet.ReadBit("Has Stationary Position", index); /*bool bit1 =*/ packet.ReadBit(); /*bool bit4 =*/ packet.ReadBit(); bool unkInt = packet.ReadBit(); bool unkFloats = packet.ReadBit(); /*bool bit2 =*/ packet.ReadBit(); /*bool bit0 =*/ packet.ReadBit(); /*bool bit3 =*/ packet.ReadBit(); bool hasGameObjectPosition = packet.ReadBit("Has GameObject position", index); bool hasAnimKits = packet.ReadBit("Has AnimKits", index); bool hasGORotation = packet.ReadBit("Has GameObject Rotation", index); bool unkFloat1 = false; bool hasFallData = false; bool unkFloat2 = false; bool bit216 = false; bool bit256 = false; bool hasSplineDurationMult = false; SplineType splineType = SplineType.Normal; var facingTarget = new byte[8]; uint splineCount = 0u; bool hasTransportData = false; var transportGuid = new byte[8]; bool hasTransportTime2 = false; bool hasTransportTime3 = false; bool hasFallDirection = false; bool hasUnkUInt = false; bool hasOrientation = false; var attackingTarget = new byte[8]; var goTransportGuid = new byte[8]; bool hasGOTransportTime2 = false; bool hasGOTransportTime3 = false; bool hasAnimKit1 = false; bool hasAnimKit2 = false; bool hasAnimKit3 = false; var guid2 = new byte[8]; // Reading bits if (living) { guid2[4] = (byte)(packet.ReadBit() ? 1 : 0); /*bool bit149 =*/ packet.ReadBit(); guid2[5] = (byte)(packet.ReadBit() ? 1 : 0); unkFloat1 = !packet.ReadBit(); hasFallData = packet.ReadBit("Has Fall Data", index); unkFloat2 = !packet.ReadBit(); guid2[6] = (byte)(packet.ReadBit() ? 1 : 0); moveInfo.HasSplineData = packet.ReadBit("Has Spline Data", index); if (moveInfo.HasSplineData) { bit216 = packet.ReadBit(); if (bit216) { bit256 = packet.ReadBit(); /*splineMode =*/ packet.ReadBits(2); hasSplineDurationMult = packet.ReadBit(); uint bits57 = packet.ReadBits(2); switch (bits57) { case 0: splineType = SplineType.FacingSpot; break; case 1: splineType = SplineType.Normal; break; case 2: splineType = SplineType.FacingTarget; break; case 3: splineType = SplineType.FacingAngle; break; } if (splineType == SplineType.FacingTarget) { facingTarget[0] = (byte)(packet.ReadBit() ? 1 : 0); facingTarget[2] = (byte)(packet.ReadBit() ? 1 : 0); facingTarget[7] = (byte)(packet.ReadBit() ? 1 : 0); facingTarget[1] = (byte)(packet.ReadBit() ? 1 : 0); facingTarget[6] = (byte)(packet.ReadBit() ? 1 : 0); facingTarget[3] = (byte)(packet.ReadBit() ? 1 : 0); facingTarget[4] = (byte)(packet.ReadBit() ? 1 : 0); facingTarget[5] = (byte)(packet.ReadBit() ? 1 : 0); } /*splineFlags =*/ packet.ReadEnum<SplineFlag422>("Spline flags", 25, index); splineCount = packet.ReadBits(22); } } hasTransportData = packet.ReadBit("Has transport data", index); guid2[1] = (byte)(packet.ReadBit() ? 1 : 0); /*bit148 =*/ packet.ReadBit(); if (hasTransportData) { hasTransportTime2 = packet.ReadBit(); transportGuid[0] = (byte)(packet.ReadBit() ? 1 : 0); transportGuid[7] = (byte)(packet.ReadBit() ? 1 : 0); transportGuid[2] = (byte)(packet.ReadBit() ? 1 : 0); transportGuid[6] = (byte)(packet.ReadBit() ? 1 : 0); transportGuid[5] = (byte)(packet.ReadBit() ? 1 : 0); transportGuid[4] = (byte)(packet.ReadBit() ? 1 : 0); transportGuid[1] = (byte)(packet.ReadBit() ? 1 : 0); transportGuid[3] = (byte)(packet.ReadBit() ? 1 : 0); hasTransportTime3 = packet.ReadBit(); } guid2[2] = (byte)(packet.ReadBit() ? 1 : 0); if (hasFallData) hasFallDirection = packet.ReadBit("Has Fall Direction", index); bool hasMovementFlags = !packet.ReadBit(); bool hasExtraMovementFlags = !packet.ReadBit(); hasUnkUInt = !packet.ReadBit(); guid2[7] = (byte)(packet.ReadBit() ? 1 : 0); if (hasExtraMovementFlags) moveInfo.FlagsExtra = packet.ReadEnum<MovementFlagExtra>("Extra Movement Flags", 12, index); guid2[0] = (byte)(packet.ReadBit() ? 1 : 0); if (hasMovementFlags) moveInfo.Flags = packet.ReadEnum<MovementFlag>("Movement Flags", 30, index); guid2[3] = (byte)(packet.ReadBit() ? 1 : 0); hasOrientation = !packet.ReadBit(); } if (hasAttackingTarget) { attackingTarget[2] = (byte)(packet.ReadBit() ? 1 : 0); attackingTarget[4] = (byte)(packet.ReadBit() ? 1 : 0); attackingTarget[0] = (byte)(packet.ReadBit() ? 1 : 0); attackingTarget[1] = (byte)(packet.ReadBit() ? 1 : 0); attackingTarget[3] = (byte)(packet.ReadBit() ? 1 : 0); attackingTarget[7] = (byte)(packet.ReadBit() ? 1 : 0); attackingTarget[5] = (byte)(packet.ReadBit() ? 1 : 0); attackingTarget[6] = (byte)(packet.ReadBit() ? 1 : 0); } if (hasGameObjectPosition) { hasGOTransportTime2 = packet.ReadBit(); goTransportGuid[1] = (byte)(packet.ReadBit() ? 1 : 0); goTransportGuid[4] = (byte)(packet.ReadBit() ? 1 : 0); goTransportGuid[5] = (byte)(packet.ReadBit() ? 1 : 0); goTransportGuid[0] = (byte)(packet.ReadBit() ? 1 : 0); goTransportGuid[6] = (byte)(packet.ReadBit() ? 1 : 0); goTransportGuid[7] = (byte)(packet.ReadBit() ? 1 : 0); goTransportGuid[3] = (byte)(packet.ReadBit() ? 1 : 0); hasGOTransportTime3 = packet.ReadBit(); goTransportGuid[2] = (byte)(packet.ReadBit() ? 1 : 0); } if (hasAnimKits) { hasAnimKit3 = !packet.ReadBit(); hasAnimKit1 = !packet.ReadBit(); hasAnimKit2 = !packet.ReadBit(); } // Reading data for (var i = 0u; i < unkLoopCounter; ++i) packet.ReadUInt32("Unk UInt32", index, (int)i); if (living) { moveInfo.WalkSpeed = packet.ReadSingle("Walk Speed", index) / 2.5f; if (moveInfo.HasSplineData) { if (bit216) { for (var i = 0u; i < splineCount; ++i) { var wp = new Vector3 { X = packet.ReadSingle(), Z = packet.ReadSingle(), Y = packet.ReadSingle(), }; packet.WriteLine("[{0}][{1}] Spline Waypoint: {2}", index, i, wp); } if (splineType == SplineType.FacingTarget) { if (facingTarget[0] != 0) facingTarget[0] ^= packet.ReadByte(); if (facingTarget[6] != 0) facingTarget[6] ^= packet.ReadByte(); if (facingTarget[5] != 0) facingTarget[5] ^= packet.ReadByte(); if (facingTarget[4] != 0) facingTarget[4] ^= packet.ReadByte(); if (facingTarget[1] != 0) facingTarget[1] ^= packet.ReadByte(); if (facingTarget[3] != 0) facingTarget[3] ^= packet.ReadByte(); if (facingTarget[7] != 0) facingTarget[7] ^= packet.ReadByte(); if (facingTarget[2] != 0) facingTarget[2] ^= packet.ReadByte(); packet.WriteLine("[{0}] Facing Target GUID {1}", index, new Guid(BitConverter.ToUInt64(facingTarget, 0))); } else if (splineType == SplineType.FacingSpot) { var point = new Vector3 { Z = packet.ReadSingle(), Y = packet.ReadSingle(), X = packet.ReadSingle(), }; packet.WriteLine("[{0}] Facing Spot: {1}", index, point); } packet.ReadUInt32("Unknown Spline Int32 2", index); if (bit256) packet.ReadUInt32("Unknown Spline Int32 3", index); packet.ReadSingle("Unknown Spline Float 2", index); packet.ReadSingle("Unknown Spline Float 1", index); packet.ReadUInt32("Unknown Spline Int32 1", index); if (splineType == SplineType.FacingAngle) packet.ReadSingle("Facing Angle", index); if (hasSplineDurationMult) packet.ReadSingle("Spline Duration Modifier", index); } var endPoint = new Vector3 { Z = packet.ReadSingle(), Y = packet.ReadSingle(), }; packet.ReadUInt32("Spline Full Time", index); endPoint.Y = packet.ReadSingle(); packet.WriteLine("[{0}] Spline Endpoint: {1}", index, endPoint); } if (hasTransportData) { if (hasTransportTime2) packet.ReadInt32("Transport Time 2", index); if (transportGuid[4] != 0) transportGuid[4] ^= packet.ReadByte(); if (transportGuid[6] != 0) transportGuid[6] ^= packet.ReadByte(); if (transportGuid[5] != 0) transportGuid[5] ^= packet.ReadByte(); if (hasTransportTime3) packet.ReadInt32("Transport Time 3", index); if (transportGuid[7] != 0) transportGuid[7] ^= packet.ReadByte(); if (transportGuid[3] != 0) transportGuid[3] ^= packet.ReadByte(); var tPos = new Vector4 { X = packet.ReadSingle(), Z = packet.ReadSingle(), O = packet.ReadSingle(), }; if (transportGuid[2] != 0) transportGuid[2] ^= packet.ReadByte(); if (transportGuid[1] != 0) transportGuid[1] ^= packet.ReadByte(); if (transportGuid[0] != 0) transportGuid[0] ^= packet.ReadByte(); tPos.Y = packet.ReadSingle(); packet.WriteLine("[{0}] Transport Position: {1}", index, tPos); packet.ReadByte("Transport Seat", index); packet.ReadInt32("Transport Time", index); } if (unkFloat1) packet.ReadSingle("float +28", index); packet.ReadSingle("FlyBack Speed", index); packet.ReadSingle("Turn Speed", index); if (guid2[5] != 0) guid2[5] ^= packet.ReadByte(); moveInfo.RunSpeed = packet.ReadSingle("Run Speed", index) / 7.0f; if (unkFloat2) packet.ReadSingle("float +36", index); if (guid2[0] != 0) guid2[0] ^= packet.ReadByte(); packet.ReadSingle("Pitch Speed", index); if (hasFallData) { packet.ReadInt32("Time Fallen", index); packet.ReadSingle("Fall Start Velocity", index); if (hasFallDirection) { packet.ReadSingle("Jump Sin", index); packet.ReadSingle("Jump Velocity", index); packet.ReadSingle("Jump Cos", index); } } packet.ReadSingle("RunBack Speed", index); moveInfo.Position = new Vector3(); moveInfo.Position.X = packet.ReadSingle(); packet.ReadSingle("SwimBack Speed", index); if (guid2[7] != 0) guid2[7] ^= packet.ReadByte(); moveInfo.Position.Z = packet.ReadSingle(); if (guid2[3] != 0) guid2[3] ^= packet.ReadByte(); if (guid2[2] != 0) guid2[2] ^= packet.ReadByte(); packet.ReadSingle("Fly Speed", index); packet.ReadSingle("Swim Speed", index); if (guid2[1] != 0) guid2[1] ^= packet.ReadByte(); if (guid2[4] != 0) guid2[4] ^= packet.ReadByte(); if (guid2[6] != 0) guid2[6] ^= packet.ReadByte(); packet.WriteLine("[{0}] GUID 2 {1}", index, new Guid(BitConverter.ToUInt64(guid2, 0))); moveInfo.Position.Y = packet.ReadSingle(); if (hasUnkUInt) packet.ReadUInt32(); if (hasOrientation) moveInfo.Orientation = packet.ReadSingle(); packet.WriteLine("[{0}] Position: {1} Orientation: {2}", index, moveInfo.Position, moveInfo.Orientation); } if (unkFloats) { int i; for (i = 0; i < 13; ++i) packet.ReadSingle("Unk float 456", index, i); packet.ReadByte("Unk byte 456", index); for (; i < 16; ++i) packet.ReadSingle("Unk float 456", index, i); } if (hasGameObjectPosition) { var tPos = new Vector4(); if (goTransportGuid[6] != 0) goTransportGuid[6] ^= packet.ReadByte(); if (goTransportGuid[5] != 0) goTransportGuid[5] ^= packet.ReadByte(); tPos.Y = packet.ReadSingle(); if (goTransportGuid[4] != 0) goTransportGuid[4] ^= packet.ReadByte(); if (goTransportGuid[2] != 0) goTransportGuid[2] ^= packet.ReadByte(); if (hasGOTransportTime3) packet.ReadUInt32("GO Transport Time 3", index); tPos.O = packet.ReadSingle(); tPos.Z = packet.ReadSingle(); if (hasGOTransportTime2) packet.ReadUInt32("GO Transport Time 2", index); packet.ReadByte("GO Transport Seat", index); if (goTransportGuid[7] != 0) goTransportGuid[7] ^= packet.ReadByte(); if (goTransportGuid[1] != 0) goTransportGuid[1] ^= packet.ReadByte(); if (goTransportGuid[0] != 0) goTransportGuid[0] ^= packet.ReadByte(); if (goTransportGuid[3] != 0) goTransportGuid[3] ^= packet.ReadByte(); tPos.X = packet.ReadSingle(); packet.ReadSingle("GO Transport Time", index); packet.WriteLine("[{0}] GO Transport Position: {1}", index, tPos); packet.WriteLine("[{0}] GO Transport GUID {1}", index, new Guid(BitConverter.ToUInt64(goTransportGuid, 0))); } if (hasAttackingTarget) { if (attackingTarget[2] != 0) attackingTarget[2] ^= packet.ReadByte(); if (attackingTarget[4] != 0) attackingTarget[4] ^= packet.ReadByte(); if (attackingTarget[7] != 0) attackingTarget[7] ^= packet.ReadByte(); if (attackingTarget[3] != 0) attackingTarget[3] ^= packet.ReadByte(); if (attackingTarget[0] != 0) attackingTarget[0] ^= packet.ReadByte(); if (attackingTarget[1] != 0) attackingTarget[1] ^= packet.ReadByte(); if (attackingTarget[5] != 0) attackingTarget[5] ^= packet.ReadByte(); if (attackingTarget[6] != 0) attackingTarget[6] ^= packet.ReadByte(); packet.WriteLine("[{0}] Attacking Target GUID {1}", index, new Guid(BitConverter.ToUInt64(attackingTarget, 0))); } if (hasGORotation) moveInfo.Rotation = packet.ReadPackedQuaternion("GO Rotation", index); if (unkInt) packet.ReadUInt32("uint32 +412", index); if (hasAnimKits) { if (hasAnimKit3) packet.ReadUInt16("Anim Kit 3", index); if (hasAnimKit1) packet.ReadUInt16("Anim Kit 1", index); if (hasAnimKit2) packet.ReadUInt16("Anim Kit 2", index); } if (hasStationaryPosition) { moveInfo.Position = new Vector3 { Z = packet.ReadSingle(), X = packet.ReadSingle(), Y = packet.ReadSingle(), }; moveInfo.Orientation = packet.ReadSingle(); packet.WriteLine("[{0}] Stationary Position: {1}, O: {2}", index, moveInfo.Position, moveInfo.Orientation); } if (hasVehicleData) { packet.ReadSingle("Vehicle Orientation", index); moveInfo.VehicleId = packet.ReadUInt32("Vehicle Id", index); } packet.ResetBitReader(); return moveInfo; }
private static MovementInfo ReadMovementUpdateBlock(ref Packet packet, Guid guid, int index) { var lines = new List<string>(); lines.Add("MovementUpdateBlock"); var moveInfo = new MovementInfo(); var flagsTypeCode = ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767) ? TypeCode.UInt16 : TypeCode.Byte; var flags = packet.ReadEnum<UpdateFlag>("[" + index + "] Update Flags", flagsTypeCode); lines.Add("[" + index + "] Update Flags"); if (flags.HasAnyFlag(UpdateFlag.Living)) { moveInfo = MovementHandler.ReadMovementInfo(ref packet, guid, index); var moveFlags = moveInfo.Flags; var speedCount = ClientVersion.AddedInVersion(ClientVersionBuild.V3_0_2_9056) ? 9 : 8; int speedShift; if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_1_0_13914) && ClientVersion.RemovedInVersion(ClientVersionBuild.V4_2_2_14545)) speedShift = 1; // enums shifted by one else speedShift = 0; for (var i = 0; i < speedCount - speedShift; i++) { var speedType = (SpeedType)(i + speedShift); var speed = packet.ReadSingle("["+ index + "] " + speedType + " Speed"); lines.Add("[" + index + "] " + speedType + " Speed: " + speed); switch (speedType) { case SpeedType.Walk: { moveInfo.WalkSpeed = speed / 2.5f; break; } case SpeedType.Run: { moveInfo.RunSpeed = speed / 7.0f; break; } } } // Either movement flags are incorrect for 4.2.2 or this has been removed if (ClientVersion.RemovedInVersion(ClientVersionBuild.V4_2_2_14545) && moveFlags.HasAnyFlag(MovementFlag.SplineEnabled) || moveInfo.HasSplineData) { // Temp solution // TODO: Make Enums version friendly if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_2_2_14545)) { var splineFlags422 = packet.ReadEnum<SplineFlag422>("Spline Flags", TypeCode.Int32, index); lines.Add("Spline Flags: " + splineFlags422.ToString()); if (splineFlags422.HasAnyFlag(SplineFlag422.FinalTarget)) { Misc.Guid targetGuid = packet.ReadGuid("Final Spline Target GUID", index); lines.Add("Final Spline Target GUID: " + targetGuid.GetLow()); } else if (splineFlags422.HasAnyFlag(SplineFlag422.FinalOrientation)) { float orientation = packet.ReadSingle("Final Spline Orientation", index); lines.Add("Final Spline Orientation: " + orientation); } else if (splineFlags422.HasAnyFlag(SplineFlag422.FinalPoint)) { Vector3 finalCords = packet.ReadVector3("Final Spline Coords", index); lines.Add("Final Spline Coords: " + finalCords.ToString()); } } else { var splineFlags = packet.ReadEnum<SplineFlag>("Spline Flags", TypeCode.Int32, index); lines.Add("Spline Flags: " + splineFlags.ToString()); if (splineFlags.HasAnyFlag(SplineFlag.FinalTarget)) { Guid targetGuid = packet.ReadGuid("Final Spline Target GUID", index); lines.Add("Final Spline Target GUID: " + targetGuid.GetLow()); } else if (splineFlags.HasAnyFlag(SplineFlag.FinalOrientation)) { float orientation = packet.ReadSingle("Final Spline Orientation", index); lines.Add("Final Spline Orientation: " + orientation); } else if (splineFlags.HasAnyFlag(SplineFlag.FinalPoint)) { Vector3 finalCords = packet.ReadVector3("Final Spline Coords", index); lines.Add("Final Spline Coords: " + finalCords.ToString()); } } lines.Add("Spline Time: " + packet.ReadInt32("Spline Time", index)); lines.Add("Spline Full Time: " + packet.ReadInt32("Spline Full Time", index)); packet.ReadInt32("Spline ID", index); if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767)) { lines.Add("Spline Duration Multiplier: " + packet.ReadSingle("Spline Duration Multiplier", index)); lines.Add("Spline Duration Multiplier Next: " + packet.ReadSingle("Spline Duration Multiplier Next", index)); lines.Add("Spline Vertical Acceleration" + packet.ReadSingle("Spline Vertical Acceleration", index)); lines.Add("Spline Start Time " + packet.ReadInt32("Spline Start Time", index)); } var splineCount = packet.ReadInt32(); for (var i = 0; i < splineCount; i++) lines.Add("[" + i + "] Spline Waypoint: " + packet.ReadVector3("Spline Waypoint", index, i).ToString()); if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767)) lines.Add("Spline Mode: " + packet.ReadEnum<SplineMode>("Spline Mode", TypeCode.Byte, index).ToString()); lines.Add("Spline Endpoint: " + packet.ReadVector3("Spline Endpoint", index).ToString()); } } else // !UpdateFlag.Living { if (flags.HasAnyFlag(UpdateFlag.GOPosition)) { packet.ReadPackedGuid("GO Position GUID", index); moveInfo.Position = packet.ReadVector3("[" + index + "] GO Position"); packet.ReadVector3("GO Transport Position", index); moveInfo.Orientation = packet.ReadSingle("[" + index + "] GO Orientation"); packet.ReadSingle("GO Transport Orientation", index); } else if (flags.HasAnyFlag(UpdateFlag.StationaryObject)) { moveInfo.Position = packet.ReadVector3(); moveInfo.Orientation = packet.ReadSingle(); packet.Writer.WriteLine("[{0}] Stationary Position: {1}, O: {2}", index, moveInfo.Position, moveInfo.Orientation); } } if (ClientVersion.RemovedInVersion(ClientVersionBuild.V4_2_2_14545)) { if (flags.HasAnyFlag(UpdateFlag.Unknown1)) packet.ReadInt32("Unk Int32", index); if (flags.HasAnyFlag(UpdateFlag.LowGuid)) packet.ReadInt32("Low GUID", index); } if (flags.HasAnyFlag(UpdateFlag.AttackingTarget)) lines.Add("Target GUID: " + packet.ReadPackedGuid("Target GUID", index)); if (flags.HasAnyFlag(UpdateFlag.Transport)) lines.Add("Transport Movement Time (ms): " + packet.ReadInt32("Transport Movement Time (ms)", index)); if (flags.HasAnyFlag(UpdateFlag.Vehicle)) { moveInfo.VehicleId = packet.ReadUInt32("[" + index + "] Vehicle ID"); lines.Add("Vehicle ID : " + moveInfo.VehicleId); lines.Add("Vehicle Orientation: " + packet.ReadSingle("Vehicle Orientation", index)); } if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_2_2_14545)) { if (flags.HasAnyFlag(UpdateFlag.AnimKits)) { packet.ReadInt16("Unk Int16", index); packet.ReadInt16("Unk Int16", index); packet.ReadInt16("Unk Int16", index); } } if (flags.HasAnyFlag(UpdateFlag.GORotation)) moveInfo.Rotation = packet.ReadPackedQuaternion("GO Rotation", index); if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_2_2_14545)) { if (flags.HasAnyFlag(UpdateFlag.TransportUnkArray)) { var count = packet.ReadByte("Count", index); for (var i = 0; i < count; i++) packet.ReadInt32("Unk Int32", index, count); } } // Initialize fields that are not used by GOs if (guid.GetObjectType() == ObjectType.GameObject) { moveInfo.VehicleId = 0; moveInfo.WalkSpeed = 0; moveInfo.RunSpeed = 0; } if (guid.HasEntry() && guid.GetObjectType() == ObjectType.Unit) { if (packet.SniffFileInfo.Stuffing.upObjPackets.ContainsKey(guid)) packet.SniffFileInfo.Stuffing.upObjPackets[guid].upObjPackets.Enqueue(new UpdateObjectPacket(packet.Time, packet.Number, lines)); else packet.SniffFileInfo.Stuffing.upObjPackets.TryAdd(guid, new UpdateObjectPackets(new UpdateObjectPacket(packet.Time, packet.Number, lines))); } return moveInfo; }
private static MovementInfo ReadMovementUpdateBlock548(ref Packet packet, Guid guid, int index) { var moveInfo = new MovementInfo(); var guid1 = new byte[8]; var transportGuid = new byte[8]; var goTransportGuid = new byte[8]; var targetGuid = new byte[8]; var SplineFacingTargetGuid = new byte[8]; var hasFallDirection = false; var hasOrientation = false; var hasFallData = false; var bit336 = false; var hasSplineStartTime = false; var splineCount = 0u; var splineType = SplineType.Stop; var hasSplineVerticalAcceleration = false; var hasSplineUnkPart = false; var hasTransport = false; var hasTransportTime2 = false; var hasTransportTime3 = false; var hasGOTransportTime2 = false; var hasGOTransportTime3 = false; var hasAnimKit1 = false; var hasAnimKit2 = false; var hasAnimKit3 = false; var Unk2Count = 0u; var Unk9Count = 0u; var loopcnt = 0u; var unk284count = 0u; var readUint32 = false; var unk144count = 0u; var skipFloat = false; var skipInt = false; var skipFloat3 = false; packet.ResetBitReader(); var hasUnk1 = packet.ReadBit("hasUnk1", index); // 676+ var hasAnimKits = packet.ReadBit("Has AnimKits", index); // 498+ var hasLiving = packet.ReadBit("Has Living", index); // 368+- var hasUnk2 = packet.ReadBit("hasUnk2", index); // 810+ var hasUnk3 = packet.ReadBit("hasUnk3", index); // 2- var unkLoopCounter = packet.ReadBits("Unknown array size", 22, index); // 1068+ var hasVehicle = packet.ReadBit("Has Vehicle Data", index); // 488+ var hasUnk4 = packet.ReadBit("hasUnk4", index); // 1044+ var hasUnk5 = packet.ReadBit("hasUnk5", index); // 1 var hasUnk6 = packet.ReadBit("hasUnk6", index); // 476+ var hasGobjectRotation = packet.ReadBit("Has GameObject Rotation", index); // 512+ var hasUnk7 = packet.ReadBit("hasUnk7", index); // 3 var hasUpdateFlagSelf = packet.ReadBit("Has Update Flag Self", index); // 680- var hasTarget = packet.ReadBit("Has Target", index); // 464+ var hasUnk8 = packet.ReadBit("hasUnk8", index); // 1032+ var hasUnk9 = packet.ReadBit("hasUnk9", index); // 1064+ var hasUnk10 = packet.ReadBit("hasUnk10", index); // 0 var hasUnk11 = packet.ReadBit("hasUnk11", index); // 668+ var hasGOPosition = packet.ReadBit("Has goTransport Position", index); // 424+ var hasUnk12 = packet.ReadBit("hasUnk12", index); // 681- var hasStationaryPosition = packet.ReadBit("Has Stationary Position", index); // 448 packet.WriteLine("pos448: " + packet.Position); //42bits if (hasLiving) // 368 { guid1[2] = packet.ReadBit(); // 10 packet.ReadBit(); // 140- skipFloat = packet.ReadBit("skip float", index); // 104+ if (skipFloat) dword ptr [esi+68h] = 0 else dword ptr [esi+68h] = ds:dword_D26EA8 hasTransport = packet.ReadBit("has transport", index); // 96+ packet.ReadBit(); // 164- if (hasTransport) // 96 { transportGuid[4] = packet.ReadBit(); // 52 transportGuid[2] = packet.ReadBit(); // 50 hasTransportTime3 = packet.ReadBit("Transport Time3", index); // 92+ transportGuid[0] = packet.ReadBit(); // 48 transportGuid[1] = packet.ReadBit(); // 49 transportGuid[3] = packet.ReadBit(); // 51 transportGuid[6] = packet.ReadBit(); // 54 transportGuid[7] = packet.ReadBit(); // 55 hasTransportTime2 = packet.ReadBit("Transport Time2", index); // 84+ transportGuid[5] = packet.ReadBit(); // 53 } readUint32 = !packet.ReadBit("skip readunit32", index); // 24+ guid1[6] = packet.ReadBit(); // 14 guid1[4] = packet.ReadBit(); // 12 guid1[3] = packet.ReadBit(); // 11 hasOrientation = packet.ReadBit("no has Orient", index); // 40+ if (hasOrientation) dword ptr [esi+28h] = 0 else dword ptr [esi+28h] = ds:dword_D26EA8 skipInt = !packet.ReadBit("no has Int", index); // 160*4 + guid1[5] = packet.ReadBit(); // 13 unk144count = packet.ReadBits("Is Living Unk Counter", 22, index); // 144+ var hasMovementFlags = !packet.ReadBit("no hasMovementFlags", index); // 16*4 + loopcnt = packet.ReadBits("IsLicingUnkLoop", 19, index); // 352+ for (var i = 0; i < loopcnt; i++ ) // 352 { packet.ReadBits("unk356", 2, index); // 356 } hasFallData = packet.ReadBit("has fall data", index); // 132+ if (hasMovementFlags) // 16*4 moveInfo.Flags = (WowPacketParser.Enums.MovementFlag)packet.ReadEnum<MovementFlag>("Movement Flags", 30, index); skipFloat3 = packet.ReadBit("skip float3", index); // 136+ if (skipFloat3) dword ptr [esi+88h] = 0 else dword ptr [esi+88h] = ds:dword_D26EA8 moveInfo.HasSplineData = packet.ReadBit("has Spline", index); // 344+ packet.ReadBit(); // 141- guid1[0] = packet.ReadBit(); // 8 guid1[7] = packet.ReadBit(); // 15 guid1[1] = packet.ReadBit(); // 9 if (moveInfo.HasSplineData) // 344 { bit336 = packet.ReadBit("Has extended spline data", index); // 336+ if (bit336) { hasSplineVerticalAcceleration = packet.ReadBit("Has spline vertical acceleration", index); // 260+ hasSplineStartTime = packet.ReadBit("Has spline start time", index); // 252+ hasSplineUnkPart = packet.ReadBit(); // 304+ splineCount = packet.ReadBits("Spline Waypoints", 20, index); // 264+ packet.ReadBits("Unk bits", 2, index); // 280- packet.ReadEnum<SplineFlag434>("Spline flags", 25, index); // 224 if (hasSplineUnkPart) // 304 { unk284count = packet.ReadBits("Unk dword284", 21, index); // 284 packet.ReadBits("Unk word300", 2, index); // unk word300 } } } var hasMovementFlagsExtra = !packet.ReadBit("no hasMovementFlagsExtra", index); // 20*4 if (hasFallData) // 132 hasFallDirection = packet.ReadBit("Has Fall Direction", index); // 128 if (hasMovementFlagsExtra) // 20*4 moveInfo.FlagsExtra = packet.ReadEnum<MovementFlagExtra>("Extra Movement Flags", 13, index); // 20*4 } //107bits packet.WriteLine("Pos20: " + packet.Position); /* if (hasUnk8) // 1032 { ... // not completed } */ if (hasGOPosition) // 424 { goTransportGuid[4] = packet.ReadBit(); // 380 goTransportGuid[1] = packet.ReadBit(); // 377 goTransportGuid[0] = packet.ReadBit(); // 376 hasGOTransportTime3 = packet.ReadBit("goTransport Time3", index); // 420 goTransportGuid[6] = packet.ReadBit(); // 382 goTransportGuid[5] = packet.ReadBit(); // 381 goTransportGuid[3] = packet.ReadBit(); // 379 goTransportGuid[2] = packet.ReadBit(); // 378 goTransportGuid[7] = packet.ReadBit(); // 383 hasGOTransportTime2 = packet.ReadBit("goTransport Time2", index); // 412 } if (hasUnk11) // 668 { var unkBlock1bit528 = packet.ReadBit(); // 528 var unkBlock1bit600 = packet.ReadBit(); // 600 var unkBlock1bit544 = packet.ReadBit(); // 544 var unkblock1bit526 = packet.ReadBit(); // 526 var unkBlock1bit552 = packet.ReadBit(); // 552 var unkBlock1bit524 = packet.ReadBit(); // 524 var unkBlock1bit572 = packet.ReadBit(); // 572 var unkBlock1bit525 = packet.ReadBit(); // 525 var unkBlock1bit664 = packet.ReadBit(); // 664 var unkBlock1bit527 = packet.ReadBit(); // 527 if (unkBlock1bit664) // 664 { packet.ReadBits("Block1 unk648", 20, index); // 648 } var unkBlock1bit536 = packet.ReadBit(); // 536 var unkBlock1bit644 = packet.ReadBit(); // 644 var unkBlock1bit560 = packet.ReadBit(); // 560 if (unkBlock1bit644) // 644 { packet.ReadBits("Block1 unk604", 21, index); // 604 packet.ReadBits("Block1 unk620", 21, index); // 620 } } if (hasAnimKits) // 498 { hasAnimKit2 = packet.ReadBit("Has AnimKit2", index); // 494*2 hasAnimKit3 = packet.ReadBit("Has AnimKit3", index); // 496*2 hasAnimKit1 = packet.ReadBit("Has AnimKit1", index); // 492*2 } if (hasTarget) // 464 targetGuid = packet.StartBitStream(4, 6, 5, 2, 0, 1, 3, 7); if (hasUnk9) // 1064 { Unk9Count = packet.ReadBits("unk1048", 22, index); // 1048 } if (hasUnk2) // 810 { Unk2Count = packet.ReadBits("unk682", 7, index); // 682*4 } // Reading data for (var i = 0u; i < unkLoopCounter; ++i) // 1068*4 packet.ReadUInt32("Unk UInt32", index, (int)i); // 1072*4 packet.ResetBitReader(); //??? /* if (hasUnk8) // 1032 { ... // not completed } */ packet.WriteLine("Pos01: " + packet.Position); if (hasLiving) // 368 { if (hasTransport) // 96 { packet.ReadXORByte(transportGuid, 7); // 55 moveInfo.TransportOffset.X = packet.ReadSingle(); // 56 if (hasTransportTime3) // 92 packet.ReadUInt32("Transport Time 3", index); // 88 moveInfo.TransportOffset.O = packet.ReadSingle(); // 68 moveInfo.TransportOffset.Y = packet.ReadSingle(); // 60 packet.ReadXORByte(transportGuid, 4); // 52 packet.ReadXORByte(transportGuid, 1); // 49 packet.ReadXORByte(transportGuid, 3); // 51 moveInfo.TransportOffset.Z = packet.ReadSingle(); // 64 packet.ReadXORByte(transportGuid, 5); // 53 if (hasTransportTime2) // 84 packet.ReadUInt32("Transport Time 2", index); // 80 packet.ReadXORByte(transportGuid, 0); // 48 packet.ReadSByte("Transport Seat", index); // 72 packet.ReadXORByte(transportGuid, 6); // 54 packet.ReadXORByte(transportGuid, 2); // 50 packet.ReadUInt32("Transport Time", index); // 76 moveInfo.TransportGuid = new Guid(BitConverter.ToUInt64(transportGuid, 0)); packet.WriteLine("[{0}] Transport GUID {1}", index, moveInfo.TransportGuid); packet.WriteLine("[{0}] Transport Position: {1}", index, moveInfo.TransportOffset); } packet.ReadXORByte(guid1, 4); // 12 for (var i = 0; i < loopcnt; i++ ) // 352 { packet.ReadSingle("Single364", index); // 364 packet.ReadSingle("Single368", index); // 368 packet.ReadSingle("Single360", index); // 360 packet.ReadInt32("Int356", index); // 356 packet.ReadInt32("Int372", index); // 372 packet.ReadSingle("Single376", index); // 376 } if (moveInfo.HasSplineData) // 344 { if (bit336) // 336 { packet.ReadUInt32("Spline Time", index); // 232 packet.ReadSingle("Spline Duration Multiplier Next", index); // 244 if (hasSplineUnkPart) // 304 { for (var i = 0; i < unk284count; i++ ) { packet.ReadSingle("unk292", index, i); // 292 packet.ReadSingle("unk288", index, i); // 288 } } packet.ReadSingle("Spline Duration Multiplier", index); // 240 for (var i = 0u; i < splineCount; ++i) // 264 { var wp = new Vector3 { X = packet.ReadSingle(), // 268 Z = packet.ReadSingle(), // 276 Y = packet.ReadSingle(), // 272 }; packet.WriteLine("[{0}][{1}] Spline Waypoint: {2}", index, i, wp); } if (hasSplineVerticalAcceleration) // 260 packet.ReadInt32("Spline Vertical Acceleration", index); // 256 splineType = packet.ReadEnum<SplineType>("Spline Type", TypeCode.Byte, index); // 228 if (splineType == SplineType.FacingAngle) // 228 packet.ReadSingle("Facing Angle", index); // 308 if (splineType == SplineType.FacingSpot) // 228 { var point = new Vector3 { X = packet.ReadSingle(), // 320 Z = packet.ReadSingle(), // 328 Y = packet.ReadSingle(), // 324 }; packet.WriteLine("[{0}] Facing Spot: {1}", index, point); } if (hasSplineStartTime) // 252 packet.ReadUInt32("Spline Start time", index); // 248 packet.ReadUInt32("Spline Full Time", index); // 236 } var endPoint = new Vector3(); endPoint.X = packet.ReadSingle(); // 212 endPoint.Z = packet.ReadSingle(); // 220 packet.ReadUInt32("Spline Id", index); // 208 endPoint.Y = packet.ReadSingle(); // 216 packet.WriteLine("[{0}] Spline Endpoint: {1}", index, endPoint); } packet.ReadSingle("Flight Speed", index); // 188 if (skipInt) // 160 packet.ReadInt32("unk160", index); // 160 packet.ReadXORByte(guid1, 2); // 10 if (hasFallData) // 132 { if (hasFallDirection) // 128 { packet.ReadSingle("Jump Speed", index); // 124 packet.ReadSingle("Jump Sin Angle", index); // 116 packet.ReadSingle("Jump Cos Angle", index); // 120 } packet.ReadUInt32("Fall Time", index); // 108 packet.ReadSingle("Jump Z Speed", index); // 112 } packet.ReadXORByte(guid1, 1); // 9 packet.ReadSingle("Turn Speed", index); // 196 if (readUint32) // 24 packet.ReadInt32("unk24", index); // 24 packet.ReadSingle("Flight Back Speed", index); // 176 if (!skipFloat3) // 136 packet.ReadSingle("unk136", index); // 136 packet.ReadXORByte(guid1, 7); // 15 packet.ReadSingle("Pitch Rate", index); // 200 for (var i = 0u; i < unk144count; i++ ) // 144 packet.ReadInt32("unk148", index); // 148 moveInfo.Position.X = packet.ReadSingle(); // 28 if (!skipFloat) // 104 packet.ReadSingle("unk104", index); // 104 if (!hasOrientation) // 40 moveInfo.Orientation = packet.ReadSingle("Orientation", index); // 40 moveInfo.WalkSpeed = packet.ReadSingle("Walk Speed", index); // 168 moveInfo.Position.Y = packet.ReadSingle(); // 32 packet.ReadSingle("Run Back Speed", index); // 192 packet.ReadXORByte(guid1, 3); // 11 packet.ReadXORByte(guid1, 5); // 13 packet.ReadXORByte(guid1, 6); // 14 packet.ReadXORByte(guid1, 0); // 8 packet.ReadSingle("Swim Back Speed", index); // 184 moveInfo.RunSpeed = packet.ReadSingle("Run Speed", index); // 172 packet.ReadSingle("Swim Speed", index); // 180 moveInfo.Position.Z = packet.ReadSingle(); // 36 packet.WriteLine("[{0}] GUID 1: {1}", index, new Guid(BitConverter.ToUInt64(guid1, 0))); packet.WriteLine("[{0}] Position: {1}", index, moveInfo.Position); packet.WriteLine("[{0}] Orientation: {1}", index, moveInfo.Orientation); } /* if (hasUnk11) // 668 { ... // not completed } */ if (hasGOPosition) // 424 { if (hasGOTransportTime3) // 420 packet.ReadUInt32("GO Transport Time 3", index); // 416 moveInfo.TransportOffset.Y = packet.ReadSingle(); // 388 packet.ReadByte("GO Transport Seat", index); // 400 moveInfo.TransportOffset.X = packet.ReadSingle(); // 384 packet.ReadXORByte(goTransportGuid, 2); // 378 packet.ReadXORByte(goTransportGuid, 4); // 380 packet.ReadXORByte(goTransportGuid, 1); // 377 if (hasGOTransportTime2) // 412 packet.ReadUInt32("GO Transport Time 2", index); // 408 packet.ReadUInt32("GO Transport Time", index); // 404 moveInfo.TransportOffset.O = packet.ReadSingle(); // 396 moveInfo.TransportOffset.Z = packet.ReadSingle(); // 392 packet.ReadXORByte(goTransportGuid, 6); // 382 packet.ReadXORByte(goTransportGuid, 0); // 376 packet.ReadXORByte(goTransportGuid, 5); // 381 packet.ReadXORByte(goTransportGuid, 3); // 379 packet.ReadXORByte(goTransportGuid, 7); // 383 moveInfo.TransportGuid = new Guid(BitConverter.ToUInt64(goTransportGuid, 0)); packet.WriteLine("[{0}] GO Transport GUID {1}", index, moveInfo.TransportGuid); packet.WriteLine("[{0}] GO Transport Position: {1}", index, moveInfo.TransportOffset); } if (hasTarget) // 464 { packet.ParseBitStream(targetGuid, 7, 1, 5, 2, 6, 3, 0, 4); // 456 packet.WriteGuid("Target GUID", targetGuid, index); } if (hasVehicle) // 488 { moveInfo.VehicleId = packet.ReadUInt32("Vehicle Id", index); // 480 packet.ReadSingle("Vehicle Orientation", index); // 484 } if (hasStationaryPosition) // 448 { moveInfo.Position.Y = packet.ReadSingle("Stationary Y", index); // 436 moveInfo.Position.Z = packet.ReadSingle("Stationary Z", index); // 440 moveInfo.Orientation = packet.ReadSingle("Stationary O", index); // 444 moveInfo.Position.X = packet.ReadSingle("Stationary X", index); // 432 } if (hasUnk1) // 676 packet.ReadInt32("unk672", index); // 672 if (hasAnimKits) // 498 { if (hasAnimKit1) // 492 packet.ReadUInt16("AnimKit1", index); // 492 if (hasAnimKit3) // 496 packet.ReadUInt16("AnimKit3", index); // 496 if (hasAnimKit2) // 494 packet.ReadUInt16("AnimKit2", index); // 494 } if (hasUnk2) // 810 packet.ReadWoWString("Str", Unk2Count, index); if (hasUnk6) // 476 packet.ReadInt32("unk472", index); // 472 if (hasUnk9) // 1064 for (var i = 0; i < Unk9Count; i++) // 1048 packet.ReadInt32("unk1052", index, i); // 1052 if (hasGobjectRotation) // 512 packet.ReadPackedQuaternion("GameObject Rotation", index); if (hasUnk4) // 1044 packet.ReadInt32("unk1040", index); // 1040 if (hasLiving) // 368 if (moveInfo.HasSplineData) // 344 if (bit336) // 336 if (splineType == SplineType.FacingTarget) { SplineFacingTargetGuid = packet.StartBitStream(4, 7, 0, 5, 1, 2, 3, 6); packet.ParseBitStream(SplineFacingTargetGuid, 4, 2, 0, 5, 6, 3, 1, 7); packet.WriteGuid("Spline Facing Target GUID", SplineFacingTargetGuid, index); } /* Don't know why this is commented out. Check IDA if (hasLiving && hasSpline) Movement::PacketBuilder::WriteFacingTargetPart(*ToUnit()->movespline, *data); */ return moveInfo; }
public static void HandleVendorInventoryList(Packet packet) { var npcVendor = new NpcVendor(); var guid = new byte[8]; packet.ReadByte("Byte18"); guid[1] = packet.ReadBit(); guid[5] = packet.ReadBit(); guid[0] = packet.ReadBit(); guid[2] = packet.ReadBit(); var itemCount = packet.ReadBits("itemCount", 18); guid[4] = packet.ReadBit(); var hasExtendedCost = new bool[itemCount]; var hasCondition = new bool[itemCount]; for (int i = 0; i < itemCount; ++i) { hasExtendedCost[i] = !packet.ReadBit(); hasCondition[i] = !packet.ReadBit(); packet.ReadBit("Unk bit", i); } guid[3] = packet.ReadBit(); guid[6] = packet.ReadBit(); guid[7] = packet.ReadBit(); npcVendor.VendorItems = new List <VendorItem>((int)itemCount); for (int i = 0; i < itemCount; ++i) { var vendorItem = new VendorItem(); vendorItem.ItemId = (uint)packet.ReadEntryWithName <Int32>(StoreNameType.Item, "Item ID", i); if (hasCondition[i]) { packet.ReadInt32("Condition ID", i); } packet.ReadInt32("Price", i); if (hasExtendedCost[i]) { vendorItem.ExtendedCostId = packet.ReadUInt32("Extended Cost", i); } packet.ReadInt32("Display ID", i); var buyCount = packet.ReadUInt32("Buy Count", i); vendorItem.Slot = packet.ReadUInt32("Item Position", i); var maxCount = packet.ReadInt32("Max Count", i); vendorItem.Type = packet.ReadUInt32("Type", i); // 1 - item, 2 - currency packet.ReadInt32("Item Upgrade ID", i); packet.ReadInt32("Max Durability", i); npcVendor.VendorItems.Add(vendorItem); } packet.ParseBitStream(guid, 0, 2, 1, 3, 5, 7, 4, 6); packet.WriteGuid("Guid", guid); var vendorGUID = new Guid(BitConverter.ToUInt64(guid, 0)); Storage.NpcVendors.Add(vendorGUID.GetEntry(), npcVendor, packet.TimeSpan); }
public static void HandleCharEnum422(Packet packet) { packet.ReadByte("Unk Flag"); int count = packet.ReadInt32("Char Count"); packet.ReadInt32("Unk Count"); var bits = new bool[count, 17]; for (int c = 0; c < count; c++) for (int j = 0; j < 17; j++) bits[c, j] = packet.ReadBit(); for (int c = 0; c < count; c++) { var low = new byte[8]; var guild = new byte[8]; var name = packet.ReadCString("Name", c); if (bits[c, 0]) guild[5] = (byte)(packet.ReadByte() ^ 1); packet.ReadByte("Face", c); var mapId = packet.ReadInt32("Map", c); if (bits[c, 12]) low[1] = (byte)(packet.ReadByte() ^ 1); if (bits[c, 1]) low[4] = (byte)(packet.ReadByte() ^ 1); if (bits[c, 10]) guild[4] = (byte)(packet.ReadByte() ^ 1); if (bits[c, 15]) guild[0] = (byte)(packet.ReadByte() ^ 1); var pos = packet.ReadVector3("Position", c); if (bits[c, 11]) low[0] = (byte)(packet.ReadByte() ^ 1); var zone = packet.ReadEntryWithName<Int32>(StoreNameType.Zone, "Zone Id", c); packet.ReadInt32("Pet Level", c); if (bits[c, 8]) low[3] = (byte)(packet.ReadByte() ^ 1); if (bits[c, 14]) low[7] = (byte)(packet.ReadByte() ^ 1); packet.ReadByte("Facial Hair", c); packet.ReadByte("Skin", c); var clss = packet.ReadEnum<Class>("Class", TypeCode.Byte, c); packet.ReadInt32("Pet Family", c); packet.ReadEnum<CharacterFlag>("CharacterFlag", TypeCode.Int32, c); if (bits[c, 9]) low[2] = (byte)(packet.ReadByte() ^ 1); packet.ReadInt32("Pet Display ID", c); if (bits[c, 3]) guild[7] = (byte)(packet.ReadByte() ^ 1); var level = packet.ReadByte("Level", c); if (bits[c, 7]) low[6] = (byte)(packet.ReadByte() ^ 1); packet.ReadByte("Hair Style", c); if (bits[c, 13]) guild[2] = (byte)(packet.ReadByte() ^ 1); var race = packet.ReadEnum<Race>("Race", TypeCode.Byte, c); packet.ReadByte("Hair Color", c); if (bits[c, 5]) guild[6] = (byte)(packet.ReadByte() ^ 1); packet.ReadEnum<Gender>("Gender", TypeCode.Byte, c); if (bits[c, 6]) low[5] = (byte)(packet.ReadByte() ^ 1); if (bits[c, 2]) guild[3] = (byte)(packet.ReadByte() ^ 1); packet.ReadByte("List Order", c); for (int itm = 0; itm < 19; itm++) { packet.ReadInt32("Item EnchantID", c, itm); packet.ReadEnum<InventoryType>("Item InventoryType", TypeCode.Byte, c, itm); packet.ReadInt32("Item DisplayID", c, itm); } for (int itm = 0; itm < 4; itm++) { packet.ReadInt32("Bag EnchantID", c, itm); packet.ReadEnum<InventoryType>("Bag InventoryType", TypeCode.Byte, c, itm); packet.ReadInt32("Bag DisplayID", c, itm); } packet.ReadEnum<CustomizationFlag>("CustomizationFlag", TypeCode.UInt32, c); if (bits[c, 4]) guild[1] = (byte)(packet.ReadByte() ^ 1); var playerGuid = new Guid(BitConverter.ToUInt64(low, 0)); packet.WriteLine("[{0}] Character GUID: {1}", c, playerGuid); packet.WriteLine("[{0}] Guild GUID: {1}", c, new Guid(BitConverter.ToUInt64(guild, 0))); var firstLogin = bits[c, 16]; if (firstLogin) { var startPos = new StartPosition {Map = mapId, Position = pos, Zone = zone}; Storage.StartPositions.Add(new Tuple<Race, Class>(race, clss), startPos, packet.TimeSpan); } var playerInfo = new Player { Race = race, Class = clss, Name = name, FirstLogin = firstLogin, Level = level }; if (Storage.Objects.ContainsKey(playerGuid)) Storage.Objects[playerGuid] = new Tuple<WoWObject, TimeSpan?>(playerInfo, packet.TimeSpan); else Storage.Objects.Add(playerGuid, playerInfo, packet.TimeSpan); } }
public static MovementInfo ReadMovementInfo420(ref Packet packet, Guid guid, int index) { var info = new MovementInfo(); info.Flags = packet.ReadEnum<MovementFlag>("Movement Flags", 30, index); packet.ReadEnum<MovementFlagExtra>("Extra Movement Flags", 12, index); var onTransport = packet.ReadBit("OnTransport", index); var hasInterpolatedMovement = false; var time3 = false; if (onTransport) { hasInterpolatedMovement = packet.ReadBit("HasInterpolatedMovement", index); time3 = packet.ReadBit("Time3", index); } var swimming = packet.ReadBit("Swimming", index); var interPolatedTurning = packet.ReadBit("InterPolatedTurning", index); var jumping = false; if (interPolatedTurning) jumping = packet.ReadBit("Jumping", index); var splineElevation = packet.ReadBit("SplineElevation", index); info.HasSplineData = packet.ReadBit("HasSplineData", index); packet.ResetBitReader(); // reset bitreader packet.ReadGuid("GUID 2", index); packet.ReadInt32("Time", index); var pos = packet.ReadVector4("Position", index); info.Position = new Vector3(pos.X, pos.Y, pos.Z); info.Orientation = pos.O; if (onTransport) { packet.ReadGuid("Transport GUID", index); packet.ReadVector4("Transport Position", index); packet.ReadByte("Transport Seat", index); packet.ReadInt32("Transport Time", index); if (hasInterpolatedMovement) packet.ReadInt32("Transport Time 2", index); if (time3) packet.ReadInt32("Transport Time 3", index); } if (swimming) packet.ReadSingle("Swim Pitch", index); if (interPolatedTurning) { packet.ReadInt32("Time Fallen", index); packet.ReadSingle("Fall Start Velocity", index); if (jumping) { packet.ReadSingle("Jump Sin", index); packet.ReadSingle("Jump Cos", index); packet.ReadSingle("Jump Velocity", index); } } if (splineElevation) packet.ReadSingle("Spline Elevation", index); return info; }
public static void HandleServerTrainerList(Packet packet) { var npcTrainer = new NpcTrainer(); var count = packet.ReadBits("Count", 19); var guid = new byte[8]; guid[3] = packet.ReadBit(); guid[2] = packet.ReadBit(); guid[0] = packet.ReadBit(); guid[7] = packet.ReadBit(); guid[1] = packet.ReadBit(); guid[5] = packet.ReadBit(); var size = packet.ReadBits("Title size", 11); guid[6] = packet.ReadBit(); guid[4] = packet.ReadBit(); //npcTrainer.Type = packet.ReadEnum<TrainerType>("Type", TypeCode.Int32); packet.ReadXORByte(guid, 3); npcTrainer.TrainerSpells = new List <TrainerSpell>((Int32)count); for (var i = 0; i < count; ++i) { var trainerSpell = new TrainerSpell(); packet.ReadEnum <TrainerSpellState>("State", TypeCode.Byte, i); trainerSpell.Spell = (uint)packet.ReadEntryWithName <Int32>(StoreNameType.Spell, "Spell ID", i); trainerSpell.RequiredSkill = packet.ReadUInt32("Required Skill", i); trainerSpell.Cost = packet.ReadUInt32("Cost", i); packet.ReadEntryWithName <Int32>(StoreNameType.Spell, "Chain Spell ID", i, 0); packet.ReadEntryWithName <Int32>(StoreNameType.Spell, "Chain Spell ID", i, 1); packet.ReadEntryWithName <Int32>(StoreNameType.Spell, "Chain Spell ID", i, 2); trainerSpell.RequiredLevel = packet.ReadByte("Required Level", i); trainerSpell.RequiredSkillLevel = packet.ReadUInt32("Required Skill Level", i); npcTrainer.TrainerSpells.Add(trainerSpell); } packet.ReadXORByte(guid, 1); packet.ReadXORByte(guid, 6); packet.ReadXORByte(guid, 0); npcTrainer.Title = packet.ReadWoWString("Title", size); npcTrainer.Type = packet.ReadEnum <TrainerType>("Type", TypeCode.Int32); packet.ReadXORByte(guid, 2); packet.ReadXORByte(guid, 4); packet.ReadXORByte(guid, 5); packet.ReadXORByte(guid, 7); packet.ReadInt32("unk1"); var guiD = new Guid(BitConverter.ToUInt64(guid, 0)); Storage.NpcTrainers.Add(guiD.GetEntry(), npcTrainer, packet.TimeSpan); }
public static void HandleNpcGossip(Packet packet) { var guid = new byte[8]; uint[] QuestTitleLength; uint[] OptionsMessageLength; uint[] BoxMessageLength; guid[7] = packet.ReadBit(); guid[6] = packet.ReadBit(); guid[1] = packet.ReadBit(); var QuestsCount = packet.ReadBits("Quests Count", 19); guid[0] = packet.ReadBit(); guid[4] = packet.ReadBit(); guid[5] = packet.ReadBit(); guid[2] = packet.ReadBit(); guid[3] = packet.ReadBit(); var OptionsCount = packet.ReadBits("Gossip Options Count", 20); OptionsMessageLength = new uint[OptionsCount]; BoxMessageLength = new uint[OptionsCount]; for (var i = 0; i < OptionsCount; ++i) { BoxMessageLength[i] = packet.ReadBits(12); OptionsMessageLength[i] = packet.ReadBits(12); } QuestTitleLength = new uint[QuestsCount]; for (var i = 0; i < QuestsCount; ++i) { packet.ReadBit("Quest Icon Change", i); QuestTitleLength[i] = packet.ReadBits(9); } for (var i = 0; i < QuestsCount; i++) { packet.ReadEnum <QuestFlags2>("Quest Special Flags", TypeCode.UInt32, i); packet.ReadEntryWithName <UInt32>(StoreNameType.Quest, "Quest Id", i); packet.ReadUInt32("Quest Level", i); packet.ReadUInt32("Quest Icon", i); packet.ReadEnum <QuestFlags>("Quest Flags", TypeCode.UInt32, i); packet.ReadWoWString("Quest Titles", QuestTitleLength[i], i); } packet.ReadXORByte(guid, 6); var ObjectGossip = new Gossip(); ObjectGossip.GossipOptions = new List <GossipOption>((int)OptionsCount); for (var i = 0; i < OptionsCount; ++i) { var gossipMenuOption = new GossipOption { RequiredMoney = packet.ReadUInt32("Message Box Required Money", i), OptionText = packet.ReadWoWString("Gossip Option Text", OptionsMessageLength[i], i), Index = packet.ReadUInt32("Gossip Option Index", i), OptionIcon = packet.ReadEnum <GossipOptionIcon>("Gossip Option Icon", TypeCode.Byte, i), BoxText = packet.ReadWoWString("Message Box Text", BoxMessageLength[i], i), Box = packet.ReadBoolean("Message Box Coded", i), // True if it has a password. }; ObjectGossip.GossipOptions.Add(gossipMenuOption); } packet.ReadXORByte(guid, 2); var GossipMenuTextId = packet.ReadUInt32("Gossip Menu Text Id"); packet.ReadXORByte(guid, 1); packet.ReadXORByte(guid, 5); var GossipMenuId = packet.ReadUInt32("Gossip Menu Id"); packet.ReadUInt32("Friendly Faction Id"); packet.ReadXORByte(guid, 4); packet.ReadXORByte(guid, 7); packet.ReadXORByte(guid, 3); packet.ReadXORByte(guid, 0); packet.WriteGuid("Object Guid", guid); var ObjectGuid = new Guid(BitConverter.ToUInt64(guid, 0)); ObjectGossip.ObjectEntry = ObjectGuid.GetEntry(); ObjectGossip.ObjectType = ObjectGuid.GetObjectType(); if (ObjectGuid.GetObjectType() == ObjectType.Unit) { if (Storage.Objects.ContainsKey(ObjectGuid)) { ((Unit)Storage.Objects[ObjectGuid].Item1).GossipId = GossipMenuId; } } Storage.Gossips.Add(Tuple.Create(GossipMenuId, GossipMenuTextId), ObjectGossip, packet.TimeSpan); packet.AddSniffData(StoreNameType.Gossip, (int)GossipMenuId, ObjectGuid.GetEntry().ToString(CultureInfo.InvariantCulture)); }
public static void HandleAuraUpdate(Packet packet) { var guid = new byte[8]; var guid2 = new byte[8]; guid[1] = packet.ReadBit(); var hasPowerData = packet.ReadBit(); uint bits3C = 0; if (hasPowerData) { packet.StartBitStream(guid2, 1, 5, 6); bits3C = packet.ReadBits(21); packet.StartBitStream(guid2, 2, 3, 7, 0, 4); } var bits4 = packet.ReadBits(24); guid[6] = packet.ReadBit(); var hasAura = new bool[bits4]; var hasCasterGUID = new bool[bits4]; var hasDuration = new bool[bits4]; var hasMaxDuration = new bool[bits4]; var effectCount = new uint[bits4]; var casterGUID = new byte[bits4][]; for (var i = 0; i < bits4; ++i) { hasAura[i] = packet.ReadBit(); if (hasAura[i]) { hasMaxDuration[i] = packet.ReadBit(); effectCount[i] = packet.ReadBits(22); hasCasterGUID[i] = packet.ReadBit(); if (hasCasterGUID[i]) { casterGUID[i] = new byte[8]; packet.StartBitStream(casterGUID[i], 5, 7, 4, 1, 6, 0, 3, 2); } hasDuration[i] = packet.ReadBit(); } } packet.StartBitStream(guid, 2, 3, 7, 4); packet.ReadBit("Is AURA_UPDATE_ALL"); packet.StartBitStream(guid, 0, 5); packet.ResetBitReader(); var auras = new List<Aura>(); for (var i = 0; i < bits4; ++i) { if (hasAura[i]) { var aura = new Aura(); if (hasCasterGUID[i]) { packet.ParseBitStream(casterGUID[i], 2, 7, 6, 1, 4, 0, 5, 3); packet.WriteGuid("Caster GUID", casterGUID[i], i); aura.CasterGuid = new Guid(BitConverter.ToUInt64(casterGUID[i], 0)); } else aura.CasterGuid = new Guid(); aura.Charges = packet.ReadByte("Charges", i); if (hasDuration[i]) aura.Duration = packet.ReadInt32("Duration", i); else aura.Duration = 0; aura.SpellId = packet.ReadUInt32("Spell Id", i); aura.AuraFlags = packet.ReadEnum<AuraFlagMoP>("Flags", TypeCode.Byte, i); for (var j = 0; j < effectCount[i]; ++j) packet.ReadSingle("Effect Value", i, j); packet.ReadInt32("Effect Mask", i); if (hasMaxDuration[i]) aura.MaxDuration = packet.ReadInt32("Max Duration", i); else aura.MaxDuration = 0; aura.Level = packet.ReadUInt16("Caster Level", i); auras.Add(aura); packet.AddSniffData(StoreNameType.Spell, (int)aura.SpellId, "AURA_UPDATE"); } packet.ReadByte("Slot", i); } if (hasPowerData) { packet.ReadXORBytes(guid2, 7, 0); for (var i = 0; i < bits3C; ++i) { packet.ReadEnum<PowerType>("Power Type", TypeCode.UInt32, i); packet.ReadInt32("Power Value", i); } packet.ReadXORBytes(guid2, 2, 5); packet.ReadInt32("Attack power"); packet.ReadInt32("Spell power"); packet.ReadXORBytes(guid2, 6, 4, 3, 1); packet.ReadInt32("Current Health"); packet.WriteGuid("PowerUnitGUID", guid2); } packet.ParseBitStream(guid, 0, 5, 7, 2, 1, 4, 3, 6); packet.WriteGuid("Guid", guid); var GUID = new Guid(BitConverter.ToUInt64(guid, 0)); if (Storage.Objects.ContainsKey(GUID)) { var unit = Storage.Objects[GUID].Item1 as Unit; if (unit != null) { // If this is the first packet that sends auras // (hopefully at spawn time) add it to the "Auras" field, // if not create another row of auras in AddedAuras // (similar to ChangedUpdateFields) if (unit.Auras == null) unit.Auras = auras; else if (unit.AddedAuras == null) unit.AddedAuras = new List<List<Aura>> { auras }; else unit.AddedAuras.Add(auras); } } }
public static void HandleVendorInventoryList422(Packet packet) { var npcVendor = new NpcVendor(); var guidBytes = new byte[8]; guidBytes[5] = (byte)(packet.ReadBit() ? 1 : 0); guidBytes[6] = (byte)(packet.ReadBit() ? 1 : 0); guidBytes[1] = (byte)(packet.ReadBit() ? 1 : 0); guidBytes[2] = (byte)(packet.ReadBit() ? 1 : 0); guidBytes[3] = (byte)(packet.ReadBit() ? 1 : 0); guidBytes[0] = (byte)(packet.ReadBit() ? 1 : 0); guidBytes[7] = (byte)(packet.ReadBit() ? 1 : 0); guidBytes[4] = (byte)(packet.ReadBit() ? 1 : 0); if (guidBytes[2] != 0) guidBytes[2] ^= packet.ReadByte(); if (guidBytes[3] != 0) guidBytes[3] ^= packet.ReadByte(); var itemCount = packet.ReadUInt32("Item Count"); if (guidBytes[5] != 0) guidBytes[5] ^= packet.ReadByte(); if (guidBytes[0] != 0) guidBytes[0] ^= packet.ReadByte(); if (guidBytes[1] != 0) guidBytes[1] ^= packet.ReadByte(); packet.ReadByte("Unk Byte"); if (guidBytes[4] != 0) guidBytes[4] ^= packet.ReadByte(); if (guidBytes[7] != 0) guidBytes[7] ^= packet.ReadByte(); if (guidBytes[6] != 0) guidBytes[6] ^= packet.ReadByte(); var guid = new Guid(BitConverter.ToUInt64(guidBytes, 0)); packet.WriteLine("GUID: {0}", guid); npcVendor.VendorItems = new List<VendorItem>((int)itemCount); for (var i = 0; i < itemCount; i++) { var vendorItem = new VendorItem(); packet.ReadInt32("Max Durability", i); vendorItem.Slot = packet.ReadUInt32("Item Position", i); vendorItem.ItemId = (uint)packet.ReadEntryWithName<Int32>(StoreNameType.Item, "Item ID", i); packet.ReadInt32("Unk Int32 1", i); packet.ReadInt32("Display ID", i); vendorItem.MaxCount = packet.ReadInt32("Max Count", i); packet.ReadUInt32("Buy Count", i); vendorItem.ExtendedCostId = packet.ReadUInt32("Extended Cost", i); packet.ReadInt32("Unk Int32 2", i); packet.ReadInt32("Price", i); npcVendor.VendorItems.Add(vendorItem); } Storage.NpcVendors.TryAdd(guid.GetEntry(), npcVendor); }
public static MovementInfo ReadMovementInfo(ref Packet packet, Guid guid) { if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_2_0_14333)) return ReadMovementInfo420(ref packet, guid, -1); return ReadMovementInfo(ref packet, guid, -1); }
public static MovementInfo ReadMovementInfo(ref Packet packet, Guid guid, int index) { string prefix = index < 0 ? string.Empty : "[" + index + "] "; var info = new MovementInfo(); info.Flags = packet.ReadEnum<MovementFlag>(prefix + "Movement Flags", TypeCode.Int32); var flagsTypeCode = ClientVersion.AddedInVersion(ClientVersionBuild.V3_0_2_9056) ? TypeCode.Int16 : TypeCode.Byte; var flags = packet.ReadEnum<MovementFlagExtra>(prefix + "Extra Movement Flags", flagsTypeCode); if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_2_2_14545)) if (packet.ReadGuid(prefix + "GUID 2") != guid) packet.Writer.WriteLine("GUIDS NOT EQUAL"); // Fo debuggingz packet.ReadInt32(prefix + "Time"); var pos = packet.ReadVector4(prefix + "Position"); info.Position = new Vector3(pos.X, pos.Y, pos.Z); info.Orientation = pos.O; if (info.Flags.HasAnyFlag(MovementFlag.OnTransport)) { if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767)) packet.ReadPackedGuid(prefix + "Transport GUID"); else packet.ReadGuid(prefix + "Transport GUID"); packet.ReadVector4(prefix + "Transport Position"); packet.ReadInt32(prefix + "Transport Time"); if (ClientVersion.AddedInVersion(ClientType.WrathOfTheLichKing)) packet.ReadByte(prefix + "Transport Seat"); if (flags.HasAnyFlag(MovementFlagExtra.InterpolateMove)) packet.ReadInt32(prefix + "Transport Time"); } if (info.Flags.HasAnyFlag(MovementFlag.Swimming | MovementFlag.Flying) || flags.HasAnyFlag(MovementFlagExtra.AlwaysAllowPitching)) packet.ReadSingle(prefix + "Swim Pitch"); if (ClientVersion.RemovedInVersion(ClientType.Cataclysm)) packet.ReadInt32(prefix + "Fall Time"); if (info.Flags.HasAnyFlag(MovementFlag.Falling)) { if (ClientVersion.AddedInVersion(ClientType.Cataclysm)) packet.ReadInt32(prefix + "Fall Time"); packet.ReadSingle(prefix + "Fall Velocity"); packet.ReadSingle(prefix + "Fall Sin angle"); packet.ReadSingle(prefix + "Fall Cos angle"); packet.ReadSingle(prefix + "Fall Speed"); } if (info.Flags.HasAnyFlag(MovementFlag.SplineElevation)) packet.ReadSingle(prefix + "Spline Elevation"); return info; }
public static void HandleServerChatMessage(Packet packet) { var text = new CreatureText(); var SenderGUID = new byte[8]; var GuildGUID = new byte[8]; var ReceiverGUID = new byte[8]; var GroupGUID = new byte[8]; var hasLang = !packet.ReadBit(); var hasReceiver = !packet.ReadBit(); packet.ReadBit(); // fake bit packet.StartBitStream(GroupGUID, 3, 7, 2, 6, 0, 4, 5, 1); var hasAchi = !packet.ReadBit(); var bit1495 = packet.ReadBit(); var hasPrefix = !packet.ReadBit(); packet.ReadBit(); // fake bit var bit43D = !packet.ReadBit(); packet.StartBitStream(GuildGUID, 1, 6, 0, 5, 2, 4, 7, 3); packet.ReadBit(); // fake bit packet.StartBitStream(ReceiverGUID, 6, 1, 3, 5, 4, 2, 7, 0); var receiverLen = 0u; if (hasReceiver) { receiverLen = packet.ReadBits(11); } var hasChannel = !packet.ReadBit(); var bit1494 = packet.ReadBit(); var bit1490 = !packet.ReadBit(); var hasRealmId = !packet.ReadBit(); var bits43D = 0u; if (bit43D) { bits43D = packet.ReadBits(11); } var channelLen = 0u; if (hasChannel) { channelLen = packet.ReadBits(7); } var bit8CF = !packet.ReadBit(); var textLen = 0u; if (bit8CF) { textLen = packet.ReadBits(12); } packet.ReadBit(); // fake bit packet.StartBitStream(SenderGUID, 4, 1, 3, 6, 2, 5, 0, 7); var bit148C = !packet.ReadBit(); var bits148C = 0u; if (bit148C) { bits148C = packet.ReadBits(9); } var prefixLen = 0u; if (hasPrefix) { prefixLen = packet.ReadBits(5); packet.ReadWoWString("Addon Message Prefix", prefixLen); } packet.ParseBitStream(GroupGUID, 4, 2, 7, 3, 6, 1, 5, 0); if (hasReceiver) { packet.ReadWoWString("Receiver Name", receiverLen); } packet.ParseBitStream(ReceiverGUID, 7, 4, 1, 3, 0, 6, 5, 2); packet.ParseBitStream(GuildGUID, 5, 7, 3, 0, 4, 6, 1, 2); if (hasLang) { text.Language = packet.ReadEnum <Language>("Language", TypeCode.Byte); } packet.ParseBitStream(SenderGUID, 7, 4, 0, 6, 3, 2, 5, 1); if (hasChannel) { packet.ReadWoWString("Channel Name", channelLen); } text.Text = packet.ReadWoWString("Text", textLen); text.Type = (ChatMessageType)packet.ReadEnum <ChatMessageType540>("Chat type", TypeCode.Byte); if (hasAchi) { packet.ReadInt32("Achievement"); } if (bit1490) { packet.ReadSingle("Float1490"); } if (hasRealmId) { packet.ReadInt32("Realm Id"); } packet.WriteGuid("SenderGUID", SenderGUID); packet.WriteGuid("ReceiverGUID", ReceiverGUID); packet.WriteGuid("GuildGUID", GuildGUID); packet.WriteGuid("GroupGUID", GroupGUID); uint entry = 0; var guid = new Guid(BitConverter.ToUInt64(SenderGUID, 0)); if (guid.GetObjectType() == ObjectType.Unit) { entry = guid.GetEntry(); } if (entry != 0) { Storage.CreatureTexts.Add(entry, text, packet.TimeSpan); } }
private static MovementInfo ReadMovementUpdateBlock(ref Packet packet, Guid guid, int index) { var moveInfo = new MovementInfo(); var guid1 = new byte[8]; var transportGuid = new byte[8]; var goTransportGuid = new byte[8]; var attackingTargetGuid = new byte[8]; var hasFallData = false; var hasFallDirection = false; var hasFullSpline = false; var hasGOTransportTime2 = false; var hasGOTransportTime3 = false; var hasMovementFlags = false; var hasMoveFlagsExtra = false; var hasOrientation = false; var hasParabolicAndNotEnded = false; var hasParabolicOrAnimation = false; var hasPitch = false; var hasSplineElevation = false; var hasTransportData = false; var hasTransportTime2 = false; var hasTransportTime3 = false; var hasTimestamp = false; var hasUnkSpline = false; var hasDWordA0 = false; var byte8C = false; var byteA4 = false; var byte8D = false; var splineCount = 0u; var Unk19BitsCounter = 0u; var UnkSpline_21BitsCounter = 0u; var Unk22BitsCounter = 0u; var splineType = SplineType.Stop; var hasVehicleData = packet.ReadBit("Has Vehicle Data", index); var isSelf = packet.ReadBit("Self", index); packet.ReadBit(); // fake bit var transport = packet.ReadBit("Transport", index); packet.ReadBit(); // fake bit var byte2A9 = packet.ReadBit("byte2A9", index); var hasAttackingTarget = packet.ReadBit("Has Attacking Target", index); var hasStationaryPosition = packet.ReadBit("Has Stationary Position", index); var isAreaTrigger = packet.ReadBit("Area Trigger", index); var byte428 = packet.ReadBit("byte428", index); var isSceneObject = packet.ReadBit("Scene Object", index); packet.ReadBit(); // fake bit var byte32A = packet.ReadBit("byte32A", index); var transportFrames = packet.ReadBits(22); var living = packet.ReadBit("Living", index); var hasGameObjectPosition = packet.ReadBit("Has GameObject Position", index); packet.ReadBit(); // fake bit var hasGameObjectRotation = packet.ReadBit("Has GameObject Rotation", index); var byte2A4 = packet.ReadBit("byte2A4", index); var byte414 = packet.ReadBit("byte414", index); var hasAnimKits = packet.ReadBit("Has AnimKits", index); if (living) { // need update guid1[5] = packet.ReadBit(); byte8D = packet.ReadBit(); hasSplineElevation = !packet.ReadBit(); guid1[6] = packet.ReadBit(); byteA4 = packet.ReadBit(); Unk19BitsCounter = packet.ReadBits(19); if (Unk19BitsCounter != 0) { for (var i = 0; i < Unk19BitsCounter; ++i) { packet.ReadBits("Unk19BitsCounter", 2, index); } } guid1[4] = packet.ReadBit(); hasOrientation = !packet.ReadBit(); hasMoveFlagsExtra = !packet.ReadBit(); hasDWordA0 = !packet.ReadBit(); guid1[2] = packet.ReadBit(); guid1[3] = packet.ReadBit(); guid1[7] = packet.ReadBit(); Unk22BitsCounter = packet.ReadBits(22); hasMovementFlags = !packet.ReadBit(); hasTimestamp = !packet.ReadBit("Lacks timestamp", index); hasPitch = !packet.ReadBit("Lacks pitch", index); guid1[1] = packet.ReadBit(); hasFallData = packet.ReadBit("Has Fall Data", index); byte8C = packet.ReadBit(); if (hasMoveFlagsExtra) { moveInfo.FlagsExtra = packet.ReadEnum <MovementFlagExtra>("Extra Movement Flags", 13, index); } guid1[0] = packet.ReadBit(); moveInfo.HasSplineData = packet.ReadBit("Has spline data", index); if (moveInfo.HasSplineData) { hasFullSpline = packet.ReadBit(); } if (hasFullSpline) { packet.ReadEnum <SplineFlag542>("Spline flags", 25, index); hasParabolicOrAnimation = packet.ReadBit("Has Parabolic Or Animation", index); splineCount = packet.ReadBits("SplineWaypointsCount", 20, index); hasUnkSpline = packet.ReadBit(); if (hasUnkSpline) { UnkSpline_21BitsCounter = packet.ReadBits(21); packet.ReadBits("UnkSpline_2BitsFlags", 2, index); } packet.ReadEnum <SplineMode>("Spline Mode", 2, index); hasParabolicAndNotEnded = packet.ReadBit("Has Parabolic And Not Ended", index); } hasTransportData = packet.ReadBit("Has Transport Data", index); if (hasTransportData) { packet.StartBitStream(transportGuid, 6, 1, 2, 5); hasTransportTime3 = packet.ReadBit(); packet.StartBitStream(transportGuid, 4, 7, 0); hasTransportTime2 = packet.ReadBit(); transportGuid[3] = packet.ReadBit(); } if (hasMovementFlags) { moveInfo.Flags = packet.ReadEnum <MovementFlag>("Movement Flags", 30, index); } if (hasFallData) { hasFallDirection = packet.ReadBit("Has Fall Direction", index); } } if (hasGameObjectPosition) { hasGOTransportTime3 = packet.ReadBit(); hasGOTransportTime2 = packet.ReadBit(); packet.StartBitStream(goTransportGuid, 4, 2, 7, 6, 3, 0, 1, 5); } if (hasAnimKits) { // need update } if (hasAttackingTarget) { attackingTargetGuid = packet.StartBitStream(4, 0, 6, 2, 1, 5, 3, 7); } if (isSceneObject) { // need update } // DWORD 418 uint dword418 = 0; if (byte428) { dword418 = packet.ReadBits(22); } // DWORD 2AA uint dword2AA = 0; if (byte32A) { dword2AA = packet.ReadBits(7); } packet.ResetBitReader(); if (living) { if (hasTransportData) { packet.ReadXORByte(transportGuid, 0); packet.ReadXORByte(transportGuid, 5); moveInfo.TransportOffset.Z = packet.ReadSingle(); packet.ReadXORByte(transportGuid, 1); moveInfo.TransportOffset.Y = packet.ReadSingle(); packet.ReadXORByte(transportGuid, 2); packet.ReadUInt32("Transport Time", index); moveInfo.TransportOffset.O = packet.ReadSingle(); packet.ReadXORByte(transportGuid, 7); if (hasTransportTime2) { packet.ReadUInt32("Transport Time 2", index); } packet.ReadXORByte(transportGuid, 6); packet.ReadXORByte(transportGuid, 4); moveInfo.TransportOffset.X = packet.ReadSingle(); packet.ReadXORByte(transportGuid, 3); packet.ReadByte("Transport Seat", index); if (hasTransportTime3) { packet.ReadUInt32("Transport Time 3", index); } } if (moveInfo.HasSplineData) { if (hasFullSpline) { if (hasUnkSpline) { for (var i = 0; i < UnkSpline_21BitsCounter; ++i) { packet.ReadSingle("UnkSplineFloat", index, i); packet.ReadSingle("UnkSplineFloat2", index, i); } } packet.ReadSingle("UnkFloat", index); if (splineCount != 0) { for (var i = 0u; i < splineCount; ++i) { var wp = new Vector3 { Y = packet.ReadSingle(), Z = packet.ReadSingle(), X = packet.ReadSingle(), }; packet.WriteLine("[{0}][{1}] Spline Waypoint: {2}", index, i, wp); } } packet.ReadInt32("Spline Time", index); var type = packet.ReadByte(); switch (type) { case 1: splineType = SplineType.Normal; break; case 2: splineType = SplineType.FacingSpot; break; case 3: splineType = SplineType.FacingTarget; break; case 4: splineType = SplineType.FacingAngle; break; } if (splineType == SplineType.FacingAngle) { packet.ReadSingle("Facing Angle", index); } packet.ReadSingle(); if (hasParabolicOrAnimation) { packet.ReadInt32("Spline Start Time", index); } if (hasParabolicAndNotEnded) { packet.ReadSingle("Spline Vertical Acceleration", index); } if (splineType == SplineType.FacingSpot) { var point = new Vector3 { Y = packet.ReadSingle(), Z = packet.ReadSingle(), X = packet.ReadSingle(), }; packet.WriteLine("[{0}] Facing Spot: {1}", index, point); } packet.ReadInt32("Spline Full Time", index); } packet.ReadInt32("Spline Id", index); packet.ReadSingle(); packet.ReadSingle(); packet.ReadSingle(); } moveInfo.Position.Y = packet.ReadSingle(); packet.ReadXORByte(guid1, 7); for (var i = 0; i < Unk19BitsCounter; ++i) { packet.ReadSingle(); packet.ReadInt32(); packet.ReadInt32(); packet.ReadSingle(); packet.ReadSingle(); packet.ReadSingle(); } if (hasFallData) { packet.ReadInt32(); if (hasFallDirection) { packet.ReadSingle(); packet.ReadSingle(); packet.ReadSingle(); } packet.ReadSingle(); } if (hasPitch) { packet.ReadSingle("Pitch", index); } if (hasDWordA0) { packet.ReadInt32(); } packet.ReadXORByte(guid1, 1); packet.ReadSingle("Turn Speed", index); packet.ReadSingle("RunBack Speed", index); moveInfo.WalkSpeed = packet.ReadSingle("Walk Speed", index) / 2.5f; if (hasTimestamp) { packet.ReadUInt32("Time", index); } moveInfo.Position.X = packet.ReadSingle(); packet.ReadXORByte(guid1, 2); packet.ReadSingle("Swim Speed", index); packet.ReadSingle("FlyBack Speed", index); if (hasOrientation) { moveInfo.Orientation = packet.ReadSingle(); } packet.ReadSingle("Fly Speed", index); packet.ReadXORByte(guid1, 6); if (hasSplineElevation) { packet.ReadSingle("Spline Elevation", index); } moveInfo.RunSpeed = packet.ReadSingle("Run Speed", index) / 7.0f; packet.ReadSingle("Pitch Speed", index); packet.ReadXORByte(guid1, 0); packet.ReadXORByte(guid1, 5); for (var i = 0; i < Unk22BitsCounter; ++i) { packet.ReadInt32(); } packet.ReadXORByte(guid1, 4); packet.ReadSingle("Swim Back Speed", index); moveInfo.Position.Z = packet.ReadSingle(); packet.ReadXORByte(guid1, 3); } if (isSceneObject) { // need update } if (hasGameObjectPosition) { packet.ReadSByte("GO Transport Seat", index); if (hasGOTransportTime2) { packet.ReadUInt32("GO Transport Time 2", index); } packet.ParseBitStream(goTransportGuid, 4, 3); if (hasGOTransportTime2) { packet.ReadUInt32("GO Transport Time 3", index); } packet.ParseBitStream(goTransportGuid, 7, 6, 5, 0); moveInfo.TransportOffset.Z = packet.ReadSingle(); moveInfo.TransportOffset.X = packet.ReadSingle(); packet.ReadUInt32("GO Transport Time", index); moveInfo.TransportOffset.O = packet.ReadSingle(); packet.ReadXORByte(goTransportGuid, 1); moveInfo.TransportOffset.Y = packet.ReadSingle(); packet.ReadXORByte(goTransportGuid, 2); moveInfo.TransportGuid = new Guid(BitConverter.ToUInt64(goTransportGuid, 0)); packet.WriteLine("[{0}] GO Transport GUID {1}", index, moveInfo.TransportGuid); packet.WriteLine("[{0}] GO Transport Position: {1}", index, moveInfo.TransportOffset); } if (hasVehicleData) { // need update } if (hasAttackingTarget) { packet.ParseBitStream(attackingTargetGuid, 1, 3, 5, 4, 7, 6, 2, 0); packet.WriteGuid("Attacking GUID", attackingTargetGuid, index); } if (hasGameObjectRotation) { packet.ReadPackedQuaternion("GameObject Rotation", index); } if (hasAnimKits) { // need update } if (hasStationaryPosition) { moveInfo.Position.X = packet.ReadSingle(); moveInfo.Position.Z = packet.ReadSingle(); moveInfo.Position.Y = packet.ReadSingle(); moveInfo.Orientation = packet.ReadSingle("Stationary Orientation", index); packet.WriteLine("[{0}] Stationary Position: {1}", index, moveInfo.Position); } if (transport) { // need update } if (living && moveInfo.HasSplineData && hasFullSpline && splineType == SplineType.FacingTarget) { var facingTargetGuid = new byte[8]; facingTargetGuid = packet.StartBitStream(5, 0, 2, 4, 1, 3, 6, 7); packet.ParseBitStream(facingTargetGuid, 5, 0, 4, 6, 3, 2, 1, 7); packet.WriteGuid("Facing Target GUID", facingTargetGuid, index); } if (byte32A) { packet.ReadString(); } if (byte414) { packet.ReadInt32(); } if (byte2A4) { packet.ReadInt32(); } if (byte428) { for (uint l_I = 0; l_I < dword418; l_I++) { packet.ReadInt32(); } } return(moveInfo); }
public static MovementInfo ReadMovementInfo(ref Packet packet, Guid guid, int index = -1) { if (ClientVersion.Build == ClientVersionBuild.V4_2_0_14333) return ReadMovementInfo420(ref packet, index); return ReadMovementInfoGen(ref packet, guid, index); }
public static void HandlePlayerLogin(Packet packet) { var guid = packet.ReadGuid("GUID"); LoginGuid = guid; }
public static void HandleVendorInventoryList(Packet packet) { var npcVendor = new NpcVendor(); var guid = new byte[8]; packet.StartBitStream(guid, 5, 4, 7, 1, 2, 3); var itemCount = packet.ReadBits("Item Count", 18); var hasExtendedCost = new bool[itemCount]; var hasCondition = new bool[itemCount]; for (int i = 0; i < itemCount; ++i) { hasCondition[i] = !packet.ReadBit(); hasExtendedCost[i] = !packet.ReadBit(); packet.ReadBit("Unk bit", i); } packet.StartBitStream(guid, 6, 0); packet.ResetBitReader(); packet.ReadXORBytes(guid, 3, 4); npcVendor.VendorItems = new List <VendorItem>((int)itemCount); for (int i = 0; i < itemCount; ++i) { var vendorItem = new VendorItem(); vendorItem.ItemId = (uint)packet.ReadEntryWithName <Int32>(StoreNameType.Item, "Item ID", i); vendorItem.Slot = packet.ReadUInt32("Item Position", i); packet.ReadInt32("Item Upgrade ID", i); packet.ReadInt32("Display ID", i); var maxCount = packet.ReadInt32("Max Count", i); var buyCount = packet.ReadUInt32("Buy Count", i); packet.ReadInt32("Price", i); if (hasCondition[i]) { packet.ReadInt32("Condition ID", i); } vendorItem.Type = packet.ReadUInt32("Type", i); // 1 - item, 2 - currency packet.ReadInt32("Max Durability", i); if (hasExtendedCost[i]) { vendorItem.ExtendedCostId = packet.ReadUInt32("Extended Cost", i); } vendorItem.MaxCount = maxCount == -1 ? 0 : maxCount; // TDB if (vendorItem.Type == 2) { vendorItem.MaxCount = (int)buyCount; } npcVendor.VendorItems.Add(vendorItem); } packet.ReadXORBytes(guid, 1, 2, 7); packet.ReadByte("Unk Byte"); packet.ReadXORBytes(guid, 6, 0, 5); packet.WriteGuid("GUID", guid); var GUID = new Guid(BitConverter.ToUInt64(guid, 0)); Storage.NpcVendors.Add(GUID.GetEntry(), npcVendor, packet.TimeSpan); }
public static void HandleCharEnum434(Packet packet) { //var unkCounter = packet.ReadBits("Unk Counter", 23); var unkCounter = packet.ReadByte(); packet.ReadByte(); packet.ReadByte(); var count = packet.ReadBits("Char count", 17); var charGuids = new byte[count][]; var guildGuids = new byte[count][]; var firstLogins = new bool[count]; var nameLenghts = new uint[count]; for (var c = 0; c < count; ++c) { charGuids[c] = new byte[8]; guildGuids[c] = new byte[8]; /* guildGuids[c][2] = (byte)(packet.ReadBit() ? 1 : 0); charGuids[c][2] = (byte)(packet.ReadBit() ? 1 : 0); charGuids[c][6] = (byte)(packet.ReadBit() ? 1 : 0); charGuids[c][5] = (byte)(packet.ReadBit() ? 1 : 0); charGuids[c][4] = (byte)(packet.ReadBit() ? 1 : 0); guildGuids[c][4] = (byte)(packet.ReadBit() ? 1 : 0); guildGuids[c][3] = (byte)(packet.ReadBit() ? 1 : 0); guildGuids[c][7] = (byte)(packet.ReadBit() ? 1 : 0); nameLenghts[c] = packet.ReadBits(7); guildGuids[c][0] = (byte)(packet.ReadBit() ? 1 : 0); charGuids[c][0] = (byte)(packet.ReadBit() ? 1 : 0); charGuids[c][3] = (byte)(packet.ReadBit() ? 1 : 0); charGuids[c][1] = (byte)(packet.ReadBit() ? 1 : 0); firstLogins[c] = packet.ReadBit(); guildGuids[c][5] = (byte)(packet.ReadBit() ? 1 : 0); charGuids[c][7] = (byte)(packet.ReadBit() ? 1 : 0); guildGuids[c][6] = (byte)(packet.ReadBit() ? 1 : 0); guildGuids[c][1] = (byte)(packet.ReadBit() ? 1 : 0);*/ charGuids[c][7] = (byte)(packet.ReadBit() ? 1 : 0); guildGuids[c][4] = (byte)(packet.ReadBit() ? 1 : 0); guildGuids[c][3] = (byte)(packet.ReadBit() ? 1 : 0); guildGuids[c][7] = (byte)(packet.ReadBit() ? 1 : 0); nameLenghts[c] = packet.ReadBits(7); charGuids[c][4] = (byte)(packet.ReadBit() ? 1 : 0); charGuids[c][3] = (byte)(packet.ReadBit() ? 1 : 0); guildGuids[c][5] = (byte)(packet.ReadBit() ? 1 : 0); charGuids[c][5] = (byte)(packet.ReadBit() ? 1 : 0); guildGuids[c][5] = (byte)(packet.ReadBit() ? 1 : 0); charGuids[c][1] = (byte)(packet.ReadBit() ? 1 : 0); guildGuids[c][5] = (byte)(packet.ReadBit() ? 1 : 0); guildGuids[c][5] = (byte)(packet.ReadBit() ? 1 : 0); firstLogins[c] = packet.ReadBit(); charGuids[c][0] = (byte)(packet.ReadBit() ? 1 : 0); charGuids[c][2] = (byte)(packet.ReadBit() ? 1 : 0); charGuids[c][6] = (byte)(packet.ReadBit() ? 1 : 0); guildGuids[c][7] = (byte)(packet.ReadBit() ? 1 : 0); packet.ReadBit(); packet.ReadBit(); packet.ReadBit(); packet.ReadBit(); packet.ReadBit(); packet.ReadBit(); packet.ReadBit(); } //packet.ReadBit(); // no idea, not used in client if (count > 0) { for (int c = 0; c < count; ++c) { var clss = packet.ReadEnum<Class>("Class", TypeCode.Byte, c); for (var itm = 0; itm < 19; ++itm) { packet.ReadEnum<InventoryType>("Item InventoryType", TypeCode.Byte, c, itm); packet.ReadInt32("Item DisplayID", c, itm); packet.ReadInt32("Item EnchantID", c, itm); } for (var itm = 0; itm < 4; ++itm) { packet.ReadEnum<InventoryType>("Bag InventoryType", TypeCode.Byte, c, itm); packet.ReadInt32("Bag DisplayID", c, itm); packet.ReadInt32("Bag EnchantID", c, itm); } packet.ReadInt32("Pet Family", c); packet.ReadByte("List Order", c); packet.ReadByte("Hair Style", c); packet.ReadInt32("Pet Display ID", c); packet.ReadEnum<CharacterFlag>("CharacterFlag", TypeCode.Int32, c); packet.ReadByte("Hair Color", c); var mapId = packet.ReadInt32("Map", c); var z = packet.ReadSingle("Position Z", c); packet.ReadInt32("Pet Level", c); if (charGuids[c][3] != 0) charGuids[c][3] ^= packet.ReadByte(); var y = packet.ReadSingle("Position Y", c); packet.ReadEnum<CustomizationFlag>("CustomizationFlag", TypeCode.UInt32, c); packet.ReadByte("Facial Hair", c); if (charGuids[c][7] != 0) charGuids[c][7] ^= packet.ReadByte(); packet.ReadEnum<Gender>("Gender", TypeCode.Byte, c); var name = packet.ReadWoWString("Name", (int)nameLenghts[c], c); packet.ReadByte("Face", c); if (charGuids[c][0] != 0) charGuids[c][0] ^= packet.ReadByte(); if (charGuids[c][2] != 0) charGuids[c][2] ^= packet.ReadByte(); var x = packet.ReadSingle("Position X", c); packet.ReadByte("Skin", c); var race = packet.ReadEnum<Race>("Race", TypeCode.Byte, c); var level = packet.ReadByte("Level", c); if (charGuids[c][1] != 0) charGuids[c][1] ^= packet.ReadByte(); var zone = packet.ReadEntryWithName<UInt32>(StoreNameType.Zone, "Zone Id", c); // Not ideal if (guildGuids[c][0] != 0) guildGuids[c][0] ^= packet.ReadByte(); if (guildGuids[c][1] != 0) guildGuids[c][1] ^= packet.ReadByte(); if (guildGuids[c][7] != 0) guildGuids[c][7] ^= packet.ReadByte(); if (guildGuids[c][4] != 0) guildGuids[c][4] ^= packet.ReadByte(); if (charGuids[c][4] != 0) charGuids[c][4] ^= packet.ReadByte(); if (charGuids[c][5] != 0) charGuids[c][5] ^= packet.ReadByte(); if (guildGuids[c][5] != 0) guildGuids[c][5] ^= packet.ReadByte(); if (charGuids[c][6] != 0) charGuids[c][6] ^= packet.ReadByte(); if (guildGuids[c][3] != 0) guildGuids[c][3] ^= packet.ReadByte(); if (guildGuids[c][6] != 0) guildGuids[c][6] ^= packet.ReadByte(); if (guildGuids[c][2] != 0) guildGuids[c][2] ^= packet.ReadByte(); var playerGuid = new Guid(BitConverter.ToUInt64(charGuids[c], 0)); packet.WriteLine("[{0}] Character GUID: {1}", c, playerGuid); packet.WriteLine("[{0}] Guild GUID: {1}", c, new Guid(BitConverter.ToUInt64(guildGuids[c], 0))); if (firstLogins[c]) { var startPos = new StartPosition(); startPos.Map = mapId; startPos.Position = new Vector3(x, y, z); startPos.Zone = zone; Storage.StartPositions.Add(new Tuple<Race, Class>(race, clss), startPos, packet.TimeSpan); } var playerInfo = new Player { Race = race, Class = clss, Name = name, FirstLogin = firstLogins[c], Level = level }; if (Storage.Objects.ContainsKey(playerGuid)) Storage.Objects[playerGuid] = new Tuple<WoWObject, TimeSpan?>(playerInfo, packet.TimeSpan); else Storage.Objects.Add(playerGuid, playerInfo, packet.TimeSpan); } for (var c = 0; c < unkCounter; c++) packet.WriteLine("Unk Loop: {0}, {1}", packet.ReadUInt32(), packet.ReadByte()); } }
public static void HandleLogoutComplete(Packet packet) { LoginGuid = new Guid(0); }
private static void ReadCreateObjectBlock(ref Packet packet, Guid guid, uint map, int index) { var objType = packet.ReadEnum<ObjectType>("Object Type", TypeCode.Byte, index); var moves = ReadMovementUpdateBlock(ref packet, guid, index); var updates = ReadValuesUpdateBlock(ref packet, objType, index); var obj = new WoWObject {Type = objType, Movement = moves, UpdateFields = updates, Map = map, Area = WorldStateHandler.CurrentAreaId, PhaseMask = (uint) MovementHandler.CurrentPhaseMask}; if (guid.HasEntry() && guid.GetObjectType() == ObjectType.Unit) { List<string> lines = new List<string>(); lines.Add("UpdateType: Values"); foreach (var data in updates) lines.Add("Block Value " + UpdateFields.GetUpdateFieldName(data.Key, "UnitField") + ": " + data.Value.Int32Value + "/" + data.Value.SingleValue); if (packet.SniffFileInfo.Stuffing.upObjPackets.ContainsKey(guid)) packet.SniffFileInfo.Stuffing.upObjPackets[guid].upObjPackets.Enqueue(new UpdateObjectPacket(packet.Time, packet.Number, lines)); else packet.SniffFileInfo.Stuffing.upObjPackets.TryAdd(guid, new UpdateObjectPackets(new UpdateObjectPacket(packet.Time, packet.Number, lines))); } packet.SniffFileInfo.Stuffing.Objects.TryAdd(guid, obj); if (guid.HasEntry() && (objType == ObjectType.Unit || objType == ObjectType.GameObject)) packet.AddSniffData(Utilities.ObjectTypeToStore(objType), (int)guid.GetEntry(), "SPAWN"); }
public static void HandlePhaseShift422(Packet packet) { byte[] bytes = { 0, 0, 0, 0, 0, 0, 0, 0 }; var guidFlag = packet.ReadEnum<BitMask>("Guid Mask Flags",TypeCode.Byte); if (guidFlag.HasFlag(BitMask.Byte0)) bytes[0] = packet.ReadByte(); if (guidFlag.HasFlag(BitMask.Byte4)) bytes[4] = packet.ReadByte(); var count = packet.ReadUInt32(); if (count > 0) { int num = (int)count - 2; packet.ReadEntryWithName<Int16>(StoreNameType.Map, "Map Swap 1"); if (num > 0) { packet.Writer.Write("Bytes: 0x"); byte[] bytes1 = packet.ReadBytes(num); for (var i = 0; i < num; ++i) packet.Writer.Write(bytes1[i].ToString("X2")); packet.Writer.WriteLine(); } } if (guidFlag.HasFlag(BitMask.Byte3)) bytes[3] = packet.ReadByte(); packet.ReadUInt32("Flag?"); if (guidFlag.HasFlag(BitMask.Byte2)) bytes[2] = packet.ReadByte(); count = packet.ReadUInt32(); if (count > 0) { int num = (int)count - 2; packet.ReadUInt16("Current Mask"); if (num > 0) { packet.Writer.Write("Bytes: 0x"); byte[] bytes1 = packet.ReadBytes(num); for (var i = 0; i < num; ++i) packet.Writer.Write(bytes1[i].ToString("X2")); packet.Writer.WriteLine(); } } if (!guidFlag.HasFlag(BitMask.Byte2)) bytes[6] = packet.ReadByte(); count = packet.ReadUInt32(); if (count > 0) { int num = (int)count - 2; packet.ReadEntryWithName<Int16>(StoreNameType.Map, "Map Swap 2"); if (num > 0) { packet.Writer.Write("Bytes: 0x"); byte[] bytes1 = packet.ReadBytes(num); for (var i = 0; i < num; ++i) packet.Writer.Write(bytes1[i].ToString("X2")); packet.Writer.WriteLine(); } } if (guidFlag.HasFlag(BitMask.Byte7)) bytes[7] = packet.ReadByte(); count = packet.ReadUInt32(); if (count > 0) { int num = (int)count - 2; packet.ReadEntryWithName<Int16>(StoreNameType.Map, "Map Swap 3"); if (num > 0) { packet.Writer.Write("Bytes: 0x"); byte[] bytes1 = packet.ReadBytes(num); for (var i = 0; i < num; ++i) packet.Writer.Write(bytes1[i].ToString("X2")); packet.Writer.WriteLine(); } } if (guidFlag.HasFlag(BitMask.Byte1)) bytes[1] = packet.ReadByte(); if (guidFlag.HasFlag(BitMask.Byte5)) bytes[5] = packet.ReadByte(); ulong tmp = 0; for (var i = 7; i > 0; --i) { if (bytes[i] > 0) bytes[i] ^= 1; tmp += bytes[i]; tmp <<= 8; } var guid = new Guid(tmp); packet.Writer.WriteLine("GUID: " + guid); }
public static void HandleCharEnum(Packet packet) { packet.ReadBit("Unk bit"); var count2 = packet.ReadBits("RIDBIT21", 21); var count = packet.ReadBits("Char count", 16); var charGuids = new byte[count][]; var guildGuids = new byte[count][]; var firstLogins = new bool[count]; var nameLenghts = new uint[count]; for (int c = 0; c < count; ++c) { charGuids[c] = new byte[8]; guildGuids[c] = new byte[8]; charGuids[c][3] = packet.ReadBit(); guildGuids[c][6] = packet.ReadBit(); guildGuids[c][3] = packet.ReadBit(); firstLogins[c] = packet.ReadBit(); guildGuids[c][7] = packet.ReadBit(); nameLenghts[c] = packet.ReadBits(6); guildGuids[c][1] = packet.ReadBit(); charGuids[c][6] = packet.ReadBit(); charGuids[c][1] = packet.ReadBit(); guildGuids[c][4] = packet.ReadBit(); charGuids[c][5] = packet.ReadBit(); guildGuids[c][0] = packet.ReadBit(); charGuids[c][7] = packet.ReadBit(); charGuids[c][2] = packet.ReadBit(); charGuids[c][0] = packet.ReadBit(); guildGuids[c][2] = packet.ReadBit(); guildGuids[c][5] = packet.ReadBit(); charGuids[c][4] = packet.ReadBit(); } packet.ResetBitReader(); for (int c = 0; c < count; ++c) { packet.ReadEnum <CharacterFlag>("CharacterFlag", TypeCode.Int32, c); var zone = packet.ReadEntryWithName <UInt32>(StoreNameType.Zone, "Zone Id", c); packet.ReadXORByte(charGuids[c], 0); packet.ReadXORByte(guildGuids[c], 5); packet.ReadXORByte(charGuids[c], 1); packet.ReadXORByte(guildGuids[c], 1); packet.ReadXORByte(charGuids[c], 3); packet.ReadInt32("Pet Family", c); // v4+116 packet.ReadXORByte(guildGuids[c], 2); packet.ReadByte("Hair Style", c); // v4+63 packet.ReadXORByte(guildGuids[c], 0); packet.ReadXORByte(guildGuids[c], 7); var y = packet.ReadSingle("Position Y", c); // v4+80 packet.ReadXORByte(charGuids[c], 6); packet.ReadInt32("Pet Level", c); // v4+112 packet.ReadXORByte(charGuids[c], 7); var name = packet.ReadWoWString("Name", (int)nameLenghts[c], c); // v4 + 8 var level = packet.ReadByte("Level", c); // v4+66 var x = packet.ReadSingle("Position X", c); //v4+76 var clss = packet.ReadEnum <Class>("Class", TypeCode.Byte, c); // v4+59 packet.ReadInt32("Pet Display ID", c); //v4+108 packet.ReadByte("List Order", c); //v4+57 packet.ReadByte("Facial Hair", c); // v4+65 var z = packet.ReadSingle("Position Z", c); //v4+84 packet.ReadXORByte(guildGuids[c], 3); var race = packet.ReadEnum <Race>("Race", TypeCode.Byte, c); //v4+58 packet.ReadXORByte(charGuids[c], 4); for (int j = 0; j < 23; ++j) { packet.ReadEnum <InventoryType>("Item InventoryType", TypeCode.Byte, c, j); packet.ReadInt32("Item DisplayID", c, j); packet.ReadInt32("Item EnchantID", c, j); } packet.ReadXORByte(guildGuids[c], 6); packet.ReadXORByte(charGuids[c], 2); packet.ReadXORByte(charGuids[c], 5); packet.ReadByte("Skin", c); //v4+61 packet.ReadByte("Hair Color", c); // v4+64 packet.ReadByte("Face", c); // v4+62 packet.ReadXORByte(guildGuids[c], 4); packet.ReadEnum <CustomizationFlag>("CustomizationFlag", TypeCode.UInt32, c); //v4+100 packet.ReadEnum <Gender>("Gender", TypeCode.Byte, c); //v4+60 var mapId = packet.ReadEntryWithName <Int32>(StoreNameType.Map, "Map Id", c); //v4+72 for (var i = 0; i < count2; ++i) { packet.ReadUInt32("unk1"); packet.ReadByte("unk2"); } var playerGuid = new Guid(BitConverter.ToUInt64(charGuids[c], 0)); packet.WriteGuid("Character GUID", charGuids[c], c); packet.WriteGuid("Guild GUID", guildGuids[c], c); if (firstLogins[c]) { var startPos = new StartPosition(); startPos.Map = mapId; startPos.Position = new Vector3(x, y, z); startPos.Zone = zone; Storage.StartPositions.Add(new Tuple <Race, Class>(race, clss), startPos, packet.TimeSpan); } var playerInfo = new Player { Race = race, Class = clss, Name = name, FirstLogin = firstLogins[c], Level = level }; if (Storage.Objects.ContainsKey(playerGuid)) { Storage.Objects[playerGuid] = new Tuple <WoWObject, TimeSpan?>(playerInfo, packet.TimeSpan); } else { Storage.Objects.Add(playerGuid, playerInfo, packet.TimeSpan); } StoreGetters.AddName(playerGuid, name); } }
private static void ReadCreateObjectBlock(ref Packet packet, Guid guid, uint map, int index) { var objType = packet.ReadEnum<ObjectType>("Object Type", TypeCode.Byte, index); var moves = ReadMovementUpdateBlock(ref packet, guid, index); var updates = ReadValuesUpdateBlock(ref packet, objType, index); WoWObject obj; switch (objType) { case ObjectType.Unit: obj = new Unit(); break; case ObjectType.GameObject: obj = new GameObject(); break; case ObjectType.Item: obj = new Item(); break; case ObjectType.Player: obj = new Player(); break; default: obj = new WoWObject(); break; } obj.Type = objType; obj.Movement = moves; obj.UpdateFields = updates; obj.Map = map; obj.Area = WorldStateHandler.CurrentAreaId; obj.PhaseMask = (uint) MovementHandler.CurrentPhaseMask; Storage.Objects.TryAdd(guid, obj); if (guid.HasEntry() && (objType == ObjectType.Unit || objType == ObjectType.GameObject)) packet.AddSniffData(Utilities.ObjectTypeToStore(objType), (int)guid.GetEntry(), "SPAWN"); }
public static void HandleCharEnum(Packet packet) { //var unkCounter = packet.ReadBits("Unk Counter", 21); packet.ReadBit("Unk bit"); var count = packet.ReadBits("Char count", 16); var charGuids = new byte[count][]; var guildGuids = new byte[count][]; var firstLogins = new bool[count]; var nameLenghts = new uint[count]; for (int c = 0; c < count; ++c) { charGuids[c] = new byte[8]; guildGuids[c] = new byte[8]; charGuids[c][1] = packet.ReadBit(); guildGuids[c][5] = packet.ReadBit(); guildGuids[c][7] = packet.ReadBit(); guildGuids[c][6] = packet.ReadBit(); charGuids[c][5] = packet.ReadBit(); guildGuids[c][3] = packet.ReadBit(); charGuids[c][2] = packet.ReadBit(); guildGuids[c][4] = packet.ReadBit(); charGuids[c][7] = packet.ReadBit(); nameLenghts[c] = packet.ReadBits(6); firstLogins[c] = packet.ReadBit(); guildGuids[c][1] = packet.ReadBit(); charGuids[c][4] = packet.ReadBit(); guildGuids[c][2] = packet.ReadBit(); guildGuids[c][0] = packet.ReadBit(); charGuids[c][6] = packet.ReadBit(); charGuids[c][3] = packet.ReadBit(); charGuids[c][0] = packet.ReadBit(); } packet.ReadBits("RIDBIT21", 21); packet.ResetBitReader(); for (int c = 0; c < count; ++c) { packet.ReadXORByte(charGuids[c], 4); var race = packet.ReadEnum<Race>("Race", TypeCode.Byte, c); packet.ReadXORByte(charGuids[c], 6); packet.ReadXORByte(guildGuids[c], 1); packet.ReadByte("List Order", c); packet.ReadByte("Hair Style", c); packet.ReadXORByte(guildGuids[c], 6); packet.ReadXORByte(charGuids[c], 3); var x = packet.ReadSingle("Position X", c); packet.ReadEnum<CharacterFlag>("CharacterFlag", TypeCode.Int32, c); packet.ReadXORByte(guildGuids[c], 0); packet.ReadInt32("Pet Level", c); var mapId = packet.ReadEntryWithName<Int32>(StoreNameType.Map, "Map Id", c); packet.ReadXORByte(guildGuids[c], 7); packet.ReadEnum<CustomizationFlag>("CustomizationFlag", TypeCode.UInt32, c); packet.ReadXORByte(guildGuids[c], 4); packet.ReadXORByte(charGuids[c], 2); packet.ReadXORByte(charGuids[c], 5); var y = packet.ReadSingle("Position Y", c); packet.ReadInt32("Pet Family", c); var name = packet.ReadWoWString("Name", (int)nameLenghts[c], c); packet.ReadInt32("Pet Display ID", c); packet.ReadXORByte(guildGuids[c], 3); packet.ReadXORByte(charGuids[c], 7); var level = packet.ReadByte("Level", c); packet.ReadXORByte(charGuids[c], 1); packet.ReadXORByte(guildGuids[c], 2); for (int j = 0; j < 23; ++j) { packet.ReadInt32("Item EnchantID", c, j); packet.ReadInt32("Item DisplayID", c, j); packet.ReadEnum<InventoryType>("Item InventoryType", TypeCode.Byte, c, j); } var z = packet.ReadSingle("Position Z", c); var zone = packet.ReadEntryWithName<UInt32>(StoreNameType.Zone, "Zone Id", c); packet.ReadByte("Facial Hair", c); var clss = packet.ReadEnum<Class>("Class", TypeCode.Byte, c); packet.ReadXORByte(guildGuids[c], 5); packet.ReadByte("Skin", c); packet.ReadEnum<Gender>("Gender", TypeCode.Byte, c); packet.ReadByte("Face", c); packet.ReadXORByte(charGuids[c], 0); packet.ReadByte("Hair Color", c); var playerGuid = new Guid(BitConverter.ToUInt64(charGuids[c], 0)); packet.WriteGuid("Character GUID", charGuids[c], c); packet.WriteGuid("Guild GUID", guildGuids[c], c); if (firstLogins[c]) { var startPos = new StartPosition(); startPos.Map = mapId; startPos.Position = new Vector3(x, y, z); startPos.Zone = zone; Storage.StartPositions.Add(new Tuple<Race, Class>(race, clss), startPos, packet.TimeSpan); } var playerInfo = new Player { Race = race, Class = clss, Name = name, FirstLogin = firstLogins[c], Level = level }; if (Storage.Objects.ContainsKey(playerGuid)) Storage.Objects[playerGuid] = new Tuple<WoWObject, TimeSpan?>(playerInfo, packet.TimeSpan); else Storage.Objects.Add(playerGuid, playerInfo, packet.TimeSpan); StoreGetters.AddName(playerGuid, name); } }
public static void HandleVendorInventoryList(Packet packet) { var npcVendor = new NpcVendor(); var guidBytes = new byte[8]; guidBytes[4] = packet.ReadBit(); var itemCount = packet.ReadBits("Item Count", 18); var hasExtendedCost = new bool[itemCount]; var hasCondition = new bool[itemCount]; var hasCondition2 = new bool[itemCount]; for (int i = 0; i < itemCount; ++i) { hasCondition[i] = !packet.ReadBit(); hasCondition2[i] = !packet.ReadBit(); hasExtendedCost[i] = !packet.ReadBit(); } guidBytes[1] = packet.ReadBit(); guidBytes[6] = packet.ReadBit(); guidBytes[2] = packet.ReadBit(); guidBytes[5] = packet.ReadBit(); guidBytes[7] = packet.ReadBit(); guidBytes[0] = packet.ReadBit(); guidBytes[3] = packet.ReadBit(); packet.ReadXORByte(guidBytes, 3); npcVendor.VendorItems = new List <VendorItem>((int)itemCount); for (int i = 0; i < itemCount; ++i) { var vendorItem = new VendorItem(); //packet.ReadInt32("Max Durability", i); packet.ReadInt32("Unk1", i); vendorItem.Type = packet.ReadUInt32("Type", i); // 1 - item, 2 - currency var buyCount = packet.ReadUInt32("Buy Count", i); if (hasExtendedCost[i]) { vendorItem.ExtendedCostId = packet.ReadUInt32("Extended Cost", i); } packet.ReadInt32("Price", i); vendorItem.ItemId = (uint)packet.ReadEntryWithName <Int32>(StoreNameType.Item, "Item ID", i); vendorItem.Slot = packet.ReadUInt32("Item Position", i); packet.ReadInt32("LeftInStock", i); packet.ReadInt32("Unk2", i); packet.ReadInt32("Display ID", i); /*if (hasCondition[i]) * packet.ReadInt32("Condition ID", i); * var maxCount = packet.ReadInt32("Max Count", i); * vendorItem.MaxCount = maxCount == -1 ? 0 : maxCount; // TDB * * if (vendorItem.Type == 2) * vendorItem.MaxCount = (int)buyCount;*/ npcVendor.VendorItems.Add(vendorItem); } packet.ReadXORByte(guidBytes, 6); packet.ReadXORByte(guidBytes, 0); packet.ReadXORByte(guidBytes, 2); packet.ReadXORByte(guidBytes, 5); packet.ReadByte("rawItemCount"); packet.ReadXORByte(guidBytes, 1); packet.ReadXORByte(guidBytes, 4); packet.ReadXORByte(guidBytes, 7); var guid = new Guid(BitConverter.ToUInt64(guidBytes, 0)); packet.WriteLine("GUID: {0}", guid); Storage.NpcVendors.Add(guid.GetEntry(), npcVendor, packet.TimeSpan); }
private static void ProcessExistingObject(ref WoWObject obj, WoWObject newObj, Guid guid) { obj.PhaseMask |= newObj.PhaseMask; if (guid.GetHighType() == HighGuidType.Unit) // skip if not an unit { if (!obj.Movement.HasWpsOrRandMov) if (obj.Movement.Position != newObj.Movement.Position) { UpdateField uf; if (obj.UpdateFields.TryGetValue(UpdateFields.GetUpdateField(UnitField.UNIT_FIELD_FLAGS), out uf)) if ((uf.UInt32Value & (uint) UnitFlags.IsInCombat) == 0) // movement could be because of aggro so ignore that obj.Movement.HasWpsOrRandMov = true; } } }
public static void HandlePetSpells(Packet packet) { var guid64 = packet.ReadUInt64(); // Equal to "Clear spells" pre cataclysm if (guid64 == 0) return; var guid = new Guid(guid64); packet.WriteLine("GUID: " + guid); var isPet = guid.GetHighType() == HighGuidType.Pet; if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767)) packet.ReadEnum<CreatureFamily>("Pet Family", TypeCode.UInt16); // vehicles -> 0 packet.ReadUInt32("Unknown 1"); // Following int8,int8,int16 is sent like int32 /*var reactState = */ packet.ReadByte("React state"); // 1 /*var commandState = */ packet.ReadByte("Command state"); // 1 packet.ReadUInt16("Unknown 2"); // pets -> 0, vehicles -> 0x800 (2048) for (var i = 1; i <= (int)MiscConstants.CreatureMaxSpells + 2; i++) // Read pet/vehicle spell ids { var spell16 = packet.ReadUInt16(); var spell8 = packet.ReadByte(); var slotid = packet.ReadByte(); var spellId = spell16 + (spell8 << 16); if (!isPet) // cleanup vehicle spells (start at 1 instead 8, { // and do not print spells with id 0) slotid -= (int)MiscConstants.PetSpellsOffset - 1; if (spellId == 0) continue; } packet.WriteLine("Spell " + slotid + ": " + StoreGetters.GetName(StoreNameType.Spell, spellId)); } var spellCount = packet.ReadByte(); // vehicles -> 0, pets -> != 0. Could this be auras? packet.WriteLine("Spell count: " + spellCount); for (var i = 0; i < spellCount; i++) { // Sent as int32 var spellId = packet.ReadUInt16(); var active = packet.ReadInt16(); packet.WriteLine("Spell " + i + ": " + StoreGetters.GetName(StoreNameType.Spell, spellId) + ", active: " + active); } var cdCount = packet.ReadByte(); packet.WriteLine("Cooldown count: " + cdCount); for (var i = 0; i < cdCount; i++) { var spellId = ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767) ? packet.ReadInt32() : packet.ReadUInt16(); var category = packet.ReadUInt16(); var cooldown = packet.ReadUInt32(); var categoryCooldown = packet.ReadUInt32(); packet.WriteLine("Cooldown: Spell: " + StoreGetters.GetName(StoreNameType.Spell, spellId) + " category: " + category + " cooldown: " + cooldown + " category cooldown: " + categoryCooldown); } }
private static MovementInfo ReadMovementUpdateBlock(ref Packet packet, Guid guid, int index) { if (ClientVersion.Build == ClientVersionBuild.V5_1_0_16309 || ClientVersion.Build == ClientVersionBuild.V5_1_0a_16357) return ReadMovementUpdateBlock510(ref packet, guid, index); if (ClientVersion.Build == ClientVersionBuild.V5_0_4_16016 || ClientVersion.Build == ClientVersionBuild.V5_0_5_16048 || ClientVersion.Build == ClientVersionBuild.V5_0_5a_16057 || ClientVersion.Build == ClientVersionBuild.V5_0_5b_16135) return ReadMovementUpdateBlock504(ref packet, guid, index); if (ClientVersion.Build == ClientVersionBuild.V4_3_4_15595) return ReadMovementUpdateBlock434(ref packet, guid, index); if (ClientVersion.Build == ClientVersionBuild.V4_3_3_15354) return ReadMovementUpdateBlock433(ref packet, guid, index); if (ClientVersion.Build == ClientVersionBuild.V4_3_2_15211) return ReadMovementUpdateBlock432(ref packet, guid, index); if (ClientVersion.Build == ClientVersionBuild.V4_3_0_15005 || ClientVersion.Build == ClientVersionBuild.V4_3_0a_15050) return ReadMovementUpdateBlock430(ref packet, guid, index); var moveInfo = new MovementInfo(); var flagsTypeCode = ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767) ? TypeCode.UInt16 : TypeCode.Byte; var flags = packet.ReadEnum<UpdateFlag>("[" + index + "] Update Flags", flagsTypeCode); if (flags.HasAnyFlag(UpdateFlag.Living)) { moveInfo = MovementHandler.ReadMovementInfo(ref packet, guid, index); var moveFlags = moveInfo.Flags; for (var i = 0; i < 9; ++i) { var speedType = (SpeedType)i; var speed = packet.ReadSingle(speedType + " Speed", index); switch (speedType) { case SpeedType.Walk: { moveInfo.WalkSpeed = speed / 2.5f; break; } case SpeedType.Run: { moveInfo.RunSpeed = speed / 7.0f; break; } } } // Movement flags seem incorrect for 4.2.2 // guess in which version they stopped checking movement flag and used bits if ((ClientVersion.RemovedInVersion(ClientVersionBuild.V4_2_0_14333) && moveFlags.HasAnyFlag(MovementFlag.SplineEnabled)) || moveInfo.HasSplineData) { // Temp solution // TODO: Make Enums version friendly if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_2_0_14333)) { var splineFlags422 = packet.ReadEnum<SplineFlag422>("Spline Flags", TypeCode.Int32, index); if (splineFlags422.HasAnyFlag(SplineFlag422.FinalOrientation)) { packet.ReadSingle("Final Spline Orientation", index); } else { if (splineFlags422.HasAnyFlag(SplineFlag422.FinalTarget)) packet.ReadGuid("Final Spline Target GUID", index); else if (splineFlags422.HasAnyFlag(SplineFlag422.FinalPoint)) packet.ReadVector3("Final Spline Coords", index); } } else { var splineFlags = packet.ReadEnum<SplineFlag>("Spline Flags", TypeCode.Int32, index); if (splineFlags.HasAnyFlag(SplineFlag.FinalTarget)) packet.ReadGuid("Final Spline Target GUID", index); else if (splineFlags.HasAnyFlag(SplineFlag.FinalOrientation)) packet.ReadSingle("Final Spline Orientation", index); else if (splineFlags.HasAnyFlag(SplineFlag.FinalPoint)) packet.ReadVector3("Final Spline Coords", index); } packet.ReadInt32("Spline Time", index); packet.ReadInt32("Spline Full Time", index); packet.ReadInt32("Spline ID", index); if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767)) { packet.ReadSingle("Spline Duration Multiplier", index); packet.ReadSingle("Spline Duration Multiplier Next", index); packet.ReadSingle("Spline Vertical Acceleration", index); packet.ReadInt32("Spline Start Time", index); } var splineCount = packet.ReadInt32(); for (var i = 0; i < splineCount; i++) packet.ReadVector3("Spline Waypoint", index, i); if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767)) packet.ReadEnum<SplineMode>("Spline Mode", TypeCode.Byte, index); packet.ReadVector3("Spline Endpoint", index); } } else // !UpdateFlag.Living { if (flags.HasAnyFlag(UpdateFlag.GOPosition)) { moveInfo.TransportGuid = packet.ReadPackedGuid("GO Position GUID", index); moveInfo.Position = packet.ReadVector3("[" + index + "] GO Position"); packet.ReadVector3("GO Transport Position", index); moveInfo.Orientation = packet.ReadSingle("[" + index + "] GO Orientation"); packet.ReadSingle("Corpse Orientation", index); } else if (flags.HasAnyFlag(UpdateFlag.StationaryObject)) { moveInfo.Position = packet.ReadVector3(); moveInfo.Orientation = packet.ReadSingle(); packet.WriteLine("[{0}] Stationary Position: {1}, O: {2}", index, moveInfo.Position, moveInfo.Orientation); } } if (ClientVersion.RemovedInVersion(ClientVersionBuild.V4_2_2_14545)) { if (flags.HasAnyFlag(UpdateFlag.Unknown1)) packet.ReadUInt32("Unk Int32", index); if (flags.HasAnyFlag(UpdateFlag.LowGuid)) packet.ReadUInt32("Low GUID", index); } if (flags.HasAnyFlag(UpdateFlag.AttackingTarget)) packet.ReadPackedGuid("Target GUID", index); if (flags.HasAnyFlag(UpdateFlag.Transport)) packet.ReadUInt32("Transport unk timer", index); if (flags.HasAnyFlag(UpdateFlag.Vehicle)) { moveInfo.VehicleId = packet.ReadUInt32("[" + index + "] Vehicle ID"); packet.ReadSingle("Vehicle Orientation", index); } if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_2_2_14545)) { if (flags.HasAnyFlag(UpdateFlag.AnimKits)) { packet.ReadInt16("Unk Int16", index); packet.ReadInt16("Unk Int16", index); packet.ReadInt16("Unk Int16", index); } } if (flags.HasAnyFlag(UpdateFlag.GORotation)) moveInfo.Rotation = packet.ReadPackedQuaternion("GO Rotation", index); if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_2_2_14545)) { if (flags.HasAnyFlag(UpdateFlag.TransportUnkArray)) { var count = packet.ReadByte("Count", index); for (var i = 0; i < count; i++) packet.ReadInt32("Unk Int32", index, count); } } return moveInfo; }
public static void HandleMovementMessages(Packet packet) { Guid guid; if ((ClientVersion.AddedInVersion(ClientVersionBuild.V3_2_0_10192) || packet.Direction == Direction.ServerToClient) && ClientVersion.Build != ClientVersionBuild.V4_2_2_14545) guid = packet.ReadPackedGuid("GUID"); else guid = new Guid(); ReadMovementInfo(ref packet, guid); if (packet.Opcode != Opcodes.GetOpcode(Opcode.MSG_MOVE_KNOCK_BACK)) return; packet.ReadSingle("Sin Angle"); packet.ReadSingle("Cos Angle"); packet.ReadSingle("Speed"); packet.ReadSingle("Velocity"); }
private static MovementInfo ReadMovementUpdateBlock504(ref Packet packet, Guid guid, int index) { var moveInfo = new MovementInfo(); // bits var hasAttackingTarget = packet.ReadBit("Has Attacking Target", index); var hasVehicleData = packet.ReadBit("Has Vehicle Data", index); var unkLoopCounter = packet.ReadBits(24); var bit284 = packet.ReadBit(); var hasGameObjectPosition = packet.ReadBit("Has GameObject Position", index); var hasStationaryPosition = packet.ReadBit("Has Stationary Position", index); var bits16C = packet.ReadBits(21); var transport = packet.ReadBit("Transport", index); var bit208 = packet.ReadBit(); var bit28C = packet.ReadBit(); var living = packet.ReadBit("Living", index); /*var bit1 =*/ packet.ReadBit(); var bit28D = packet.ReadBit(); /*var bit2 =*/ packet.ReadBit(); var hasGameObjectRotation = packet.ReadBit("Has GameObject Rotation", index); var hasAnimKits = packet.ReadBit("Has AnimKits", index); /*var bit3 =*/ packet.ReadBit(); packet.ReadBit("Self", index); for (var i = 0; i < bits16C; ++i) packet.ReadBits(2); var hasOrientation = false; var guid2 = new byte[8]; var hasPitch = false; var hasFallData = false; var hasSplineElevation = false; var hasTransportData = false; var hasTimestamp = false; var transportGuid = new byte[8]; var hasTransportTime2 = false; var hasTransportTime3 = false; var hasFullSpline = false; var hasSplineStartTime = false; var splineCount = 0u; var splineType = SplineType.Stop; var facingTargetGuid = new byte[8]; var hasSplineVerticalAcceleration = false; var hasFallDirection = false; var goTransportGuid = new byte[8]; var hasGOTransportTime2 = false; var hasGOTransportTime3 = false; var attackingTargetGuid = new byte[8]; var hasAnimKit1 = false; var hasAnimKit2 = false; var hasAnimKit3 = false; var bit228 = false; var bit21C = false; var bit278 = 0u; var bit244 = false; var bit24C = 0u; var bit25C = 0u; var field9C = 0u; var hasFieldA8 = false; var unkSplineCounter = 0u; if (hasGameObjectPosition) { goTransportGuid[4] = packet.ReadBit(); goTransportGuid[3] = packet.ReadBit(); goTransportGuid[6] = packet.ReadBit(); goTransportGuid[0] = packet.ReadBit(); goTransportGuid[5] = packet.ReadBit(); goTransportGuid[1] = packet.ReadBit(); hasGOTransportTime2 = packet.ReadBit(); hasGOTransportTime3 = packet.ReadBit(); goTransportGuid[2] = packet.ReadBit(); goTransportGuid[7] = packet.ReadBit(); } if (bit208) { bit228 = packet.ReadBit(); var bit270 = packet.ReadBit(); packet.ReadBit(); // bit219 packet.ReadBit(); // bit21A bit21C = packet.ReadBit(); if (bit270) bit278 = packet.ReadBits(22); bit244 = packet.ReadBit(); if (bit244) { bit24C = packet.ReadBits(23); bit25C = packet.ReadBits(23); } packet.ReadBit(); // bit218 } if (living) { guid2[3] = packet.ReadBit(); moveInfo.HasSplineData = packet.ReadBit("Has Spline Data", index); field9C = packet.ReadBits(24); guid2[4] = packet.ReadBit(); hasPitch = !packet.ReadBit("Lacks Pitch", index); hasTransportData = packet.ReadBit("Has Transport Data", index); hasFallData = packet.ReadBit("Has Fall Data", index); hasTimestamp = !packet.ReadBit("Lacks Timestamp", index); if (hasTransportData) { transportGuid[3] = packet.ReadBit(); hasTransportTime3 = packet.ReadBit(); transportGuid[7] = packet.ReadBit(); transportGuid[0] = packet.ReadBit(); transportGuid[6] = packet.ReadBit(); hasTransportTime2 = packet.ReadBit(); transportGuid[4] = packet.ReadBit(); transportGuid[1] = packet.ReadBit(); transportGuid[2] = packet.ReadBit(); transportGuid[5] = packet.ReadBit(); } hasFieldA8 = !packet.ReadBit(); guid2[7] = packet.ReadBit(); var hasMoveFlagsExtra = !packet.ReadBit(); guid2[0] = packet.ReadBit(); packet.ReadBit(); guid2[5] = packet.ReadBit(); if (hasMoveFlagsExtra) moveInfo.FlagsExtra = packet.ReadEnum<MovementFlagExtra>("Extra Movement Flags", 13, index); guid2[2] = packet.ReadBit(); guid2[6] = packet.ReadBit(); var hasMovementFlags = !packet.ReadBit(); if (hasFallData) hasFallDirection = packet.ReadBit("Has Fall Direction", index); if (hasMovementFlags) moveInfo.Flags = packet.ReadEnum<MovementFlag>("Movement Flags", 30, index); hasOrientation = !packet.ReadBit(); packet.ReadBit(); packet.ReadBit(); if (moveInfo.HasSplineData) { hasFullSpline = packet.ReadBit("Has extended spline data", index); if (hasFullSpline) { hasSplineVerticalAcceleration = packet.ReadBit(); /*var splineMode =*/ packet.ReadEnum<SplineMode>("Spline Mode", 2, index); var bit134 = packet.ReadBit(); if (bit134) { unkSplineCounter = packet.ReadBits(23); packet.ReadBits(2); } /*splineFlags =*/ packet.WriteLine("[{0}] Spline flags 0x{1}", index, packet.ReadBits(25).ToString("X8")); hasSplineStartTime = packet.ReadBit(); splineCount = packet.ReadBits("Spline Waypoints", 22, index); var bits57 = packet.ReadBits(2); switch (bits57) { case 0: splineType = SplineType.FacingTarget; break; case 1: splineType = SplineType.FacingSpot; break; case 2: splineType = SplineType.Normal; break; case 3: splineType = SplineType.FacingAngle; break; } if (splineType == SplineType.FacingTarget) facingTargetGuid = packet.StartBitStream(4, 5, 0, 7, 1, 3, 2, 6); packet.WriteLine("[{0}] Spline type: {1}", index, splineType); } } guid2[1] = packet.ReadBit(); hasSplineElevation = !packet.ReadBit(); } if (hasAttackingTarget) attackingTargetGuid = packet.StartBitStream(2, 6, 5, 1, 7, 3, 4, 0); if (hasAnimKits) { hasAnimKit2 = !packet.ReadBit(); hasAnimKit3 = !packet.ReadBit(); hasAnimKit1 = !packet.ReadBit(); } if (bit28D) packet.ReadBits(9); packet.ResetBitReader(); // Reading data for (var i = 0; i < bits16C; ++i) { packet.ReadUInt32(); packet.ReadSingle(); packet.ReadSingle(); packet.ReadUInt32(); packet.ReadSingle(); packet.ReadSingle(); } for (var i = 0u; i < unkLoopCounter; ++i) packet.ReadUInt32("Unk UInt32", index, (int)i); if (living) { if (moveInfo.HasSplineData) { if (hasFullSpline) { if (splineType == SplineType.FacingSpot) { var point = new Vector3 { X = packet.ReadSingle(), Z = packet.ReadSingle(), Y = packet.ReadSingle(), }; packet.WriteLine("[{0}] Facing Spot: {1}", index, point); } else if (splineType == SplineType.FacingTarget) { packet.ParseBitStream(facingTargetGuid, 5, 6, 0, 1, 2, 4, 7, 3); packet.WriteGuid("Facing Target GUID", facingTargetGuid, index); } packet.ReadUInt32("Spline Time", index); if (hasSplineVerticalAcceleration) packet.ReadSingle("Spline Vertical Acceleration", index); if (hasSplineStartTime) packet.ReadUInt32("Spline Start time", index); for (var i = 0; i < unkSplineCounter; ++i) { packet.ReadSingle(); packet.ReadSingle(); } if (splineType == SplineType.FacingAngle) packet.ReadSingle("Facing Angle", index); for (var i = 0u; i < splineCount; ++i) { var wp = new Vector3 { X = packet.ReadSingle(), Y = packet.ReadSingle(), Z = packet.ReadSingle(), }; packet.WriteLine("[{0}][{1}] Spline Waypoint: {2}", index, i, wp); } packet.ReadSingle("Spline Duration Multiplier", index); packet.ReadUInt32("Spline Full Time", index); packet.ReadSingle("Spline Duration Multiplier Next", index); } var endPoint = new Vector3(); endPoint.Z = packet.ReadSingle(); packet.ReadUInt32("Spline Id", index); endPoint.X = packet.ReadSingle(); endPoint.Y = packet.ReadSingle(); packet.WriteLine("[{0}] Spline Endpoint: {1}", index, endPoint); } for (var i = 0; i < field9C; ++i) packet.ReadUInt32(); moveInfo.WalkSpeed = packet.ReadSingle("Walk Speed", index) / 2.5f; if (hasTransportData) { packet.ReadXORByte(transportGuid, 4); packet.ReadXORByte(transportGuid, 0); moveInfo.TransportOffset.Y = packet.ReadSingle(); moveInfo.TransportOffset.X = packet.ReadSingle(); packet.ReadSByte("Transport Seat", index); packet.ReadXORByte(transportGuid, 7); packet.ReadXORByte(transportGuid, 3); if (hasTransportTime3) packet.ReadUInt32("Transport Time 3", index); packet.ReadXORByte(transportGuid, 6); moveInfo.TransportOffset.O = packet.ReadSingle(); packet.ReadUInt32("Transport Time", index); packet.ReadXORByte(transportGuid, 2); packet.ReadXORByte(transportGuid, 1); moveInfo.TransportOffset.Z = packet.ReadSingle(); packet.ReadXORByte(transportGuid, 5); if (hasTransportTime2) packet.ReadUInt32("Transport Time 2", index); moveInfo.TransportGuid = new Guid(BitConverter.ToUInt64(transportGuid, 0)); packet.WriteLine("[{0}] Transport GUID {1}", index, moveInfo.TransportGuid); packet.WriteLine("[{0}] Transport Position: {1}", index, moveInfo.TransportOffset); } packet.ReadXORByte(guid2, 2); if (hasFallData) { packet.ReadInt32("Time Fallen", index); if (hasFallDirection) { packet.ReadSingle("Jump Sin", index); packet.ReadSingle("Jump Cos", index); packet.ReadSingle("Jump Velocity", index); } packet.ReadSingle("Fall Start Velocity", index); } packet.ReadXORByte(guid2, 7); if (hasTimestamp) packet.ReadUInt32("Time", index); packet.ReadSingle("Fly Speed", index); moveInfo.Position.X = packet.ReadSingle(); if (hasFieldA8) packet.ReadUInt32(); moveInfo.Position.Y = packet.ReadSingle(); packet.ReadXORByte(guid2, 5); moveInfo.Position.Z = packet.ReadSingle(); if (hasPitch) packet.ReadSingle("Pitch", index); packet.ReadXORByte(guid2, 3); packet.ReadXORByte(guid2, 6); packet.ReadXORByte(guid2, 1); if (hasSplineElevation) packet.ReadSingle("Spline Elevation", index); packet.ReadSingle("Turn Speed", index); packet.ReadSingle("Pitch Speed", index); moveInfo.RunSpeed = packet.ReadSingle("Run Speed", index) / 7.0f; if (hasOrientation) moveInfo.Orientation = packet.ReadSingle(); packet.ReadXORByte(guid2, 4); packet.ReadSingle("Swim Speed", index); packet.ReadSingle("SwimBack Speed", index); packet.ReadSingle("FlyBack Speed", index); packet.ReadSingle("RunBack Speed", index); packet.ReadXORByte(guid2, 0); packet.WriteLine("[{0}] GUID 2: {1}", index, new Guid(BitConverter.ToUInt64(guid2, 0))); packet.WriteLine("[{0}] Position: {1}", index, moveInfo.Position); packet.WriteLine("[{0}] Orientation: {1}", index, moveInfo.Orientation); } if (bit208) { if (bit228) { packet.ReadSingle(); packet.ReadSingle(); packet.ReadSingle(); packet.ReadSingle(); packet.ReadSingle(); packet.ReadSingle(); } if (bit21C) { packet.ReadSingle(); packet.ReadSingle(); } if (bit244) { for (var i = 0; i < bit24C; ++i) { packet.ReadSingle(); packet.ReadSingle(); } packet.ReadSingle(); for (var i = 0; i < bit25C; ++i) { packet.ReadSingle(); packet.ReadSingle(); } packet.ReadSingle(); } packet.ReadUInt32(); for (var i = 0; i < bit278; ++i) { packet.ReadSingle(); packet.ReadSingle(); packet.ReadSingle(); } packet.ReadSingle(); packet.ReadSingle(); } if (hasGameObjectPosition) { packet.ReadXORByte(goTransportGuid, 7); packet.ReadXORByte(goTransportGuid, 3); packet.ReadXORByte(goTransportGuid, 5); moveInfo.TransportOffset.O = packet.ReadSingle(); packet.ReadXORByte(goTransportGuid, 6); packet.ReadXORByte(goTransportGuid, 0); packet.ReadXORByte(goTransportGuid, 2); packet.ReadUInt32("GO Transport Time", index); if (hasGOTransportTime3) packet.ReadUInt32("GO Transport Time 3", index); packet.ReadXORByte(goTransportGuid, 1); moveInfo.TransportOffset.Z = packet.ReadSingle(); packet.ReadSByte("GO Transport Seat", index); if (hasGOTransportTime2) packet.ReadUInt32("GO Transport Time 2", index); moveInfo.TransportOffset.X = packet.ReadSingle(); packet.ReadXORByte(goTransportGuid, 4); moveInfo.TransportOffset.Y = packet.ReadSingle(); moveInfo.TransportGuid = new Guid(BitConverter.ToUInt64(goTransportGuid, 0)); packet.WriteLine("[{0}] GO Transport GUID {1}", index, moveInfo.TransportGuid); packet.WriteLine("[{0}] GO Transport Position: {1}", index, moveInfo.TransportOffset); } if (hasStationaryPosition) { moveInfo.Position.Y = packet.ReadSingle(); moveInfo.Position.Z = packet.ReadSingle(); moveInfo.Position.X = packet.ReadSingle(); packet.WriteLine("[{0}] Stationary Position: {1}", index, moveInfo.Position); moveInfo.Orientation = packet.ReadSingle("Stationary Orientation", index); } if (hasAttackingTarget) { packet.ParseBitStream(attackingTargetGuid, 3, 6, 4, 1, 5, 7, 0, 2); packet.WriteGuid("Attacking Target GUID", attackingTargetGuid, index); } if (transport) packet.ReadUInt32("Transport path timer", index); if (hasGameObjectRotation) packet.ReadPackedQuaternion("GameObject Rotation", index); if (hasVehicleData) { moveInfo.VehicleId = packet.ReadUInt32("Vehicle Id", index); packet.ReadSingle("Vehicle Orientation", index); } if (hasAnimKits) { if (hasAnimKit2) packet.ReadUInt16("Anim Kit 2", index); if (hasAnimKit3) packet.ReadUInt16("Anim Kit 3", index); if (hasAnimKit1) packet.ReadUInt16("Anim Kit 1", index); } if (bit284) packet.ReadUInt32(); return moveInfo; }
private static MovementInfo ReadMovementInfoGen(ref Packet packet, Guid guid, int index) { var info = new MovementInfo(); info.Flags = packet.ReadEnum<MovementFlag>("Movement Flags", TypeCode.Int32, index); var flagsTypeCode = ClientVersion.AddedInVersion(ClientVersionBuild.V3_0_2_9056) ? TypeCode.Int16 : TypeCode.Byte; info.FlagsExtra = packet.ReadEnum<MovementFlagExtra>("Extra Movement Flags", flagsTypeCode, index); if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_2_2_14545)) if (packet.ReadGuid("GUID 2", index) != guid) throw new InvalidDataException("Guids are not equal."); packet.ReadInt32("Time", index); info.Position = packet.ReadVector3("Position", index); info.Orientation = packet.ReadSingle("Orientation", index); if (info.Flags.HasAnyFlag(MovementFlag.OnTransport)) { if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767)) info.TransportGuid = packet.ReadPackedGuid("Transport GUID", index); else info.TransportGuid = packet.ReadGuid("Transport GUID", index); info.TransportOffset = packet.ReadVector4("Transport Position", index); packet.ReadInt32("Transport Time", index); if (ClientVersion.AddedInVersion(ClientType.WrathOfTheLichKing)) packet.ReadByte("Transport Seat", index); if (info.FlagsExtra.HasAnyFlag(MovementFlagExtra.InterpolateMove)) packet.ReadInt32("Transport Time", index); } if (info.Flags.HasAnyFlag(MovementFlag.Swimming | MovementFlag.Flying) || info.FlagsExtra.HasAnyFlag(MovementFlagExtra.AlwaysAllowPitching)) packet.ReadSingle("Swim Pitch", index); if (ClientVersion.AddedInVersion(ClientType.Cataclysm)) { if (info.FlagsExtra.HasAnyFlag(MovementFlagExtra.InterpolateTurning)) { packet.ReadInt32("Fall Time", index); packet.ReadSingle("Fall Velocity", index); if (info.Flags.HasAnyFlag(MovementFlag.Falling)) { packet.ReadSingle("Fall Sin Angle", index); packet.ReadSingle("Fall Cos Angle", index); packet.ReadSingle("Fall Speed", index); } } } else { packet.ReadInt32("Fall Time", index); if (info.Flags.HasAnyFlag(MovementFlag.Falling)) { packet.ReadSingle("Fall Velocity", index); packet.ReadSingle("Fall Sin Angle", index); packet.ReadSingle("Fall Cos Angle", index); packet.ReadSingle("Fall Speed", index); } } if (info.Flags.HasAnyFlag(MovementFlag.SplineElevation)) packet.ReadSingle("Spline Elevation", index); return info; }
private static MovementInfo ReadMovementUpdateBlock510(ref Packet packet, Guid guid, int index) { var moveInfo = new MovementInfo(); var bit654 = packet.ReadBit("Has bit654", index); packet.ReadBit("Self", index); var hasGameObjectRotation = packet.ReadBit("Has GameObject Rotation", index); var hasAttackingTarget = packet.ReadBit("Has Attacking Target", index); /*var bit2 = */ packet.ReadBit(); var bit520 = packet.ReadBit("Has bit520", index); var unkLoopCounter = packet.ReadBits(24); var transport = packet.ReadBit("Transport", index); var hasGameObjectPosition = packet.ReadBit("Has GameObject Position", index); /*var bit653 = */ packet.ReadBit(); var bit784 = packet.ReadBit("Has bit784", index); /*var bit652 = */ packet.ReadBit(); /*var bit1 = */ packet.ReadBit(); var living = packet.ReadBit("Living", index); /*var bit3 = */ packet.ReadBit(); var bit644 = packet.ReadBit("Has bit644", index); var hasStationaryPosition = packet.ReadBit("Has Stationary Position", index); var hasVehicleData = packet.ReadBit("Has Vehicle Data", index); var bits360 = packet.ReadBits(21); var hasAnimKits = packet.ReadBit("Has AnimKits", index); for (var i = 0; i < bits360; ++i) packet.ReadBits(2); var guid2 = new byte[8]; var facingTargetGuid = new byte[8]; var unkSplineCounter = 0u; var attackingTargetGuid = new byte[8]; var transportGuid = new byte[8]; var goTransportGuid = new byte[8]; var hasFallData = false; var hasFallDirection = false; var hasTimestamp = false; var hasOrientation = false; var hasMoveFlagsExtra = false; var hasMovementFlags = false; var hasPitch = false; var hasSplineElevation = false; var hasTransportData = false; var hasTransportTime2 = false; var hasTransportTime3 = false; var hasFullSpline = false; var hasSplineVerticalAcceleration = false; var hasUnkSplineCounter = false; var hasSplineStartTime = false; var hasGOTransportTime3 = false; var hasGOTransportTime2 = false; var hasAnimKit1 = false; var hasAnimKit2 = false; var hasAnimKit3 = false; var splineType = SplineType.Stop; var unkLoopCounter2 = 0u; var splineCount = 0u; var field8 = false; var bit540 = false; var bit552 = false; var bit580 = false; var bit624 = false; var bit147 = 0u; var bit151 = 0u; var bit158 = 0u; var bit198 = 0u; if (living) { guid2[3] = packet.ReadBit(); hasFallData = packet.ReadBit("Has Fall Data", index); hasTimestamp = !packet.ReadBit("Lacks Timestamp", index); packet.ReadBit(); // bit172 guid2[2] = packet.ReadBit(); packet.ReadBit(); // bit149 hasPitch = !packet.ReadBit("Lacks Pitch", index); hasMoveFlagsExtra = !packet.ReadBit(); guid2[4] = packet.ReadBit(); guid2[5] = packet.ReadBit(); unkLoopCounter2 = packet.ReadBits(24); hasSplineElevation = !packet.ReadBit(); field8 = !packet.ReadBit(); packet.ReadBit(); // bit148 guid2[0] = packet.ReadBit(); guid2[6] = packet.ReadBit(); guid2[7] = packet.ReadBit(); hasTransportData = packet.ReadBit("Has Transport Data", index); hasOrientation = !packet.ReadBit(); if (hasTransportData) { transportGuid[3] = packet.ReadBit(); transportGuid[0] = packet.ReadBit(); transportGuid[4] = packet.ReadBit(); transportGuid[5] = packet.ReadBit(); transportGuid[2] = packet.ReadBit(); transportGuid[7] = packet.ReadBit(); transportGuid[1] = packet.ReadBit(); hasTransportTime2 = packet.ReadBit(); transportGuid[6] = packet.ReadBit(); hasTransportTime3 = packet.ReadBit(); } if (hasMoveFlagsExtra) moveInfo.FlagsExtra = packet.ReadEnum<MovementFlagExtra>("Extra Movement Flags", 13, index); hasMovementFlags = !packet.ReadBit(); guid2[1] = packet.ReadBit(); if (hasFallData) hasFallDirection = packet.ReadBit("Has Fall Direction", index); moveInfo.HasSplineData = packet.ReadBit("Has Spline Data", index); if (hasMovementFlags) moveInfo.Flags = packet.ReadEnum<MovementFlag>("Movement Flags", 30, index); if (moveInfo.HasSplineData) { hasFullSpline = packet.ReadBit("Has extended spline data", index); if (hasFullSpline) { hasSplineStartTime = packet.ReadBit(); splineCount = packet.ReadBits("Spline Waypoints", 22, index); /*var splineFlags = */ packet.ReadEnum<SplineFlag434>("Spline flags", 25, index); var bits57 = packet.ReadBits(2); switch (bits57) { case 1: splineType = SplineType.FacingTarget; break; case 0: splineType = SplineType.FacingAngle; break; case 2: splineType = SplineType.Normal; break; case 3: splineType = SplineType.FacingSpot; break; } if (splineType == SplineType.FacingTarget) facingTargetGuid = packet.StartBitStream(0, 1, 6, 5, 2, 3, 4, 7); hasUnkSplineCounter = packet.ReadBit(); if (hasUnkSplineCounter) { unkSplineCounter = packet.ReadBits(23); packet.ReadBits(2); } /*var splineMode = */ packet.ReadEnum<SplineMode>("Spline Mode", 2, index); hasSplineVerticalAcceleration = packet.ReadBit(); } } } if (hasGameObjectPosition) { hasGOTransportTime3 = packet.ReadBit(); goTransportGuid[3] = packet.ReadBit(); goTransportGuid[1] = packet.ReadBit(); goTransportGuid[4] = packet.ReadBit(); goTransportGuid[7] = packet.ReadBit(); goTransportGuid[2] = packet.ReadBit(); goTransportGuid[5] = packet.ReadBit(); goTransportGuid[0] = packet.ReadBit(); goTransportGuid[6] = packet.ReadBit(); hasGOTransportTime2 = packet.ReadBit(); } if (bit654) packet.ReadBits(9); if (bit520) { bit540 = packet.ReadBit("bit540", index); packet.ReadBit("bit536", index); bit552 = packet.ReadBit("bit552", index); packet.ReadBit("bit539", index); bit624 = packet.ReadBit("bit624", index); bit580 = packet.ReadBit("bit580", index); packet.ReadBit("bit537", index); if (bit580) { bit147 = packet.ReadBits(23); bit151 = packet.ReadBits(23); } if (bit624) bit158 = packet.ReadBits(22); packet.ReadBit("bit538", index); } if (hasAttackingTarget) attackingTargetGuid = packet.StartBitStream(2, 6, 7, 1, 0, 3, 4, 5); if (bit784) bit198 = packet.ReadBits(9); if (hasAnimKits) { hasAnimKit3 = !packet.ReadBit(); hasAnimKit1 = !packet.ReadBit(); hasAnimKit2 = !packet.ReadBit(); } packet.ResetBitReader(); // Reading data for (var i = 0; i < bits360; ++i) { packet.ReadSingle(); packet.ReadUInt32(); packet.ReadSingle(); packet.ReadUInt32(); packet.ReadSingle(); packet.ReadSingle(); } for (var i = 0u; i < unkLoopCounter; ++i) packet.ReadUInt32("Unk UInt32", index, (int)i); if (living) { packet.ReadSingle("Fly Speed", index); if (moveInfo.HasSplineData) { if (hasFullSpline) { if (hasUnkSplineCounter) { for (var i = 0; i < unkSplineCounter; ++i) { packet.ReadSingle("Unk Spline Float1", index, (int)i); packet.ReadSingle("Unk Spline Float2", index, (int)i); } } if (splineType == SplineType.FacingTarget) { packet.ParseBitStream(facingTargetGuid, 3, 2, 0, 5, 6, 7, 4, 1); packet.WriteGuid("Facing Target GUID", facingTargetGuid, index); } packet.ReadUInt32("Spline Time", index); packet.ReadUInt32("Spline Full Time", index); if (hasSplineVerticalAcceleration) packet.ReadSingle("Spline Vertical Acceleration", index); packet.ReadSingle("Spline Duration Multiplier Next", index); packet.ReadSingle("Spline Duration Multiplier", index); if (splineType == SplineType.FacingSpot) { var point = new Vector3 { X = packet.ReadSingle(), Z = packet.ReadSingle(), Y = packet.ReadSingle(), }; packet.WriteLine("[{0}] Facing Spot: {1}", index, point); } if (hasSplineStartTime) packet.ReadUInt32("Spline Start Time", index); for (var i = 0u; i < splineCount; ++i) { var wp = new Vector3 { Y = packet.ReadSingle(), Z = packet.ReadSingle(), X = packet.ReadSingle(), }; packet.WriteLine("[{0}][{1}] Spline Waypoint: {2}", index, i, wp); } if (splineType == SplineType.FacingAngle) packet.ReadSingle("Facing Angle", index); } var endPoint = new Vector3 { Y = packet.ReadSingle(), X = packet.ReadSingle(), Z = packet.ReadSingle(), }; packet.ReadUInt32("Spline Id", index); packet.WriteLine("[{0}] Spline Endpoint: {1}", index, endPoint); } packet.ReadSingle("Swim Speed", index); if (hasFallData) { if (hasFallDirection) { packet.ReadSingle("Jump Cos", index); packet.ReadSingle("Jump Velocity", index); packet.ReadSingle("Jump Sin", index); } packet.ReadSingle("Fall Start Velocity", index); packet.ReadInt32("Time Fallen", index); } if (hasTransportData) { moveInfo.TransportOffset.Z = packet.ReadSingle(); packet.ReadXORByte(transportGuid, 4); moveInfo.TransportOffset.X = packet.ReadSingle(); if (hasTransportTime3) packet.ReadUInt32("Transport Time 3", index); packet.ReadXORByte(transportGuid, 6); packet.ReadXORByte(transportGuid, 5); packet.ReadXORByte(transportGuid, 1); moveInfo.TransportOffset.O = packet.ReadSingle(); moveInfo.TransportOffset.X = packet.ReadSingle(); packet.ReadSByte("Transport Seat", index); packet.ReadXORByte(transportGuid, 7); if (hasTransportTime2) packet.ReadUInt32("Transport Time 2", index); packet.ReadUInt32("Transport Time", index); packet.ReadXORByte(transportGuid, 0); packet.ReadXORByte(transportGuid, 2); packet.ReadXORByte(transportGuid, 3); moveInfo.TransportGuid = new Guid(BitConverter.ToUInt64(transportGuid, 0)); packet.WriteLine("[{0}] Transport GUID {1}", index, moveInfo.TransportGuid); packet.WriteLine("[{0}] Transport Position: {1}", index, moveInfo.TransportOffset); } packet.ReadXORByte(guid2, 1); packet.ReadSingle("FlyBack Speed", index); moveInfo.Position.Y = packet.ReadSingle(); packet.ReadXORByte(guid2, 3); moveInfo.Position.Z = packet.ReadSingle(); if (hasOrientation) moveInfo.Orientation = packet.ReadSingle(); packet.ReadSingle("SwimBack Speed", index); if (hasSplineElevation) packet.ReadSingle("Spline Elevation", index); packet.ReadXORByte(guid2, 0); packet.ReadXORByte(guid2, 6); for (var i = 0u; i < unkLoopCounter2; ++i) packet.ReadUInt32("Unk2 UInt32", index, (int)i); moveInfo.Position.X = packet.ReadSingle(); if (hasTimestamp) packet.ReadUInt32("Time", index); moveInfo.WalkSpeed = packet.ReadSingle("Walk Speed", index) / 2.5f; if (hasPitch) packet.ReadSingle("Pitch", index); packet.ReadXORByte(guid2, 5); if (field8) packet.ReadUInt32("Unk UInt32", index); packet.ReadSingle("Pitch Speed", index); packet.ReadXORByte(guid2, 2); moveInfo.RunSpeed = packet.ReadSingle("Run Speed", index) / 7.0f; packet.ReadXORByte(guid2, 7); packet.ReadSingle("RunBack Speed", index); packet.ReadXORByte(guid2, 4); packet.ReadSingle("Turn Speed", index); packet.WriteLine("[{0}] GUID 2: {1}", index, new Guid(BitConverter.ToUInt64(guid2, 0))); packet.WriteLine("[{0}] Position: {1}", index, moveInfo.Position); packet.WriteLine("[{0}] Orientation: {1}", index, moveInfo.Orientation); } if (bit520) { if (bit580) { packet.ReadSingle("field154", index); packet.ReadSingle("field155", index); for (var i = 0; i < bit147; ++i) { packet.ReadSingle(); packet.ReadSingle(); } for (var i = 0; i < bit151; ++i) { packet.ReadSingle(); packet.ReadSingle(); } } if (bit540) { packet.ReadSingle("field136", index); packet.ReadSingle("field134", index); } if (bit552) { packet.ReadSingle("field143", index); packet.ReadSingle("field141", index); packet.ReadSingle("field142", index); packet.ReadSingle("field140", index); packet.ReadSingle("field139", index); packet.ReadSingle("field144", index); } packet.ReadSingle("field132", index); if (bit624) { for (var i = 0; i < bit158; ++i) { packet.ReadSingle(); packet.ReadSingle(); packet.ReadSingle(); } } packet.ReadSingle("field133", index); packet.ReadSingle("field131", index); } if (hasAttackingTarget) { packet.ParseBitStream(attackingTargetGuid, 3, 4, 2, 5, 1, 6, 7, 0); packet.WriteGuid("Attacking Target GUID", attackingTargetGuid, index); } if (hasStationaryPosition) { moveInfo.Position.X = packet.ReadSingle(); moveInfo.Orientation = packet.ReadSingle("Stationary Orientation", index); moveInfo.Position.Y = packet.ReadSingle(); moveInfo.Position.Z = packet.ReadSingle(); packet.WriteLine("[{0}] Stationary Position: {1}", index, moveInfo.Position); } if (hasGameObjectPosition) { packet.ReadXORByte(goTransportGuid, 3); packet.ReadXORByte(goTransportGuid, 1); packet.ReadSByte("GO Transport Seat", index); moveInfo.TransportOffset.Z = packet.ReadSingle(); packet.ReadXORByte(goTransportGuid, 2); packet.ReadXORByte(goTransportGuid, 7); if (hasGOTransportTime3) packet.ReadUInt32("GO Transport Time 3", index); packet.ReadXORByte(goTransportGuid, 6); if (hasGOTransportTime2) packet.ReadUInt32("GO Transport Time 2", index); packet.ReadUInt32("GO Transport Time", index); moveInfo.TransportOffset.Y = packet.ReadSingle(); moveInfo.TransportOffset.X = packet.ReadSingle(); packet.ReadXORByte(goTransportGuid, 0); packet.ReadXORByte(goTransportGuid, 4); packet.ReadXORByte(goTransportGuid, 5); moveInfo.TransportOffset.O = packet.ReadSingle(); moveInfo.TransportGuid = new Guid(BitConverter.ToUInt64(goTransportGuid, 0)); packet.WriteLine("[{0}] GO Transport GUID {1}", index, moveInfo.TransportGuid); packet.WriteLine("[{0}] GO Transport Position: {1}", index, moveInfo.TransportOffset); } if (hasAnimKits) { if (hasAnimKit3) packet.ReadUInt16("Anim Kit 3", index); if (hasAnimKit1) packet.ReadUInt16("Anim Kit 1", index); if (hasAnimKit2) packet.ReadUInt16("Anim Kit 2", index); } if (hasVehicleData) { packet.ReadSingle("Vehicle Orientation", index); moveInfo.VehicleId = packet.ReadUInt32("Vehicle Id", index); } if (transport) packet.ReadUInt32("Transport Path Timer", index); if (bit644) packet.ReadUInt32("field162", index); if (bit784) { for (var i = 0; i < bit198; ++i) packet.ReadUInt32(); } if (hasGameObjectRotation) packet.ReadPackedQuaternion("GameObject Rotation", index); return moveInfo; }
public static void HandleNpcGossip(Packet packet) { var guid = new byte[8]; uint[] titleLen; uint[] OptionTextLen; uint[] BoxTextLen; packet.StartBitStream(guid, 0, 1); var questgossips = packet.ReadBits("Amount of Quest gossips", 19); guid[2] = packet.ReadBit(); var AmountOfOptions = packet.ReadBits("Amount of Options", 20); titleLen = new uint[questgossips]; for (var i = 0; i < questgossips; ++i) { packet.ReadBit("Change Icon", i); titleLen[i] = packet.ReadBits(9); } guid[3] = packet.ReadBit(); OptionTextLen = new uint[AmountOfOptions]; BoxTextLen = new uint[AmountOfOptions]; for (var i = 0; i < AmountOfOptions; ++i) { BoxTextLen[i] = packet.ReadBits(12); OptionTextLen[i] = packet.ReadBits(12); } packet.StartBitStream(guid, 5, 4, 6, 7); packet.ResetBitReader(); packet.ReadXORByte(guid, 6); var gossip = new Gossip(); gossip.GossipOptions = new List <GossipOption>((int)AmountOfOptions); for (var i = 0; i < AmountOfOptions; ++i) { var gossipOption = new GossipOption { OptionText = packet.ReadWoWString("Text", OptionTextLen[i], i), BoxText = packet.ReadWoWString("Box Text", BoxTextLen[i], i), RequiredMoney = packet.ReadUInt32("Required money", i), OptionIcon = packet.ReadEnum <GossipOptionIcon>("Icon", TypeCode.Byte, i), Box = packet.ReadBoolean("Box", i), Index = packet.ReadUInt32("Index", i) }; gossip.GossipOptions.Add(gossipOption); } packet.ReadXORByte(guid, 0); for (var i = 0; i < questgossips; i++) { packet.ReadEnum <QuestFlags>("Flags", TypeCode.UInt32, i); packet.ReadWoWString("Title", titleLen[i], i); packet.ReadUInt32("Icon", i); packet.ReadEnum <QuestFlags2>("Flags 2", TypeCode.UInt32, i); packet.ReadInt32("Level", i); packet.ReadEntryWithName <UInt32>(StoreNameType.Quest, "Quest ID", i); } var textId = packet.ReadUInt32("Text Id"); packet.ReadXORBytes(guid, 4, 3); var menuId = packet.ReadUInt32("Menu Id"); packet.ReadUInt32("Friendship Faction"); packet.ReadXORBytes(guid, 7, 1, 5, 2); packet.WriteGuid("GUID", guid); var GUID = new Guid(BitConverter.ToUInt64(guid, 0)); gossip.ObjectType = GUID.GetObjectType(); gossip.ObjectEntry = GUID.GetEntry(); if (Storage.Gossips.ContainsKey(Tuple.Create(menuId, textId))) { var oldGossipOptions = Storage.Gossips[Tuple.Create(menuId, textId)]; if (oldGossipOptions != null) { foreach (var gossipOptions in gossip.GossipOptions) { oldGossipOptions.Item1.GossipOptions.Add(gossipOptions); } } } else { Storage.Gossips.Add(Tuple.Create(menuId, textId), gossip, packet.TimeSpan); } packet.AddSniffData(StoreNameType.Gossip, (int)menuId, GUID.GetEntry().ToString(CultureInfo.InvariantCulture)); }
private static MovementInfo ReadMovementUpdateBlock432(ref Packet packet, Guid guid, int index) { var moveInfo = new MovementInfo(); /*bool bit2 = */packet.ReadBit(); /*bool bit3 = */packet.ReadBit(); /*bool bit4 = */packet.ReadBit(); var hasStationaryPosition = packet.ReadBit("Has Stationary Position", index); var hasAnimKits = packet.ReadBit("Has AnimKits", index); var unkLoopCounter = packet.ReadBits(24); /*bool bit1 = */packet.ReadBit(); bool hasTransportExtra = packet.ReadBit("Has Transport Extra", index); bool hasGORotation = packet.ReadBit("Has GameObject Rotation", index); bool living = packet.ReadBit("Living", index); bool hasGameObjectPosition = packet.ReadBit("Has GameObject Position", index); bool hasVehicleData = packet.ReadBit("Has Vehicle Data", index); bool hasAttackingTarget = packet.ReadBit("Has Attacking Target", index); /*bool bit0 =*/packet.ReadBit(); bool unkFloats = packet.ReadBit(); bool unkFloat1 = false; bool hasFallData = false; bool unkFloat2 = false; bool bit216 = false; bool bit256 = false; bool hasSplineDurationMult = false; SplineType splineType = SplineType.Normal; var facingTarget = new byte[8]; uint splineCount = 0u; bool hasTransportData = false; var transportGuid = new byte[8]; bool hasTransportTime2 = false; bool hasTransportTime3 = false; bool hasFallDirection = false; bool hasUnkUInt = false; bool hasOrientation = false; var attackingTarget = new byte[8]; var goTransportGuid = new byte[8]; bool hasGOTransportTime2 = false; bool hasGOTransportTime3 = false; bool hasAnimKit1 = false; bool hasAnimKit2 = false; bool hasAnimKit3 = false; var guid2 = new byte[8]; if (living) { unkFloat1 = !packet.ReadBit(); hasOrientation = !packet.ReadBit(); bool hasExtraMovementFlags = !packet.ReadBit(); hasFallData = packet.ReadBit("Has Fall Data", index); guid2[0] = packet.ReadBit(); guid2[5] = packet.ReadBit(); guid2[4] = packet.ReadBit(); bool hasMovementFlags = !packet.ReadBit(); moveInfo.HasSplineData = packet.ReadBit("Has Spline Data", index); /*bool bit148 = */packet.ReadBit(); if (hasExtraMovementFlags) moveInfo.FlagsExtra = packet.ReadEnum<MovementFlagExtra>("Extra Movement Flags", 12, index); hasUnkUInt = !packet.ReadBit(); guid2[3] = packet.ReadBit(); /*bool bit149 = */packet.ReadBit(); if (hasMovementFlags) moveInfo.Flags = packet.ReadEnum<MovementFlag>("Movement Flags", 30, index); guid2[1] = packet.ReadBit(); unkFloat2 = !packet.ReadBit(); hasTransportData = packet.ReadBit("Has Transport Data", index); guid2[2] = packet.ReadBit(); if (hasTransportData) { transportGuid[3] = packet.ReadBit(); transportGuid[5] = packet.ReadBit(); transportGuid[1] = packet.ReadBit(); transportGuid[7] = packet.ReadBit(); hasTransportTime2 = packet.ReadBit(); transportGuid[4] = packet.ReadBit(); transportGuid[0] = packet.ReadBit(); transportGuid[2] = packet.ReadBit(); transportGuid[6] = packet.ReadBit(); hasTransportTime3 = packet.ReadBit(); } if (moveInfo.HasSplineData) { bit216 = packet.ReadBit(); if (bit216) { uint bits57 = packet.ReadBits(2); splineCount = packet.ReadBits(22); switch (bits57) { case 0: splineType = SplineType.FacingTarget; break; case 1: splineType = SplineType.FacingSpot; break; case 2: splineType = SplineType.Normal; break; case 3: splineType = SplineType.FacingAngle; break; } if (splineType == SplineType.FacingTarget) facingTarget = packet.StartBitStream(4, 3, 2, 5, 7, 1, 0, 6); packet.ReadEnum<SplineFlag422>("Spline flags", 25, index); /*splineMode =*/packet.ReadBits(2); hasSplineDurationMult = packet.ReadBit("HasSplineDurationMult", index); bit256 = packet.ReadBit(); } } if (hasFallData) hasFallDirection = packet.ReadBit("Has Fall Direction", index); guid2[6] = packet.ReadBit(); guid2[7] = packet.ReadBit(); } if (hasGameObjectPosition) { goTransportGuid[5] = packet.ReadBit(); goTransportGuid[4] = packet.ReadBit(); hasGOTransportTime3 = packet.ReadBit(); goTransportGuid[7] = packet.ReadBit(); goTransportGuid[6] = packet.ReadBit(); goTransportGuid[1] = packet.ReadBit(); goTransportGuid[2] = packet.ReadBit(); hasGOTransportTime2 = packet.ReadBit(); goTransportGuid[0] = packet.ReadBit(); goTransportGuid[3] = packet.ReadBit(); } if (hasAnimKits) { hasAnimKit1 = !packet.ReadBit(); hasAnimKit3 = !packet.ReadBit(); hasAnimKit2 = !packet.ReadBit(); } if (hasAttackingTarget) attackingTarget = packet.StartBitStream(4, 3, 2, 5, 0, 6, 1, 7); for (var i = 0; i < unkLoopCounter; ++i) { packet.ReadInt32(); } if (hasGameObjectPosition) { if (hasGOTransportTime3) packet.ReadInt32("GO Transport Time 3", index); packet.ReadXORByte(goTransportGuid, 7); moveInfo.TransportOffset.Y = packet.ReadSingle(); packet.ReadByte("GO Transport Seat", index); moveInfo.TransportOffset.O = packet.ReadSingle(); moveInfo.TransportOffset.Z = packet.ReadSingle(); packet.ReadXORByte(goTransportGuid, 4); packet.ReadXORByte(goTransportGuid, 5); packet.ReadXORByte(goTransportGuid, 6); moveInfo.TransportOffset.X = packet.ReadSingle(); packet.ReadInt32("GO Transport Time", index); packet.ReadXORByte(goTransportGuid, 1); if (hasGOTransportTime2) packet.ReadInt32("GO Transport Time 2", index); packet.ReadXORByte(goTransportGuid, 0); packet.ReadXORByte(goTransportGuid, 2); packet.ReadXORByte(goTransportGuid, 3); moveInfo.TransportGuid = new Guid(BitConverter.ToUInt64(goTransportGuid, 0)); packet.WriteLine("[{0}] GO Transport Position: {1}", index, moveInfo.TransportOffset); packet.WriteLine("[{0}] GO Transport GUID {1}", index, moveInfo.TransportGuid); } if (living) { if (moveInfo.HasSplineData) { if (bit216) { packet.ReadSingle("Unknown Spline Float 2", index); for (var i = 0u; i < splineCount; ++i) { var wp = new Vector3 { Y = packet.ReadSingle(), Z = packet.ReadSingle(), X = packet.ReadSingle(), }; packet.WriteLine("[{0}][{1}] Spline Waypoint: {2}", index, i, wp); } if (splineType == SplineType.FacingTarget) { packet.ParseBitStream(facingTarget, 2, 1, 3, 7, 0, 5, 4, 6); packet.WriteGuid("Facing Target GUID", facingTarget, index); } else if (splineType == SplineType.FacingSpot) { var point = new Vector3 { Y = packet.ReadSingle(), Z = packet.ReadSingle(), X = packet.ReadSingle(), }; packet.WriteLine("[{0}] Facing Spot: {1}", index, point); } if (hasSplineDurationMult) packet.ReadSingle("Spline Duration Modifier", index); if (bit256) packet.ReadUInt32("Unknown Spline Int32 1", index); packet.ReadUInt32("Unknown Spline Int32 2", index); packet.ReadSingle("Unknown Spline Float 1", index); if (splineType == SplineType.FacingAngle) packet.ReadSingle("Facing Angle", index); packet.ReadUInt32("Unknown Spline Int32 3", index); } packet.ReadUInt32("Spline Full Time", index); var endPoint = new Vector3 { Z = packet.ReadSingle(), Y = packet.ReadSingle(), X = packet.ReadSingle(), }; packet.WriteLine("[{0}] Spline Endpoint: {1}", index, endPoint); } if (hasTransportData) { packet.ReadXORByte(transportGuid, 6); if (hasTransportTime2) packet.ReadInt32("Transport Time 2", index); packet.ReadByte("Transport Seat", index); moveInfo.TransportOffset.O = packet.ReadSingle(); packet.ReadXORByte(transportGuid, 7); moveInfo.TransportOffset.Y = packet.ReadSingle(); packet.ReadXORByte(transportGuid, 3); if (hasTransportTime3) packet.ReadInt32("Transport Time 3", index); packet.ReadInt32("Transport Time", index); packet.ReadXORByte(transportGuid, 0); packet.ReadXORByte(transportGuid, 1); moveInfo.TransportOffset.X = packet.ReadSingle(); packet.ReadXORByte(transportGuid, 4); moveInfo.TransportOffset.Z = packet.ReadSingle(); packet.ReadXORByte(transportGuid, 5); packet.ReadXORByte(transportGuid, 2); moveInfo.TransportGuid = new Guid(BitConverter.ToUInt64(transportGuid, 0)); packet.WriteLine("[{0}] Transport GUID: {1}", index, moveInfo.TransportGuid); packet.WriteLine("[{0}] Transport Position: {1}", index, moveInfo.TransportOffset); } moveInfo.Position = new Vector3(); moveInfo.Position.Z = packet.ReadSingle(); packet.ReadSingle("FlyBack Speed", index); moveInfo.Position.Y = packet.ReadSingle(); packet.ReadXORByte(guid2, 4); packet.ReadXORByte(guid2, 0); moveInfo.Position.X = packet.ReadSingle(); if (hasFallData) { packet.ReadInt32("Time Fallen", index); if (hasFallDirection) { packet.ReadSingle("Jump Sin", index); packet.ReadSingle("Jump Velocity", index); packet.ReadSingle("Jump Cos", index); } packet.ReadSingle("Fall Start Velocity", index); } if (hasOrientation) moveInfo.Orientation = packet.ReadSingle(); packet.WriteLine("[{0}] Position: {1} Orientation: {2}", index, moveInfo.Position, moveInfo.Orientation); packet.ReadSingle("Swim Speed", index); moveInfo.RunSpeed = packet.ReadSingle("Run Speed", index) / 7.0f; packet.ReadSingle("Fly Speed", index); packet.ReadXORByte(guid2, 2); if (unkFloat2) packet.ReadSingle("Unk float +36", index); if (unkFloat1) packet.ReadSingle("Unk float +28", index); packet.ReadXORByte(guid2, 3); packet.ReadSingle("RunBack Speed", index); packet.ReadXORByte(guid2, 6); packet.ReadSingle("Pitch Speed", index); packet.ReadXORByte(guid2, 7); packet.ReadXORByte(guid2, 5); packet.ReadSingle("Turn Speed", index); packet.ReadSingle("SwimBack Speed", index); packet.ReadXORByte(guid2, 1); packet.WriteLine("[{0}] GUID 2 {1}", index, new Guid(BitConverter.ToUInt64(guid2, 0))); if (hasUnkUInt) packet.ReadInt32(); moveInfo.WalkSpeed = packet.ReadSingle("Walk Speed", index) / 2.5f; } if (hasAttackingTarget) { packet.ParseBitStream(attackingTarget, 6, 5, 3, 2, 0, 1, 7, 4); packet.WriteGuid("Attacking Target GUID", attackingTarget, index); } if (unkFloats) { int i; for (i = 0; i < 13; ++i) packet.ReadSingle("Unk float 456", index, i); packet.ReadByte("Unk byte 456", index); for (; i < 16; ++i) packet.ReadSingle("Unk float 456", index, i); } if (hasVehicleData) { packet.ReadSingle("Vehicle Orientation", index); moveInfo.VehicleId = packet.ReadUInt32("Vehicle Id", index); } if (hasGORotation) moveInfo.Rotation = packet.ReadPackedQuaternion("GO Rotation", index); if (hasStationaryPosition) { moveInfo.Position = new Vector3 { X = packet.ReadSingle(), Z = packet.ReadSingle(), Y = packet.ReadSingle(), }; moveInfo.Orientation = packet.ReadSingle(); packet.WriteLine("[{0}] Stationary Position: {1}, O: {2}", index, moveInfo.Position, moveInfo.Orientation); } if (hasAnimKits) { if (hasAnimKit3) packet.ReadUInt16("Anim Kit 3", index); if (hasAnimKit1) packet.ReadUInt16("Anim Kit 1", index); if (hasAnimKit2) packet.ReadUInt16("Anim Kit 2", index); } if (hasTransportExtra) packet.ReadInt32("Transport Time", index); packet.ResetBitReader(); return moveInfo; }