public static void DbItemGroups <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> db) { foreach (DbAttribute attribute in ServerItemGroupSubAttributes.AttributeList.Attributes) { db.Attached[attribute.DisplayName] = false; } if (debug.FileType == FileType.Txt) { if (db.Attached["FromUserRawInput"] != null && (bool)db.Attached["FromUserRawInput"]) { _loadItemsGroupdDb(db, debug.FilePath); return; } using (StreamReader reader = new StreamReader(File.OpenRead(debug.FilePath))) { string line; while (!reader.EndOfStream) { line = reader.ReadLine(); if (line != null && line.StartsWith("import: ")) { string dbPath = AllLoaders.DetectPathAll(line.Replace("import: ", "")); if (dbPath == null) { ErrorHandler.HandleException("Couldn't find the file '" + line.Replace("import: ", "") + "'."); } else { db.Attached[dbPath] = new Tuple <string, HashSet <int> >(line.Replace("import: ", ""), new HashSet <int>()); _loadItemsGroupdDb(db, dbPath); } } } } } else if (debug.FileType == FileType.Conf) { ItemGroupParser itemHelper = new ItemGroupParser(); Table <int, ReadableTuple <int> > itemsDb = db.GetMeta <int>(ServerDbs.Items); int index = ServerItemAttributes.AegisName.Index; var table = db.Table; var items = itemsDb.FastItems; // The reverse table is used for an optimization (~3 seconds to ~50 ms) // All the items are stored in a dictionary by their name instead of their ID TkDictionary <string, int> reverseTable = new TkDictionary <string, int>(); foreach (var item in items) { reverseTable[item.GetStringValue(index).ToLowerInvariant()] = item.GetKey <int>(); } #if SDE_DEBUG Z.StopAndRemoveWithoutDisplay(-1); Z.StopAndRemoveWithoutDisplay(-2); Z.StopAndRemoveWithoutDisplay(-3); CLHelper.CR(-2); #endif foreach (string elements in TextFileHelper.GetElementsByParenthesis(File.ReadAllBytes(debug.FilePath))) { #if SDE_DEBUG CLHelper.CS(-2); CLHelper.CR(-1); CLHelper.CR(-3); #endif if (!itemHelper.Init(debug, elements)) { return; } #if SDE_DEBUG CLHelper.CS(-3); #endif try { Tuple tupleItem = itemsDb.TryGetTuple(reverseTable[itemHelper.Id.ToLowerInvariant()]); if (tupleItem == null) { if (itemHelper.Id.StartsWith("ID")) { int ival; if (Int32.TryParse(itemHelper.Id.Substring(2), out ival)) { tupleItem = itemsDb.TryGetTuple(ival); } if (tupleItem == null) { debug.ReportIdException("Item ID '" + ival + "' couldn't be found.", itemHelper.Id, ErrorLevel.Critical); continue; } } if (tupleItem == null) { debug.ReportIdException("Item ID '" + itemHelper.Id + "' couldn't be found.", itemHelper.Id, ErrorLevel.Critical); continue; } } TKey itemId = tupleItem.GetKey <TKey>(); if (!table.ContainsKey(itemId)) { ReadableTuple <TKey> tuple = new ReadableTuple <TKey>(itemId, db.AttributeList); tuple.SetRawValue(ServerItemGroupAttributes.Table, new Dictionary <int, ReadableTuple <int> >()); table.Add(itemId, tuple); } for (int i = 0; i < itemHelper.Quantities.Count; i++) { string onameId = itemHelper.Quantities[i].Item1; string orate = itemHelper.Quantities[i].Item2; int id = 0; int rate; tupleItem = itemsDb.TryGetTuple(reverseTable[onameId.ToLowerInvariant()]); if (tupleItem == null) { if (onameId.StartsWith("ID")) { if (!Int32.TryParse(onameId.Substring(2), out id)) { debug.ReportIdException("Item ID '" + itemHelper.Quantities[i].Item1 + "' couldn't be found in group '" + itemHelper.Id + "'.", itemHelper.Id, ErrorLevel.Critical); continue; } } else { debug.ReportIdException("Item ID '" + itemHelper.Quantities[i].Item1 + "' couldn't be found in group '" + itemHelper.Id + "'.", itemHelper.Id, ErrorLevel.Critical); continue; } } int nameId = tupleItem == null ? id : tupleItem.GetKey <int>(); Int32.TryParse(orate, out rate); Dictionary <int, ReadableTuple <int> > dico = (Dictionary <int, ReadableTuple <int> >)table.GetRaw(itemId, ServerItemGroupAttributes.Table); ReadableTuple <int> tuple = new ReadableTuple <int>(nameId, ServerItemGroupSubAttributes.AttributeList); tuple.SetRawValue(ServerItemGroupSubAttributes.Rate, rate); dico[nameId] = tuple; } } catch { if (!debug.ReportIdException(itemHelper.Id)) { return; } } #if SDE_DEBUG CLHelper.CS(-1); CLHelper.CR(-2); #endif } #if SDE_DEBUG CLHelper.CS(-2); CLHelper.CS(-3); CLHelper.WA = ", method core : " + CLHelper.CD(-1) + "ms, loop getter : " + CLHelper.CD(-2) + "ms, internal parser : " + CLHelper.CD(-3); #endif } }