Пример #1
0
        internal static void Initialize()
        {
            TierReader =
                new MappedDBCReader <SkillTiers, SkillTierConverter>(
                    RealmServerConfiguration.GetDBCFile("SkillTiers.dbc"));
            foreach (SkillLine skillLine in new MappedDBCReader <SkillLine, SkillLineConverter>(
                         RealmServerConfiguration.GetDBCFile("SkillLine.dbc")).Entries.Values)
            {
                ById[(uint)skillLine.Id] = skillLine;
                if (skillLine.Category == SkillCategory.Language)
                {
                    LanguageDescription languageDescBySkillType =
                        LanguageHandler.GetLanguageDescBySkillType(skillLine.Id);
                    if (languageDescBySkillType != null)
                    {
                        skillLine.Language = languageDescBySkillType.Language;
                    }
                }
            }

            RaceClassReader =
                new MappedDBCReader <SkillRaceClassInfo, SkillRaceClassInfoConverter>(
                    RealmServerConfiguration.GetDBCFile("SkillRaceClassInfo.dbc"));
            MappedDBCReader <SkillAbility, SkillAbilityConverter> mappedDbcReader =
                new MappedDBCReader <SkillAbility, SkillAbilityConverter>(
                    RealmServerConfiguration.GetDBCFile("SkillLineAbility.dbc"));

            List <SkillAbility>[] arr = new List <SkillAbility> [2000];
            foreach (SkillAbility skillAbility in mappedDbcReader.Entries.Values)
            {
                if (skillAbility.Spell != null)
                {
                    skillAbility.Spell.Ability = skillAbility;
                }
                if (skillAbility.NextSpellId > SpellId.None)
                {
                    Spell spell = SpellHandler.Get(skillAbility.NextSpellId);
                    if (spell != null)
                    {
                        skillAbility.NextAbility = spell.Ability;
                        if (spell.Ability != null)
                        {
                            spell.Ability.PreviousAbility = skillAbility;
                        }
                    }
                }

                List <SkillAbility> val = arr.Get((uint)skillAbility.Skill.Id);
                if (val == null)
                {
                    val = new List <SkillAbility>();
                    ArrayUtil.Set(ref arr, (uint)skillAbility.Skill.Id, val);
                }

                val.Add(skillAbility);
            }

            for (int index = 0; index < arr.Length; ++index)
            {
                if (arr[index] != null)
                {
                    AbilitiesBySkill[index] = arr[index].ToArray();
                }
            }
        }
Пример #2
0
        internal static void Initialize()
        {
            TierReader = new MappedDBCReader <SkillTiers, SkillTierConverter>(RealmServerConfiguration.GetDBCFile(WCellConstants.DBC_SKILLTIERS));

            var lineReader =
                new MappedDBCReader <SkillLine, SkillLineConverter>(RealmServerConfiguration.GetDBCFile(WCellConstants.DBC_SKILLLINE));

            // make sure that all these skill types have correct tiers
            foreach (var line in lineReader.Entries.Values)
            {
                ById[(uint)line.Id] = line;

                /*if ((line.Category == SkillCategory.WeaponSkill && line.Id != SkillId.DualWield) ||
                 *      line.Category == SkillCategory.ClassSkill ||
                 *      line.Category == SkillCategory.Profession ||
                 *      line.Category == SkillCategory.SecondarySkill)
                 * {
                 *
                 *      line.Tier = new SkillTier(SkillTier.DefaultTier, line.Id);
                 * }
                 * else*/
                if (line.Category == SkillCategory.Language)
                {
                    var lang = LanguageHandler.GetLanguageDescBySkillType(line.Id);
                    if (lang != null)
                    {
                        line.Language = lang.Language;
                    }
                }
            }

            RaceClassReader = new MappedDBCReader <SkillRaceClassInfo, SkillRaceClassInfoConverter>(
                RealmServerConfiguration.GetDBCFile(WCellConstants.DBC_SKILLRACECLASSINFO));


            var abilityReader =
                new MappedDBCReader <SkillAbility, SkillAbilityConverter>(
                    RealmServerConfiguration.GetDBCFile(WCellConstants.DBC_SKILLLINEABILITY));

            var abilityLists = new List <SkillAbility> [MaxSkillId];

            foreach (var ability in abilityReader.Entries.Values)
            {
                // why would the spell be null?
                if (ability.Spell != null)
                {
                    // some skills link the same spell multiple times
                    //if (!AbilitiesBySpellId.ContainsKey((SpellId)ability.Spell.Id)) {
                    //AbilitiesBySpellId.Add((SpellId)ability.Spell.Id, ability.SkillLine);
                    //}
                    ability.Spell.Ability = ability;
                }
                else
                {
                    // Don't know whats wrong here?
                }

                // create a doubly linked list
                if (ability.NextSpellId > 0)
                {
                    var nextSpell = SpellHandler.Get(ability.NextSpellId);
                    if (nextSpell != null)
                    {
                        ability.NextAbility = nextSpell.Ability;
                        if (nextSpell.Ability != null)
                        {
                            nextSpell.Ability.PreviousAbility = ability;
                        }
                    }
                }

                // initial ability to a skill
                //if (ability.AcquireMethod == SkillAcquireMethod.OnLearningSkill)
                //{
                //    ability.Skill.InitialAbilities.Add(ability);
                //}

                List <SkillAbility> abilities = abilityLists.Get((uint)ability.Skill.Id);

                if (abilities == null)
                {
                    abilities = new List <SkillAbility>();

                    ArrayUtil.Set(ref abilityLists, (uint)ability.Skill.Id, abilities);
                }

                abilities.Add(ability);
            }

            for (int i = 0; i < abilityLists.Length; i++)
            {
                if (abilityLists[i] != null)
                {
                    AbilitiesBySkill[i] = abilityLists[i].ToArray();
                }
            }
        }