Пример #1
0
        public static void DumpFile(string prefix, string fileName, string header, List <MethodInfo> builderMethods, Dictionary <WowGuid, Unit> units, Dictionary <WowGuid, GameObject> gameObjects)
        {
            var startTime = DateTime.Now;

            using (var store = new SQLFile(fileName))
            {
                store.WriteData(UnitMisc.CreatureEquip(units)); // ensure this is run before spawns

                for (int i = 1; i <= builderMethods.Count; i++)
                {
                    var method = builderMethods[i - 1];
                    var attr   = method.GetCustomAttribute <BuilderMethodAttribute>();

                    if (attr.CheckVersionMismatch)
                    {
                        if (!GetExpectedTargetDatabasesForExpansion(ClientVersion.Expansion).Contains(Settings.TargetedDatabase))
                        {
                            Trace.WriteLine(
                                $"{i}/{builderMethods.Count} - Error: Couldn't generate SQL output of {method.Name} since the targeted database and the sniff version don't match.");
                            continue;
                        }
                    }

                    var parameters = new List <object>();
                    if (attr.Units)
                    {
                        parameters.Add(units);
                    }

                    if (attr.Gameobjects)
                    {
                        parameters.Add(gameObjects);
                    }

                    Trace.WriteLine($"{i}/{builderMethods.Count} - Write {method.Name}");
                    try
                    {
                        store.WriteData(method.Invoke(null, parameters.ToArray()).ToString());
                    }
                    catch (TargetInvocationException e)
                    {
                        Trace.WriteLine($"{i}/{builderMethods.Count} - Error: Failed writing {method.Name}");
                        Trace.TraceError(e.InnerException?.ToString() ?? e.ToString());
                    }
                }

                Trace.WriteLine(store.WriteToFile(header)
                    ? $"{prefix}: Saved file to '{fileName}'"
                    : "No SQL files created -- empty.");
                var endTime = DateTime.Now;
                var span    = endTime.Subtract(startTime);
                Trace.WriteLine($"Finished SQL file {fileName} in {span.ToFormattedString()}.");
            }
        }
