Наследование: IDataModel
Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
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);

            npcTrainer.TrainerSpells = new List<TrainerSpell>(count);
            for (var i = 0; i < count; ++i)
            {
                //var trainerSpell = new TrainerSpell();
                packet.ReadInt32("Int824", i);
                packet.ReadInt32("Int824", i);
                packet.ReadByte("Byte824", i);
                for (var j = 0; j < 3; ++j)
                    packet.ReadInt32("Int824", i, j);
                packet.ReadInt32("Int824", i);
                packet.ReadByte("Byte824", i);
                packet.ReadInt32("Int824", i);

                //npcTrainer.TrainerSpells.Add(trainerSpell);
            }

            packet.ReadXORByte(guid, 5);
            packet.ReadXORByte(guid, 7);
            packet.ReadXORByte(guid, 6);
            npcTrainer.Title = packet.ReadWoWString("Title", titleLen);
            packet.ReadInt32("Int818");
            packet.ReadXORByte(guid, 2);
            packet.ReadXORByte(guid, 3);
            packet.ReadXORByte(guid, 1);
            packet.ReadXORByte(guid, 0);
            packet.ReadXORByte(guid, 4);
            packet.ReadInt32("Int81C");

            packet.WriteGuid("GUID", guid);
            //var GUID = new Guid(BitConverter.ToUInt64(guid, 0));
            //Storage.NpcTrainers.Add(GUID.GetEntry(), npcTrainer, packet.TimeSpan);
        }
Пример #7
0
        public static void HandleServerTrainerList(Packet packet)
        {
            var guid = new byte[8];

            guid[4] = packet.ReadBit();
            guid[0] = packet.ReadBit();
            uint count = packet.ReadBits(19);

            guid[3] = packet.ReadBit();
            guid[7] = packet.ReadBit();

            uint titleLen = packet.ReadBits(11);

            guid[5] = packet.ReadBit();
            guid[6] = packet.ReadBit();
            guid[2] = packet.ReadBit();
            guid[1] = packet.ReadBit();

            var tempList = new List<NpcTrainer>();
            for (int i = 0; i < count; ++i)
            {
                NpcTrainer trainer = new NpcTrainer
                {
                    SpellID = packet.ReadInt32<SpellId>("Spell ID", i)
                };

                for (var j = 0; j < 3; ++j)
                    packet.ReadInt32("Int818", i, j);

                packet.ReadByteE<TrainerSpellState>("State", i);
                trainer.ReqLevel = packet.ReadByte("Required Level", i);
                trainer.ReqSkillRank = packet.ReadUInt32("Required Skill Level", i);
                trainer.MoneyCost = packet.ReadUInt32("Cost", i);
                trainer.ReqSkillLine = packet.ReadUInt32("Required Skill", i);

                tempList.Add(trainer);
            }

            packet.ReadXORByte(guid, 4);
            packet.ReadXORByte(guid, 3);
            packet.ReadXORByte(guid, 2);
            packet.ReadXORByte(guid, 5);
            packet.ReadXORByte(guid, 1);
            packet.ReadXORByte(guid, 6);

            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);

            uint entry = packet.WriteGuid("Guid", guid).GetEntry();
            tempList.ForEach(v =>
            {
                v.ID = entry;
                Storage.NpcTrainers.Add(v, packet.TimeSpan);
            });
        }
Пример #8
0
        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);
        }
Пример #9
0
        public static void HandleServerTrainerList(Packet packet)
        {
            uint entry = packet.ReadPackedGuid128("TrainerGUID").GetEntry();

            packet.ReadInt32("TrainerType");
            packet.ReadInt32("TrainerID");
            int count = packet.ReadInt32("Spells");

            for (int i = 0; i < count; ++i)
            {
                NpcTrainer trainer = new NpcTrainer
                {
                    ID = entry,
                    SpellID = packet.ReadInt32<SpellId>("SpellID", i),
                    MoneyCost = packet.ReadUInt32("MoneyCost", i),
                    ReqSkillLine = packet.ReadUInt32("ReqSkillLine", i),
                    ReqSkillRank = packet.ReadUInt32("ReqSkillRank", i)
                };

                for (var j = 0; j < 3; ++j)
                    packet.ReadInt32("ReqAbility", i, j);

                packet.ReadByteE<TrainerSpellState>("Usable", i);
                trainer.ReqLevel = packet.ReadByte("ReqLevel", i);

                Storage.NpcTrainers.Add(trainer, packet.TimeSpan);
            }

            uint bits56 = packet.ReadBits(11);
            packet.ReadWoWString("Greeting", bits56);
        }
