예제 #1
0
            public override SkillRaceClassInfo ConvertTo(byte[] rawData, ref int id)
            {
                id = GetInt32(rawData, 0);
                int num1 = 0;
                SkillRaceClassInfo skillRaceClassInfo1 = new SkillRaceClassInfo();
                SkillRaceClassInfo skillRaceClassInfo2 = skillRaceClassInfo1;

                byte[] data1    = rawData;
                int    field1   = num1;
                int    num2     = field1 + 1;
                int    uint32_1 = (int)GetUInt32(data1, field1);

                skillRaceClassInfo2.Id = (uint)uint32_1;
                byte[]             data2               = rawData;
                int                field2              = num2;
                int                num3                = field2 + 1;
                SkillId            uint32_2            = (SkillId)GetUInt32(data2, field2);
                SkillRaceClassInfo skillRaceClassInfo3 = skillRaceClassInfo1;

                byte[] data3    = rawData;
                int    field3   = num3;
                int    num4     = field3 + 1;
                int    uint32_3 = (int)GetUInt32(data3, field3);

                skillRaceClassInfo3.RaceMask = (RaceMask)uint32_3;
                SkillRaceClassInfo skillRaceClassInfo4 = skillRaceClassInfo1;

                byte[] data4    = rawData;
                int    field4   = num4;
                int    num5     = field4 + 1;
                int    uint32_4 = (int)GetUInt32(data4, field4);

                skillRaceClassInfo4.ClassMask = (ClassMask)uint32_4;
                SkillRaceClassInfo skillRaceClassInfo5 = skillRaceClassInfo1;

                byte[] data5    = rawData;
                int    field5   = num5;
                int    num6     = field5 + 1;
                int    uint32_5 = (int)GetUInt32(data5, field5);

                skillRaceClassInfo5.Flags = (SkillRaceClassFlags)uint32_5;
                SkillRaceClassInfo skillRaceClassInfo6 = skillRaceClassInfo1;

                byte[] data6    = rawData;
                int    field6   = num6;
                int    num7     = field6 + 1;
                int    uint32_6 = (int)GetUInt32(data6, field6);

                skillRaceClassInfo6.MinimumLevel = (uint)uint32_6;
                byte[] data7  = rawData;
                int    field7 = num7;
                int    field8 = field7 + 1;
                int    int32  = GetInt32(data7, field7);

                if (int32 > 0)
                {
                    TierReader.Entries.TryGetValue(int32, out skillRaceClassInfo1.Tiers);
                }
                skillRaceClassInfo1.SkillCostIndex = GetUInt32(rawData, field8);
                skillRaceClassInfo1.SkillLine      = ById.Get((uint)uint32_2);
                if (skillRaceClassInfo1.SkillLine != null)
                {
                    foreach (ClassId allClassId in WCellConstants.AllClassIds)
                    {
                        if (allClassId < ClassId.End)
                        {
                            ClassMask mask = allClassId.ToMask();
                            foreach (RaceMask key in WCellConstants.RaceTypesByMask.Keys)
                            {
                                RaceId raceType = WCellConstants.GetRaceType(key);
                                if (skillRaceClassInfo1.RaceMask.HasAnyFlag(key) &&
                                    skillRaceClassInfo1.ClassMask.HasAnyFlag(mask))
                                {
                                    Dictionary <SkillId, SkillRaceClassInfo>[] dictionaryArray =
                                        RaceClassInfos[(int)raceType];
                                    if (dictionaryArray == null)
                                    {
                                        RaceClassInfos[(int)raceType] = dictionaryArray =
                                            new Dictionary <SkillId, SkillRaceClassInfo> [WCellConstants.ClassTypeLength];
                                    }
                                    Dictionary <SkillId, SkillRaceClassInfo> dictionary =
                                        dictionaryArray[(int)allClassId];
                                    if (dictionary == null)
                                    {
                                        dictionaryArray[(int)allClassId] =
                                            dictionary = new Dictionary <SkillId, SkillRaceClassInfo>();
                                    }
                                    SkillRaceClassInfo skillRaceClassInfo7;
                                    if (dictionary.TryGetValue(uint32_2, out skillRaceClassInfo7))
                                    {
                                        skillRaceClassInfo1.RaceMask  |= skillRaceClassInfo7.RaceMask;
                                        skillRaceClassInfo1.ClassMask |= skillRaceClassInfo7.ClassMask;
                                    }
                                    else if (skillRaceClassInfo1.SkillLine.Tiers.Id == 0U &&
                                             skillRaceClassInfo1.Tiers.Id != 0U)
                                    {
                                        skillRaceClassInfo1.SkillLine.Tiers = skillRaceClassInfo1.Tiers;
                                    }

                                    dictionary[uint32_2] = skillRaceClassInfo1;
                                }
                            }
                        }
                    }
                }

                return(skillRaceClassInfo1);
            }
