Beispiel #1
0
        private List <SkillLineAbilityEntry> GetSkillLineAbilityEntries()
        {
            var abilityList   = new List <SkillLineAbilityEntry>();
            var targetSkillId = (int)SkillLine;

            WoWDb.DbTable table    = StyxWoW.Db[ClientDb.SkillLineAbility];
            var           minIndex = (uint)table.MinIndex;
            var           topIndex = (uint)table.NumRows;
            uint          bomIndex = 0;
            uint          half;

            var firstRowPtr =
                ObjectManager.Wow.Read <uint>(((uint)ClientDb.SkillLineAbility + ObjectManager.Wow.ImageBase) + 0x14);
            uint id;

            // optimized search
            do
            {
                half = (topIndex + bomIndex) / 2;
                id   = ObjectManager.Wow.Read <uint>((firstRowPtr + half * SkillLineAbilityEntrySize) + 4); // skill
                if (id > targetSkillId)
                {
                    topIndex = (topIndex + half) / 2;
                }
                else if (id < targetSkillId)
                {
                    bomIndex = ((half + bomIndex) / 2) + 1;
                }
                else
                {
                    break;
                }
            } while (bomIndex < topIndex);

            var  index     = ObjectManager.Wow.Read <uint>((firstRowPtr + (half - 1) * SkillLineAbilityEntrySize));
            uint prevIndex = index;

            while (index > minIndex)
            {
                id    = ObjectManager.Wow.Read <uint>((firstRowPtr + (half - 1) * SkillLineAbilityEntrySize) + 4);
                index = ObjectManager.Wow.Read <uint>((firstRowPtr + (half - 1) * SkillLineAbilityEntrySize));
                if (id != targetSkillId)
                {
                    break;
                }
                half--;
                prevIndex = index;
            }

            for (uint i = prevIndex; i <= table.MaxIndex;)
            {
                WoWDb.Row row   = table.GetRow(i);
                var       entry = row.GetStruct <SkillLineAbilityEntry>();
                if ((int)entry.SkillLine != targetSkillId)
                {
                    break;
                }
                abilityList.Add(entry);
                if (i != table.MaxIndex) // get next index
                {
                    i = row.GetField <uint>((SkillLineAbilityFieldNum));
                }
            }
            return(abilityList);
        }
Beispiel #2
0
        private List <SkillLineAbilityEntry> GetSkillLineAbilityEntries()
        {
            var abilityList   = new List <SkillLineAbilityEntry>();
            var targetSkillId = (int)SkillLine;

            WoWDb.DbTable table    = StyxWoW.Db[ClientDb.SkillLineAbility];
            var           minIndex = (uint)table.MinIndex;
            var           topIndex = (uint)table.NumRows;
            uint          bomIndex = 0;
            uint          half;
            var           firstRowPtr = StyxWoW.Memory.Read <uint>((IntPtr)((uint)ClientDb.SkillLineAbility - 0x400000) + 0x14, true);
            // var firstRowPtr = StyxWoW.Memory.Read<uint>((IntPtr)((uint)ClientDb.SkillLineAbility) + 0x14, true);
            uint id;

            // optimized search
            do
            {
                half = (topIndex + bomIndex) / 2;
                id   = StyxWoW.Memory.Read <uint>((IntPtr)(firstRowPtr + half * SkillLineAbilityEntrySize) + 4);              // skill id
                if (id > targetSkillId)
                {
                    topIndex = (topIndex + half) / 2;
                }
                else if (id < targetSkillId)
                {
                    bomIndex = ((half + bomIndex) / 2) + 1;
                }
                else
                {
                    break;
                }
            } while (bomIndex < topIndex);

            var  index     = StyxWoW.Memory.Read <uint>((IntPtr)(firstRowPtr + (half - 1) * SkillLineAbilityEntrySize));
            uint prevIndex = index;

            while (index > minIndex)
            {
                id    = StyxWoW.Memory.Read <uint>((IntPtr)(firstRowPtr + (half - 1) * SkillLineAbilityEntrySize) + 4);
                index = StyxWoW.Memory.Read <uint>((IntPtr)(firstRowPtr + (half - 1) * SkillLineAbilityEntrySize));
                if (id != targetSkillId)
                {
                    break;
                }
                half--;
                prevIndex = index;
            }

            for (uint i = prevIndex; i <= table.MaxIndex;)
            {
                WoWDb.Row row   = table.GetRow(i);
                var       entry = row.GetStruct <SkillLineAbilityEntry>();
                if ((int)entry.SkillLine != targetSkillId)
                {
                    break;
                }
                var spell = WoWSpell.FromId((int)entry.SpellId);
                if (spell != null && spell.IsValid)
                {
                    abilityList.Add(entry);
                }

                if (i != table.MaxIndex)                 // get next index
                {
                    i = row.GetField <uint>((SkillLineAbilityFieldNum));
                }
            }

            return(abilityList);
        }