Ejemplo n.º 1
0
        private void LoadAllRowData()
        {
            Rows = new ObservableCollection <SpecDBRowData>();
            for (int i = 0; i < Keys.Count; i++)
            {
                RowData key = Keys[i];
                GetRowByIndex(i, out Span <byte> rowData);
                var result = TableMetadata.ReadRow(rowData, DBT.Endian);
                result.Row.ID    = key.Id;
                result.Row.Label = key.Label;
                Rows.Add(result.Row);

                IsTableProperlyMapped = result.ReadAll;
            }
        }
Ejemplo n.º 2
0
        public int DumpTable(string path)
        {
            // Make a list of all the keys the IDI contains. IDI sometimes have keys without data.
            SpanReader idiReader = new SpanReader(IDI.Buffer, IDI.Endian);
            SortedList <int, string> idsToLabels = new SortedList <int, string>();
            int idiKeyCount = IDI.KeyCount;

            for (int i = 0; i < idiKeyCount; i++)
            {
                idiReader.Position = IDI.HeaderSize + (i * 0x08);
                int labelOffset = idiReader.ReadInt32();
                int id          = idiReader.ReadInt32();

                idiReader.Position  = IDI.HeaderSize + (idiKeyCount * 0x08) + labelOffset;
                idiReader.Position += 2; // Ignore string length
                string label = idiReader.ReadString0();
                idsToLabels.Add(id, label);
            }


            // Register all our keys that actually have data now.
            SpanReader dbtReader = new SpanReader(DBT.Buffer, DBT.Endian);
            var        keys      = new List <RowData>();

            int keyCount = DBT.EntryCount;

            for (int i = 0; i < keyCount; i++)
            {
                dbtReader.Position = DBT.HeaderSize + (i * 0x08);
                int id = dbtReader.ReadInt32();
                keys.Add(new RowData()
                {
                    Id = id, Label = idsToLabels[id]
                });
            }

            using (var sw = new StreamWriter(path))
            {
                for (int i = 0; i < keys.Count; i++)
                {
                    RowData key = keys[i];
                    GetRowByIndex(i, out Span <byte> rowData);
                    sw.WriteLine($"{key.Label} ({key.Id}) | {BitConverter.ToString(rowData.ToArray())}");
                }
            }

            return(keys.Count);
        }