Example #1
0
        public static void DbIOWriterConf <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> db, DbIOWriteEntryMethod <TKey> writeEntryMethod)
        {
            try {
                if (debug.FileType == FileType.Conf)
                {
                    try {
                        var lines = new LibconfigParser(debug.OldPath, LibconfigMode.Write);
                        lines.Remove(db);

                        foreach (ReadableTuple <TKey> tuple in db.Table.FastItems.Where(p => !p.Normal).OrderBy(p => p.GetKey <TKey>()))
                        {
                            string key = tuple.Key.ToString();

                            StringBuilder builder = new StringBuilder();
                            writeEntryMethod(builder, tuple);
                            lines.Write(key, builder.ToString());
                        }

                        lines.WriteFile(debug.FilePath);
                    }
                    catch (Exception err) {
                        debug.ReportException(err);
                    }
                }
            }
            catch (Exception err) {
                debug.ReportException(err);
            }
        }
Example #2
0
        public static void Writer <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> db)
        {
            if (debug.FileType == FileType.Conf)
            {
                try {
                    var lines = new LibconfigParser(debug.OldPath, LibconfigMode.Write);
                    lines.Remove(db);
                    string line;

                    foreach (ReadableTuple <TKey> tuple in db.Table.FastItems.Where(p => !p.Normal).OrderBy(p => p.GetKey <TKey>()))
                    {
                        int           key     = tuple.GetKey <int>();
                        StringBuilder builder = new StringBuilder();
                        WriteEntry(builder, tuple);
                        line = builder.ToString();
                        lines.Write(key.ToString(CultureInfo.InvariantCulture), line);
                    }

                    lines.WriteFile(debug.FilePath);
                }
                catch (Exception err) {
                    debug.ReportException(err);
                }
            }
            else
            {
                int format = db.GetAttacked <int>("rAthenaFormat");

                try {
                    IntLineStream lines = new IntLineStream(debug.OldPath);
                    lines.Remove(db);
                    string line;

                    foreach (ReadableTuple <TKey> tuple in db.Table.FastItems.Where(p => !p.Normal).OrderBy(p => p.GetKey <TKey>()))
                    {
                        int key = tuple.GetKey <int>();

                        if (format == 18)
                        {
                            line = string.Join(",", tuple.GetRawElements().Select(p => (p ?? "").ToString()).ToArray());
                        }
                        else
                        {
                            line = string.Join(",", tuple.GetRawElements().Take(ServerQuestsAttributes.MobId1.Index).Concat(new object[] { tuple.GetRawValue(ServerQuestsAttributes.QuestTitle.Index) }).Select(p => (p ?? "").ToString()).ToArray());
                        }

                        lines.Write(key, line);
                    }

                    lines.WriteFile(debug.FilePath);
                }
                catch (Exception err) {
                    debug.ReportException(err);
                }
            }
        }
Example #3
0
        public static void Writer <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> db)
        {
            if (debug.FileType == FileType.Conf)
            {
                try {
                    var lines = new LibconfigParser(debug.OldPath, LibconfigMode.Write);
                    lines.Remove(db);

                    foreach (ReadableTuple <TKey> tuple in db.Table.FastItems.Where(p => !p.Normal).OrderBy(p => p.GetKey <TKey>()))
                    {
                        string key = tuple.GetKey <string>();

                        StringBuilder builder = new StringBuilder();
                        WriteEntry(builder, tuple);
                        lines.Write(key, builder.ToString());
                    }

                    lines.WriteFile(debug.FilePath);
                }
                catch (Exception err) {
                    debug.ReportException(err);
                }
            }
            else
            {
                try {
                    StringLineStream lines = new StringLineStream(debug.OldPath);
                    lines.Remove(db);
                    string line;

                    foreach (ReadableTuple <TKey> tuple in db.Table.FastItems.Where(p => !p.Normal).OrderBy(p => p.GetKey <TKey>()))
                    {
                        string key = tuple.GetKey <string>();

                        int item2 = tuple.GetValue <int>(2);

                        if (item2 == 0)
                        {
                            line = string.Join("\t", tuple.GetRawElements().Take(2).Select(p => (p ?? "").ToString()).ToArray());
                        }
                        else
                        {
                            line = string.Join("\t", tuple.GetRawElements().Take(3).Select(p => (p ?? "").ToString()).ToArray());
                        }

                        lines.Write(key, line);
                    }

                    lines.WriteFile(debug.FilePath);
                }
                catch (Exception err) {
                    debug.ReportException(err);
                }
            }
        }
Example #4
0
        public static void Writer <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> db)
        {
            if (debug.FileType == FileType.Yaml)
            {
                var itemDb = SdeEditor.Instance.ProjectDatabase.GetMetaTable <int>(ServerDbs.Items);
                var mobDb  = SdeEditor.Instance.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs);

                try {
                    var lines = new YamlParser(debug.OldPath, ParserMode.Write, "Id");

                    if (lines.Output == null)
                    {
                        return;
                    }

                    lines.Remove(db, v => DbIOUtils.Id2Name(mobDb, ServerMobAttributes.AegisName, v.ToString()));

                    foreach (ReadableTuple <TKey> tuple in db.Table.FastItems.Where(p => !p.Normal).OrderBy(p => p.GetKey <int>()))
                    {
                        string key = tuple.Key.ToString();

                        StringBuilder builder = new StringBuilder();
                        WriteEntryYaml(builder, tuple, itemDb, mobDb);
                        lines.Write(key, builder.ToString().Trim('\r', '\n'));
                    }

                    lines.WriteFile(debug.FilePath);
                }
                catch (Exception err) {
                    debug.ReportException(err);
                }
            }
            else if (debug.FileType == FileType.Conf)
            {
                try {
                    var lines = new LibconfigParser(debug.OldPath, ParserMode.Write);
                    lines.Remove(db);
                    string line;

                    foreach (ReadableTuple <TKey> tuple in db.Table.FastItems.Where(p => !p.Normal).OrderBy(p => p.GetKey <TKey>()))
                    {
                        int           key     = tuple.GetKey <int>();
                        StringBuilder builder = new StringBuilder();
                        WriteEntry(builder, tuple);
                        line = builder.ToString();
                        lines.Write(key.ToString(CultureInfo.InvariantCulture), line);
                    }

                    lines.WriteFile(debug.FilePath);
                }
                catch (Exception err) {
                    debug.ReportException(err);
                }
            }
            else
            {
                int format = db.GetAttacked <int>("rAthenaFormat");

                try {
                    IntLineStream lines = new IntLineStream(debug.OldPath);
                    lines.Remove(db);
                    string line;

                    foreach (ReadableTuple <TKey> tuple in db.Table.FastItems.Where(p => !p.Normal).OrderBy(p => p.GetKey <TKey>()))
                    {
                        int key = tuple.GetKey <int>();

                        if (format == 18)
                        {
                            line = string.Join(",", tuple.GetRawElements().Take(18).Select(p => (p ?? "").ToString()).ToArray());
                        }
                        else
                        {
                            line = string.Join(",", tuple.GetRawElements().Take(ServerQuestsAttributes.MobId1.Index).Concat(new object[] { tuple.GetRawValue(ServerQuestsAttributes.QuestTitle.Index) }).Select(p => (p ?? "").ToString()).ToArray());
                        }

                        lines.Write(key, line);
                    }

                    lines.WriteFile(debug.FilePath);
                }
                catch (Exception err) {
                    debug.ReportException(err);
                }
            }
        }