/// <summary> /// Process all of the data loaded into the database. /// </summary> public static void Process() { // Go through all of the items in the database and calculate the Filter ID // if the Filter ID is not already assigned. (manual assignment should always override this) foreach (var data in Items.AllItems) { Objects.AssignFilterID(data); Objects.AssignFactionID(data); } // Merge the Item Data into the Containers. foreach (var container in Objects.AllContainers.Values) { Process(container, 1, 1); } // Sort World Drops by Name var worldDrops = Objects.GetNull("WorldDrops"); if (worldDrops != null) { SortByName(worldDrops); } // Build the Unsorted Container. List <object> listing; int requireSkill; var unsorted = new List <object>(); Objects.AllContainers["Unsorted"] = unsorted; var tierLists = new Dictionary <int, TierList>(); for (int tierID = 1; tierID <= 8; ++tierID) { unsorted.Add(new Dictionary <string, object> { { "tierID", tierID }, { "g", (tierLists[tierID] = new TierList()).Groups }, }); } foreach (var item in Items.AllItemsWithoutReferences) { TierList tier; if (item.TryGetValue("lvl", out object lvlRef) && lvlRef is int level) { if (level < 61) { tier = tierLists[1]; // Classic } else if (level < 71) { tier = tierLists[2]; // Burning Crusade } else if (level < 81) { tier = tierLists[3]; // Wrath of the Lich King } else if (level < 86) { tier = tierLists[4]; // Cataclysm } else if (level < 91) { tier = tierLists[5]; // Mists of Pandaria } else if (level < 101) { tier = tierLists[6]; // Warlords of Draenor } else if (level < 111) { tier = tierLists[7]; // Legion } else { tier = tierLists[8]; // Battle For Azeroth } } else if (item.TryGetValue("itemID", out object itemIDRef)) { var itemID = Convert.ToInt32(itemIDRef); if (itemID < 22727) { tier = tierLists[1]; // Classic } else if (itemID < 29205) { tier = tierLists[2]; // Burning Crusade } else if (itemID < 37649) { tier = tierLists[3]; // Wrath of the Lich King } else if (itemID < 72019) { tier = tierLists[4]; // Cataclysm } else if (itemID < 100855) { tier = tierLists[5]; // Mists of Pandaria } else if (itemID < 130731) { tier = tierLists[6]; // Warlords of Draenor } else if (itemID < 156823) { tier = tierLists[7]; // Legion } else { tier = tierLists[8]; // Battle For Azeroth } } else { tier = tierLists[1]; } if (item.TryGetValue("f", out object objRef)) { int filterID = Convert.ToInt32(objRef); if (filterID >= 0 && (filterID < 56 || filterID > 90)) { switch ((Objects.Filters)filterID) { /* * case Objects.Filters.Invalid: * case Objects.Filters.Ignored: * case Objects.Filters.Toy: * case Objects.Filters.Illusion: * case Objects.Filters.Mount: * case Objects.Filters.Quest: * case Objects.Filters.Holiday: */ case Objects.Filters.Recipe: { if (!tier.FilteredLists.TryGetValue(filterID, out listing)) { tier.Groups.Add(new Dictionary <string, object> { { "f", filterID }, { "g", listing = tier.FilteredLists[filterID] = new List <object>() } }); } if (item.TryGetValue("requireSkill", out object requireSkillRef)) { requireSkill = Convert.ToInt32(requireSkillRef); if (!tier.ProfessionLists.TryGetValue(requireSkill, out List <object> sublisting)) { listing.Add(new Dictionary <string, object> { { "professionID", requireSkill }, { "g", listing = tier.ProfessionLists[requireSkill] = new List <object>() } }); } else { listing = sublisting; } } else { if (!tier.ProfessionLists.TryGetValue(-1, out List <object> sublisting)) { listing.Add(new Dictionary <string, object> { { "f", (int)Objects.Filters.Miscellaneous }, { "g", listing = tier.ProfessionLists[-1] = new List <object>() } }); } else { listing = sublisting; } } if (item.TryGetValue("itemID", out int itemID)) { var newItem = new Dictionary <string, object> { { "itemID", itemID }, }; Items.MergeInto(itemID, item, newItem); listing.Add(newItem); } break; } default: { item.Remove("spellID"); if ((item.TryGetValue("q", out objRef) && Convert.ToInt32(objRef) >= 2) || (filterID == 101 || filterID == 102 || filterID == 100 || filterID == 108 || filterID == 10)) { if (!tier.FilteredLists.TryGetValue(filterID, out listing)) { tier.Groups.Add(new Dictionary <string, object> { { "f", filterID }, { "g", listing = tier.FilteredLists[filterID] = new List <object>() } }); } if (item.TryGetValue("itemID", out int itemID)) { var newItem = new Dictionary <string, object> { { "itemID", itemID }, }; Items.MergeInto(itemID, item, newItem); listing.Add(newItem); } } break; } } } } } // Merge the Item Data into the Containers again. foreach (var container in Objects.AllContainers.Values) { Process(container, 1, 1); } }
/// <summary> /// Process a data container. /// </summary> /// <param name="data">The data container.</param> /// <param name="modID">The modID.</param> /// <param name="minLevel">The minimum required level.</param> private static void Process(Dictionary <string, object> data, int modID, int minLevel) { // Check to make sure the data is valid. if (data == null) { return; } // Assign the modID if not already specified. if (data.TryGetValue("modID", out object modIDRef)) { modID = Convert.ToInt32(modIDRef); if (modID < 1) { data["modID"] = modID = 1; } } else if (data.ContainsKey("ignoreBonus")) { // Assign the modID, but set it back to 1. data["modID"] = modID = 1; } else if (data.ContainsKey("itemID")) { // Assign the modID, but only for items. data["modID"] = modID; } if (data.TryGetValue("npcID", out int npcID)) { NPCS_WITH_REFERENCES[npcID] = true; } if (data.TryGetValue("creatureID", out npcID)) { NPCS_WITH_REFERENCES[npcID] = true; } if (data.TryGetValue("qg", out npcID)) { NPCS_WITH_REFERENCES[npcID] = true; } if (data.TryGetValue("qgs", out List <object> qgs)) { foreach (var qg in qgs) { NPCS_WITH_REFERENCES[Convert.ToInt32(qg)] = true; } } if (data.TryGetValue("crs", out qgs)) { foreach (var qg in qgs) { NPCS_WITH_REFERENCES[Convert.ToInt32(qg)] = true; } } // Cache whether or not this entry had an explicit spellID assignment already. bool hasSpellID = data.ContainsKey("spellID"); // Merge all relevant Item Data into the data container. Items.Merge(data); Items.MergeInto(data); Objects.AssignFactionID(data); // Cache the Filter ID. Objects.Filters filter = Objects.Filters.Ignored; if (data.TryGetValue("f", out int f)) { // Parse it! filter = (Objects.Filters)f; } // Throw away automatic Spell ID assignments for certain filter types. if (data.TryGetValue("spellID", out f)) { if (f < 1) { data.Remove("spellID"); } else { switch (filter) { case Objects.Filters.Recipe: data["recipeID"] = data["spellID"]; break; default: if (!hasSpellID) { data.Remove("spellID"); } break; } } } if (data.TryGetValue("recipeID", out f)) { if (f < 1) { data.Remove("recipeID"); } } if (data.TryGetValue("s", out f)) { if (f < 1) { data.Remove("s"); } } if (data.TryGetValue("q", out f)) { if (f == 7 && data.TryGetValue("itemID", out object itemRef)) { data["heirloomID"] = itemRef; if (data.TryGetValue("ignoreSource", out itemRef)) { Trace.WriteLine("WTF WHY IS THIS HEIRLOOM IGNORING SOURCE IDS?!"); Console.ReadLine(); } else if (data.TryGetValue("ignoreBonus", out itemRef)) { Trace.WriteLine("WTF WHY IS THIS HEIRLOOM IGNORING BONUS IDS?!"); Console.ReadLine(); } } // If the level of this object is less than the current minimum level, we can safely remove it. if (data.TryGetValue("lvl", out object lvlRef)) { var level = Convert.ToInt32(lvlRef); if (level <= minLevel) { data.Remove("lvl"); } else { minLevel = level; } } // For Rings, Necklaces, and Trinkets - Ignore BoE filters switch (filter) { /* * case Objects.Filters.Ring: * case Objects.Filters.Trinket: * case Objects.Filters.Neck: * case Objects.Filters.Relic: * data.Remove("b"); * break; */ case Objects.Filters.Consumable: data.Remove("heirloomID"); break; default: break; } } // If this container has groups, then process those groups as well. if (data.TryGetValue("g", out List <object> groups)) { Process(groups, modID, minLevel); } if (data.TryGetValue("requireSkill", out object requiredSkill)) { if (Objects.SKILL_ID_CONVERSION_TABLE.TryGetValue(requiredSkill, out object newRequiredSkill)) { data["requireSkill"] = newRequiredSkill; } else { switch (Convert.ToInt32(requiredSkill)) { // https://www.wowhead.com/skill= case 40: // Rogue Poisons case 150: // Tiger Riding case 762: // Riding case 849: // Warlock { // Ignore! (and remove!) data.Remove("requireSkill"); break; } default: { Trace.Write("Missing Skill ID in Conversion Table: "); Trace.WriteLine(requiredSkill); Trace.WriteLine(ToJSON(data)); Console.ReadLine(); break; } } } } if (data.TryGetValue("name", out string name)) { // Determine the Most-Significant ID Type (itemID, questID, npcID, etc) if (ATT.Export.ObjectData.TryGetMostSignificantObjectType(data, out Export.ObjectData objectData) && data.TryGetValue(objectData.ObjectType, out int id)) { // Store the name of this object (or whatever it is) in our table. if (!NAMES_BY_TYPE.TryGetValue(objectData.ObjectType, out Dictionary <int, object> names)) { names = new Dictionary <int, object>(); NAMES_BY_TYPE[objectData.ObjectType] = names; } names[id] = name; data.Remove("name"); } } }