Пример #2
0
        public static void DumpSQL(string prefix, string fileName, string header)
        {
            var units       = Storage.Objects.IsEmpty() ? null : Storage.Objects.Where(obj => obj.Value.Item1.Type == ObjectType.Unit && obj.Key.GetHighType() != HighGuidType.Pet && !obj.Value.Item1.IsTemporarySpawn()).ToDictionary(obj => obj.Key, obj => obj.Value.Item1 as Unit);
            var gameObjects = Storage.Objects.IsEmpty() ? null : Storage.Objects.Where(obj => obj.Value.Item1.Type == ObjectType.GameObject).ToDictionary(obj => obj.Key, obj => obj.Value.Item1 as GameObject);

            //var pets = Storage.Objects.Where(obj => obj.Value.Type == ObjectType.Unit && obj.Key.GetHighType() == HighGuidType.Pet).ToDictionary(obj => obj.Key, obj => obj.Value as Unit);
            //var players = Storage.Objects.Where(obj => obj.Value.Type == ObjectType.Player).ToDictionary(obj => obj.Key, obj => obj.Value as Player);
            //var items = Storage.Objects.Where(obj => obj.Value.Type == ObjectType.Item).ToDictionary(obj => obj.Key, obj => obj.Value as Item);

            foreach (var obj in Storage.Objects)
            {
                obj.Value.Item1.LoadValuesFromUpdateFields();
            }

            // Ewwwww...
            var build = ClientVersion.BuildInt;

            if (!Storage.GameObjectTemplates.IsEmpty())
            {
                foreach (var obj in Storage.GameObjectTemplates)
                {
                    obj.Value.Item1.VerifiedBuild = build;
                }
            }
            if (!Storage.NpcTexts.IsEmpty())
            {
                foreach (var obj in Storage.NpcTexts)
                {
                    obj.Value.Item1.VerifiedBuild = build;
                }
            }
            if (!Storage.NpcTextsMop.IsEmpty())
            {
                foreach (var obj in Storage.NpcTextsMop)
                {
                    obj.Value.Item1.VerifiedBuild = build;
                }
            }
            if (!Storage.PageTexts.IsEmpty())
            {
                foreach (var obj in Storage.PageTexts)
                {
                    obj.Value.Item1.VerifiedBuild = build;
                }
            }
            if (!Storage.UnitTemplates.IsEmpty())
            {
                foreach (var obj in Storage.UnitTemplates)
                {
                    obj.Value.Item1.VerifiedBuild = build;
                }
            }
            if (!Storage.QuestTemplates.IsEmpty())
            {
                foreach (var obj in Storage.QuestTemplates)
                {
                    obj.Value.Item1.VerifiedBuild = build;
                }
            }
            if (!Storage.ItemTemplates.IsEmpty())
            {
                foreach (var obj in Storage.ItemTemplates)
                {
                    obj.Value.Item1.VerifiedBuild = build;
                }
            }
            if (!Storage.BroadcastTexts.IsEmpty())
            {
                foreach (var obj in Storage.BroadcastTexts)
                {
                    obj.Value.Item1.VerifiedBuild = build;
                }
            }
            if (!Storage.GameObjectTemplateDB2s.IsEmpty())
            {
                foreach (var obj in Storage.GameObjectTemplateDB2s)
                {
                    obj.Value.Item1.VerifiedBuild = build;
                }
            }
            if (!Storage.GameObjectTemplatePositionDB2s.IsEmpty())
            {
                foreach (var obj in Storage.GameObjectTemplatePositionDB2s)
                {
                    obj.Value.Item1.VerifiedBuild = build;
                }
            }

            using (var store = new SQLFile(fileName))
            {
                // TODO: Rewrite this
                var       i   = 0;
                const int max = 33;
                Trace.WriteLine(string.Format("{0}/{1} - Write WDBTemplates.GameObject", ++i, max)); store.WriteData(WDBTemplates.GameObject());
                Trace.WriteLine(string.Format("{0}/{1} - Write Spawns.GameObject", ++i, max)); if (gameObjects != null)
                {
                    store.WriteData(Spawns.GameObject(gameObjects));
                }
                Trace.WriteLine(string.Format("{0}/{1} - Write WDBTemplates.Quest", ++i, max)); store.WriteData(WDBTemplates.Quest());
                Trace.WriteLine(string.Format("{0}/{1} - Write QuestOffer.QuestPOI", ++i, max)); store.WriteData(QuestMisc.QuestPOI());
                Trace.WriteLine(string.Format("{0}/{1} - Write WDBTemplates.Npc", ++i, max)); store.WriteData(WDBTemplates.Npc());
                Trace.WriteLine(string.Format("{0}/{1} - Write WDBTemplates.NpcName", ++i, max)); store.WriteData(WDBTemplates.NpcName());
                Trace.WriteLine(string.Format("{0}/{1} - Write UnitMisc.NpcTemplateNonWDB", ++i, max)); if (units != null)
                {
                    store.WriteData(UnitMisc.NpcTemplateNonWDB(units));
                }
                Trace.WriteLine(string.Format("{0}/{1} - Write Miscellaneous.GameObjectTemplateNonWDB", ++i, max)); if (gameObjects != null)
                {
                    store.WriteData(Miscellaneous.GameobjectTemplateNonWDB(gameObjects));
                }
                Trace.WriteLine(string.Format("{0}/{1} - Write DB2.GameObjectDB2", ++i, max)); store.WriteData(DB2.GameObjectDB2());
                Trace.WriteLine(string.Format("{0}/{1} - Write DB2.GameObjectDB2Position", ++i, max)); store.WriteData(DB2.GameObjectDB2Position());
                Trace.WriteLine(string.Format("{0}/{1} - Write DB2.CreatureDifficulty", ++i, max)); store.WriteData(DB2.CreatureDifficulty());
                Trace.WriteLine(string.Format("{0}/{1} - Write UnitMisc.Addon", ++i, max)); if (units != null)
                {
                    store.WriteData(UnitMisc.Addon(units));
                }
                Trace.WriteLine(string.Format("{0}/{1} - Write UnitMisc.ModelData", ++i, max)); if (units != null)
                {
                    store.WriteData(UnitMisc.ModelData(units));
                }
                Trace.WriteLine(string.Format("{0}/{1} - Write UnitMisc.SpellsX", ++i, max)); store.WriteData(UnitMisc.SpellsX());
                Trace.WriteLine(string.Format("{0}/{1} - Write UnitMisc.CreatureText", ++i, max)); store.WriteData(UnitMisc.CreatureText());
                Trace.WriteLine(string.Format("{0}/{1} - Write Spawns.Creature", ++i, max)); if (units != null)
                {
                    store.WriteData(Spawns.Creature(units, gameObjects));
                }
                Trace.WriteLine(string.Format("{0}/{1} - Write UnitMisc.NpcTrainer", ++i, max)); store.WriteData(UnitMisc.NpcTrainer());
                Trace.WriteLine(string.Format("{0}/{1} - Write UnitMisc.NpcVendor", ++i, max)); store.WriteData(UnitMisc.NpcVendor());
                Trace.WriteLine(string.Format("{0}/{1} - Write WDBTemplates.PageText", ++i, max)); store.WriteData(WDBTemplates.PageText());
                Trace.WriteLine(string.Format("{0}/{1} - Write WDBTemplates.NpcText", ++i, max)); store.WriteData(WDBTemplates.NpcText());
                Trace.WriteLine(string.Format("{0}/{1} - Write UnitMisc.Gossip", ++i, max)); store.WriteData(UnitMisc.Gossip());
                Trace.WriteLine(string.Format("{0}/{1} - Write UnitMisc.Loot", ++i, max)); store.WriteData(UnitMisc.Loot());
                Trace.WriteLine(string.Format("{0}/{1} - Write Miscellaneous.SniffData", ++i, max)); store.WriteData(Miscellaneous.SniffData());
                Trace.WriteLine(string.Format("{0}/{1} - Write Miscellaneous.StartInformation", ++i, max)); store.WriteData(Miscellaneous.StartInformation());
                Trace.WriteLine(string.Format("{0}/{1} - Write Miscellaneous.ObjectNames", ++i, max)); store.WriteData(Miscellaneous.ObjectNames());
                Trace.WriteLine(string.Format("{0}/{1} - Write UnitMisc.CreatureEquip", ++i, max)); if (units != null)
                {
                    store.WriteData(UnitMisc.CreatureEquip(units));
                }
                Trace.WriteLine(string.Format("{0}/{1} - Write UnitMisc.CreatureMovement", ++i, max)); if (units != null)
                {
                    store.WriteData(UnitMisc.CreatureMovement(units));
                }
                Trace.WriteLine(string.Format("{0}/{1} - Write QuestOffer.QuestOffers", ++i, max)); store.WriteData(QuestMisc.QuestOffer());
                Trace.WriteLine(string.Format("{0}/{1} - Write QuestOffer.QuestRewards", ++i, max)); store.WriteData(QuestMisc.QuestReward());
                Trace.WriteLine(string.Format("{0}/{1} - Write WDBTemplates.Item", ++i, max)); store.WriteData(WDBTemplates.Item());
                Trace.WriteLine(string.Format("{0}/{1} - Write UnitMisc.PointsOfInterest", ++i, max)); store.WriteData(UnitMisc.PointsOfInterest());
                Trace.WriteLine(string.Format("{0}/{1} - Write DB2.BroadcastText", ++i, max)); store.WriteData(DB2.BroadcastText());
                Trace.WriteLine(string.Format("{0}/{1} - Write Miscellaneous.DefenseMessage", ++i, max)); store.WriteData(Miscellaneous.DefenseMessage());

                Trace.WriteLine(store.WriteToFile(header)
                    ? String.Format("{0}: Saved file to '{1}'", prefix, fileName)
                    : "No SQL files created -- empty.");
            }
        }
