Exemplo n.º 1
0
        public static void DbItemsStack <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> db)
        {
            try {
                IntLineStream lines = new IntLineStream(debug.OldPath);
                lines.Remove(db);
                string line;

                TkDictionary <TKey, string[]> phantom = _getPhantomTable(debug);

                if (phantom != null)
                {
                    var itemDb = debug.AbsractDb.GetDb <TKey>(ServerDbs.Items).Table;

                    // Check if the phantom values differ from the Items1
                    foreach (var tuple in phantom)
                    {
                        if (debug.AbsractDb.Table.ContainsKey(tuple.Key))
                        {
                            continue;
                        }

                        var key      = tuple.Key;
                        var elements = tuple.Value;
                        var tuple1   = itemDb.TryGetTuple(key);

                        if (tuple1 != null)
                        {
                            string val1 = tuple1.GetValue <string>(ServerItemAttributes.Stack);
                            string val2 = elements[1];

                            if (val1 != val2)
                            {
                                lines.Delete(tuple1.GetKey <int>());
                            }
                        }
                    }
                }

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

                    string item1 = tuple.GetValue <string>(ServerItemAttributes.Stack);

                    if (item1 == "")
                    {
                        lines.Delete(key);
                        continue;
                    }

                    line = String.Join(",", new string[] { key.ToString(CultureInfo.InvariantCulture), item1 }.ToArray());
                    lines.Write(key, line);
                }

                lines.WriteFile(debug.FilePath);
            }
            catch (Exception err) {
                debug.ReportException(err);
            }
        }
Exemplo n.º 2
0
        public static void DbItemsBuyingStore <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> db)
        {
            try {
                IntLineStream lines = new IntLineStream(db.UsePreviousOutput ? debug.FilePath : 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>();

                    bool item1 = tuple.GetValue <bool>(ServerItemAttributes.BuyingStore);

                    if (!item1)
                    {
                        lines.Delete(key);
                        continue;
                    }

                    line = key.ToString(CultureInfo.InvariantCulture) + "  // " + tuple.GetValue <string>(ServerItemAttributes.AegisName);
                    lines.Write(key, line);
                }

                lines.WriteFile(debug.FilePath);
            }
            catch (Exception err) {
                debug.ReportException(err);
            }
        }
Exemplo n.º 3
0
        public static void DbSkillsCastCommaRange <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> db, int from, int length)
        {
            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>();

                    List <string> items = tuple.GetRawElements().Skip(from).Take(length).Select(p => p.ToString()).ToList();

                    if (items.All(p => p == "0"))
                    {
                        lines.Delete(key);
                        continue;
                    }

                    line = string.Join(",", new string[] { key.ToString(CultureInfo.InvariantCulture) }.Concat(items).ToArray());
                    lines.Write(key, line);
                }

                lines.WriteFile(debug.FilePath);
            }
            catch (Exception err) {
                debug.ReportException(err);
            }
        }
Exemplo n.º 4
0
        public static void DbItemsStack <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> db)
        {
            try {
                IntLineStream lines = new IntLineStream(db.UsePreviousOutput ? debug.FilePath : 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>();

                    string item1 = tuple.GetValue <string>(ServerItemAttributes.Stack);

                    if (item1 == "")
                    {
                        lines.Delete(key);
                        continue;
                    }

                    line = string.Join(",", new string[] { key.ToString(CultureInfo.InvariantCulture), item1 }.ToArray());
                    lines.Write(key, line);
                }

                lines.WriteFile(debug.FilePath);
            }
            catch (Exception err) {
                debug.ReportException(err);
            }
        }
Exemplo n.º 5
0
        public static void DbItemsNouse <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> db)
        {
            try {
                IntLineStream lines = new IntLineStream(db.UsePreviousOutput ? debug.FilePath : debug.OldPath);
                lines.Remove(db);
                string line;
                NoUse  nouse = new NoUse();

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

                    string item1 = tuple.GetValue <string>(ServerItemAttributes.NoUse);
                    nouse.Override = ParserHelper.GetVal(item1, "override", "100");
                    nouse.Sitting  = ParserHelper.GetVal(item1, "sitting", "false");

                    if (nouse.Override == "100" && nouse.Sitting == "false")
                    {
                        lines.Delete(key);
                        continue;
                    }

                    line = string.Join(",", new string[] { key.ToString(CultureInfo.InvariantCulture), nouse.Sitting == "true" ? "1" : "0", nouse.Override }.ToArray());
                    lines.Write(key, line);
                }

                lines.WriteFile(debug.FilePath);
            }
            catch (Exception err) {
                debug.ReportException(err);
            }
        }
