Exemplo n.º 1
0
        public static Dictionary <uint, uint> GetRowEntriesAndPointers(uint pointer, uint rowSize)
        {
            Dictionary <uint, uint> dictionary = new Dictionary <uint, uint>();

            Internal.DBC tempDbc = new Internal.DBC((IntPtr)pointer, rowSize);

            for (int i = 0; i < tempDbc.NumRows; i++)
            {
                uint rowEntry   = tempDbc.GetRowEntry(i);
                uint rowPointer = tempDbc.GetRowPtr(i);

                dictionary.Add(rowEntry, rowPointer);
            }

            return(dictionary);
        }
Exemplo n.º 2
0
        private static Dictionary <int, T> ReadDBCCompressedRows <T>(uint DBC) where T : DBCRow, new()
        {
            Dictionary <int, T> dictionary = new Dictionary <int, T>();

            uint mem = (uint)Marshal.AllocHGlobal(100000000);

            Internal.DBC tempDbc = new Internal.DBC((IntPtr)DBC, 0 /*we dont need a row size for this one*/);

            uint MinIndex = (uint)tempDbc.MinIndex;
            uint MaxIndex = (uint)tempDbc.MaxIndex;

            uint RowPtr = 0;

            //uint currentRow = 0;
            for (uint a = MinIndex; a < MaxIndex; a++)
            {
                RowPtr = _GetCompressedRows(DBC, mem);

                if (RowPtr != 0)
                {
                    break;
                    // currentRow = a;
                }
            }

            T firstInstance = Activator.CreateInstance <T>();

            firstInstance.Pointer = RowPtr;
            firstInstance.Initialize(RowPtr);
            dictionary.Add((int)firstInstance.Entry, firstInstance);
            RowPtr = RowPtr + firstInstance.RowSize;

            for (uint i = 1; i < tempDbc.NumRows; i++)
            {
                T tempInstance = Activator.CreateInstance <T>();
                tempInstance.Pointer = RowPtr;
                tempInstance.Initialize(RowPtr);
                dictionary.Add((int)tempInstance.Entry, tempInstance);
                RowPtr = RowPtr + firstInstance.RowSize;
            }

            //for (uint i = MinIndex; i < MaxIndex; i++)
            //{
            //    uint rowPtr = _GetCompressedRows(DBC, i);
            //    while (rowPtr == 0)
            //    if (rowPtr != 0)
            //    {
            //        T instance = Activator.CreateInstance<T>();
            //        instance.Pointer = rowPtr;
            //        instance.Initialize(rowPtr);
            //        //I need to be able to do like

            //        //uint entry = 0;
            //        //if (typeof (T) == typeof (SpellDBC))
            //        //{
            //        //    SpellDBC o = instance as SpellDBC;
            //        //    entry = o.SpellId;
            //        //}
            //        //else if (typeof (T) == typeof (SpellEffectDBC))
            //        //{
            //        //    SpellEffectDBC o = instance as SpellEffectDBC;
            //        //    entry = o.Id;
            //        //}

            //        dictionary.Add((int) instance.Entry, instance);
            //    }
            //}

            return(dictionary);
        }