Beispiel #1
0
            public void SetValue <TTarget>(TTarget target, int inputVal, DbcTable table)
                where TTarget : class
            {
                switch (Type)
                {
                case TargetType.Int32:
                    SetValue(target, inputVal);
                    break;

                case TargetType.Float32:
                    byte[] bits = BitConverter.GetBytes(inputVal);
                    SetValue(target, BitConverter.ToSingle(bits, 0));
                    break;

                case TargetType.String:
                    string tmp = table.GetString(inputVal);
                    SetValue(target, tmp);
                    break;

                case TargetType.StringReference:
                    DbcStringReference sref = new DbcStringReference(table, inputVal);
                    SetValue(target, sref);
                    break;
                }
            }
Beispiel #2
0
        static void Main(string[] args)
        {
            //Config.ForceSlowMode = true;

            Stopwatch timer = new Stopwatch();

            timer.Start();
            using (var fs = File.OpenRead(@"D:\Users\rob_000\Downloads\mpqediten64\Work\DBFilesClient\ChatProfanity.dbc"))
                using (DbcTable <ChatProfanityRecord> table = new DbcTable <ChatProfanityRecord>(fs, false))
                    using (var fsOut = File.OpenWrite("output.txt"))
                        using (var sw = new StreamWriter(fsOut, Encoding.UTF8))
                        {
                            foreach (var item in table)
                            {
                                //Console.WriteLine("{0}: {1}", item.ID, item.DirtyWord);
                                //sw.WriteLine("{0,-8}{1,-40}{2}", item.ID, item.DirtyWord, item.LanguageID);
                            }

                            foreach (var item in table)
                            {
                                //Console.WriteLine("{0}: {1}", item.ID, item.DirtyWord);
                                //sw.WriteLine("{0,-8}{1,-40}{2}", item.ID, item.DirtyWord, item.LanguageID);
                            }

                            foreach (var item in table)
                            {
                                //Console.WriteLine("{0}: {1}", item.ID, item.DirtyWord);
                                //sw.WriteLine("{0,-8}{1,-40}{2}", item.ID, item.DirtyWord, item.LanguageID);
                            }

                            foreach (var item in table)
                            {
                                //Console.WriteLine("{0}: {1}", item.ID, item.DirtyWord);
                                //sw.WriteLine("{0,-8}{1,-40}{2}", item.ID, item.DirtyWord, item.LanguageID);
                            }

                            foreach (var item in table)
                            {
                                //Console.WriteLine("{0}: {1}", item.ID, item.DirtyWord);
                                //sw.WriteLine("{0,-8}{1,-40}{2}", item.ID, item.DirtyWord, item.LanguageID);
                            }
                        }
            timer.Stop();
            Console.WriteLine("Completed in {0}ms", timer.ElapsedMilliseconds);

            Console.WriteLine("Done; press <enter> to exit.");
            Console.ReadLine();
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            //Config.ForceSlowMode = true;

            Stopwatch timer = new Stopwatch();
            timer.Start();
            using (var fs = File.OpenRead(@"D:\Users\rob_000\Downloads\mpqediten64\Work\DBFilesClient\ChatProfanity.dbc"))
            using (DbcTable<ChatProfanityRecord> table = new DbcTable<ChatProfanityRecord>(fs, false))
            using (var fsOut = File.OpenWrite("output.txt"))
            using (var sw = new StreamWriter(fsOut, Encoding.UTF8))
            {
                foreach (var item in table)
                {
                    //Console.WriteLine("{0}: {1}", item.ID, item.DirtyWord);
                    //sw.WriteLine("{0,-8}{1,-40}{2}", item.ID, item.DirtyWord, item.LanguageID);
                }

                foreach (var item in table)
                {
                    //Console.WriteLine("{0}: {1}", item.ID, item.DirtyWord);
                    //sw.WriteLine("{0,-8}{1,-40}{2}", item.ID, item.DirtyWord, item.LanguageID);
                }

                foreach (var item in table)
                {
                    //Console.WriteLine("{0}: {1}", item.ID, item.DirtyWord);
                    //sw.WriteLine("{0,-8}{1,-40}{2}", item.ID, item.DirtyWord, item.LanguageID);
                }

                foreach (var item in table)
                {
                    //Console.WriteLine("{0}: {1}", item.ID, item.DirtyWord);
                    //sw.WriteLine("{0,-8}{1,-40}{2}", item.ID, item.DirtyWord, item.LanguageID);
                }

                foreach (var item in table)
                {
                    //Console.WriteLine("{0}: {1}", item.ID, item.DirtyWord);
                    //sw.WriteLine("{0,-8}{1,-40}{2}", item.ID, item.DirtyWord, item.LanguageID);
                }
            }
            timer.Stop();
            Console.WriteLine("Completed in {0}ms", timer.ElapsedMilliseconds);

            Console.WriteLine("Done; press <enter> to exit.");
            Console.ReadLine();
        }
        internal DbcStringReference(DbcTable owner, int position)
        {
            if (owner == null)
                throw new ArgumentNullException("owner");
            if (position < 0)
                throw new ArgumentException("position");

            _owner = new WeakReference<DbcTable>(owner);
            _pos = position;
            _val = new Lazy<string>(() =>
            {
                DbcTable table;
                if (!_owner.TryGetTarget(out table))
                    throw new ObjectDisposedException("DbcTable");

                return table.GetString(_pos);
            });
        }
Beispiel #5
0
        internal DbcStringReference(DbcTable owner, int position)
        {
            if (owner == null)
            {
                throw new ArgumentNullException("owner");
            }
            if (position < 0)
            {
                throw new ArgumentException("position");
            }

            _owner = new WeakReference <DbcTable>(owner);
            _pos   = position;
            _val   = new Lazy <string>(() =>
            {
                DbcTable table;
                if (!_owner.TryGetTarget(out table))
                {
                    throw new ObjectDisposedException("DbcTable");
                }

                return(table.GetString(_pos));
            });
        }
Beispiel #6
0
 internal DbcRecord(int position, int index, DbcTable owner)
 {
     _position = position;
     _index    = index;
     _owner    = new WeakReference <DbcTable>(owner);
 }
Beispiel #7
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (ofdOpenDbc.ShowDialog() == DialogResult.OK)
            {
                if (_table != null)
                {
                    dgv.Rows.Clear();
                    dgv.Columns.Clear();

                    _table.Dispose();
                    _table = null;
                }

                FileStream fs = File.OpenRead(ofdOpenDbc.FileName);
                _table = new DbcTable(fs, true);
                _dbcFileName = Path.GetFileName(ofdOpenDbc.FileName);
                _dbcFilePath = Path.GetDirectoryName(ofdOpenDbc.FileName);

                var testSchema = Path.Combine(_dbcFilePath, _dbcFileName + "schema");
                if (File.Exists(testSchema))
                {
                    using (var file = File.OpenRead(testSchema))
                    {
                        _schema = DbcSchema.Load(file, _table.ColumnCount);
                        _schemaFileName = testSchema;
                    }

                    BindSchema();
                }
                else
                {
                    CreateDefaultSchema();
                    _schemaFileName = null;
                }
                PopulateDbc();
            }
        }
Beispiel #8
0
 internal DbcRecord(int position, int index, DbcTable owner)
 {
     _position = position;
     _index = index;
     _owner = new WeakReference<DbcTable>(owner);
 }