예제 #1
0
        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);
            }
        }