예제 #2
0
            public override SkillRaceClassInfo ConvertTo(byte[] rawData, ref int id)
            {
                id = GetInt32(rawData, 0);

                int currentIndex = 0;

                var info = new SkillRaceClassInfo();

                info.Id = GetUInt32(rawData, currentIndex++);

                var skillId = (SkillId)GetUInt32(rawData, currentIndex++);

                info.RaceMask     = (RaceMask)GetUInt32(rawData, currentIndex++);
                info.ClassMask    = (ClassMask)GetUInt32(rawData, currentIndex++);
                info.Flags        = (SkillRaceClassFlags)GetUInt32(rawData, currentIndex++);
                info.MinimumLevel = GetUInt32(rawData, currentIndex++);

                int skillTierId = GetInt32(rawData, currentIndex++);

                if (skillTierId > 0)
                {
                    TierReader.Entries.TryGetValue(skillTierId, out info.Tiers);
                }

                info.SkillCostIndex = GetUInt32(rawData, currentIndex);

                // there are outdated skills referenced by this DBC (which do not exist anymore)
                info.SkillLine = ById.Get((uint)skillId);
                if (info.SkillLine != null)
                {
                    foreach (var classId in WCellConstants.AllClassIds)
                    {
                        if (classId >= ClassId.End)
                        {
                            continue;
                        }
                        var classMask = classId.ToMask();
                        foreach (var raceMask in WCellConstants.RaceTypesByMask.Keys)
                        {
                            RaceId raceId = WCellConstants.GetRaceType(raceMask);
                            if (info.RaceMask.HasAnyFlag(raceMask) && info.ClassMask.HasAnyFlag(classMask))
                            {
                                Dictionary <SkillId, SkillRaceClassInfo>[] byClass = RaceClassInfos[(int)raceId];
                                if (byClass == null)
                                {
                                    RaceClassInfos[(int)raceId] = byClass = new Dictionary <SkillId, SkillRaceClassInfo> [WCellConstants.ClassTypeLength];
                                }

                                Dictionary <SkillId, SkillRaceClassInfo> infos = byClass[(int)classId];
                                if (infos == null)
                                {
                                    byClass[(int)classId] = infos = new Dictionary <SkillId, SkillRaceClassInfo>();
                                }

                                SkillRaceClassInfo oldInf;
                                if (infos.TryGetValue(skillId, out oldInf))
                                {
                                    // double skill entry: Update races and classes, everything else is the same
                                    info.RaceMask  |= oldInf.RaceMask;
                                    info.ClassMask |= oldInf.ClassMask;
                                }
                                else
                                {
                                    // we can do this here because SkillTiers are the same for all races/classes
                                    if (info.SkillLine.Tiers.Id == 0 && info.Tiers.Id != 0)
                                    {
                                        info.SkillLine.Tiers = info.Tiers;
                                    }
                                }

                                infos[skillId] = info;
                            }
                        }
                    }
                }

                return(info);
            }