Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e) {
            server = host.Text;
            database = world.Text;
            uid = username.Text;
            password = psw.Text;
            string connectionString;
            connectionString = "SERVER=" + server + ";" + "DATABASE=" +
            database + ";" + "UID=" + uid + ";" + "PASSWORD="******";";
            connection = new MySqlConnection(connectionString);


            List<int>[] selected = GetItems();

            itemID = selected[0];
            itemClass = selected[1];
            itemSubClass = selected[2];
            soundOverride = selected[3];
            matID = selected[4];
            itemDisplayInfo = selected[5];
            inventorySlot = selected[6];
            sheathID = selected[7];

            columns = new DBCDataColumn[] {
                new DBCDataColumn("itemID", true),
                new DBCDataColumn("itemClass", true),
                new DBCDataColumn("ItemSubClass", true),
                new DBCDataColumn("sound_override_subclassid", true),
                new DBCDataColumn("MaterialID", true),
                new DBCDataColumn("ItemDisplayInfo", true),
                new DBCDataColumn("InventorySlotID", true),
                new DBCDataColumn("SheathID", true)
            };

            List<DBCDataRow> tempRows = new List<DBCDataRow>();
            for (int x = 0; x < itemID.Count; x++) {
                DBCDataRow tempRow = new DBCDataRow(8);
                byte[] itEntry = BitConverter.GetBytes(itemID[x]);
                byte[] itClass = BitConverter.GetBytes(itemClass[x]);
                byte[] itSubClass = BitConverter.GetBytes(itemSubClass[x]);
                byte[] itSoundOverride = BitConverter.GetBytes(soundOverride[x]);
                byte[] itMatId = BitConverter.GetBytes(matID[x]);
                byte[] itDisplayID = BitConverter.GetBytes(itemDisplayInfo[x]);
                byte[] itInvSlot = BitConverter.GetBytes(inventorySlot[x]);
                byte[] itSheathID = BitConverter.GetBytes(sheathID[x]);
                tempRow.Cells = new DBCDataField[] {
                    new DBCDataField(itEntry),
                    new DBCDataField(itClass),
                    new DBCDataField(itSubClass),
                    new DBCDataField(itSoundOverride),
                    new DBCDataField(itMatId),
                    new DBCDataField(itDisplayID),
                    new DBCDataField(itInvSlot),
                    new DBCDataField(itSheathID),
                };

                tempRows.Add(tempRow);
            }

            rows = tempRows.ToArray();


            using (Stream file = File.Create("Item.dbc")) {
                DBCWriter dbcWriter = new DBCWriter(file);


                DBCDataTable newDBCTable = new DBCDataTable();
                newDBCTable.Columns = columns;
                newDBCTable.Rows = rows;
                dbcWriter.DataTable = newDBCTable;

                dbcWriter.Write();
            }
        }
Exemplo n.º 2
0
        void readData()
        {
            //-- Create a new data table and setup its columns
            dataTable = new DBCDataTable();
            dataTable.Columns = new DBCDataColumn[fileInfo.Fields];

            if (columns == null)
            {
                for (int i = 0; i < fileInfo.Fields; i++)
                    dataTable.Columns[i] = new DBCDataColumn("Column" + i, false);
            }
            else
            {
                for (int i = 0; i < fileInfo.Fields; i++)
                    dataTable.Columns[i] = columns[i];
            }
            
            //-- Output some reflection data
            writeInfoData("Records to read: " + fileInfo.Records);

            //-- Read all strings
            reader.ReadStrings(FileInfo.FieldSize);

            //-- Read each row
            dataTable.Rows = new DBCDataRow[fileInfo.Records];
            for (int i = 0; i < fileInfo.Records; i++)
                reader.ReadRecord(dataTable, FileInfo.FieldSize, i);
        }
Exemplo n.º 3
0
        public void ReadRecord(DBCDataTable table, int fieldSize, int num)
        {
            //-- Read the DBC's field count
            int fieldCount = ReadFieldCount();

            //-- Set the internal stream pointer to the record to read
            long offset = DBCFile.HEADER_SIZE + (num * fieldSize * table.Columns.Length);
            binReader.BaseStream.Seek(offset, SeekOrigin.Begin);

            //-- Create a new row for this DBCDataTable
            DBCDataRow row = table.NewRow();

            //-- Read each column and fill in its value
            for (int i = 0; i < fieldCount; i++)
            {
                byte[] fieldValue = binReader.ReadBytes(fieldSize);

                // If compression has been enabled, check if compression should be applied
                if (bEnableCompression)
                {
                    if (!byteIsNull(fieldValue))
                        row.Cells[i] = new DBCDataField(fieldValue); //no, so assign it
                }
                else
                    row.Cells[i] = new DBCDataField(fieldValue); // compression disabled
            }

            table.Rows[num] = row;
        }