コード例 #1
0
        public SpellRadius(MainWindow window, SpellDBC theSpellDBC)
        {
            main = window;
            spell = theSpellDBC;

            if (!File.Exists("SpellRadius.dbc"))
            {
                main.ERROR_STR = "SpellRadius.dbc was not found!";
                return;
            }

            FileStream fs = new FileStream("SpellRadius.dbc", FileMode.Open);
            // Read header
            int count = Marshal.SizeOf(typeof(SpellDBC_Header));
            byte[] readBuffer = new byte[count];
            BinaryReader reader = new BinaryReader(fs);
            readBuffer = reader.ReadBytes(count);
            GCHandle handle = GCHandle.Alloc(readBuffer, GCHandleType.Pinned);
            header = (SpellDBC_Header)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(SpellDBC_Header));
            handle.Free();

            body.records = new SpellRadiusRecord[header.record_count];
            // Read body
            for (UInt32 i = 0; i < header.record_count; ++i)
            {
                count = Marshal.SizeOf(typeof(SpellRadiusRecord));
                readBuffer = new byte[count];
                reader = new BinaryReader(fs);
                readBuffer = reader.ReadBytes(count);
                handle = GCHandle.Alloc(readBuffer, GCHandleType.Pinned);
                body.records[i] = (SpellRadiusRecord)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(SpellRadiusRecord));
                handle.Free();
            }

            reader.Close();
            fs.Close();

            body.lookup = new List<RadiusLookup>();

            main.RadiusIndex1.Items.Add("0 - 0");
            main.RadiusIndex2.Items.Add("0 - 0");
            main.RadiusIndex3.Items.Add("0 - 0");

            int boxIndex = 1;
            for (UInt32 i = 0; i < header.record_count; ++i)
            {
                RadiusLookup temp;

                temp.ID = (int)body.records[i].ID;
                temp.comboBoxIndex = boxIndex;

                main.RadiusIndex1.Items.Add(body.records[i].radius + " - " + body.records[i].maxRadius);
                main.RadiusIndex2.Items.Add(body.records[i].radius + " - " + body.records[i].maxRadius);
                main.RadiusIndex3.Items.Add(body.records[i].radius + " - " + body.records[i].maxRadius);

                body.lookup.Add(temp);

                boxIndex++;
            }
        }
コード例 #2
0
        public SpellDispelType(MainWindow window, SpellDBC theSpellDBC)
        {
            main = window;
            spell = theSpellDBC;

            if (!File.Exists("SpellDispelType.dbc"))
            {
                main.ERROR_STR = "SpellDispelType.dbc was not found!";
                return;
            }

            FileStream fs = new FileStream("SpellDispelType.dbc", FileMode.Open);
            // Read header
            int count = Marshal.SizeOf(typeof(SpellDBC_Header));
            byte[] readBuffer = new byte[count];
            BinaryReader reader = new BinaryReader(fs);
            readBuffer = reader.ReadBytes(count);
            GCHandle handle = GCHandle.Alloc(readBuffer, GCHandleType.Pinned);
            header = (SpellDBC_Header)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(SpellDBC_Header));
            handle.Free();

            body.records = new DispelDBC_Record[header.record_count];
            // Read body
            for (UInt32 i = 0; i < header.record_count; ++i)
            {
                count = Marshal.SizeOf(typeof(DispelDBC_Record));
                readBuffer = new byte[count];
                reader = new BinaryReader(fs);
                readBuffer = reader.ReadBytes(count);
                handle = GCHandle.Alloc(readBuffer, GCHandleType.Pinned);
                body.records[i] = (DispelDBC_Record)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(DispelDBC_Record));
                handle.Free();
            }

            body.StringBlock = Encoding.UTF8.GetString(reader.ReadBytes(header.string_block_size));

            reader.Close();
            fs.Close();

            int boxIndex = 0;

            for (UInt32 i = 0; i < header.record_count; ++i)
            {
                int offset = (int)body.records[i].Name[0];
                if (offset == 0)
                    continue;
                int returnValue = offset;
                string toAdd = "";
                while (body.StringBlock[offset] != '\0')
                    toAdd += body.StringBlock[offset++];

                // Index to ID
                IndexToIDMap.Add(boxIndex, body.records[i].ID);
                // Hash to index
                stringHashMap.Add(toAdd.GetHashCode(), boxIndex++);
                // Offset to hash
                offsetHashMap.Add(returnValue, toAdd.GetHashCode());
                // Add to box
                main.DispelType.Items.Add(toAdd);
            }
        }