Пример #10
0
        public static void HandleServerTrainerList(Packet packet)
        {
            var guidBytes = new byte[8];

            guidBytes[0] = packet.ReadBit();
            uint count = packet.ReadBits("Count", 19);
            packet.StartBitStream(guidBytes, 2, 6);
            uint titleLen = packet.ReadBits(11);
            packet.StartBitStream(guidBytes, 3, 7, 1, 4, 5);
            packet.ResetBitReader();

            var tempList = new List<NpcTrainer>();
            for (int i = 0; i < count; ++i)
            {
                NpcTrainer trainer = new NpcTrainer();
                trainer.ReqSkillLine = packet.ReadUInt32("Required Skill", i);
                trainer.ReqSkillRank = packet.ReadUInt32("Required Skill Level", i);
                trainer.MoneyCost = packet.ReadUInt32("Cost", i);

                trainer.ReqLevel = packet.ReadByte("Required Level", i);
                packet.ReadInt32<SpellId>("Required Spell ID", i);
                packet.ReadInt32("Profession Dialog", i);
                packet.ReadInt32("Profession Button", i);

                trainer.SpellID = packet.ReadInt32<SpellId>("Spell ID", i);
                packet.ReadByteE<TrainerSpellState>("State", i);

                tempList.Add(trainer);
            }

            packet.ReadXORBytes(guidBytes, 3, 2);
            packet.ReadWoWString("Title", titleLen);
            packet.ReadXORBytes(guidBytes, 7, 6, 4, 1, 0, 5);

            packet.ReadInt32E<TrainerType>("Type");
            packet.ReadInt32("Unk Int32"); // Same unk exists in CMSG_TRAINER_BUY_SPELL

            uint entry = packet.WriteGuid("Guid", guidBytes).GetEntry();
            tempList.ForEach(v =>
            {
                v.ID = entry;
                Storage.NpcTrainers.Add(v, packet.TimeSpan);
            });
        }
Пример #11
0
        public static void HandleServerTrainerList(Packet packet)
        {
            uint entry = packet.ReadGuid("GUID").GetEntry();

            packet.ReadInt32E<TrainerType>("Type");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_0_6a_13623))
                packet.ReadInt32("TrainerID"); // Same TrainerID exists in CMSG_TRAINER_BUY_SPELL

            int count = packet.ReadInt32("Count");
            for (int i = 0; i < count; ++i)
            {
                NpcTrainer trainer = new NpcTrainer
                {
                    ID = entry,
                    SpellID = packet.ReadInt32<SpellId>("Spell ID", i)
                };

                packet.ReadByteE<TrainerSpellState>("State", i);

                trainer.MoneyCost = packet.ReadUInt32("Cost", i);

                if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_0_6a_13623))
                {
                    trainer.ReqLevel = packet.ReadByte("Required Level", i);
                    trainer.ReqSkillLine = packet.ReadUInt32("Required Skill", i);
                    trainer.ReqSkillRank = packet.ReadUInt32("Required Skill Level", i);
                    if (ClientVersion.RemovedInVersion(ClientVersionBuild.V5_1_0_16309))
                    {
                        packet.ReadInt32<SpellId>("Chain Spell ID", i, 0);
                        packet.ReadInt32<SpellId>("Chain Spell ID", i, 1);
                    }
                    else
                        packet.ReadInt32<SpellId>("Required Spell ID", i);
                }

                packet.ReadInt32("Profession Dialog", i);
                packet.ReadInt32("Profession Button", i);

                if (ClientVersion.RemovedInVersion(ClientVersionBuild.V4_0_6a_13623))
                {
                    trainer.ReqLevel = packet.ReadByte("Required Level", i);
                    trainer.ReqSkillLine = packet.ReadUInt32("Required Skill", i);
                    trainer.ReqSkillRank = packet.ReadUInt32("Required Skill Level", i);
                    packet.ReadInt32<SpellId>("Chain Spell ID", i, 0);
                    packet.ReadInt32<SpellId>("Chain Spell ID", i, 1);
                }

                if (ClientVersion.RemovedInVersion(ClientVersionBuild.V4_0_6a_13623))
                    packet.ReadInt32("Unk Int32", i);

                Storage.NpcTrainers.Add(trainer, packet.TimeSpan);
            }

            packet.ReadCString("Title");
        }
Пример #12
0
        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);
        }
Пример #13
0
        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);
        }