public ItemRange(UInt32[] range, Constants.ItemClass itemClass, Constants.WeaponSubclass weaponSubClass) { this.range = range; this.itemClass = itemClass; this.weaponSubClass = weaponSubClass; this.armorSubClass = Constants.ArmorSubclass.NULL; }
static void Main(string[] args) { try { print("Reading config..."); Config config = new Config(); config.loadFile(); print("Creating MySQL connection..."); MySQL mySQL = new MySQL(config); Item dbc = new Item(); print("Loaded Item.dbc, records: {0}", dbc.header.RecordCount); foreach (ItemRange range in RANGES) { Constants.WeaponSubclass weapon = range.weaponSubClass; String type = ""; if (weapon != Constants.WeaponSubclass.NULL) { type = weapon.ToString(); } else { type = range.armorSubClass.ToString(); } UInt32[] r = range.range; print("{0} type {1} has range:\t\t{2} - {3}", range.itemClass.ToString(), type, r[0], r[1]); } List <Item.DBC_Record> newRecords = new List <Item.DBC_Record>(); Random rand = new Random(); foreach (ItemRange range in RANGES) { int subClass = 0; if (range.itemClass == Constants.ItemClass.ARMOR) { subClass = (int)range.armorSubClass; } else { subClass = (int)range.weaponSubClass; } print("Generating: {0}, {1}, {2}...", range.itemClass.ToString(), range.weaponSubClass.ToString(), range.armorSubClass.ToString()); String query = String.Format(@" SELECT entry,class,subclass,SoundOverrideSubclass,displayid,inventoryType,Material,sheath FROM item_template WHERE class = '{0}' AND subclass = '{1}' AND itemlevel < '{2}' AND itemlevel > '{3}' AND quality < '{4}' AND quality > '{5}' ORDER BY entry;" , (int)range.itemClass, subClass, 58, 10, 4, 1); UInt32[] ranges = range.range; var resultSet = mySQL.query(query).Rows; int count = resultSet.Count - 1; for (uint i = ranges[0]; i < ranges[1]; ++i) { var row = resultSet[rand.Next(0, count)]; Item.DBC_Record record = new Item.DBC_Record(); record.ID = i; record.itemClass = UInt32.Parse(row[1].ToString()); record.itemSubClass = UInt32.Parse(row[2].ToString()); record.sound_override_subclassid = Int32.Parse(row[3].ToString()); record.itemDisplayInfo = UInt32.Parse(row[4].ToString()); record.inventorySlotID = UInt32.Parse(row[5].ToString()); record.materialID = Int32.Parse(row[6].ToString()); record.sheathID = Int32.Parse(row[7].ToString()); newRecords.Add(record); if (debug) { print("[{0},\t{1},\t{2},\t{3},\t{4},\t{5},\t{6},\t{7},\t{8}]", record.ID, record.itemClass, record.itemSubClass, record.sound_override_subclassid, record.itemDisplayInfo, record.inventorySlotID, record.materialID, record.sheathID); } } } print("Generated {0} new records.", newRecords.Count); print("Saving new Item.dbc..."); dbc.SaveDBCFile(newRecords.ToArray()); print("Done. Program terminating."); } catch (Exception e) { print("ERROR: {0}", e.Message); } }