Exemplo n.º 6
0
        public static void DbItemsBuyingStore <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> db)
        {
            try {
                IntLineStream lines = new IntLineStream(debug.OldPath);
                lines.Remove(db);
                string line;

                TkDictionary <TKey, string[]> phantom = _getPhantomTable(debug);

                if (phantom != null)
                {
                    var itemDb = debug.AbsractDb.GetDb <TKey>(ServerDbs.Items).Table;

                    // Check if the phantom values differ from the Items1
                    foreach (var tuple in phantom)
                    {
                        if (debug.AbsractDb.Table.ContainsKey(tuple.Key))
                        {
                            continue;
                        }

                        var key    = tuple.Key;
                        var tuple1 = itemDb.TryGetTuple(key);

                        if (tuple1 != null)
                        {
                            bool val1 = tuple1.GetValue <bool>(ServerItemAttributes.BuyingStore);

                            if (val1 != true)
                            {
                                lines.Delete(tuple1.GetKey <int>());
                            }
                        }
                    }
                }

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

                    bool item1 = tuple.GetValue <bool>(ServerItemAttributes.BuyingStore);

                    if (!item1)
                    {
                        lines.Delete(key);
                        continue;
                    }

                    line = key.ToString(CultureInfo.InvariantCulture) + "  // " + tuple.GetValue <string>(ServerItemAttributes.AegisName);
                    lines.Write(key, line);
                }

                lines.WriteFile(debug.FilePath);
            }
            catch (Exception err) {
                debug.ReportException(err);
            }
        }
Exemplo n.º 7
0
        public static void DbIntCommaRange <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> db, int from, int to)
        {
            try {
                IntLineStream lines = new IntLineStream(debug.OldPath);
                lines.Remove(db);
                string line;

                for (int i = from; i < to; i++)
                {
                    DbAttribute att = db.AttributeList.Attributes[i];

                    if (att.Visibility == 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 <TKey> > list;

                if (db.Attached["EntireRewrite"] != null && (bool)db.Attached["EntireRewrite"])
                {
                    list = db.Table.FastItems.Where(p => !p.Deleted).OrderBy(p => p.GetKey <TKey>());
                }
                else
                {
                    list = db.Table.FastItems.Where(p => !p.Normal).OrderBy(p => p.GetKey <TKey>());
                }

                foreach (ReadableTuple <TKey> tuple in list)
                {
                    int           key         = tuple.GetKey <int>();
                    List <object> rawElements = tuple.GetRawElements().Skip(from).Take(to).ToList();

                    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);
            }
        }
Exemplo n.º 8
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);
                }
            }
        }
Exemplo n.º 9
0
        public static void DbSkillsCommaRange <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> db, int from, int length)
        {
            try {
                IntLineStream lines = new IntLineStream(debug.OldPath);
                lines.Remove(db);
                ServerType serverType;

                if (db.Attached["DbCommaLoaderSkill.IsRAthena"] == null)
                {
                    serverType = ServerType.Hercules;
                }
                else
                {
                    serverType = (bool)db.Attached["DbCommaLoaderSkill.IsRAthena"] ? ServerType.RAthena : ServerType.Hercules;
                }

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

                        List <string> items = tuple.GetRawElements().Skip(from).Take(length).Select(p => p.ToString()).ToList();
                        lines.Write(key, string.Join(",", new string[] { key.ToString(CultureInfo.InvariantCulture) }.Concat(items).ToArray()));
                    }
                }
                else
                {
                    foreach (ReadableTuple <TKey> tuple in db.Table.FastItems.Where(p => !p.Normal).OrderBy(p => p.GetKey <TKey>()))
                    {
                        int key = tuple.GetKey <int>();

                        var items = tuple.GetRawElements().Skip(0).Take(length + 1).Select(p => p.ToString()).ToList();
                        items.RemoveAt(ServerSkillAttributes.Inf3.Index);

                        lines.Write(key, string.Join(",", items.ToArray()));
                    }
                }

                lines.WriteFile(debug.FilePath);
            }
            catch (Exception err) {
                debug.ReportException(err);
            }
        }
Exemplo n.º 10
0
        public static void DbSkillsNoCastCommaRange <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> db, int from, int length)
        {
            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>();

                    string item1 = tuple.GetValue <string>(from);
                    string item2 = tuple.GetValue <string>(from + 1);

                    if (item1 != "0" && item2 == "0")
                    {
                        line = string.Join(",", new string[] { key.ToString(CultureInfo.InvariantCulture), item1 });
                    }
                    else if (item1 == "0" && item2 == "0")
                    {
                        lines.Delete(key);
                        continue;
                    }
                    else
                    {
                        line = string.Join(",", new string[] { key.ToString(CultureInfo.InvariantCulture), item1, item2 });
                    }

                    lines.Write(key, line);
                }

                lines.WriteFile(debug.FilePath);
            }
            catch (Exception err) {
                debug.ReportException(err);
            }
        }
