Exemple #1
0
        public static void DumpSQL(string prefix, string fileName, string header)
        {
            var startTime = DateTime.Now;

            var units = Storage.Objects.IsEmpty()
                ? new Dictionary <WowGuid, Unit>()                                                               // empty dict if there are no objects
                : Storage.Objects.Where(
                obj =>
                obj.Value.Item1.Type == ObjectType.Unit && obj.Key.GetHighType() != HighGuidType.Pet &&         // remove pets
                !obj.Value.Item1.IsTemporarySpawn())                                                            // remove temporary spawns
                        .OrderBy(pair => pair.Value.Item2)                                                      // order by spawn time
                        .ToDictionary(obj => obj.Key, obj => obj.Value.Item1 as Unit);

            var gameObjects = Storage.Objects.IsEmpty()
                ? new Dictionary <WowGuid, GameObject>()                                                        // empty dict if there are no objects
                : Storage.Objects.Where(obj => obj.Value.Item1.Type == ObjectType.GameObject)
                              .OrderBy(pair => pair.Value.Item2)                                                // order by spawn time
                              .ToDictionary(obj => obj.Key, obj => obj.Value.Item1 as GameObject);

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

            using (var store = new SQLFile(fileName))
            {
                var builderMethods = Assembly.GetExecutingAssembly()
                                     .GetTypes()
                                     .Where(type => type.GetCustomAttributes(typeof(BuilderClassAttribute), true).Length > 0)
                                     .SelectMany(x => x.GetMethods())
                                     .Where(y => y.GetCustomAttributes().OfType <BuilderMethodAttribute>().Any())
                                     .ToList();

                var i = 0;
                foreach (var method in builderMethods)
                {
                    var attr       = method.GetCustomAttribute <BuilderMethodAttribute>();
                    var parameters = new List <object>();
                    if (attr.Units)
                    {
                        parameters.Add(units);
                    }

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

                    Trace.WriteLine(string.Format("{0}/{1} - Write {2}", ++i, builderMethods.Count, method.Name));
                    store.WriteData(method.Invoke(null, parameters.ToArray()).ToString());
                }

                Trace.WriteLine(store.WriteToFile(header)
                    ? String.Format("{0}: Saved file to '{1}'", prefix, fileName)
                    : "No SQL files created -- empty.");
                var endTime = DateTime.Now;
                var span    = endTime.Subtract(startTime);
                Trace.WriteLine(String.Format("Finished SQL file in {0}.", span.ToFormattedString()));
            }
        }
        public static void DumpSQL(string prefix, string fileName, string header)
        {
            var startTime = DateTime.Now;

            var units = Storage.Objects.IsEmpty()
                ? new Dictionary<WowGuid, Unit>()                                                               // empty dict if there are no objects
                : Storage.Objects.Where(
                    obj =>
                        obj.Value.Item1.Type == ObjectType.Unit && obj.Key.GetHighType() != HighGuidType.Pet && // remove pets
                        !obj.Value.Item1.IsTemporarySpawn())                                                    // remove temporary spawns
                    .OrderBy(pair => pair.Value.Item2)                                                          // order by spawn time
                    .ToDictionary(obj => obj.Key, obj => obj.Value.Item1 as Unit);

            var gameObjects = Storage.Objects.IsEmpty()
                ? new Dictionary<WowGuid, GameObject>()                                                         // empty dict if there are no objects
                : Storage.Objects.Where(obj => obj.Value.Item1.Type == ObjectType.GameObject)
                    .OrderBy(pair => pair.Value.Item2)                                                          // order by spawn time
                    .ToDictionary(obj => obj.Key, obj => obj.Value.Item1 as GameObject);

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

            using (var store = new SQLFile(fileName))
            {
                var builderMethods = Assembly.GetExecutingAssembly()
                    .GetTypes()
                    .Where(type => type.GetCustomAttributes(typeof (BuilderClassAttribute), true).Length > 0)
                    .SelectMany(x => x.GetMethods())
                    .Where(y => y.GetCustomAttributes().OfType<BuilderMethodAttribute>().Any())
                    .ToList();

                var i = 0;
                foreach (var method in builderMethods)
                {
                    var attr = method.GetCustomAttribute<BuilderMethodAttribute>();
                    var parameters = new List<object>();
                    if (attr.Units)
                        parameters.Add(units);

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

                    Trace.WriteLine(string.Format("{0}/{1} - Write {2}", ++i, builderMethods.Count, method.Name));
                    store.WriteData(method.Invoke(null, parameters.ToArray()).ToString());
                }

                Trace.WriteLine(store.WriteToFile(header)
                    ? String.Format("{0}: Saved file to '{1}'", prefix, fileName)
                    : "No SQL files created -- empty.");
                var endTime = DateTime.Now;
                var span = endTime.Subtract(startTime);
                Trace.WriteLine(String.Format("Finished SQL file in {0}.", span.ToFormattedString()));
            }
        }
