public static void Writer(DbDebugItem <int> debug, AbstractDb <int> db, int groupId) { bool isHercules = (db.Attached[ServerMobBossAttributes.MobGroup.DisplayName] != null && !(bool)db.Attached[ServerMobBossAttributes.MobGroup.DisplayName]); try { IntLineStream lines = new IntLineStream(debug.OldPath, isHercules ? 0 : 1); bool isChanged = lines.Remove2(db, groupId); string line; var tupleParent = db.Table.TryGetTuple(groupId); if (tupleParent == null) { // File content was deleted lines.ClearAfterComments(); lines.WriteFile(debug.FilePath); return; } var dico = (Dictionary <int, ReadableTuple <int> >)tupleParent.GetRawValue(ServerMobGroupAttributes.Table.Index); var values = dico.Values.Where(p => !p.Normal).OrderBy(p => p.Key).ToList(); if (values.Count == 0 && !isChanged) { return; } foreach (ReadableTuple <int> tuple in values) { int key = tuple.Key; var rawElements = tuple.GetRawElements().Select(p => (p ?? "").ToString()).ToArray(); if (isHercules) { line = string.Join(",", new string[] { rawElements[0], rawElements[1], rawElements[2] }); } else { line = string.Join(",", new string[] { _groupIdToConst(groupId), rawElements[0], rawElements[1], rawElements[2] }); } lines.Write(key, line); } lines.WriteFile(debug.FilePath); } catch (Exception err) { debug.ReportException(err); } }
public static void DbWriterComma(DbDebugItem <int> debug, AbstractDb <int> db, int from, int to, Action <ReadableTuple <int>, List <object> > funcItems) { try { IntLineStream lines = new IntLineStream(debug.OldPath); if (db.Attached["EntireRewrite"] != null && (bool)db.Attached["EntireRewrite"]) { lines.ClearAfterComments(); } lines.Remove(db); string line; for (int i = from; i < to; i++) { DbAttribute att = db.AttributeList.Attributes[i]; if ((att.Visibility & VisibleState.Hidden) == VisibleState.Hidden) { to = i; break; } } List <DbAttribute> attributes = new List <DbAttribute>(db.AttributeList.Attributes.Skip(from).Take(to)); attributes.Reverse(); List <DbAttribute> attributesToRemove = (from attribute in attributes where db.Attached[attribute.DisplayName] != null let isLoaded = (bool)db.Attached[attribute.DisplayName] where !isLoaded select attribute).ToList(); IEnumerable <ReadableTuple <int> > list; if (db.Attached["EntireRewrite"] != null && (bool)db.Attached["EntireRewrite"]) { list = db.Table.FastItems.Where(p => !p.Deleted).OrderBy(p => p.Key); } else { list = db.Table.FastItems.Where(p => !p.Normal).OrderBy(p => p.Key); } foreach (ReadableTuple <int> tuple in list) { int key = tuple.GetKey <int>(); List <object> rawElements = tuple.GetRawElements().Skip(from).Take(to).ToList(); funcItems(tuple, rawElements); foreach (var attribute in attributesToRemove) { rawElements.RemoveAt(attribute.Index - from); } line = string.Join(",", rawElements.Select(p => (p ?? "").ToString()).ToArray()); lines.Write(key, line); } lines.WriteFile(debug.FilePath); } catch (Exception err) { debug.ReportException(err); } }