Пример #1
0
        public static void HandleCreatureQueryResponse(Packet packet)
        {
            Creature c     = new Creature();
            var      entry = packet.ReadEntryKey("Entry");

            if (entry.Value)
            {
                return;
            }

            c.Entry = entry.Key;

            c.Name = packet.ReadCString("Name");

            for (var i = 0; i < 7; i++)
            {
                packet.ReadString();
            }

            /*
             * for (var i = 0; i < 4; i++)
             *  c.Name[i] = packet.ReadCString("Name " + i);
             *
             * for (var i = 0; i < 4; i++)
             *  c.Name[i] = packet.ReadCString("Unk string " + i);*/

            c.SubName  = packet.ReadCString("Sub Name");
            c.IconName = packet.ReadCString("Icon Name");

            c.TypeFlags1 = packet.ReadEnum <CreatureTypeFlag>("Type Flags1");
            c.TypeFlags2 = packet.ReadEnum <CreatureTypeFlag>("Type Flags2");
            c.Type       = packet.ReadEnum <CreatureType>("Type");

            c.Family = packet.ReadEnum <CreatureFamily>("Family");
            //int val = packet.ReadInt32("Unk int");
            c.Rank        = packet.ReadEnum <CreatureRank>("Rank");
            c.KillCredit1 = packet.ReadInt32("Kill Credit 1");
            c.KillCredit2 = packet.ReadInt32("Kill Credit 2");

            for (var i = 0; i < 4; i++)
            {
                c.DisplayIDs[i] = packet.ReadInt32("Display ID " + i);
            }

            c.HealthModifier = packet.ReadSingle("Health Modifier");
            c.ManaModifier   = packet.ReadSingle("Mana Modifier");
            c.RacialLeader   = packet.ReadBoolean("Racial Leader");

            for (var i = 0; i < 6; i++)
            {
                c.QuestItems[i] = packet.ReadInt32("Quest Item " + i);
            }

            c.MovementID = packet.ReadInt32("Movement ID");
            c.Exp        = packet.ReadInt32("Expansion ID");
            CreatureStorage.GetSingleton().Add(c);
        }
Пример #2
0
        private static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            CmdLine = new CommandLine(args);

            string file;
            string loader;
            string nodump;
            string nohex;
            string tosql;
            string skiplarge;
            bool   _toSQL = false;

            try
            {
                file      = CmdLine.GetValue("-file");
                loader    = CmdLine.GetValue("-loader");
                nodump    = CmdLine.GetValue("-nodump");
                nohex     = CmdLine.GetValue("-nohex");
                tosql     = CmdLine.GetValue("-tosql");
                skiplarge = CmdLine.GetValue("-skiplarge");
                if (tosql.Equals(bool.TrueString, StringComparison.InvariantCultureIgnoreCase))
                {
                    _toSQL = true;
                }
            }
            catch (IndexOutOfRangeException)
            {
                PrintUsage("All command line options require an argument.");
                return;
            }

            try
            {
                var packets = Reader.Read(loader, file);
                if (packets == null)
                {
                    PrintUsage("Could not open file " + file + " for reading.");
                    return;
                }

                if (packets.Count() > 0)
                {
                    var fullPath = Utilities.GetPathFromFullPath(file);
                    Handler.InitializeLogFile(Path.Combine(fullPath, file + ".txt"), nodump, nohex, skiplarge);

                    foreach (var packet in packets)
                    {
                        Handler.Parse(packet);
                    }
                    Handler.WriteToFile();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.GetType());
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }

            Console.ResetColor();
            if (_toSQL)
            {
                var fullPath = Utilities.GetPathFromFullPath(file);
                QuestStorage.GetSingleton().Output(Path.Combine(fullPath, file + "_questcache.sql"));
                CreatureStorage.GetSingleton().Output(Path.Combine(fullPath, file + "_creaturecache.sql"));
                GameObjectStorage.GetSingleton().Output(Path.Combine(fullPath, file + "_gameobjectcache.sql"));
                CreatureTemplateUpdateStorage.GetSingleton().Output(Path.Combine(fullPath, file + "_creaturecacheupdates.sql"));
                CreatureSpawnStorage   css = CreatureSpawnStorage.GetSingleton();
                GameObjectSpawnStorage gss = GameObjectSpawnStorage.GetSingleton();
                Dictionary <int, Dictionary <Guid, WowObject> > dict = ObjectHandler.Objects;
                foreach (int map in dict.Keys)
                {
                    Dictionary <Guid, WowObject> objectsInMap = dict[map];
                    foreach (Guid guid in objectsInMap.Keys)
                    {
                        WowObject obj = objectsInMap[guid];
                        if (obj.Type == ObjectType.Unit)
                        {
                            CreatureSpawn spawn = new CreatureSpawn();
                            spawn.Entry = guid.GetEntry();
                            spawn.Map   = map;
                            spawn.X     = obj.Position.X;
                            spawn.Y     = obj.Position.Y;
                            spawn.Z     = obj.Position.Z;
                            spawn.O     = obj.Movement.Orientation;
                            css.Add(spawn);
                        }
                        else if (obj.Type == ObjectType.GameObject)
                        {
                            GameObjectSpawn spawn = new GameObjectSpawn();
                            spawn.Entry = guid.GetEntry();
                            spawn.Map   = map;
                            spawn.X     = obj.Position.X;
                            spawn.Y     = obj.Position.Y;
                            spawn.Z     = obj.Position.Z;
                            spawn.O     = obj.Movement.Orientation;
                            gss.Add(spawn);
                        }
                    }
                }
                css.Output(Path.Combine(fullPath, file + "_creaturesniffedspawns.sql"));
                gss.Output(Path.Combine(fullPath, file + "_gameobjectsniffedspawns.sql"));
            }
        }