public static void HandleServerTrainerList(Packet packet) { var npcTrainer = new NpcTrainer(); var guidBytes = new byte[8]; var count = (int)packet.ReadBits(19); guidBytes[3] = packet.ReadBit(); guidBytes[2] = packet.ReadBit(); guidBytes[0] = packet.ReadBit(); guidBytes[7] = packet.ReadBit(); guidBytes[1] = packet.ReadBit(); guidBytes[5] = packet.ReadBit(); var titleLen = packet.ReadBits(11); guidBytes[6] = packet.ReadBit(); guidBytes[4] = packet.ReadBit(); packet.ReadXORByte(guidBytes, 3); npcTrainer.TrainerSpells = new List<TrainerSpell>(count); for (var i = 0; i < count; ++i) { var trainerSpell = new TrainerSpell(); packet.ReadByteE<TrainerSpellState>("State", i); trainerSpell.Spell = (uint)packet.ReadInt32<SpellId>("Spell ID", i); trainerSpell.RequiredSkill = packet.ReadUInt32("Required Skill", i); trainerSpell.Cost = packet.ReadUInt32("Cost", i); for (var j = 0; j < 3; ++j) packet.ReadInt32("Int818", i, j); trainerSpell.RequiredLevel = packet.ReadByte("Required Level", i); trainerSpell.RequiredSkillLevel = packet.ReadUInt32("Required Skill Level", i); npcTrainer.TrainerSpells.Add(trainerSpell); } packet.ReadXORByte(guidBytes, 1); packet.ReadXORByte(guidBytes, 6); packet.ReadXORByte(guidBytes, 0); npcTrainer.Title = packet.ReadWoWString("Title", titleLen); npcTrainer.Type = packet.ReadInt32E<TrainerType>("Type"); packet.ReadXORByte(guidBytes, 2); packet.ReadXORByte(guidBytes, 4); packet.ReadXORByte(guidBytes, 5); packet.ReadXORByte(guidBytes, 7); packet.ReadInt32("Unk Int32"); // Same unk exists in CMSG_TRAINER_BUY_SPELL var guid = packet.WriteGuid("Guid", guidBytes); if (Storage.NpcTrainers.ContainsKey(guid.GetEntry())) { var oldTrainer = Storage.NpcTrainers[guid.GetEntry()]; if (oldTrainer != null) { foreach (var trainerSpell in npcTrainer.TrainerSpells) oldTrainer.Item1.TrainerSpells.Add(trainerSpell); } } else Storage.NpcTrainers.Add(guid.GetEntry(), npcTrainer, packet.TimeSpan); }
public static void HandleServerTrainerList(Packet packet) { var npcTrainer = new NpcTrainer(); var guid = packet.ReadGuid("GUID"); npcTrainer.Type = packet.ReadEnum<TrainerType>("Type", TypeCode.Int32); if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_2_0_14333)) packet.ReadInt32("Unk Int32"); var count = packet.ReadInt32("Count"); npcTrainer.TrainerSpells = new List<TrainerSpell>(count); for (var i = 0; i < count; i++) { var trainerSpell = new TrainerSpell(); trainerSpell.Spell = (uint)packet.ReadEntryWithName<Int32>(StoreNameType.Spell, "Spell ID", i); packet.ReadEnum<TrainerSpellState>("State", TypeCode.Byte, i); trainerSpell.Cost = packet.ReadUInt32("Cost", i); if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_2_0_14333)) { trainerSpell.RequiredLevel = packet.ReadByte("Required Level", i); trainerSpell.RequiredSkill = packet.ReadUInt32("Required Skill", i); trainerSpell.RequiredSkillLevel = packet.ReadUInt32("Required Skill Level", i); packet.ReadInt32("Chain Node 1", i); packet.ReadInt32("Chain Node 2", i); } packet.ReadInt32("Profession Dialog", i); packet.ReadInt32("Profession Button", i); if (ClientVersion.RemovedInVersion(ClientVersionBuild.V4_2_0_14333)) { trainerSpell.RequiredLevel = packet.ReadByte("Required Level", i); trainerSpell.RequiredSkill = packet.ReadUInt32("Required Skill", i); trainerSpell.RequiredSkillLevel = packet.ReadUInt32("Required Skill Level", i); packet.ReadInt32("Chain Node 1", i); packet.ReadInt32("Chain Node 2", i); } if (ClientVersion.RemovedInVersion(ClientVersionBuild.V4_2_0_14333)) packet.ReadInt32("Unk Int32", i); npcTrainer.TrainerSpells.Add(trainerSpell); } npcTrainer.Title = packet.ReadCString("Title"); Storage.NpcTrainers.TryAdd(guid.GetEntry(), npcTrainer); }
public static void HandleServerTrainerList(Packet packet) { var guidBytes = new byte[8]; var npcTrainer = new NpcTrainer(); guidBytes[0] = packet.ReadBit(); var count = (int)packet.ReadBits("Count", 19); packet.StartBitStream(guidBytes, 2, 6); var titleLen = packet.ReadBits(11); packet.StartBitStream(guidBytes, 3, 7, 1, 4, 5); packet.ResetBitReader(); npcTrainer.TrainerSpells = new List<TrainerSpell>(count); for (var i = 0; i < count; ++i) { 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.ReadInt32<SpellId>("Required Spell ID", i); packet.ReadInt32("Profession Dialog", i); packet.ReadInt32("Profession Button", i); trainerSpell.Spell = (uint)packet.ReadInt32<SpellId>("Spell ID", i); packet.ReadByteE<TrainerSpellState>("State", i); npcTrainer.TrainerSpells.Add(trainerSpell); } packet.ReadXORBytes(guidBytes, 3, 2); npcTrainer.Title = packet.ReadWoWString("Title", titleLen); packet.ReadXORBytes(guidBytes, 7, 6, 4, 1, 0, 5); npcTrainer.Type = packet.ReadInt32E<TrainerType>("Type"); packet.ReadInt32("Unk Int32"); // Same unk exists in CMSG_TRAINER_BUY_SPELL var guid = packet.WriteGuid("GUID", guidBytes); Storage.NpcTrainers.Add(guid.GetEntry(), npcTrainer, packet.TimeSpan); }
public static void HandleServerTrainerList(Packet packet) { var npcTrainer = new NpcTrainer(); var guid = packet.ReadGuid("GUID"); npcTrainer.Type = packet.ReadEnum<TrainerType>("Type", TypeCode.Int32); if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_0_6a_13623)) packet.ReadInt32("Unk Int32"); // Same unk exists in CMSG_TRAINER_BUY_SPELL var count = packet.ReadInt32("Count"); npcTrainer.TrainerSpells = new List<TrainerSpell>(count); for (var i = 0; i < count; i++) { var trainerSpell = new TrainerSpell(); trainerSpell.Spell = (uint)packet.ReadEntryWithName<Int32>(StoreNameType.Spell, "Spell ID", i); packet.ReadEnum<TrainerSpellState>("State", TypeCode.Byte, i); trainerSpell.Cost = packet.ReadUInt32("Cost", i); if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_0_6a_13623)) { trainerSpell.RequiredLevel = packet.ReadByte("Required Level", i); trainerSpell.RequiredSkill = packet.ReadUInt32("Required Skill", i); trainerSpell.RequiredSkillLevel = packet.ReadUInt32("Required Skill Level", i); if (ClientVersion.RemovedInVersion(ClientVersionBuild.V5_1_0_16309)) { packet.ReadEntryWithName<Int32>(StoreNameType.Spell, "Chain Spell ID", i, 0); packet.ReadEntryWithName<Int32>(StoreNameType.Spell, "Chain Spell ID", i, 1); } else packet.ReadEntryWithName<Int32>(StoreNameType.Spell, "Required Spell ID", i); } packet.ReadInt32("Profession Dialog", i); packet.ReadInt32("Profession Button", i); if (ClientVersion.RemovedInVersion(ClientVersionBuild.V4_0_6a_13623)) { trainerSpell.RequiredLevel = packet.ReadByte("Required Level", i); trainerSpell.RequiredSkill = packet.ReadUInt32("Required Skill", i); trainerSpell.RequiredSkillLevel = packet.ReadUInt32("Required Skill Level", i); packet.ReadEntryWithName<Int32>(StoreNameType.Spell, "Chain Spell ID", i, 0); packet.ReadEntryWithName<Int32>(StoreNameType.Spell, "Chain Spell ID", i, 1); } if (ClientVersion.RemovedInVersion(ClientVersionBuild.V4_0_6a_13623)) packet.ReadInt32("Unk Int32", i); npcTrainer.TrainerSpells.Add(trainerSpell); } npcTrainer.Title = packet.ReadCString("Title"); Storage.NpcTrainers.Add(guid.GetEntry(), npcTrainer, packet.TimeSpan); }
public static void HandleServerTrainerList(Packet packet) { var npcTrainer = new NpcTrainer(); var guid = new byte[8]; guid[4] = packet.ReadBit(); guid[5] = packet.ReadBit(); var count = (int)packet.ReadBits(19); var titleLen = packet.ReadBits(11); guid[6] = packet.ReadBit(); guid[2] = packet.ReadBit(); guid[7] = packet.ReadBit(); guid[1] = packet.ReadBit(); guid[3] = packet.ReadBit(); guid[0] = packet.ReadBit(); packet.ReadXORByte(guid, 4); npcTrainer.TrainerSpells = new List<TrainerSpell>(count); for (var i = 0; i < count; ++i) { var trainerSpell = new TrainerSpell(); trainerSpell.RequiredLevel = packet.ReadByte("Required Level", i); trainerSpell.Cost = packet.ReadUInt32("Cost", i); trainerSpell.Spell = (uint)packet.ReadEntryWithName<Int32>(StoreNameType.Spell, "Spell ID", i); for (var j = 0; j < 3; ++j) packet.ReadInt32("Int818", i, j); trainerSpell.RequiredSkill = packet.ReadUInt32("Required Skill", i); trainerSpell.RequiredSkillLevel = packet.ReadUInt32("Required Skill Level", i); packet.ReadEnum<TrainerSpellState>("State", TypeCode.Byte, i); npcTrainer.TrainerSpells.Add(trainerSpell); } npcTrainer.Title = packet.ReadWoWString("Title", titleLen); packet.ReadXORByte(guid, 6); packet.ReadXORByte(guid, 7); packet.ReadXORByte(guid, 1); packet.ReadXORByte(guid, 3); packet.ReadInt32("Unk Int32"); // Same unk exists in CMSG_TRAINER_BUY_SPELL packet.ReadXORByte(guid, 5); packet.ReadXORByte(guid, 0); packet.ReadXORByte(guid, 2); npcTrainer.Type = packet.ReadEnum<TrainerType>("Type", TypeCode.Int32); packet.WriteGuid("Guid", guid); var GUID = new Guid(BitConverter.ToUInt64(guid, 0)); if (Storage.NpcTrainers.ContainsKey(GUID.GetEntry())) { var oldTrainer = Storage.NpcTrainers[GUID.GetEntry()]; if (oldTrainer != null) { foreach (var trainerSpell in npcTrainer.TrainerSpells) oldTrainer.Item1.TrainerSpells.Add(trainerSpell); } } else Storage.NpcTrainers.Add(GUID.GetEntry(), npcTrainer, packet.TimeSpan); }
public static void HandleServerTrainerList(Packet packet) { var npcTrainer = new NpcTrainer(); var guid = new byte[8]; guid[4] = packet.ReadBit(); guid[0] = packet.ReadBit(); var count = (int)packet.ReadBits(19); guid[3] = packet.ReadBit(); guid[7] = packet.ReadBit(); var titleLen = packet.ReadBits(11); guid[5] = packet.ReadBit(); guid[6] = packet.ReadBit(); guid[2] = packet.ReadBit(); guid[1] = packet.ReadBit(); npcTrainer.TrainerSpells = new List<TrainerSpell>(count); for (var i = 0; i < count; ++i) { var trainerSpell = new TrainerSpell(); trainerSpell.Spell = (uint)packet.ReadInt32<SpellId>("Spell ID", i); for (var j = 0; j < 3; ++j) packet.ReadInt32("Int818", i, j); packet.ReadByteE<TrainerSpellState>("State", i); trainerSpell.RequiredLevel = packet.ReadByte("Required Level", i); trainerSpell.RequiredSkillLevel = packet.ReadUInt32("Required Skill Level", i); trainerSpell.Cost = packet.ReadUInt32("Cost", i); trainerSpell.RequiredSkill = packet.ReadUInt32("Required Skill", i); } packet.ReadXORByte(guid, 4); packet.ReadXORByte(guid, 3); packet.ReadXORByte(guid, 2); packet.ReadXORByte(guid, 5); packet.ReadXORByte(guid, 1); packet.ReadXORByte(guid, 6); npcTrainer.Type = packet.ReadInt32E<TrainerType>("Type"); packet.ReadWoWString("Title", titleLen); packet.ReadInt32("Unk Int32"); // Same unk exists in CMSG_TRAINER_BUY_SPELL packet.ReadXORByte(guid, 7); packet.ReadXORByte(guid, 0); packet.WriteGuid("Guid", guid); }
public static void HandleServerTrainerList(Packet packet) { var npcTrainer = new NpcTrainer(); var guid = packet.ReadPackedGuid128("TrainerGUID"); packet.ReadInt32("TrainerType"); packet.ReadInt32("TrainerID"); var int36 = packet.ReadInt32("Spells"); npcTrainer.TrainerSpells = new List<TrainerSpell>(int36); // ClientTrainerListSpell for (var i = 0; i < int36; ++i) { var trainerSpell = new TrainerSpell(); trainerSpell.Spell = (uint)packet.ReadInt32<SpellId>("SpellID", i); trainerSpell.Cost = (uint)packet.ReadInt32("MoneyCost", i); trainerSpell.RequiredSkill = (uint)packet.ReadInt32("ReqSkillLine", i); trainerSpell.RequiredSkillLevel = (uint)packet.ReadInt32("ReqSkillRank", i); for (var j = 0; j < 3; ++j) packet.ReadInt32("ReqAbility", i, j); packet.ReadByteE<TrainerSpellState>("Usable", i); trainerSpell.RequiredLevel = packet.ReadByte("ReqLevel", i); npcTrainer.TrainerSpells.Add(trainerSpell); } var bits56 = packet.ReadBits(11); npcTrainer.Title = packet.ReadWoWString("Greeting", bits56); if (Storage.NpcTrainers.ContainsKey(guid.GetEntry())) { var oldTrainer = Storage.NpcTrainers[guid.GetEntry()]; if (oldTrainer != null) { foreach (var trainerSpell in npcTrainer.TrainerSpells) oldTrainer.Item1.TrainerSpells.Add(trainerSpell); } } else Storage.NpcTrainers.Add(guid.GetEntry(), npcTrainer, packet.TimeSpan); }
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); }