Пример #3
0
        public static void DumpSQL(string prefix, string fileName, string header)
        {
            var units       = Storage.Objects.IsEmpty() ? null : Storage.Objects.Where(obj => obj.Value.Item1.Type == ObjectType.Unit && obj.Key.GetHighType() != HighGuidType.Pet).ToDictionary(obj => obj.Key, obj => obj.Value.Item1 as Unit);
            var gameObjects = Storage.Objects.IsEmpty() ? null : Storage.Objects.Where(obj => obj.Value.Item1.Type == ObjectType.GameObject).ToDictionary(obj => obj.Key, obj => obj.Value.Item1 as GameObject);

            //var pets = Storage.Objects.Where(obj => obj.Value.Type == ObjectType.Unit && obj.Key.GetHighType() == HighGuidType.Pet).ToDictionary(obj => obj.Key, obj => obj.Value as Unit);
            //var players = Storage.Objects.Where(obj => obj.Value.Type == ObjectType.Player).ToDictionary(obj => obj.Key, obj => obj.Value as Player);
            //var items = Storage.Objects.Where(obj => obj.Value.Type == ObjectType.Item).ToDictionary(obj => obj.Key, obj => obj.Value as Item);

            if (units != null)
            {
                foreach (var unit in units)
                {
                    unit.Value.LoadValuesFromUpdateFields();
                }
            }

            using (var store = new SQLFile(fileName))
            {
                Trace.WriteLine("01/24 - Write WDBTemplates.GameObject"); store.WriteData(WDBTemplates.GameObject());
                Trace.WriteLine("02/24 - Write Spawns.GameObject"); if (gameObjects != null)
                {
                    store.WriteData(Spawns.GameObject(gameObjects));
                }
                Trace.WriteLine("03/24 - Write WDBTemplates.Quest"); store.WriteData(WDBTemplates.Quest());
                Trace.WriteLine("04/24 - Write QuestOffer.QuestPOI"); store.WriteData(QuestMisc.QuestPOI());
                Trace.WriteLine("05/24 - Write WDBTemplates.Npc"); store.WriteData(WDBTemplates.Npc());
                Trace.WriteLine("06/24 - Write UnitMisc.NpcTemplateNonWDB"); if (units != null)
                {
                    store.WriteData(UnitMisc.NpcTemplateNonWDB(units));
                }
                Trace.WriteLine("07/24 - Write UnitMisc.Addon"); if (units != null)
                {
                    store.WriteData(UnitMisc.Addon(units));
                }
                Trace.WriteLine("08/24 - Write UnitMisc.ModelData"); if (units != null)
                {
                    store.WriteData(UnitMisc.ModelData(units));
                }
                Trace.WriteLine("09/24 - Write UnitMisc.SpellsX"); store.WriteData(UnitMisc.SpellsX());
                Trace.WriteLine("10/24 - Write UnitMisc.CreatureText"); store.WriteData(UnitMisc.CreatureText());
                Trace.WriteLine("11/24 - Write Spawns.Creature"); if (units != null)
                {
                    store.WriteData(Spawns.Creature(units));
                }
                Trace.WriteLine("12/24 - Write UnitMisc.NpcTrainer"); store.WriteData(UnitMisc.NpcTrainer());
                Trace.WriteLine("13/24 - Write UnitMisc.NpcVendor"); store.WriteData(UnitMisc.NpcVendor());
                Trace.WriteLine("14/24 - Write WDBTemplates.PageText"); store.WriteData(WDBTemplates.PageText());
                Trace.WriteLine("15/24 - Write WDBTemplates.NpcText"); store.WriteData(WDBTemplates.NpcText());
                Trace.WriteLine("16/24 - Write UnitMisc.Gossip"); store.WriteData(UnitMisc.Gossip());
                Trace.WriteLine("17/24 - Write UnitMisc.Loot"); store.WriteData(UnitMisc.Loot());
                Trace.WriteLine("18/24 - Write Miscellaneous.SniffData"); store.WriteData(Miscellaneous.SniffData());
                Trace.WriteLine("19/24 - Write Miscellaneous.StartInformation"); store.WriteData(Miscellaneous.StartInformation());
                Trace.WriteLine("20/24 - Write Miscellaneous.ObjectNames"); store.WriteData(Miscellaneous.ObjectNames());
                Trace.WriteLine("21/24 - Write UnitMisc.CreatureEquip"); if (units != null)
                {
                    store.WriteData(UnitMisc.CreatureEquip(units));
                }
                Trace.WriteLine("22/24 - Write UnitMisc.CreatureMovement"); if (units != null)
                {
                    store.WriteData(UnitMisc.CreatureMovement(units));
                }
                Trace.WriteLine("23/24 - Write QuestOffer.QuestOffers"); store.WriteData(QuestMisc.QuestOffer());
                Trace.WriteLine("24/24 - Write QuestOffer.QuestRewards"); store.WriteData(QuestMisc.QuestReward());

                Trace.WriteLine(store.WriteToFile(header)
                                    ? String.Format("{0}: Saved file to '{1}'", prefix, fileName)
                                    : "No SQL files created -- empty.");
            }
        }