Exemple #3
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()}.");
            }
        }
Exemple #4
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.");
            }
        }
Exemple #5
0
        public static void DumpSQL(string prefix, string fileName, string header)
        {
            var startTime = DateTime.Now;

            LoadNames();

            var units = Storage.Objects.IsEmpty()
                ? new Dictionary <WowGuid, Unit>()                                                               // empty dict if there are no objects
                : Storage.Objects.Where(
                obj =>
                obj.Value.Item1.Type == ObjectType.Unit && obj.Key.GetHighType() != HighGuidType.Pet &&         // remove pets
                !obj.Value.Item1.IsTemporarySpawn())                                                            // remove temporary spawns
                        .OrderBy(pair => pair.Value.Item2)                                                      // order by spawn time
                        .ToDictionary(obj => obj.Key, obj => obj.Value.Item1 as Unit);

            var gameObjects = Storage.Objects.IsEmpty()
                ? new Dictionary <WowGuid, GameObject>()                                                        // empty dict if there are no objects
                : Storage.Objects.Where(obj => obj.Value.Item1.Type == ObjectType.GameObject)
                              .OrderBy(pair => pair.Value.Item2)                                                // order by spawn time
                              .ToDictionary(obj => obj.Key, obj => obj.Value.Item1 as GameObject);

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

            using (var store = new SQLFile(fileName))
            {
                var builderMethods = Assembly.GetExecutingAssembly()
                                     .GetTypes()
                                     .Where(type => type.GetCustomAttributes(typeof(BuilderClassAttribute), true).Length > 0)
                                     .SelectMany(x => x.GetMethods())
                                     .Where(y => y.GetCustomAttributes().OfType <BuilderMethodAttribute>().Any())
                                     .ToList();

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

                    if (attr.CheckVersionMismatch)
                    {
                        if (!((ClientVersion.Expansion == ClientType.WrathOfTheLichKing &&
                               Settings.TargetedDatabase == TargetedDatabase.WrathOfTheLichKing)
                              ||
                              (ClientVersion.Expansion == ClientType.Cataclysm &&
                               Settings.TargetedDatabase == TargetedDatabase.Cataclysm)
                              ||
                              (ClientVersion.Expansion == ClientType.WarlordsOfDraenor &&
                               Settings.TargetedDatabase == TargetedDatabase.WarlordsOfDraenor)
                              ||
                              (ClientVersion.Expansion == ClientType.Legion &&
                               Settings.TargetedDatabase == TargetedDatabase.Legion)))
                        {
                            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 in {span.ToFormattedString()}.");
            }
        }
Exemple #6
0
        public static void DumpSQL(string prefix, string fileName, string header)
        {
            DateTime startTime = DateTime.Now;

            var units = Storage.Objects.IsEmpty()
                ? new Dictionary<WowGuid, Unit>()                                                               // empty dict if there are no objects
                : Storage.Objects.Where(
                    obj =>
                        obj.Value.Item1.Type == ObjectType.Unit && obj.Key.GetHighType() != HighGuidType.Pet && // remove pets
                        !obj.Value.Item1.IsTemporarySpawn())                                                    // remove temporary spawns
                    .OrderBy(pair => pair.Value.Item2)                                                          // order by spawn time
                    .ToDictionary(obj => obj.Key, obj => obj.Value.Item1 as Unit);

            var gameObjects = Storage.Objects.IsEmpty()
                ? new Dictionary<WowGuid, GameObject>()                                                         // empty dict if there are no objects
                : Storage.Objects.Where(obj => obj.Value.Item1.Type == ObjectType.GameObject)
                    .OrderBy(pair => pair.Value.Item2)                                                          // order by spawn time
                    .ToDictionary(obj => obj.Key, obj => obj.Value.Item1 as GameObject);

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

            using (SQLFile store = new SQLFile(fileName))
            {
                var builderMethods = Assembly.GetExecutingAssembly()
                    .GetTypes()
                    .Where(type => type.GetCustomAttributes(typeof (BuilderClassAttribute), true).Length > 0)
                    .SelectMany(x => x.GetMethods())
                    .Where(y => y.GetCustomAttributes().OfType<BuilderMethodAttribute>().Any())
                    .ToList();

                int i = 0;
                foreach (MethodInfo method in builderMethods)
                {
                    BuilderMethodAttribute attr = method.GetCustomAttribute<BuilderMethodAttribute>();

                    if (attr.CheckVersionMismatch)
                    {
                        if (!((ClientVersion.Expansion == ClientType.WrathOfTheLichKing &&
                             Settings.TargetedDatabase == TargetedDatabase.WrathOfTheLichKing)
                            ||
                            (ClientVersion.Expansion == ClientType.Cataclysm &&
                             Settings.TargetedDatabase == TargetedDatabase.Cataclysm)
                            ||
                            (ClientVersion.Expansion == ClientType.WarlordsOfDraenor &&
                             Settings.TargetedDatabase == TargetedDatabase.WarlordsOfDraenor)))
                        {
                            Trace.WriteLine($"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)
                    {
                        ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                    }

                }

                Trace.WriteLine(store.WriteToFile(header)
                    ? $"{prefix}: Saved file to '{fileName}'"
                    : "No SQL files created -- empty.");
                DateTime endTime = DateTime.Now;
                TimeSpan span = endTime.Subtract(startTime);
                Trace.WriteLine($"Finished SQL file in {span.ToFormattedString()}.");
            }
        }
Exemple #7
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.WDBVerified = build;
            if (!Storage.NpcTexts.IsEmpty())
                foreach (var obj in Storage.NpcTexts)
                    obj.Value.Item1.WDBVerified = build;
            if (!Storage.PageTexts.IsEmpty())
                foreach (var obj in Storage.PageTexts)
                    obj.Value.Item1.WDBVerified = build;
            if (!Storage.UnitTemplates.IsEmpty())
                foreach (var obj in Storage.UnitTemplates)
                    obj.Value.Item1.WDBVerified = build;
            if (!Storage.QuestTemplates.IsEmpty())
                foreach (var obj in Storage.QuestTemplates)
                    obj.Value.Item1.WDBVerified = build;
            if (!Storage.ItemTemplates.IsEmpty())
                foreach (var obj in Storage.ItemTemplates)
                    obj.Value.Item1.WDBVerified = build;

            using (var store = new SQLFile(fileName))
            {
                // TODO: Rewrite this
                var i = 0;
                const int max = 26;
                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 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 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));
                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(store.WriteToFile(header)
                                    ? String.Format("{0}: Saved file to '{1}'", prefix, fileName)
                                    : "No SQL files created -- empty.");
            }
        }
Exemple #8
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.");
            }
        }
Exemple #9
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.");
            }
        }