public void LoadItemInfo() { var effectcache = new Dictionary <string, ItemUseEffectInfo>(); ItemUseEffects = new Dictionary <ushort, ItemUseEffectInfo>(); DataTable effectid = null; DataTable dataItem = null; using (var dbClient = Program.DatabaseManager.GetClient()) { effectid = dbClient.ReadDataTable("SELECT * FROM data_itemuseeffect"); dataItem = dbClient.ReadDataTable("SELECT * FROM data_iteminfo"); } if (effectid != null) { foreach (DataRow row in effectid.Rows) { string inxname; var info = ItemUseEffectInfo.Load(row, out inxname); effectcache.Add(inxname, info); } } ItemsByID = new Dictionary <ushort, ItemInfo>(); ItemsByName = new Dictionary <string, ItemInfo>(); if (dataItem != null) { foreach (DataRow row in dataItem.Rows) { var info = ItemInfo.Load(row); if (ItemsByID.ContainsKey(info.ItemID) || ItemsByName.ContainsKey(info.InxName)) { Log.WriteLine(LogLevel.Warn, "Duplicate item found ID: {0} ({1}).", info.ItemID, info.InxName); continue; } ItemsByID.Add(info.ItemID, info); ItemsByName.Add(info.InxName, info); if (effectcache.ContainsKey(info.InxName)) { if (info.Type != ItemType.Useable) { Log.WriteLine(LogLevel.Warn, "Invalid useable item: {0} ({1})", info.ItemID, info.InxName); continue; } var effectinfo = effectcache[info.InxName]; effectinfo.ID = info.ItemID; ItemUseEffects.Add(effectinfo.ID, effectinfo); } } } effectcache.Clear(); Log.WriteLine(LogLevel.Info, "Loaded {0} items.", ItemsByID.Count); }
public void LoadItemInfo() { Dictionary <string, ItemUseEffectInfo> effectcache = new Dictionary <string, ItemUseEffectInfo>(); ItemUseEffects = new Dictionary <ushort, ItemUseEffectInfo>(); using (var file = new SHNFile(folder + @"\ItemUseEffect.shn")) { using (DataTableReaderEx reader = new DataTableReaderEx(file)) { while (reader.Read()) { string inxname; ItemUseEffectInfo info = ItemUseEffectInfo.Load(reader, out inxname); effectcache.Add(inxname, info); } } } ItemsByID = new Dictionary <ushort, ItemInfo>(); ItemsByName = new Dictionary <string, ItemInfo>(); using (var file = new SHNFile(folder + @"\ItemInfo.shn")) { using (DataTableReaderEx reader = new DataTableReaderEx(file)) { while (reader.Read()) { ItemInfo info = ItemInfo.Load(reader); if (ItemsByID.ContainsKey(info.ItemID) || ItemsByName.ContainsKey(info.InxName)) { Log.WriteLine(LogLevel.Warn, "Duplicate item found ID: {0} ({1}).", info.ItemID, info.InxName); continue; } ItemsByID.Add(info.ItemID, info); ItemsByName.Add(info.InxName, info); if (effectcache.ContainsKey(info.InxName)) { if (info.Type != ItemType.Useable) { Log.WriteLine(LogLevel.Warn, "Invalid useable item: {0} ({1})", info.ItemID, info.InxName); continue; } ItemUseEffectInfo effectinfo = effectcache[info.InxName]; effectinfo.ID = info.ItemID; ItemUseEffects.Add(effectinfo.ID, effectinfo); } } } } effectcache.Clear(); Log.WriteLine(LogLevel.Info, "Loaded {0} items.", ItemsByID.Count); }