public static void Writer(DbDebugItem <int> debug, AbstractDb <int> db) { if (debug.FileType == FileType.Txt) { DbIOMethods.DbWriterComma(debug, db); } else if (debug.FileType == FileType.Yaml) { try { var lines = new YamlParser(debug.OldPath, ParserMode.Write, "Id"); if (lines.Output == null) { return; } lines.Remove(db); foreach (ReadableTuple <int> tuple in db.Table.FastItems.Where(p => !p.Normal).OrderBy(p => p.GetKey <int>())) { string key = tuple.Key.ToString(CultureInfo.InvariantCulture); StringBuilder builder = new StringBuilder(); WriteEntryYaml(builder, tuple); lines.Write(key, builder.ToString().Trim('\r', '\n')); } lines.WriteFile(debug.FilePath); } catch (Exception err) { debug.ReportException(err); } } }
public static void Writer(DbDebugItem <int> debug, AbstractDb <int> db) { if (debug.FileType == FileType.Conf) { DbIOMethods.DbIOWriterConf(debug, db, (q, r) => WriteEntry(db, q, r)); } else if (debug.FileType == FileType.Txt) { DbIOMethods.DbWriterComma(debug, db); } }
public static void Writer(DbDebugItem <int> debug, AbstractDb <int> db) { if (debug.FileType == FileType.Conf) { DbIOMethods.DbIOWriter(debug, db, (q, r) => WriteEntry(db, q, r)); } else if (debug.FileType == FileType.Txt) { DbIOMethods.DbWriterComma(debug, db); } else if (debug.FileType == FileType.Yaml) { var itemDb = SdeEditor.Instance.ProjectDatabase.GetMetaTable <int>(ServerDbs.Items); DbIOMethods.DbIOWriter(debug, db, (r, q) => WriteEntryYaml(r, q, itemDb)); } }
public static void DbItemsWriter(DbDebugItem <int> debug, AbstractDb <int> db) { try { StringBuilder builder = new StringBuilder(); if (debug.FileType == FileType.Txt) { if (DbPathLocator.GetServerType() == ServerType.RAthena) { DbIOMethods.DbWriterComma(debug, db, 0, ServerItemAttributes.OnUnequipScript.Index + 1, (tuple, items) => { if (db.ProjectDatabase.IsRenewal) { string value = tuple.GetValue <string>(ServerItemAttributes.Matk) ?? ""; if (value == "" || value == "0") { return; } string atk = items[ServerItemAttributes.Attack.Index].ToString(); items[ServerItemAttributes.Attack.Index] = (atk == "" ? "0" : atk) + ":" + value; } }); return; } DbItemsWriterSub(builder, db, db.Table.FastItems.OrderBy(p => p.GetKey <int>()), ServerType.RAthena); FtpHelper.WriteAllText(debug.FilePath, builder.ToString()); } else if (debug.FileType == FileType.Conf) { DbIOMethods.DbIOWriterConf(debug, db, (r, q) => WriteEntry(db, r, q)); } else if (debug.FileType == FileType.Sql) { SqlParser.DbSqlItems(debug, db); } } catch (Exception err) { debug.ReportException(err); } }
public static void DbSqlMobs(DbDebugItem <int> debug, AbstractDb <int> db) { DbSqlWriter writer = new DbSqlWriter(); writer.Init(debug); if (DbPathLocator.DetectPath(debug.DbSource).EndsWith(".conf")) { object value = db.Attached["EntireRewrite"]; db.Attached["EntireRewrite"] = true; DbIOMethods.DbWriterComma(debug, db); db.Attached["EntireRewrite"] = value; } else { DbIOMethods.DbWriterComma(debug, db); } if (debug.DestinationServer == ServerType.RAthena) { writer.AppendHeader(ResourceString.Get("RAthenaMobDbSqlHeader")); } else if (debug.DestinationServer == ServerType.Hercules) { writer.AppendHeader(ResourceString.Get("HerculesMobDbSqlHeader"), writer.TableName.Replace("_re", "")); writer.TableName = "mob_db"; } foreach (string line in writer.Read()) { string[] elements = TextFileHelper.ExcludeBrackets(line.Trim('\t')); if (!_getMob(writer.IsHercules, writer.TableName, writer.Builder, elements)) { writer.Line(writer.IsHercules ? line.ReplaceFirst("//", "--" + (writer.NumberOfLinesProcessed > 1 ? " " : "")) : line.ReplaceFirst("//", "#")); } else { writer.NumberOfLinesProcessed++; } } writer.Write(); }
public static void Writer(DbDebugItem <int> debug, AbstractDb <int> db) { if (debug.FileType == FileType.Txt) { DbIOMethods.DbWriterComma(debug, db, 0, db.TabGenerator.MaxElementsToCopyInCustomMethods); //DbIOMethods.DbWriterComma(debug, db, 0, 22); } //else if (debug.FileType == FileType.Conf) // DbIOMethods.DbIOWriter(debug, db, WriteEntry); else 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, "Mob"); if (lines.Output == null) { return; } lines.Remove(db, v => DbIOUtils.Id2Name(mobDb, ServerMobAttributes.AegisName, v.ToString(CultureInfo.InvariantCulture))); foreach (ReadableTuple <int> tuple in db.Table.FastItems.Where(p => !p.Normal).OrderBy(p => p.GetKey <int>())) { string key = tuple.Key.ToString(CultureInfo.InvariantCulture); StringBuilder builder = new StringBuilder(); WriteEntryYaml(builder, tuple, itemDb, mobDb); lines.Write(DbIOUtils.Id2Name(mobDb, ServerMobAttributes.AegisName, key), builder.ToString().Trim('\r', '\n')); } lines.WriteFile(debug.FilePath); } catch (Exception err) { debug.ReportException(err); } } }