Ejemplo n.º 1
0
        private void MainGameLoop()
        {
            DateTime time;
            TimeSpan spent;

            while (gameLoopActive)
            {
                if (gameLoopEnabled)
                {
                    try
                    {
                        GameLoopStatus = 1;
                        time           = DateTime.Now;
                        LowPriorityWorker.Process(); //1 query
                        spent = DateTime.Now - time;
                        if (spent.TotalSeconds > 3)
                        {
                            Console.WriteLine("Low priority Process worker took really long time to cycle!");
                        }

                        GameLoopStatus = 2;
                        time           = DateTime.Now;
                        LowPriorityWorker.ConsoleTitleWorker();
                        spent = DateTime.Now - time;
                        if (spent.TotalSeconds > 3)
                        {
                            Console.WriteLine("Low priority ConsoleTitleWorker worker took really long time to cycle!");
                        }

                        GameLoopStatus = 5;
                        time           = DateTime.Now;
                        RoomManager.OnCycle(); // Queries for furni save
                        spent = DateTime.Now - time;
                        if (spent.TotalSeconds > 3)
                        {
                            Console.WriteLine("RoomManager.OnCycle took really long time to cycle!");
                        }

                        GameLoopStatus = 6;
                        time           = DateTime.Now;
                        ClientManager.OnCycle();
                        spent = DateTime.Now - time;
                        if (spent.TotalSeconds > 3)
                        {
                            Console.WriteLine("ClientManager.OnCycle took really long time to cycle!");
                        }

                        GameLoopStatus = 7;
                    }
                    catch (Exception e)
                    {
                        Logging.LogCriticalException("INVALID MARIO BUG IN GAME LOOP: " + e.ToString());
                    }
                    GameLoopStatus = 8;
                }
                Thread.Sleep(gameLoopSleepTime);
            }

            gameLoopEnded = true;
        }
Ejemplo n.º 2
0
Archivo: Game.cs Proyecto: sgf/Yupi
 /// <summary>
 ///     Mains the game loop.
 /// </summary>
 private void MainGameLoop()
 {
     while (GameLoopActiveExt)
     {
         ServerCpuLowPriorityWorker.Process();
         try
         {
             RoomManagerCycleEnded   = false;
             ClientManagerCycleEnded = false;
             _roomManager.OnCycle();
             _clientManager.OnCycle();
         }
         catch (Exception ex)
         {
             ServerLogManager.LogCriticalException($"Exception in Game Loop!: {ex}");
         }
         Thread.Sleep(GameLoopSleepTimeExt);
     }
 }
Ejemplo n.º 3
0
        private void MainGameLoop()
        {
            while (gameLoopActive)
            {
                try
                {
                    LowPriorityWorker.Process();
                    ClientManager.OnCycle();
                    RoomManager.OnCycle();

                    GroupManager.OnCycle();
                    AlfaManager.OnCycle();
                }
                catch (Exception e)
                {
                    Logging.LogCriticalException("[Otanix] @ Alerta de erro: ERRO MARIO INVALIDO NO LOBO DO JOGO: " + e.StackTrace + " - " + e.Message + " - " + e);
                }

                Thread.Sleep(gameLoopSleepTime);
            }
        }
Ejemplo n.º 4
0
        private void GameCycle()
        {
            ServerStatusUpdater.StartProcessing();

            while (GameLoopActiveExt)
            {
                if (GameLoopEnabled)
                {
                    try
                    {
                        RoomManagerCycleEnded   = false;
                        ClientManagerCycleEnded = false;
                        _roomManager.OnCycle();
                        _clientManager.OnCycle();
                    }
                    catch (Exception ex)
                    {
                        ExceptionLogger.LogCriticalException(ex);
                    }
                }
                Thread.Sleep(25);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Mains the game loop.
        /// </summary>
        private void MainGameLoop()
        {
            LowPriorityWorker.StartProcessing();

            while (GameLoopActiveExt)
            {
                if (GameLoopEnabled)
                {
                    try
                    {
                        RoomManagerCycleEnded   = false;
                        ClientManagerCycleEnded = false;
                        _roomManager.OnCycle();
                        _clientManager.OnCycle();
                    }
                    catch (Exception ex)
                    {
                        Logging.LogCriticalException(string.Format("Exception in Game Loop!: {0}", ex));
                    }
                }
                Thread.Sleep(25);
            }
        }
Ejemplo n.º 6
0
        private void MainGameLoop()
        {
            while (gameLoopActive)
            {
                DateTime startTaskTime;
                TimeSpan spentTime;
                startTaskTime = DateTime.Now;
                if (gameLoopEnabled)
                {
                    try
                    {
                        LowPriorityWorker_ended  = false;
                        RoomManagerCycle_ended   = false;
                        ClientManagerCycle_ended = false;
                        if (FirewindEnvironment.SeparatedTasksInMainLoops != true)
                        {
                            GameLoopStatus = 1;
                            LowPriorityWorker.Process(); //1 query
                            GameLoopStatus = 5;
                            RoomManager.OnCycle();       // Queries for furni save
                            GameLoopStatus = 6;
                            ClientManager.OnCycle();
                            GameLoopStatus = 7;
                            //groupManager.OnCycle();
                        }
                        else
                        {
                            if (LowPriorityWorker_task == null || LowPriorityWorker_task.IsCompleted == true)
                            {
                                LowPriorityWorker_task = new Task(LowPriorityWorker.Process);
                                LowPriorityWorker_task.Start();
                            }

                            if (RoomManagerCycle_task == null || RoomManagerCycle_task.IsCompleted == true)
                            {
                                RoomManagerCycle_task = new Task(RoomManager.OnCycle);
                                RoomManagerCycle_task.Start();
                            }

                            if (ClientManagerCycle_task == null || ClientManagerCycle_task.IsCompleted == true)
                            {
                                ClientManagerCycle_task = new Task(ClientManager.OnCycle);
                                ClientManagerCycle_task.Start();
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Logging.LogCriticalException("INVALID MARIO BUG IN GAME LOOP: " + e.ToString());
                    }
                    GameLoopStatus = 8;
                }
                spentTime = DateTime.Now - startTaskTime;
                if (spentTime.TotalSeconds > 3)
                {
                    Logging.LogDebug("Game.MainGameLoop spent: " + spentTime.TotalSeconds + " seconds in working.");
                }

                Thread.Sleep(gameLoopSleepTime);
            }
        }