Exemplo n.º 1
0
        static void Main(string[] args)
        {
            try {                                 // The goddamn debugger can't seem to handle TypeInitializationExceptions so we'll just handle it ourselves.
                Logger.Announce("Hello, world!");
                object x = GlobalVars._preloader; // This forces global initialization ASAP

                ServiceDev.Setup();
                ServiceGame.Setup();
                WebServer.Start(Config.HOST_ADDR, Config.HOST_PORT);

                Logger.Announce("Loading Map!");
                var maploader = new DMMLoader();
                maploader.LoadMap("_maps/map_files/TgStation/tgstation.2.1.3.dmm", 0, 0, 1);
                //maploader.LoadMap("maps/tgstation.dmm", 0, 0, 1);

                //DMMLoader.Load("../../../-tg-station/_maps/map_files/TgStation/tgstation.2.1.3.dmm");

                Logger.Announce("Initializing Game!");
                Game13.New();

                Logger.Announce("Starting Scheduler!");
                Task13.__RunSchedulerLoop();
            }
            catch (Exception e) {
                Logger.Error("Fatal Error in Main!", e);
                Console.ReadLine();
            }
        }
Exemplo n.º 2
0
        // ALL OF THE SCHEDULER LOOP'S STATE SHOULD BE STORED IN
        // STATIC VARIABLES OF THE CLASS, NOT LOCALLY
        public static void __RunSchedulerLoop()
        {
            frame_timer.Start();             // start the goddamn timer if it hasn't started yet

            while (true)
            {
                // Load up a new set of frame tasks, if necessary.


                do
                {
                    while (frame_tasks.Count > 0)
                    {
                        var t = frame_tasks.First.Value;
                        frame_tasks.RemoveFirst();
                        try {
                            t();
                        }
                        catch (Exception e) {
                            Logger.Error("Scheduled task crashed!", e);
                        }
                    }

                    while (background_tasks.Count > 0 && frame_ms_remaining >= BG_MIN_MS)
                    {
                        var t = background_tasks.First.Value;
                        background_tasks.RemoveFirst();
                        try {
                            t();
                        }
                        catch (Exception e) {
                            Logger.Error("Scheduled task crashed!", e);
                        }
                    }
                } while (frame_tasks.Count > 0);

                // ENGINE SHIT GOES HERE

                ServiceGame.Process();
                ServiceDev.Process();

                // Increment frame, load tasks for next frame.

                frame_number++;

                LinkedList <Closure> temp_tasks;

                if (task_pq.TryGetValue(frame_number, out temp_tasks))
                {
                    frame_tasks = temp_tasks;
                }

                // Sleep until next frame time, or print a warning if we're over budget.

                int sleep_ms = frame_ms_remaining;

                if (sleep_ms < 0)
                {
                    Logger.LogScheduler("FRAME " + (frame_number - 1) + " WAS OVER BUDGET (" + (-sleep_ms) + "MS)");
                }
                else if (sleep_ms > 0)
                {
                    System.Threading.Thread.Sleep(sleep_ms);
                }

                frame_timer.Restart();
            }
        }