예제 #1
0
        public void RemoveSpawn(GameObjectSpawn spawn)
        {
            GameObjectSpawn removedGameObject;

            GameObjectSpawns.TryRemove(spawn.Guid, out removedGameObject);

            DB.World.Execute("DELETE FROM creature_spawns WHERE Guid = ?", SmartGuid.GetGuid(spawn.Guid));
        }
예제 #2
0
    // Use this for initialization
    void Start()
    {
        DataPool.f_InitPool();
        m_GameObjectSpawn = GetComponent <GameObjectSpawn>();
        Img_Ten           = GameOverUI.transform.FindChild("Ten").GetComponent <Image>();
        Img_Num           = GameOverUI.transform.FindChild("Num").GetComponent <Image>();

        UI_StartGame.onClick.AddListener(delegate()
        {
            this.OnStartGameClick();
        });

        UI_TimeImg.gameObject.SetActive(false);
        GameOverUI.SetActive(false);
    }
예제 #3
0
        public void LoadGameObjectSpawns()
        {
            Log.Message(LogType.DB, "Loading gameobject spawns...");

            SQLResult result = DB.World.Select("SELECT * FROM gameobject_spawns");

            Parallel.For(0, result.Count, (i, loop) =>
            {
                var guid = result.Read <UInt64>(i, "Guid");
                var id   = result.Read <Int32>(i, "Id");

                GameObject data = Globals.DataMgr.FindGameObject(id);
                if (data == null)
                {
                    Log.Message(LogType.ERROR, "Loading a gameobject spawn (Guid: {0}) with non-existing stats (Id: {1}) skipped.", guid, id);
                    return;
                }

                GameObjectSpawn spawn = new GameObjectSpawn()
                {
                    Guid = guid,
                    Id   = id,
                    Map  = result.Read <UInt32>(i, "Map"),

                    Position = new Vector4()
                    {
                        X = result.Read <Single>(i, "X"),
                        Y = result.Read <Single>(i, "Y"),
                        Z = result.Read <Single>(i, "Z"),
                        O = result.Read <Single>(i, "O")
                    },

                    FactionTemplate = result.Read <UInt32>(i, "FactionTemplate"),
                    AnimProgress    = result.Read <Byte>(i, "AnimProgress"),
                    Activated       = result.Read <bool>(i, "Activated"),
                };

                spawn.CreateFullGuid();
                spawn.CreateData(data);

                AddSpawn(spawn, ref data);
            });

            Log.Message(LogType.DB, "Loaded {0} gameobject spawns.", GameObjectSpawns.Count);
            Log.Message();
        }
예제 #4
0
        public static void AddObject(string[] args, WorldClass session)
        {
            var pChar = session.Character;

            int objectId = CommandParser.Read <int>(args, 1);

            GameObject gObject = DataMgr.FindGameObject(objectId);

            if (gObject != null)
            {
                ChatMessageValues chatMessage = new ChatMessageValues(0, "");

                GameObjectSpawn spawn = new GameObjectSpawn()
                {
                    Guid       = GameObjectSpawn.GetLastGuid() + 1,
                    Id         = objectId,
                    GameObject = gObject,
                    Position   = pChar.Position,
                    Map        = pChar.Map
                };

                if (spawn.AddToDB())
                {
                    chatMessage.Message = "Spawn successfully added.";

                    spawn.AddToWorld();
                    ChatHandler.SendMessage(ref session, chatMessage);
                }
                else
                {
                    chatMessage.Message = "Spawn can't be added.";

                    ChatHandler.SendMessage(ref session, chatMessage);
                }
            }
        }
예제 #5
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"));
            }
        }
예제 #6
0
 public bool AddSpawn(GameObjectSpawn spawn, ref GameObject data)
 {
     return(GameObjectSpawns.TryAdd(spawn.Guid, spawn));
 }
예제 #7
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"));
            }
        }