Exemplo n.º 11
0
        public static void DbItemsCommaRange <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> db, int from, int length, string defaultValue, Func <ReadableTuple <TKey>, List <string>, string, string> append)
        {
            try {
                IntLineStream lines = new IntLineStream(debug.OldPath);
                lines.Remove(db);
                string line;

                TkDictionary <TKey, string[]> phantom = _getPhantomTable(debug);

                if (phantom != null)
                {
                    var itemDb = debug.AbsractDb.GetDb <TKey>(ServerDbs.Items).Table;

                    // Check if the phantom values differ from the Items1
                    foreach (var tuple in phantom)
                    {
                        if (debug.AbsractDb.Table.ContainsKey(tuple.Key))
                        {
                            continue;
                        }

                        var key      = tuple.Key;
                        var elements = tuple.Value;
                        var tuple1   = itemDb.TryGetTuple(key);

                        if (tuple1 != null)
                        {
                            string val1 = tuple1.GetValue <string>(@from);
                            string val2 = elements[1];

                            if (val1 != val2)
                            {
                                lines.Delete(tuple1.GetKey <int>());
                            }
                        }
                    }
                }

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

                    List <string> items = tuple.GetRawElements().Skip(@from).Take(length).Select(p => p.ToString()).ToList();

                    if (items.All(p => p == defaultValue))
                    {
                        lines.Delete(key);
                        continue;
                    }

                    if (append != null)
                    {
                        line = append(tuple, items, String.Join(",", new string[] { key.ToString(CultureInfo.InvariantCulture) }.Concat(items).ToArray()));
                    }
                    else
                    {
                        line = String.Join(",", new string[] { key.ToString(CultureInfo.InvariantCulture) }.Concat(items).ToArray());
                    }
                    lines.Write(key, line);
                }

                lines.WriteFile(debug.FilePath);
            }
            catch (Exception err) {
                debug.ReportException(err);
            }
        }
Exemplo n.º 12
0
        public static void DbItemsTrade <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> db)
        {
            try {
                IntLineStream lines = new IntLineStream(debug.OldPath);
                lines.Remove(db);
                string line;

                TkDictionary <TKey, string[]> phantom = _getPhantomTable(debug);

                if (phantom != null)
                {
                    var itemDb = debug.AbsractDb.GetDb <TKey>(ServerDbs.Items).Table;

                    // Check if the phantom values differ from the Items1
                    foreach (var tuple in phantom)
                    {
                        if (debug.AbsractDb.Table.ContainsKey(tuple.Key))
                        {
                            continue;
                        }

                        var key      = tuple.Key;
                        var elements = tuple.Value;
                        var tuple1   = itemDb.TryGetTuple(key);

                        if (tuple1 != null)
                        {
                            int val1 = tuple1.GetIntNoThrow(ServerItemAttributes.TradeFlag);
                            int val2 = FormatConverters.IntOrHexConverter(elements[1]);

                            int val3 = tuple1.GetIntNoThrow(ServerItemAttributes.TradeOverride);
                            int val4 = FormatConverters.IntOrHexConverter(elements[2]);

                            // There is no flag set
                            if (val1 != val2 || val3 != val4)
                            {
                                lines.Delete(tuple1.GetKey <int>());
                            }
                        }
                    }
                }

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

                    string overrideValue = tuple.GetValue <string>(ServerItemAttributes.TradeOverride);
                    string flagValue     = tuple.GetValue <string>(ServerItemAttributes.TradeFlag);

                    if (flagValue == "0")
                    {
                        if (overrideValue == "100" || SdeAppConfiguration.DbTradeIgnoreOverride)
                        {
                            lines.Delete(key);
                            continue;
                        }
                    }

                    line = String.Join(",", new string[] { key.ToString(CultureInfo.InvariantCulture), flagValue, overrideValue }.ToArray());

                    if (SdeAppConfiguration.AddCommentForItemTrade)
                    {
                        line += "\t// " + tuple.GetValue <string>(ServerItemAttributes.AegisName);
                    }

                    lines.Write(key, line);
                }

                lines.WriteFile(debug.FilePath);
            }
            catch (Exception err) {
                debug.ReportException(err);
            }
        }
Exemplo n.º 13
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);
                }
            }
        }