コード例 #3
0
        public SpellRange(MainWindow window, SpellDBC theSpellDBC)
        {
            main = window;
            spell = theSpellDBC;

            if (!File.Exists("SpellRange.dbc"))
            {
                main.ERROR_STR = "SpellRange.dbc was not found!";
                return;
            }

            FileStream fs = new FileStream("SpellRange.dbc", FileMode.Open);
            // Read header
            int count = Marshal.SizeOf(typeof(SpellDBC_Header));
            byte[] readBuffer = new byte[count];
            BinaryReader reader = new BinaryReader(fs);
            readBuffer = reader.ReadBytes(count);
            GCHandle handle = GCHandle.Alloc(readBuffer, GCHandleType.Pinned);
            header = (SpellDBC_Header)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(SpellDBC_Header));
            handle.Free();

            body.records = new SpellRangeDBC_Record[header.record_count];
            // Read body
            for (UInt32 i = 0; i < header.record_count; ++i)
            {
                count = Marshal.SizeOf(typeof(SpellRangeDBC_Record));
                readBuffer = new byte[count];
                reader = new BinaryReader(fs);
                readBuffer = reader.ReadBytes(count);
                handle = GCHandle.Alloc(readBuffer, GCHandleType.Pinned);
                body.records[i] = (SpellRangeDBC_Record)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(SpellRangeDBC_Record));
                handle.Free();
            }

            body.StringBlock = reader.ReadBytes(header.string_block_size);

            reader.Close();
            fs.Close();

            body.lookup = new List<SpellRange_Lookup>();
            int boxIndex = 0;

            int locale = 0;
            // Attempt to get the nearest locality
            for (int i = 0; i < 9; ++i)
            {
                if (body.records[0].Name[i] > 0)
                {
                    locale = i;
                    break;
                }
            }

            List<byte> bytes = new List<byte>();
            for (UInt32 i = 0; i < header.record_count; ++i)
            {
                int offset = (int)body.records[i].Name[locale];
                if (offset == 0)
                    continue;
                int returnValue = offset;

                while (body.StringBlock[offset] != 0)
                    bytes.Add(body.StringBlock[offset++]);

                string toAdd = body.records[i].ID + " - ";
                toAdd += Encoding.UTF8.GetString(bytes.ToArray<byte>());

                bytes.Clear();

                SpellRange_Lookup temp;
                temp.ID = (int)body.records[i].ID;
                temp.comboBoxIndex = boxIndex;

                main.SpellRange.Items.Add(toAdd);

                body.lookup.Add(temp);

                boxIndex++;
            }
        }
コード例 #4
0
 public SpellIconDBC(MainWindow window, SpellDBC theSpellDBC)
 {
     main = window;
     spell = theSpellDBC;
 }
コード例 #5
0
        public SpellMechanic(MainWindow window, SpellDBC theSpellDBC)
        {
            main = window;
            spell = theSpellDBC;

            if (!File.Exists("SpellMechanic.dbc"))
            {
                main.ERROR_STR = "SpellMechanic.dbc was not found!";
                return;
            }

            FileStream fs = new FileStream("SpellMechanic.dbc", FileMode.Open);
            // Read header
            int count = Marshal.SizeOf(typeof(SpellDBC_Header));
            byte[] readBuffer = new byte[count];
            BinaryReader reader = new BinaryReader(fs);
            readBuffer = reader.ReadBytes(count);
            GCHandle handle = GCHandle.Alloc(readBuffer, GCHandleType.Pinned);
            header = (SpellDBC_Header)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(SpellDBC_Header));
            handle.Free();

            body.records = new MechanicDBC_Record[header.record_count];
            // Read body
            for (UInt32 i = 0; i < header.record_count; ++i)
            {
                count = Marshal.SizeOf(typeof(MechanicDBC_Record));
                readBuffer = new byte[count];
                reader = new BinaryReader(fs);
                readBuffer = reader.ReadBytes(count);
                handle = GCHandle.Alloc(readBuffer, GCHandleType.Pinned);
                body.records[i] = (MechanicDBC_Record)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(MechanicDBC_Record));
                handle.Free();
            }

            body.StringBlock = Encoding.UTF8.GetString(reader.ReadBytes(header.string_block_size));

            reader.Close();
            fs.Close();

            body.lookup = new List<MechanicLookup>();
            int boxIndex = 1;

            main.MechanicType.Items.Add("None");
            MechanicLookup t;
            t.ID = 0;
            t.offset = 0;
            t.stringHash = "None".GetHashCode();
            t.comboBoxIndex = 0;
            body.lookup.Add(t);

            for (UInt32 i = 0; i < header.record_count; ++i)
            {
                int offset = (int)body.records[i].Name[0];
                if (offset == 0)
                    continue;
                int returnValue = offset;
                string toAdd = "";
                while (body.StringBlock[offset] != '\0')
                    toAdd += body.StringBlock[offset++];

                MechanicLookup temp;

                temp.ID = (int)body.records[i].ID;
                temp.stringHash = toAdd.GetHashCode();
                temp.offset = returnValue;
                temp.comboBoxIndex = boxIndex;

                main.MechanicType.Items.Add(toAdd);

                body.lookup.Add(temp);

                boxIndex++;
            }
        }