Пример #4
0
        public static void DumpSQL(string prefix, string fileName, SQLOutputFlags sqlOutput)
        {
            var units       = Storage.Objects.Where(obj => obj.Value.Type == ObjectType.Unit && obj.Key.GetHighType() != HighGuidType.Pet).ToDictionary(obj => obj.Key, obj => obj.Value as Unit);
            var gameObjects = Storage.Objects.Where(obj => obj.Value.Type == ObjectType.GameObject).ToDictionary(obj => obj.Key, obj => obj.Value as GameObject);

            //var pets = Storage.Objects.Where(obj => obj.Value.Type == ObjectType.Unit && obj.Key.GetHighType() == HighGuidType.Pet).ToDictionary(obj => obj.Key, obj => obj.Value as Unit);
            //var players = Storage.Objects.Where(obj => obj.Value.Type == ObjectType.Player).ToDictionary(obj => obj.Key, obj => obj.Value as Player);
            //var items = Storage.Objects.Where(obj => obj.Value.Type == ObjectType.Item).ToDictionary(obj => obj.Key, obj => obj.Value as Item);

            foreach (var unit in units)
            {
                unit.Value.LoadValuesFromUpdateFields();
            }

            using (var store = new SQLStore(fileName))
            {
                if (sqlOutput.HasAnyFlag(SQLOutputFlags.GameObjectTemplate))
                {
                    store.WriteData(WDBTemplates.GameObject());
                }

                if (sqlOutput.HasAnyFlag(SQLOutputFlags.GameObjectSpawns))
                {
                    store.WriteData(Spawns.GameObject(gameObjects));
                }

                if (sqlOutput.HasAnyFlag(SQLOutputFlags.QuestTemplate))
                {
                    store.WriteData(WDBTemplates.Quest());
                }

                if (sqlOutput.HasAnyFlag(SQLOutputFlags.QuestPOI))
                {
                    store.WriteData(QuestMisc.QuestPOI());
                }

                if (sqlOutput.HasAnyFlag(SQLOutputFlags.CreatureTemplate))
                {
                    store.WriteData(WDBTemplates.Npc());
                    store.WriteData(UnitMisc.NpcTemplateNonWDB(units));
                    //store.WriteData(UnitMisc.Addon(units));
                    store.WriteData(UnitMisc.ModelData(units));
                    store.WriteData(UnitMisc.SpellsX());
                }

                if (sqlOutput.HasAnyFlag(SQLOutputFlags.CreatureSpawns))
                {
                    store.WriteData(Spawns.Creature(units));
                }

                if (sqlOutput.HasAnyFlag(SQLOutputFlags.NpcTrainer))
                {
                    store.WriteData(UnitMisc.NpcTrainer());
                }

                if (sqlOutput.HasAnyFlag(SQLOutputFlags.NpcVendor))
                {
                    store.WriteData(UnitMisc.NpcVendor());
                }

                if (sqlOutput.HasAnyFlag(SQLOutputFlags.PageText))
                {
                    store.WriteData(WDBTemplates.PageText());
                }

                if (sqlOutput.HasAnyFlag(SQLOutputFlags.NpcText))
                {
                    store.WriteData(WDBTemplates.NpcText());
                }

                if (sqlOutput.HasAnyFlag(SQLOutputFlags.Gossip))
                {
                    store.WriteData(UnitMisc.Gossip());
                }

                if (sqlOutput.HasAnyFlag(SQLOutputFlags.Loot))
                {
                    store.WriteData(UnitMisc.Loot());
                }

                if (sqlOutput.HasAnyFlag(SQLOutputFlags.StartInformation))
                {
                    store.WriteData(Miscellaneous.StartInformation());
                }

                if (sqlOutput.HasAnyFlag(SQLOutputFlags.CreatureEquip))
                {
                    store.WriteData(UnitMisc.CreatureEquip(units));
                }

                if (sqlOutput.HasAnyFlag(SQLOutputFlags.CreatureMovement))
                {
                    store.WriteData(UnitMisc.CreatureMovement(units));
                }

                Trace.WriteLine(store.WriteToFile()
                                    ? String.Format("{0}: Saved file to '{1}'", prefix, fileName)
                                    : "No SQL files created -- empty.");
            }
        }